07-06-2007 03:13 AM
src="/alfresco/service/api/path/content/workspace/SpacesStore/Company%20Home/wz_dragdrop.js"></script>
<div class="spaceIcon">
<#if d.isDocument && (d.mimetype = "image/gif" || d.mimetype = "image/jpeg" || d.mimetype = "image/png")>
<a href="${url.context}${d.url}" target="new" onclick="event.cancelBubble=true"><img class="spaceIconImage" alt="" width="16" height="16" src="${url.context}${d.url}?${d.size}" border=0></a>
<div style="display:none"><img name=d.name class="spaceIconImage64" alt="" width="64" height="64" src="${url.context}${d.url}?${d.size}"></div>
<script type="text/javascript">
<!–
SET_DHTML(d.name);
//–>
</script>
<#else>
<a href="${url.context}${d.url}" target="new" onclick="event.cancelBubble=true"><img class="spaceIconImage" alt="" width="16" height="16" src="${url.context}${d.icon16?replace(".gif",".png")}" border=0></a>
<div style="display:none"><img class="spaceIconImage64" alt="" width="64" height="64" src="${url.context}${d.icon64}"></div>
</#if>
07-06-2007 05:17 AM
07-09-2007 04:56 AM
space.addEvent('domready', function() {
…..
Now the squares inside the content's panel can be dragged and dropped though, the movements are slow and sometimes the squares get far away of the mouse. I guess that must come from all the resize of the content's rows and that there is a function about drag and drop defined for the main window and each space inside the content's panel.
space.addEvent('domready', function() {
// HERE IS WHAT YOU READ IN JS CODE
var fx = [];
$$('#draggables div').each(function(drag){
new Drag.Move(img, {
droppables: $$('#droppables div')
});
and I ve put my list in myspacespanel between a dev id=draggable.07-12-2007 12:36 AM
<#assign user=person.properties.userName>
<#assign count=0>
<#assign weekms=1000*60*60*24*7>
<div id="draggables">
<#list companyhome.nodeByReference[args.h].children?sort_by('name') as d>
<#if (d.isDocument) &&
((args.f="0") ||
(args.f="1" && d.isContainer) ||
(args.f="2" && d.isDocument) ||
(args.f="3" && (d.properties.creator == user || d.properties.modifier == user)) ||
(args.f="4" && (dateCompare(d.properties["cm:modified"],date,weekms) == 1 || dateCompare(d.properties["cm:created"], date, weekms) == 1)))>
<#assign count=count+1>
<div class="spaceRow spaceRow${(count % 2 = 0)?string("Odd", "Even")}">
<div style="display:none"><img class="spaceType" alt="fichier" ></div>
<div class="spaceIcon">
<#if d.isDocument && (d.mimetype = "image/gif" || d.mimetype = "image/jpeg" || d.mimetype = "image/png")>
<div class="dragg">
<a href="${url.context}${d.url}" target="new" onclick="event.cancelBubble=true"><img class="spaceIconImage" alt="" width="20" height="20" src="${url.context}${d.url}?${d.size}" border=0></a>
<div style="display:none"><img class="spaceIconImage64" alt="" width="64" height="64" src="${url.context}${d.url}?${d.size}"></div>
</div>
<#else>
<a href="${url.context}${d.url}" target="new" onclick="event.cancelBubble=true"><img class="spaceIconImage" alt="" width="16" height="16" src="${url.context}${d.icon16?replace(".gif",".png")}" border=0></a>
<div style="display:none"><img class="spaceIconImage64" alt="" width="64" height="64" src="${url.context}${d.icon64}"></div>
</#if>
</div>
<div class="spaceItem">
${d.name?html}
<span class="spaceInfo" onclick="event.cancelBubble=true"; AlfNodeInfoMgr.toggle('${d.nodeRef}',this);">
<img src="${url.context}/images/icons/popup.gif" class="popupImage" width="16" height="16" />
</span>
</div>
<div class="spaceDetail">
<table cellpadding="2" cellspacing="0" border="0">
<tr>
<td>
<span class="spaceMetaprop">Description:</span> <span class="spaceMetadata"><#if d.properties.description?exists>${d.properties.description?html}<#else> </#if></span><br />
<span class="spaceMetaprop">Modified:</span> <span class="spaceMetadata">${d.properties.modified?datetime}</span><br />
<span class="spaceMetaprop">Modified By:</span> <span class="spaceMetadata">${d.properties.modifier}</span>
</td>
<td width="24"> </td>
<td>
<span class="spaceMetaprop">Created:</span> <span class="spaceMetadata">${d.properties.created?datetime}</span><br />
<span class="spaceMetaprop">Created By:</span> <span class="spaceMetadata">${d.properties.creator}</span><br />
<span class="spaceMetaprop">Size:</span> <span class="spaceMetadata">${(d.size/1000)?string("0.##")} KB</span>
</td>
</tr>
</table>
</div>
<div class="spaceResource spacesAjaxWait" id="${d.nodeRef}"></div>
</div>
</#if>
</#list>
</div>
<div id="cart">
<#list companyhome.nodeByReference[args.h].children?sort_by('name') as d>
<#if (d.isContainer) &&
((args.f="0") ||
(args.f="1" && d.isContainer) ||
(args.f="2" && d.isDocument) ||
(args.f="3" && (d.properties.creator == user || d.properties.modifier == user)) ||
(args.f="4" && (dateCompare(d.properties["cm:modified"],date,weekms) == 1 || dateCompare(d.properties["cm:created"], date, weekms) == 1)))>
<#assign count=count+1>
<div class="spaceRow spaceRow${(count % 2 = 0)?string("Odd", "Even")}">
<div style="display:none"><img class="spaceType" alt="space" ></div>
<div class="spaceIcon">
<#if d.isDocument>
<a href="${url.context}${d.url}" target="new" onclick="event.cancelBubble=true"><img class="spaceIconImage" alt="" width="16" height="16" src="${url.context}${d.icon16?replace(".gif",".png")}" border=0></a>
<#else>
<#– the component parts need to build up an encoded url to the outer webscript –>
<#– the client-side url encoder method of the outer webscript runtime will be used –>
<span class="spaceNavLinkUrl">${url.serviceContext}/sample/myspaces2?f=${args.f}&p=${args.p}/${d.name}</span>
<span class="spaceNavLinkImg" style="display:none" ><img class="spaceIconImage" alt="" width="16" height="16" src="${url.context}${d.icon16?replace(".gif",".png")}" border="0"></span>
</#if>
<div style="display:none"><img class="spaceIconImage64" alt="" width="64" height="64" src="${url.context}${d.icon64}"></div>
</div>
<div class="spaceItem">
${d.name?html}
<span class="spaceInfo" onclick="event.cancelBubble=true"; AlfNodeInfoMgr.toggle('${d.nodeRef}',this);">
<img src="${url.context}/images/icons/popup.gif" class="popupImage" width="16" height="16" />
</span>
</div>
<div class="spaceDetail">
<table cellpadding="2" cellspacing="0" border="0">
<tr>
<td>
<span class="spaceMetaprop">Description:</span> <span class="spaceMetadata"><#if d.properties.description?exists>${d.properties.description?html}<#else> </#if></span><br />
<span class="spaceMetaprop">Modified:</span> <span class="spaceMetadata">${d.properties.modified?datetime}</span><br />
<span class="spaceMetaprop">Modified By:</span> <span class="spaceMetadata">${d.properties.modifier}</span>
</td>
<td width="24"> </td>
<td>
<span class="spaceMetaprop">Created:</span> <span class="spaceMetadata">${d.properties.created?datetime}</span><br />
<span class="spaceMetaprop">Created By:</span> <span class="spaceMetadata">${d.properties.creator}</span><br />
<span class="spaceMetaprop">Size:</span> <span class="spaceMetadata">${(d.size/1000)?string("0.##")} KB</span>
</td>
</tr>
</table>
</div>
<div class="spaceResource spacesAjaxWait" id="${d.nodeRef}"></div>
</div>
</#if>
</#list>
</div>
<#– hidden div with the count value for the page –>
<div id="spaceCountValue" style="display:none">${count}</div>
<!–in the CSS part–>
.spaceIcon
{
float: left;
padding-left: 16px;
padding-top: 4px;
position: relative;
}
//at the beginning of the file and necessary for drag and drop, dont know //why thought
window.addEvent('domready', function() {
// HERE IS WHAT YOU READ IN JS CODE
var drop = $('cart');
$$('#draggables div').each(function(dragg){
dragg.addEvent('mousedown', function(e) {
e = new Event(e).stop();
var clone = this.clone()
.setStyles(this.getCoordinates()) // this returns an object with left/top/bottom/right, so its perfect
.setStyles({'opacity': 0.4, 'position': 'absolute' })
.addEvent('emptydrop', function() {
this.remove();
}).inject(document.body);
var drag = clone.makeDraggable({
droppables: [drop]
}); // this returns the dragged element
drag.start(e); // start the event manual
});
});
});
……..
parseSpacePanels: function()
{
var spaces = $$('#spacePanel .spaceRow');
var items = $$('#spacePanel .spaceItem');
var infos = $$('#spacePanel .spaceInfo');
var details = $$('#spacePanel .spaceDetail');
var icons = $$('#spacePanel .spaceIcon'); //added
var imgs = $$('#spacePanel .spaceIconImage');
var imgs64 = $$('#spacePanel .spaceIconImage64');
var resources = $$('#spacePanel .spaceResource');
var types = $$('#spacePanel .spaceType'); //added
……..
……..
spaces.each(function(space, i)
{
var item = items[i],
icon = icons[i], //added
info = infos[i],
detail = details[i],
type = types[i], //added
img = imgs[i],
dzone = new Array(), //added
nzone = 0, //added
resource = resources[i];
….
….
//the following is to be added inside the spaces.each loop and implements //the actual drag and drop inside spacePanel
//in order to have a list of the folders
spaces.each(function(ic, i)
{
if (types[i].getProperty('alt')=="space")
{
dzone[nzone]=ic;
nzone++;
}
});
$('spacePanel').addEvent('domready', function() {
if (type.getProperty('alt')=="fichier" ){
icon.addEvent('mousedown', function(e) {
e = new Event(e).stop();
var clone = this.clone();
//creates a clone that is transparent and if dropped elsewhere than on a //spaces row will go back to its initial [place then dissapear
clone.setStyles(this.getCoordinates());
var fx = new Fx.Styles(clone, {duration: 1000, wait: false});
var lefte = this.getLeft();
var tope =this.getTop(); // this returns an object with left/top/bottom/right, so its perfect
fx.options.duration=500;
fx.options.transition = Fx.Transitions.Cubic.easeInOut;
clone.setStyles({'opacity': 0.4, 'position': 'absolute' });
clone.addEvent('emptydrop', function() {
fx.start({ //start the return animation
'top': tope,
'left': lefte
}
);
setTimeout(function(){clone.remove();},500);
//if the array dzone is used here an unknown error occurs
spaces.each(function(ic, i)
{
if (types[i].getProperty('alt')=="space")
{
//it is necessary to remove these events or there will be errors
spaces[i].removeEvents('drop');
spaces[i].removeEvents('over');
spaces[i].removeEvents('leave');;
}
});
}
);
clone.inject(document.body);
/* code usind dzone but not working
for( var y = 0; y < nzone; y++ ) {
dzone[y].addEvents({
'drop': function() {
for( var k = 0; k < nzone; k++ ) {
dzone[k].removeEvents('drop');
dzone[k].removeEvents('leave');
dzone[k].removeEvents('over');
}
clone.remove();
item.clone().inject(dzone[y]);
},
'over': function() {
},
'leave': function() {
}
});
};*/
spaces.each(function(ic, i)
{
if (types[i].getProperty('alt')=="space")
{
spaces[i].addEvents({
'drop': function() {
spaces.each(function(ic2, j)
{
if (types[j].getProperty('alt')=="space")
{
spaces[j].removeEvents('drop');
spaces[j].removeEvents('over');
spaces[j].removeEvents('leave');;
}
});
clone.remove();
item.clone().inject(spaces[i]);
},
'over': function() {
},
'leave': function() {
}
});
}
});
var drag = clone.makeDraggable({
droppables: dzone
}); // this returns the dragged element
drag.start(e); // start the event manual
});
}
});
07-16-2007 04:01 AM
deleteItem: function(name, noderef)
{
if (confirm("Are you sure you want to delete: " + name))
{
// ajax call to delete item
YAHOO.util.Connect.asyncRequest(
"POST",
getContextPath() + '/ajax/invoke/PortletActionsBean.deleteItem',
{
success: function(response)
{
But it seems to me that the name and noderef in argumetn arent even used. and I dont know what available beans are inside getContextPath() + '/ajax/invoke.<#list companyhome.nodeByReference[args.h].children?sort_by('name') as d
……………….
<div class="dragg">
<a href="${url.context}${d.url}" target="new" onmouseDown='MySpaces.dragItem("${d.name}", "${d.nodeRef}","${d}");' >…………….
</div>
dragItem: function(name, noderef , currentnode){
MySpaces.Npath=noderef;
MySpaces.Nnode=name;
// MySpaces.MoveNode=companyhome.parent.childByNamePath(somepath);
//var node=companyhome.childByNamePath(somepath);
MySpaces.likethat=MySpaces.likethat+1;
// if (MySpaces.MoveNode.name==name) {Myspaces.likethat=20;}
//alert("voila le nom du node enregistre " + MySpaces.MoveNode.name);
$('spacedisk').setHTML(MySpaces.likethat); //to see if there is an event triggered
},
07-16-2007 05:45 AM
But it seems to me that the name and noderef in argumetn arent even used. and I dont know what available beans are inside getContextPath() + '/ajax/invoke.Look further down the parameter list for the asyncRequest() call:
"noderef=" + noderef
I also tried to get the path and use the companyhome.childByNamePath(somepath); method but weirdly enough in firebug it tells me that companyhome isnt defined.You're still confusing client-side javascript with server-side javascript. The two are very different and you need to understand that difference in order to proceed:
07-16-2007 11:53 PM
YAHOO.util.Connect.asyncRequest(
"GET",
getContextPath() ,
{
success: function(response)
{
//response is my node and here I can use javascript node API
},
failure: function(response)
{
alert("Error during check out of item: " + response.responseText);
}
},
"noderef=" + noderef
);
Obviously If I m posting my code here as a question it is because I tried that and it didnt work but I hope I m facing the good way.07-17-2007 04:53 AM
07-17-2007 05:37 AM
07-17-2007 07:26 AM
THough I must say webscripting is very hard for the novices.
Tags
Find what you came for
We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.