|
From: <el...@us...> - 2008-04-23 13:10:53
|
Revision: 501
http://salto-framework.svn.sourceforge.net/salto-framework/?rev=501&view=rev
Author: eloiez
Date: 2008-04-23 06:10:46 -0700 (Wed, 23 Apr 2008)
Log Message:
-----------
Modified Paths:
--------------
salto-framework/trunk/webapp/fwk/config/salto.tld
salto-framework/trunk/webapp/fwk/js/generic2.js
salto-framework/trunk/webapp/fwk/js/labels.jsp
salto-framework/trunk/webapp/fwk/js/salto-fwk.js
salto-framework/trunk/webapp/fwk/js/salto.js
salto-framework/trunk/webapp/fwk/js/table.js
salto-framework/trunk/webapp/fwk/js/treeview.js
salto-framework/trunk/webapp/fwk/style/framework.css
salto-framework/trunk/webapp/fwk/tafelTree/salto-tree.js
Modified: salto-framework/trunk/webapp/fwk/config/salto.tld
===================================================================
--- salto-framework/trunk/webapp/fwk/config/salto.tld 2008-04-23 13:10:01 UTC (rev 500)
+++ salto-framework/trunk/webapp/fwk/config/salto.tld 2008-04-23 13:10:46 UTC (rev 501)
@@ -179,7 +179,14 @@
<type>java.lang.String</type>
<description>le nom sous lequel l'objet en cours de traitement dans la liste sera mis \xE0 disposition dans le contexte de page </description>
</attribute>
- <attribute>
+ <attribute>
+ <name>selectOnClick</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <type>boolean</type>
+ <description>selection activ\xE9e sur le click (par d\xE9faut \xE0 true). Si false, la s\xE9lection se fait sur le double click.</description>
+ </attribute>
+ <attribute>
<name>coloredSelection</name>
<required>false</required>
<rtexprvalue>true</rtexprvalue>
@@ -1470,6 +1477,30 @@
<rtexprvalue>true</rtexprvalue>
<description>javascript function to call on double click</description>
</attribute>
+ <attribute>
+ <name>activeStyle</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>mode pour savoir le comportement sur le click ou le double click</description>
+ </attribute>
+ <attribute>
+ <name>selectedStyle</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>mode pour savoir le comportement sur le click ou le double click</description>
+ </attribute>
+ <attribute>
+ <name>actionsOnClick</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>mode pour savoir le comportement sur le click ou le double click</description>
+ </attribute>
+ <attribute>
+ <name>actionsOnDblClick</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ <description>mode pour savoir le comportement sur le click ou le double click</description>
+ </attribute>
<attribute>
<name>enableCopyPaste</name>
<required>false</required>
Modified: salto-framework/trunk/webapp/fwk/js/generic2.js
===================================================================
--- salto-framework/trunk/webapp/fwk/js/generic2.js 2008-04-23 13:10:01 UTC (rev 500)
+++ salto-framework/trunk/webapp/fwk/js/generic2.js 2008-04-23 13:10:46 UTC (rev 501)
@@ -307,7 +307,7 @@
if (getEvent(eventNS).ctrlKey && (8 == getKeyCode(eventNS) || 46 == getKeyCode(eventNS))) {
try {
if (fwkCurrentObject)
- fwkCurrentObject._keyCtrlSupp();
+ fwkCurrentObject._keyCtrlSupp(eventNS);
} catch(e) {}
}
@@ -315,7 +315,7 @@
if (27 == getKeyCode(eventNS)) {
try {
if (fwkCurrentObject)
- fwkCurrentObject._keyEsc();
+ fwkCurrentObject._keyEsc(eventNS);
else
fwk_esc();
}catch (e) {
@@ -330,7 +330,7 @@
if (getKeyCode(eventNS) == 13) {
try {
if (fwkCurrentObject)
- fwkCurrentObject._keyEnter();
+ fwkCurrentObject._keyEnter(eventNS);
else
fwk_validerForm();
}catch (e) {}
@@ -350,7 +350,7 @@
if (getKeyCode(eventNS) == Event.KEY_UP )
{
try{
- fwkCurrentObject._keyUp();
+ fwkCurrentObject._keyUp(eventNS);
}catch (e) { return true;}
try{
@@ -365,7 +365,7 @@
if (getKeyCode(eventNS) == Event.KEY_DOWN )
{
try{
- fwkCurrentObject._keyDown();
+ fwkCurrentObject._keyDown(eventNS);
}catch (e) { return true;}
try{
eventNS.keyCode = 0;
@@ -379,7 +379,7 @@
if (getKeyCode(eventNS) == Event.KEY_RIGHT )
{
try{
- fwkCurrentObject._keyRight();
+ fwkCurrentObject._keyRight(eventNS);
}catch (e) { return true;}
try{
eventNS.keyCode = 0;
@@ -393,7 +393,7 @@
if (getKeyCode(eventNS) == Event.KEY_LEFT )
{
try{
- fwkCurrentObject._keyLeft();
+ fwkCurrentObject._keyLeft(eventNS);
}catch (e) { return true;}
try{
eventNS.keyCode = 0;
Modified: salto-framework/trunk/webapp/fwk/js/labels.jsp
===================================================================
--- salto-framework/trunk/webapp/fwk/js/labels.jsp 2008-04-23 13:10:01 UTC (rev 500)
+++ salto-framework/trunk/webapp/fwk/js/labels.jsp 2008-04-23 13:10:46 UTC (rev 501)
@@ -1,5 +1,6 @@
<%@ page contentType="text/javascript; charset=UTF-8" %>
<%@taglib prefix="bean" uri="/WEB-INF/struts-bean.tld" %>
-var i18n_messages={};
+var i18n_messages={};
+i18n_messages["treeview.confirmOnDelete"]="<bean:message bundle="salto.fwk.i18n.Messages" key='treeview.confirmOnDelete'/>";
i18n_messages["datatable.confirmOnDelete"]="<bean:message bundle="salto.fwk.i18n.Messages" key='datatable.confirmOnDelete'/>";
i18n_messages["warnOnFormModified"]="<bean:message bundle="salto.fwk.i18n.Messages" key='warnOnFormModified'/>";
Modified: salto-framework/trunk/webapp/fwk/js/salto-fwk.js
===================================================================
--- salto-framework/trunk/webapp/fwk/js/salto-fwk.js 2008-04-23 13:10:01 UTC (rev 500)
+++ salto-framework/trunk/webapp/fwk/js/salto-fwk.js 2008-04-23 13:10:46 UTC (rev 501)
@@ -35,7 +35,7 @@
{
var path = s.src.replace(/prototype\.js(\?.*)?$/,'');
var includes = s.src.match(/\?.*load=([a-z,]*)/);
- (includes ? includes[1] : 'salto-common,window,salto,general,generic2,menu,onglet,suggest,table,combobox,wizard,fwk/calendar/date,fwk/calendar/calendar,contextmenu,cleanup,dhtmlHistory,treeview').split(',').each(
+ (includes ? includes[1] : 'salto-common,window,salto,general,generic2,menu,onglet,suggest,table,combobox,wizard,fwk/calendar/date,fwk/calendar/calendar,contextmenu,cleanup,dhtmlHistory,treeview,../tafelTree/Tree-1.8.4,../tafelTree/salto-tree').split(',').each(
function(include) {
Salto.require(path+include+'.js')
});
Modified: salto-framework/trunk/webapp/fwk/js/salto.js
===================================================================
--- salto-framework/trunk/webapp/fwk/js/salto.js 2008-04-23 13:10:01 UTC (rev 500)
+++ salto-framework/trunk/webapp/fwk/js/salto.js 2008-04-23 13:10:46 UTC (rev 501)
@@ -237,6 +237,7 @@
}
var popup = Salto.Window.setup(opts);
+ fwkCurrentObject = null;
popup.show();
fwkInterceptTab('PopupFirstElement'+winId);
}
Modified: salto-framework/trunk/webapp/fwk/js/table.js
===================================================================
--- salto-framework/trunk/webapp/fwk/js/table.js 2008-04-23 13:10:01 UTC (rev 500)
+++ salto-framework/trunk/webapp/fwk/js/table.js 2008-04-23 13:10:46 UTC (rev 501)
@@ -43,7 +43,9 @@
this.stackArray = new Array();
tableContainer.onclick = this._onclick.bind(this);
- tableContainer.ondblclick = this._ondblclick.bind(this);
+ if (! this.options.selectOnClick) {
+ Event.observe(tableContainer, 'dblclick', this._doSelectAction.bind(this));
+ }
this._doEvenOdd();
if (header && this.options.isSortable) {
@@ -367,7 +369,8 @@
allowColumnResizing:false,
sortingImage:null,
sortingAction:null,
- sortingActionParameters:null
+ sortingActionParameters:null,
+ selectOnClick:true
}.extend(options || {});
},
@@ -527,10 +530,49 @@
// Key events - catched when fwkCurrentObject = this
+
+ /* autre m\xE9thode -- la gestion des fl\xE8ches engendre une activation des lignes
+
// down arrow key behavior
_keyDown: function ()
{
var tableContainer = $(this.containerId);
+ var rowId = this.activeRowId;
+ if (! rowId) {
+ rowId = this.options.currSelIdx;
+ } else {
+ Element.removeClassName($(this.containerId).rows[rowId], this.options.rowActiveCssClass);
+ }
+ if (rowId < 1) {
+ rowId = 1;
+ } else {
+ rowId ++;
+ }
+ //si derni\xE8re ligne, on ne fait rien
+ if (rowId == $(this.containerId).rows.length || rowId == this.options.curSelIdx) return;
+ Element.addClassName($(this.containerId).rows[rowId], this.options.rowActiveCssClass);
+ },
+
+ // up arrow key behavior
+ _keyUp: function()
+ {
+ var tableContainer = $(this.containerId);
+ var rowId = this.activeRowId;
+ if (! rowId) {
+ rowId = this.options.currSelIdx;
+ } else {
+ Element.removeClassName($(this.containerId).rows[rowId], this.options.rowActiveCssClass);
+ }
+ //si premi\xE8re ligne, on ne fait rien
+ if (rowId == 1 || rowId == this.options.curSelIdx) return;
+ rowId --;
+ Element.addClassName($(this.containerId).rows[rowId], this.options.rowActiveCssClass);
+ },
+ */
+ // down arrow key behavior
+ _keyDown: function ()
+ {
+ var tableContainer = $(this.containerId);
if (this.options.currSelIdx == -1){ // no current selection
this.selectFirstRow();
@@ -639,12 +681,11 @@
},
_onclick:function(eventNS) {
-
if (eventNS && eventNS.detail) {
if (eventNS.detail > 1) return;
}
//Sets the focus on datatable to catch key events
- if (this.options.keyboard){
+ if (this.options.keyboard && this.clickObserver == null) {
this.clickObserver = this._lostFocus.bindAsEventListener(this);
Event.observe(document, 'click', this.clickObserver);
fwkCurrentObject = this;
@@ -652,16 +693,22 @@
var eventSource = getSource(eventNS);
var src = fwkGetParent(eventSource, 'A');
+ var anchor = src; //ceci permet de diff\xE9rencier le selectAction dans un link et celui d'une row (vraiment bizarre de devoir faire cela)
if (src == null)
src = eventSource;
-
+
+ //fonction \xE9quivalente \xE0 un tableTreeview (pourquoi ne pas avoir r\xE9ellement g\xE9r\xE9 un tableTreeview)
var check = fwkGetParent(src, 'TR');
if (this.isChild(check))
return;
var tableContainer = $(this.containerId);
+ // test si le click a eu lieu dans une ancre appelant un deleteAction
var deleteAction = src.getAttribute("deleteAction");
if (deleteAction && deleteAction != null && deleteAction.length>0) {
+ if (!confirm(i18n_messages['datatable.confirmOnDelete'])) {
+ return;
+ }
var trToDlete = fwkGetParent(src, 'TR');
var rowIndexParm = '&_fwk_rowIndex=' + trToDlete.rowIndex;
var tblId = trToDlete.getAttribute('tblId');
@@ -675,8 +722,6 @@
var staticParms = getQueryParameters(deleteAction);
if (staticParms && staticParms.length>0)
parms = parms + '&' + staticParms;
- if (!confirm(i18n_messages['datatable.confirmOnDelete']))
- return;
var deleteForm = src.getAttribute("deleteForm");
if (deleteForm && deleteForm!=null && deleteForm.length>0){
FormAjaxCall(getSingleQuery(deleteAction)+'?'+parms, deleteForm, null);
@@ -738,13 +783,15 @@
}
return;
}
-
- // links for simple clic triggering action
- var selectAction = src.getAttribute("selectAction");
- if (selectAction && selectAction != null && selectAction.length>0 && selectAction=="true") {
- this._ondblclick(eventNS);
+ if (anchor != null) {
+ var selAct = anchor.getAttribute('selectAction');
+ if (selAct && selAct.length > 0) {
+ var row = fwkGetParent(anchor, 'TR');
+ this.forceSelectAction(row.getAttribute('selectAction'), row);
+ }
}
+
if (src == tableContainer || src == this.header)
{
return;
@@ -755,63 +802,45 @@
cell = fwkGetParent(src, 'TH', 'TR');
}
src = fwkGetParent(src, 'TR');
+ var row = src;
if (!src)
{
return;
}
- var table = fwkGetParent(src, 'TABLE');
- if (((src.rowIndex == 0 && ! this.header) || table == this.header) && this.options.isSortable)
- {
- if ( (this.options.sortingImage != null && eventSource.nodeName == "IMG" && eventSource.id == "__fwk__IMG_SORTING")
- || this.options.sortingImage == null ) {
- if (this.options.sortingAction != null) {
- if (this.options.sortingImage != null )
- cell = fwkGetParent(fwkGetParent(cell, 'TABLE'), 'TH');
- var colNum = fwkCellIndex(cell);
- AjaxCall(this.options.sortingAction, tableContainer, '_sortable_colnum='+colNum);
- return false;
- } else {
- this._sort(cell);
- this._doEvenOdd();
- this.hideArrowButtons();
- }
+ var table = tableContainer;
+ if (((src.rowIndex == 0 && ! this.header) || table == this.header) && this.options.isSortable) {
+ if ( (this.options.sortingImage != null && eventSource.nodeName == "IMG" && eventSource.id == "__fwk__IMG_SORTING") || this.options.sortingImage == null ) {
+ //on tri la table
+ if (this.options.sortingAction != null) {
+ if (this.options.sortingImage != null )
+ cell = fwkGetParent(fwkGetParent(cell, 'TABLE'), 'TH');
+ var colNum = fwkCellIndex(cell);
+ AjaxCall(this.options.sortingAction, cell, '_sortable_colnum='+colNum);
+ return false;
+ } else {
+ this._sort(cell);
+ this._doEvenOdd();
+ this.hideArrowButtons();
+ }
}
- }
- else if (src.getAttribute('tblSelected') == 'true')
- {
+ } else if (src.getAttribute('tblSelected') == 'true') {
// C'est un click sur un element deja selectionne
// on remet style avant selection
- /*if (this.options.coloredSelection === true)
- {
- Element.removeClassName(src, this.options.rowSelectedCssClass);
+ //gestion de la tableTreeView
+ //gestion des fils (style tableTreeView) qui ne peuvent pas avoir de selectAction
+ if (this.isChild(row)) return;
+ //gestion des fils (style tableTreeView). Sur le premier click, on supprime les fils, sur le deuxi\xE8me click, on appelle le serveur pour qu'ils les remettent
+ if (this.hasChildren(row)) {
+ this.removeChildren(row);
+ return;
+ }
+ } else {
+ //check si on fait un selectAction
+ if (this.options.selectOnClick) {
+ this._doSelectAction(eventNS);
}
- src.setAttribute('tblSelected', 'false');
- this.options.currSelIdx = -1;
- this.options.currColIdx = -1; */
- }
- else
- {
- if (this.options.currSelIdx != -1)
- {
- // il y a deja un element selectionne
- var oldSelectedRow = table.rows.item(this.options.currSelIdx);
- if (this.options.coloredSelection === true) {
- Element.removeClassName(oldSelectedRow, this.options.rowSelectedCssClass);
- }
- oldSelectedRow.setAttribute('tblSelected', 'false');
- }
- if (this.options.coloredSelection === true) {
-
- if (!Element.hasClassName(src, this.options.rowSelectedCssClass))
- {
- Element.addClassName(src, this.options.rowSelectedCssClass);
- }
- }
- src.setAttribute('tblSelected', 'true');
- this.options.currSelIdx = src.rowIndex;
var cell = fwkGetParent(src, 'TH', 'TR');
- if (cell == null)
- {
+ if (cell == null) {
cell = fwkGetParent(eventSource, 'TD', 'TR');
}
if (cell != null) {
@@ -850,35 +879,81 @@
this.hideArrowButtons();
*/
},
- _ondblclick:function(eventNS) {
-
+ /**
+ * fonction qui lance l'action
+ */
+ _doSelectAction: function(eventNS) {
var src = getSource(eventNS);
-
- var tableContainer = $(this.containerId);
- if (src == tableContainer) return;
- src = fwkGetParent(src, 'TR');
- if (this.isChild(src))
- return;
- if (this.hasChildren(src)) {
- this.removeChildren(src);
- return;
- }
- var rowIndexParm = '&_fwk_rowIndex=' + src.rowIndex;
- // ajouts pour support selectAction par ligne pour la datatable (les parametres d'action peuvent etre differents)
- var selectAction = src.getAttribute('selectAction');
+ var table = $(this.containerId);
+ if (src == table) return;
+ var row = fwkGetParent(src, 'TR');
+ var selectAction = row.getAttribute('selectAction');
if (selectAction == null){
selectAction = this.options.selectAction;
}
if (selectAction != null){
- var tab = fwkGetParent(src, 'TABLE');
- var parms = src.getAttribute('tblId') + rowIndexParm + "&tableId=" + tab.getAttribute('id');
- var staticParms = getQueryParameters(selectAction);
- if (staticParms && staticParms.length>0)
- parms = parms + '&' + staticParms;
- AjaxCall(getSingleQuery(selectAction), src, parms/*src.getAttribute('tblId')*/);
+ //gestion des fils (style tableTreeView) qui ne peuvent pas avoir de selectAction
+ if (this.isChild(row)) return;
+ //gestion des fils (style tableTreeView). Sur le premier click, on supprime les fils, sur le deuxi\xE8me click, on appelle le serveur pour qu'ils les remettent
+ if (this.hasChildren(row)) {
+ this.removeChildren(row);
+ return;
+ }
+ this.forceSelectAction(selectAction, row);
+ } else {
+ this._doSelectRow(eventNS);
+ }
+ },
+ forceSelectAction: function(selectAction, row) {
+ this.forceSelectRow(row);
+ var tab = $(this.containerId);
+ var rowIndexParm = '&_fwk_rowIndex=' + row.rowIndex;
+ var parms = row.getAttribute('tblId') + rowIndexParm + "&tableId=" + tab.getAttribute('id');
+ var staticParms = getQueryParameters(selectAction);
+ if (staticParms && staticParms.length>0)
+ parms = parms + '&' + staticParms;
+ AjaxCall(getSingleQuery(selectAction), row, parms);
+ },
+ forceSelectRow: function(rowToSelect) {
+ var table = $(this.containerId);
+ //
+ var oldIndex = this.options.currSelIdx;
+ var oldSelectedRow = null;
+ if (oldIndex >= 0 && oldIndex < table.rows.length) {
+ oldSelectedRow = table.rows[oldIndex];
+ }
+ if (this.options.coloredSelection) {
+ //remove style from the old row
+ if (oldSelectedRow != null) {
+ Element.removeClassName(oldSelectedRow, this.options.rowSelectedCssClass);
+ }
+ //put it on the new row
+ if (Element.hasClassName(rowToSelect, this.options.rowActiveCssClass))
+ Element.removeClassName(rowToSelect, this.options.rowActiveCssClass);
+ if (!Element.hasClassName(rowToSelect, this.options.rowSelectedCssClass))
+ Element.addClassName(rowToSelect, this.options.rowSelectedCssClass);
+
+ }
+ //gestion de la s\xE9lection
+ if (oldSelectedRow != null) {
+ oldSelectedRow.setAttribute('tblSelected', 'false');
+ }
+ rowToSelect.setAttribute('tblSelected', 'true');
+ this.options.currSelIdx = rowToSelect.rowIndex;
+ },
+ /**
+ * force la s\xE9lection de la ligne (changement de couleur)
+ */
+ _doSelectRow : function(eventNS) {
+ var src = getSource(eventNS);
+ var table = $(this.containerId);
+ if (src == table) return;
+ if (fwkGetParent(src, 'TH')) {
+ return; //pas de s\xE9lection sur le header
}
+ var rowToSelect = fwkGetParent(src, 'TR');
+ this.forceSelectRow(rowToSelect);
},
-
_sort:function(cell) {
var tableContainer = $(this.containerId);
var dtInit = new Date().getTime();
@@ -997,7 +1072,7 @@
var parent = tableContainer.tBodies[0];
var insertBeforeElement = null;
- if (position != -1 && position < parent.rows.length)
+ if (position != -1 && (position + 1) < parent.rows.length)
insertBeforeElement = parent.rows[position+1];
while (trs.length>1) {
@@ -1088,7 +1163,7 @@
line_hover:function (evt){
var src = Event.element(evt);
src = fwkGetParent(src, "TR");
- if (!Element.hasClassName(src, this.options.rowActiveCssClass))
+ if (!Element.hasClassName(src, this.options.rowActiveCssClass) && ! Element.hasClassName(src, this.options.rowSelectedCssClass))
{
Element.addClassName(src, this.options.rowActiveCssClass);
}
Modified: salto-framework/trunk/webapp/fwk/js/treeview.js
===================================================================
--- salto-framework/trunk/webapp/fwk/js/treeview.js 2008-04-23 13:10:01 UTC (rev 500)
+++ salto-framework/trunk/webapp/fwk/js/treeview.js 2008-04-23 13:10:46 UTC (rev 501)
@@ -17,7 +17,9 @@
tmp.innerHTML = '<TABLE>'+rows+'</TABLE>';
rows = tmp.firstChild.rows;
var source = null;
- if (src.options != null) {
+ if (src.nodeName == 'TR') {
+ source = src;
+ } else if (src.options != null) {
source = src.options.clickedRow;
} else {
// gestion du copier / coller
@@ -31,8 +33,6 @@
var img = fwkGetChild(fwkGetChild(source,'TD'),'IMG');
var imgPlus = img;
- var imagePath = tempTree.options.imgDir+tempTree.options.imgPrefix;
-
while (img != null && img.src.indexOf('doc') < 0) {
imgPlus = img;
img = fwkGetBrother(img,'IMG');
@@ -40,10 +40,10 @@
// est-ce un nouveau folder
if (img != null) {
- img.src = imagePath+'folderopen.gif';
+ img.src = tempTree.imagePath+'folderopen.gif';
img.width = 24;
img.height = 22;
- imgPlus.src = imagePath+'mnode.gif';
+ imgPlus.src = tempTree.imagePath+'mnode.gif';
} else {
// est-ce un folder ferme
img = fwkGetChild(fwkGetChild(source,'TD'),'IMG');
@@ -52,7 +52,7 @@
img = fwkGetBrother(img,'IMG');
}
if (img != null) {
- tempTree.expand(imgPlus, imagePath);
+ tempTree.expand(imgPlus);
}
}
}
@@ -72,23 +72,45 @@
this.container = $(container);
fwkSetComponent($(this.container), this);
this.setOptions(options);
+ this.imagePath = this.options.imgDir+this.options.imgPrefix;
+ this.imgPrefix = this.options.imgPrefix;
this._attachBehaviors(options);
this.isObs = false;
},
_attachBehaviors: function(options) {
- this.container.onclick = this.gestTreeview.bind(this);
- this.container.ondblclick = this._ondblclick.bind(this);
+ var clickActions = this.options.clickActions.split(';');
+ var dblClickActions = this.options.dblClickActions.split(';');
+ for (var i = 0; i < clickActions.length; i++) {
+ if (clickActions[i] == 'open') Event.observe(this.container, 'click', this._expand.bind(this));
+ if (clickActions[i] == 'select') Event.observe(this.container, 'click', this._callAction.bind(this));
+ }
+ for (var i = 0; i < dblClickActions.length; i++) {
+ if (dblClickActions[i] == 'open') Event.observe(this.container, 'dblclick', this._expand.bind(this));
+ if (dblClickActions[i] == 'select') {
+ Event.observe(this.container, 'dblclick', this._callAction.bind(this));
+ }
+ }
+ //gestion des images (on ouvre la treeview lorsque l'on clique sur l'image)
+ Event.observe(this.container, 'click', this.gestTreeview.bind(this));
+ //gestion du focus pour les fl\xE8ches
},
- _ondblclick : function (eventNS) {
+ _callAction : function (eventNS) {
+ //si on click sur les images, alors on n'appelle pas l'\xE9v\xE8nement
+ var src = getSource(eventNS);
+ if (src.nodeName == 'IMG') return;
+ //s\xE9lection du noeud courant (s\xE9lectionn\xE9)
try {
if (this.options.dblclickFunction != null)
eval(this.options.dblclickFunction+"();");
else {
- var row = fwkGetParent(getSource(eventNS), 'TR');
+ var row = fwkGetParent(src, 'TR');
+ Element.removeClassName(this.options.previousNode, this.options.selectedStyle);
this.options.previousNode = row.getElementsByTagName('span')[0];
this.options.clickedRow = row;
-
+ if (! Element.hasClassName()) {
+ Element.addClassName(this.options.previousNode, this.options.selectedStyle);
+ }
this.callAction();
}
} catch (e) {
@@ -193,6 +215,7 @@
_lostFocus : function ()
{
fwkDebug('_lostFocus');
+/*
var theContainer = $(this.container.id);
fwkDebug('---'+theContainer);
Event.stopObserving(document, "click", this.clickObserver,false);
@@ -200,7 +223,7 @@
this.options.active = false;
if (this.options.keyboard === true)
fwkCurrentObject = null;
-
+*/
},
setOptions: function(options) {
@@ -215,107 +238,82 @@
currentFolder : null,
keyboard : false,
dblclickFunction : null,
- selectMode : 'simpleClick'
+ clickActions : '',
+ dblClickActions : 'select;open',
+ selectedStyle : 'treeviewSelectedItem',
+ activeStyle : 'treeviewActiveItem'
}.extend(options || {});
},
setFocus: function() {
id = this.container.id;
- //selection de l'element root
- var spanNode = $('root_span_'+id);
- var row = $('root_row_'+id);
- this.options.clickedRow = row;
- if (spanNode != null)
- {
- if (this.options.previousNode)
- {
- Element.removeClassName(this.options.previousNode, "treeviewSelectedItem");
-// Element.addClassName(this.options.previousNode, "treeviewNonSelectedItem");
- }
- this.options.previousNode = spanNode;
-// Element.removeClassName(spanNode, "treeviewNonSelectedItem");
- Element.addClassName(spanNode, "treeviewSelectedItem");
- }
- this.isObs = false;
- if (this.options.keyboard === true)
- fwkCurrentObject = this;
-
- this.treeGestFocus();
},
/**
* Appelle l'action en envoyant le contenu du noeud data2send
*/
gestTreeview: function(eventNS) {
+
fwkDebug('gestTreeview');
this.isObs = false;
- if (this.options.keyboard === true)
- fwkCurrentObject = this;
- var imagePath = this.options.imgDir+this.options.imgPrefix;
- var imgPrefix = this.options.imgPrefix;
-
+ var src = getSource(eventNS);
+ var row = fwkGetParent(getSource(eventNS), 'TR');
+ var span = row.getElementsByTagName('span')[0];
+ this.swapStyle(this.activeNode, span);
+ this.activeNode = span;
+ fwkCurrentObject = this;
if (!this.options.imgPrefix)
return false;
try {
- var src = getSource(eventNS);
var initSrc = src;
- if (src.nodeName == undefined)
- {
- return;
- }
- if (src.nodeName != 'IMG') {
- //selection de l'element
- var spanNode = fwkGetParent(src, 'SPAN');
- var row = fwkGetParent(src, 'TR');
+ if (src.nodeName == 'A') {
+ Element.removeClassName(this.options.previousNode, this.options.selectedStyle);
+ this.options.previousNode = span;
this.options.clickedRow = row;
- if (spanNode != null)
- {
- if (this.options.previousNode)
- {
- Element.removeClassName(this.options.previousNode, "treeviewSelectedItem");
-// Element.addClassName(this.options.previousNode, "treeviewNonSelectedItem");
- }
- this.options.previousNode = spanNode;
-// Element.removeClassName(spanNode, "treeviewNonSelectedItem");
- Element.addClassName(spanNode, "treeviewSelectedItem");
-
- if (row.getAttribute("level") != "0") {
- // this.callAction();
- }
+ if (! Element.hasClassName(this.options.previousNode, this.options.selectedStyle)) {
+ Element.removeClassName(this.options.previousNode, this.options.selectedStyle);
}
- if (this.options.selectMode == 'simpleClick') {
- src = fwkGetPreviousBrother(src, 'IMG');
- if (src == null) {
- src = fwkGetPreviousBrother(spanNode, 'IMG');
- }
- if (src == null) return;
- this.options.previousNode = row.getElementsByTagName('span')[0];
- this.options.clickedRow = row;
- } else
- return;
+ return;
}
-
- if (src.nodeName == 'IMG' && (src.src.indexOf(imgPrefix+'folderopen.gif')>0 || src.src.indexOf(imgPrefix+'folderclosed.gif')>0)) {
+ if (src.nodeName == undefined || src.nodeName != 'IMG') {
+ return;
+ }
+ //gestion de l'ouverture du noeud
+ if (src.nodeName == 'IMG' && (src.src.indexOf(this.imgPrefix+'folderopen.gif')>0 || src.src.indexOf(this.imgPrefix+'folderclosed.gif')>0)) {
+ //click sur image correspondant \xE0 l'ouverture du noeud
if(fwkGetPreviousBrother(src, 'IMG') && fwkGetPreviousBrother(src, 'IMG')!=null)
+
src = fwkGetPreviousBrother(src, 'IMG');
else {
- this.expandRoot(initSrc, imagePath);
+ this.expandRoot(initSrc);
return;
}
}
if (src.nodeName == 'IMG' && (src.src.indexOf('pnode')>0 || src.src.indexOf('mnode')>0 || src.src.indexOf('plastnode')>0 || src.src.indexOf('mlastnode')>0)) {
- this.expand(src, imagePath);
+ this.expand(src);
}
-
+
} catch (e) {
alert('treeview.js:gestTreeview():,'+fwkPrintError(e));
}
},
-
- expand : function (src, imagePath)
- {
+ _expand : function(eventNS) {
+ var src = getSource(eventNS);
+ //cette fonction ne g\xE8re que le span , pas les images (voir gestTreeview)
+ if (src.nodeName == 'IMG') return;
+ var img = fwkGetPreviousBrother(src, 'IMG');
+ if (! img || img == null || (img.src.indexOf('pNode') <= 0 && img.src.indexOf('mNode'))) {
+ //c'est une terminaison, on ne fait rien
+ return;
+ }
+ var row = fwkGetParent(src, 'TR');
+ var spanNode = row.getElementsByTagName('span')[0];
+ var img = fwkGetPreviousBrother(spanNode, 'IMG');
+ img = fwkGetPreviousBrother(img, 'IMG');
+ this.expand(img);
+ },
+ expand : function (src) {
var display = false;
var row = fwkGetParent(src, 'TR');
- this.options.clickedRow = row;
var level = Number(row.getAttribute("level"));
var nbCells = row.cells[0].childNodes.length;
var table = fwkGetParent(row, 'TABLE');
@@ -323,75 +321,65 @@
//recuperation des id de tous les peres
var theData2Send = row.getAttribute("data2send");
//call to AJAX
- this.options.clickedRow = row;
- AjaxCall(this.options.loadChildAction, this, "level=" +row.getAttribute("level") + "&" + theData2Send + "&treeId=" + this.container.id + "&imgDir=" + this.options.imgDir + "&imgPrefix=" + this.options.imgPrefix);
+ AjaxCall(this.options.loadChildAction, row, "level=" +row.getAttribute("level") + "&" + theData2Send + "&treeId=" + this.container.id + "&imgDir=" + this.options.imgDir + "&imgPrefix=" + this.options.imgPrefix);
row.setAttribute('loaded', 'true');
} else {
- //affichage des fils
+ //affichage des fils (noeud tr avec level > currentLevel)
for (var i = row.rowIndex + 1; i < table.rows.length; i++) {
var row = table.rows.item(i);
- if (Number(row.getAttribute("level")) <= level)
- {
+ if (Number(row.getAttribute("level")) <= level) {
break;
- }
- else if (Number(row.getAttribute("level")) == (level + 1))
- {
+ } else if (Number(row.getAttribute("level")) == (level + 1)) {
if (row.style.display == 'none') {
display = true;
row.style.display = 'block';
} else {
row.style.display = 'none';
}
- }
- else
- {
+ } else {
if (display) {
var oldValue = row.getAttribute('displayed');
- if (oldValue != undefined && oldValue !== null)
- {
+ if (oldValue != undefined && oldValue !== null) {
row.style.display = oldValue;
- }
- else
- {
+ } else {
row.style.display = 'none';
}
- }
- else
- {
+ } else {
row.setAttribute('displayed', row.style.display);
row.style.display = 'none';
}
}
}
}
+
var img = fwkGetBrother(src,'IMG');
var spanNode = fwkGetBrother(src,'SPAN');
if (src.src.indexOf('pnode') > 0) {
- src.src = imagePath+'mnode.gif';
- img.src = imagePath+'folderopen.gif';
+ src.src = this.imagePath+'mnode.gif';
+ img.src = this.imagePath+'folderopen.gif';
this.options.currentFolder = spanNode;
Element.removeClassName(spanNode, "treeviewClosedFolder");
Element.addClassName(spanNode, "treeviewOpenedFolder");
} else if (src.src.indexOf('plastnode') > 0) {
- src.src = imagePath+'mlastnode.gif';
- img.src = imagePath+'folderopen.gif';
+ src.src = this.imagePath+'mlastnode.gif';
+ img.src = this.imagePath+'folderopen.gif';
this.options.currentFolder = spanNode;
Element.removeClassName(spanNode, "treeviewClosedFolder");
Element.addClassName(spanNode, "treeviewOpenedFolder");
} else if (src.src.indexOf('mlastnode') > 0) {
- src.src = imagePath+'plastnode.gif';
- img.src = imagePath+'folderclosed.gif';
+ src.src = this.imagePath+'plastnode.gif';
+ img.src = this.imagePath+'folderclosed.gif';
Element.removeClassName(spanNode, "treeviewOpenedFolder");
Element.addClassName(spanNode, "treeviewClosedFolder");
} else {
- src.src = imagePath+'pnode.gif';
- img.src = imagePath+'folderclosed.gif';
+ src.src = this.imagePath+'pnode.gif';
+ img.src = this.imagePath+'folderclosed.gif';
Element.removeClassName(spanNode, "treeviewOpenedFolder");
Element.addClassName(spanNode, "treeviewClosedFolder");
}
},
- expandRoot : function(initSrc, imagePath)
+ expandRoot : function(initSrc)
{
//ceci est le root du noeud
var display = false;
@@ -417,15 +405,16 @@
}
}
if (display) {
- initSrc.src = imagePath+'folderopen.gif';
+ initSrc.src = this.imagePath+'folderopen.gif';
this.options.currentFolder = fwkGetBrother(initSrc, 'SPAN');
} else {
- initSrc.src = imagePath+'folderclosed.gif';
+ initSrc.src = this.imagePath+'folderclosed.gif';
}
return;
},
treeGestFocus : function () {
fwkDebug('treeGeestFocus');
+/*
if (!this.isObs) {
var observed = false;
for (var i = 0; i < Event.observers.length; i++)
@@ -445,45 +434,52 @@
}
this.isObs = true;
}
+*/
}
,
- _keyDown : function ()
+ _keyDown : function (eventNS)
{
- var previousSpan = this.options.previousNode;
- var newSpan = this.nextLine(this.options.previousNode);
+ var previousSpan = this.activeNode;
+ if (! previousSpan) {
+ previousSpan = this.options.previousNode;
+ }
+ var newSpan = this.nextLine(previousSpan);
this.swapStyle(previousSpan, newSpan);
- this.treeGestFocus();
},
_keyUp : function ()
{
- var previousSpan = this.options.previousNode;
- var newSpan = this.previousLine(this.options.previousNode);
+ var previousSpan = this.activeNode;
+ if (! previousSpan) {
+ previousSpan = this.options.previousNode;
+ }
+ var newSpan = this.previousLine(previousSpan);
this.swapStyle(previousSpan, newSpan);
- this.treeGestFocus();
},
- _keyRight : function ()
- {
- var initSrc = fwkGetPreviousBrother(this.options.previousNode,'IMG');
- var src = fwkGetPreviousBrother(fwkGetPreviousBrother(this.options.previousNode,'IMG'),'IMG');
+ _keyRight : function () {
+ var current = this.activeNode;
+ if (! current) {
+ current = this.options.previousNode;
+ }
+ if (! current) return;
+ var initSrc = fwkGetPreviousBrother(current, 'IMG');
+ var src = fwkGetPreviousBrother(initSrc, 'IMG');
if (src == null && (initSrc.src.indexOf('folderclosed')>0 )) {
- this.expandRoot(initSrc, this.options.imgDir+this.options.imgPrefix);
- }else if (src.nodeName == 'IMG' && (src.src.indexOf('pnode')>0 || src.src.indexOf('plastnode')>0 )) {
- this.expand(src,this.options.imgDir+this.options.imgPrefix);
- }else
- {
+ this.expandRoot(initSrc);
+ } else if (src.nodeName == 'IMG' && (src.src.indexOf('pnode')>0 || src.src.indexOf('plastnode')>0 )) {
+ this.expand(src);
+ } else {
var myTr = fwkGetParent(src,'TR');
var level = Number(myTr.getAttribute("level"));
level++;
var newTr = fwkGetBrother(myTr, 'TR');
-
if ( newTr && (newTr.getAttribute("display")!="none") && (Number(newTr.getAttribute("level")) == level) )
newSpan = this.getSpan(newTr);
else
return;
- this.swapStyle(this.options.previousNode, newSpan);
+ this.swapStyle(this.activeNode, newSpan);
}
this.treeGestFocus();
@@ -491,12 +487,16 @@
_keyLeft : function ()
{
- var initSrc = fwkGetPreviousBrother(this.options.previousNode,'IMG');
- var src = fwkGetPreviousBrother(fwkGetPreviousBrother(this.options.previousNode,'IMG'),'IMG');
+ var current = this.activeNode;
+ if (! current) {
+ current = this.options.previousNode;
+ }
+ var initSrc = fwkGetPreviousBrother(current, 'IMG');
+ var src = fwkGetPreviousBrother(initSrc, 'IMG');
if (src == null && (initSrc.src.indexOf('folderopen')>0 )) {
- this.expandRoot(initSrc, this.options.imgDir+this.options.imgPrefix);
+ this.expandRoot(initSrc);
}else if (src.nodeName == 'IMG' && (src.src.indexOf('mnode')>0 || src.src.indexOf('mlastnode')>0 )) {
- this.expand(src,this.options.imgDir+this.options.imgPrefix);
+ this.expand(src);
}
else
{
@@ -510,13 +510,19 @@
newTr = fwkGetPreviousBrother(newTr, 'TR');
newSpan = this.getSpan(newTr);
- this.swapStyle(this.options.previousNode, newSpan);
+ this.swapStyle(this.activeNode, newSpan);
}
this.treeGestFocus();
},
_keyEnter : function ()
{
+ if (! this.activeNode) return;
+ Element.removeClassName(this.options.previousNode, this.options.selectedStyle);
+ this.options.previousNode = this.activeNode;
+ if (! Element.hasClassName(this.options.previousNode, this.options.selectedStyle)) {
+ Element.removeClassName(this.options.previousNode, this.options.selectedStyle);
+ }
this.callAction();
},
@@ -562,9 +568,13 @@
},
callAction : function()
{
+ //s\xE9lection du noeud
+ if (this.options.previousNode)
+ {
+ Element.removeClassName(this.options.previousNode, this.options.selectedStyle);
+ }
if(this.options.selectNodeAction != "")
{
- this.treeGestFocus();
var src = this.options.previousNode;
var row = fwkGetParent(src, 'TR');
this.options.clickedRow = row;
@@ -573,15 +583,18 @@
//alert('data2send='+data2send);
AjaxCall(this.options.selectNodeAction, this, "level=" +row.getAttribute("level") + "&" + data2send);
}
+ Element.addClassName(this.options.previousNode, this.options.selectedStyle);
},
- swapStyle : function(oldNode, newNode)
- {
- Element.removeClassName(oldNode, "treeviewSelectedItem");
- //Element.addClassName(oldNode, "treeviewNonSelectedItem");
- //Element.removeClassName(newNode, "treeviewNonSelectedItem");
- Element.addClassName(newNode, "treeviewSelectedItem");
- this.options.previousNode = newNode;
+ swapStyle : function(oldNode, newNode) {
+ if (oldNode != null && Element.hasClassName(oldNode, this.options.activeStyle)) {
+ Element.removeClassName(oldNode, this.options.activeStyle);
+ }
+ if (! Element.hasClassName(newNode, this.options.activeStyle)) {
+ Element.addClassName(newNode, this.options.activeStyle);
+ }
+ //noeud actif mais pas s\xE9lectionn\xE9
+ this.activeNode = newNode;
}
};
@@ -631,8 +644,10 @@
}
function removeSelectedNode(treeId,action2call){
- if (fwkGetComponent(treeId).getData2send() != null) {
- AjaxCall(action2call, treeId,"treeId="+encodeURIComponent(treeId)+
- "&id="+encodeURIComponent(fwkGetComponent(treeId).getData2send()));
+ if (confirm(i18n_messages['treeview.confirmOnDelete'])) {
+ if (fwkGetComponent(treeId).getData2send() != null) {
+ AjaxCall(action2call, treeId,"treeId="+encodeURIComponent(treeId)+
+ "&id="+encodeURIComponent(fwkGetComponent(treeId).getData2send()));
+ }
}
-}
\ No newline at end of file
+}
Modified: salto-framework/trunk/webapp/fwk/style/framework.css
===================================================================
--- salto-framework/trunk/webapp/fwk/style/framework.css 2008-04-23 13:10:01 UTC (rev 500)
+++ salto-framework/trunk/webapp/fwk/style/framework.css 2008-04-23 13:10:46 UTC (rev 501)
@@ -1,4 +1,4 @@
-/* CSS d\xE9finissant les styles par d\xE9faut
+/* CSS d�finissant les styles par d�faut
des composants du framework
*/
@@ -50,9 +50,9 @@
.odd{
background-color:#EEF7FC;
}
-//.rowActive {
-// background-color:#FFCC99;
-//}
+.rowActive {
+ background-color:#FFCC99;
+}
.error{
font-size:12px;
Modified: salto-framework/trunk/webapp/fwk/tafelTree/salto-tree.js
===================================================================
--- salto-framework/trunk/webapp/fwk/tafelTree/salto-tree.js 2008-04-23 13:10:01 UTC (rev 500)
+++ salto-framework/trunk/webapp/fwk/tafelTree/salto-tree.js 2008-04-23 13:10:46 UTC (rev 501)
@@ -1,15 +1,30 @@
-// fichier complementaire \xE0 tafeltreeview
+// fichier complementaire � tafeltreeview
/**
* Ajout d'une branche a une treeview
* @param {Object} maTreeView
* @param {Object} branch
*/
-function _fwk_AddBranchToTreeView(maTreeView, branch) {
- var id_branch = maTreeView.getBranches()[0].getId();
+function _fwk_AddBranchToTreeView(maTreeView, branch, initBranch) {
+ if (! initBranch) {
+ initBranch = maTreeView.getBranches()[0];
+ }
+ if (! initBranch.isOpened()) {
+ initBranch.setOpen(true);
+ }
+ var id_branch = initBranch.getId();
maTreeView.insertBranch(id_branch, branch, false, true);
}
+function _fwk_returnResult(branch, node) {
+ var items = eval(node.childNodes[0].data);
+ for (var i = 0; i < items.length; i++) {
+ branch.insert(items[i]);
+ }
+ branch.openIt(true);
+}
+
+
/**
* Function par defaut d'un open populate
* @param {Object} branch
@@ -27,7 +42,7 @@
* @param {Object} branch
*/
function fwk_onClickAjax (branch) {
- var actionAjax = branch.tree.options.click_action;
+ var actionAjax = branch.struct.openlink + '?mine=true';
fwk_callAjaxByBranch(branch,actionAjax,false);
}
@@ -107,7 +122,7 @@
function fwk_callAjaxByBranch(selected, actionAjax, boWaitImg){
if (boWaitImg) selected._setWaitImg(selected,true,true);
var params = 'branch=' + selected.serialize() + '&branch_id=' + selected.getId() + '&tree_id=' + selected.tree.id;
- AjaxCall(actionAjax,this,params);
+ AjaxCall(actionAjax,selected,params);
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|