Code:
ImageDropZone = function(view, config){
this.view = view;
ImageDropZone.superclass.constructor.call(this, view.getEl(), config);
};
Ext.extend(ImageDropZone, Ext.dd.DropZone, {
getTargetFromEvent: function(e) {
var target = null;
target = e.getTarget('.icon-wrap');
if (undefined == target || null == target)
{
//target = e.getTarget('li.x-tree-node');
target = e.getTarget('x-tree-node-el');
}
return target;
},
onContainerDrop:function ( source, e, data ){
this.onNodeDrop(e.target, source, e, data);
},
..........
...........
Code:
MyDesktop.DynamicShareBoxModule = Ext.extend(Ext.app.Module, {
sbToolbar:null,
sbStore :null,
sbView : null,
id:Ext.Box.ID.Panel.shareBoxesModulesId,
winId : null,
shareboxes : [] ,
dataView : undefined,
init : function(config){
this.launcher = {
id: Ext.Box.ID.Panel.shareBoxesMenuId,
text: Ext.Box.ID.Panel.shareBoxesMenuText,
iconCls: 'shareboxes-icon',
handler: function() {return false;},
menu:this.initMenu(config),
shareboxObj:{},
scope: this
};
},
initMenu : function(shareboxResources){
var menu = new Ext.menu.Menu();
for(var i = 0, len = shareboxResources.length; i < len; i++){
var m = shareboxResources[i];
var menuitem = new Ext.menu.Item ({text: m.name, iconCls:'bogus',handler : this.createWindow, scope: this, windowId: m.id, shareboxObj: m });
menu.addMenuItem ( menuitem );
}
return menu;
},
initModule : function(win){
this.shareboxes.push(win);
},
setViewTemplate : function(item){
if (item.name =='icon')
{ this.app.desktop.getWindow(item.winId).items.items[0].tpl=Ext.Box.Globals.ShareBoxes.shareboxiconTemplate;
this.app.desktop.getWindow(item.winId).items.items[0].refresh();
this.app.desktop.getWindow(item.winId).items.items[0].store.sort('name','ASC');}
else
{ this.app.desktop.getWindow(item.winId).items.items[0].tpl=Ext.Box.Globals.ShareBoxes.shareboxstandardTemplate;
this.app.desktop.getWindow(item.winId).items.items[0].store.sort('name','ASC');
this.app.desktop.getWindow(item.winId).items.items[0].refresh();}
},
getToolbar: function(src){
return new Ext.Toolbar ({
//height: 25,
items:[
{winId:src.windowId,cls:'x-btn-icon', name:'icon',iconCls:'connect',handler: this.setViewTemplate,scope:this,tooltip:{title:'Icon view', text:'see your files as icons'}},
'-',
{winId:src.windowId,cls:'x-btn-icon',name:'detail',iconCls:'user-add',handler: this.setViewTemplate,scope:this,tooltip:{title:'Detail view', text:'see your files with extra info'}}
]
});
}
,
getStore: function(p){
return new Ext.data.JsonStore({
//storeId: 'shareBoxStore',
root: 'sharebox',
idProperty: 'id',
proxy : new Ext.data.ScriptTagProxy({
url : Ext.Box.Globals.getOnlineShareboxResourceURL(p)
}),
autoLoad: false,
//fields:Ext.Box.Globals.JsonReaders.filetreeJsonFields,
fields:Ext.Box.Globals.JsonReaders.shareboxResourceJsonFields,
sortInfo: {
field: 'name',
direction: 'ASC'
}
});
},
getView : function(config){
return new Ext.DataView({
//id:Ext.Box.Globals.ShareBoxes.dataViewId,
id:Ext.Box.Globals.ShareBoxes.dataViewPrefix+config.windowId,
objtype:Ext.Box.Globals.DDobjType.shareBoxDataview,
cls:'imagessharebox',
layout:'fit',
html:'<div class="imagessharebox">',
itemSelector: config.shareboxObj.viewtype == Ext.Box.Globals.ShareBoxViews.icon ? 'div.icon-wrap' : 'div.thumb-wrap',
style:'overflow:auto',
multiSelect: true,
plugins: new Ext.DataView.DragSelector({dragSafe:true}),
store: config.store,
tpl: config.shareboxObj.viewtype == Ext.Box.Globals.ShareBoxViews.icon ? Ext.Box.Globals.ShareBoxes.shareboxiconTemplate : Ext.Box.Globals.ShareBoxes.shareboxstandardTemplate,
prepareData: function(data){
var path, ext, type;
var color = 'blue';
data.imgfoldericon = 'images/desktop/resources/folders/blue-default-closed-64.gif';
data.imgfileicon = 'images/desktop/resources/files/blue-default-64.gif';
return data;
}
});
},
createWindow : function(src){
var desktop = this.app.getDesktop();
var win = desktop.getWindow(src.windowId);
if(!win){
// type of view
if (src.shareboxObj.viewtype != Ext.Box.Globals.ShareBoxViews.icon && src.shareboxObj.viewtype != Ext.Box.Globals.ShareBoxViews.detail) {
throw 'Invalid view in Sharebox constructor: ' + this.shareboxObj.viewtype;
}
var sbStore = this.getStore(src.windowId);
var sbToolbar = this.getToolbar(src);
src.store = sbStore;
var nview = this.getView(src);
sbStore.load();
/*config ={id:src.windowId,rootLocationId:src.windowId };
this.dataView = this.createView(config);
Ext.Box.ActionMgr.selectLocation(Box.Util.Element.encodeId(src.windowId), Box.Util.Element.encodeId(src.windowId));
*/
win = desktop.createWindow({
id: src.windowId,
winId:src.windowId,
title:src.text,
width:640,
height:480,
tbar:sbToolbar,
layout:'fit',
iconCls: 'shareboxes-icon',
shim:false,
animCollapse:false,
constrainHeader:true,
items: [nview]
});
//src.store.load();
this.initModule(win);
var dragZone = new ImageDragZone(nview, {containerScroll:true,
ddGroup: 'organizerDD'});
var dropZone = new ImageDropZone(nview, {containerScroll:true,
ddGroup: 'organizerDD'});
}
win.show();
}
});