// JavaScript Document
site=new function(){
this.infoPanels=[
'panel_document_info',
'panel_folder_info',
'panel_document_info_edit'
];
this.currentFolder=null;
this.currentDocument=null;
this._cfgDefaults={
'baseurl' :'',
'services' :'',
'service.treestruct' :'',
'service.folderInfo' :'',
'service.docInfo' :''
};
this.cfg=function(cfgName){
if(arguments.length>0){
$.cookie(cfgName,arguments[1]);
}
var d=undefined;
if(this._cfgDefaults[cfgName]!=undefined)d=this._cfgDefaults[cfgName];
return lib.def($.cookie(cfgName),d);
}
/*
* The script includes are made instead of running site.bootStrap for Titanium compatibility
* (see index.html)
*
*/
this.libraries={
'js/lib.js' :'Framework Main Library',
'js/lib.debug.js' :'Framework Debugger Library',
'js/events.js' :'Events Delegation Engine',
'js/site.event.js' :'Site Events',
'js/jquery-1.3.2.min.js' :'jQuery Ver 1.3.2',
'js/jquery.cookie.js' :'jQuery Cookie Plugin',
'js/ui/ui.core.js' :'jQuery UI Core',
'js/ui/ui.tabs.js' :'jQuery UI Tabs Plugin',
'js/jquery.dynatree.min.js' :'jQuery DynaTree Tree Menu Plugin',
'js/ktApp.js' :'KT Atom Publishing Protocol Library'
}
this.init=function(){
this.setupUrls();
$('#perspectives').tabs().fadeIn(400);
this.setupCommsPanel();
this.setupTabEvents();
this.setupInspectors();
this.setupDisplay();
this.checkSettings();
events.trigger('perspective.folders.show');
}
this.checkSettings=function(){
if(this.cfg('baseurl')==''){
$('#setup').dialog('open');
}else{
}
}
this.bootStrap=function(){
for(var liburl in this.libraries){
this.includeJs(liburl);
}
$('document').ready(function(){site.init();});
}
this.includeJs=function(url){
$.ajax({async:false,url:url}); //Preload the javascript
var e = document.createElement("script");
e.src = url;
e.type="text/javascript";
document.getElementsByTagName("head")[0].appendChild(e);
}
this.setupDisplay=function(){
events.trigger('panel.clear');
$('#dialog').dialog({autoOpen:false, modal:true, dialogClass:'dialogs', closeOnEscape:true, buttons:{'OK':function(){$(this).dialog('close');}}});
$('#setup').dialog({width: 400, height:200, modal: true, autoOpen:false, dialogClass: 'dialogs'});
$('.fg-button').each(function(){
$(this).mouseover(function(){
$(this).addClass('ui-state-hover');
});
$(this).mouseout(function(){
$(this).removeClass('ui-state-hover');
});
});
}
this.showDialog=function(title,msg,buttons){
var d=$('#dialog');
if(buttons!=undefined)if(typeof(buttons)=='object'){
d.dialog('option','buttons',buttons);
}
d.dialog('option','title',title);
d.html(msg);
d.dialog('open');
}
this.hideDialog=function(){
var d=$('#dialog');
d.dialog('close');
}
this.setupUrls=function(){
lib.resources.setResourceUrl('base',this.cfg('baseurl'));
lib.resources.setResourceUrl('services',this.cfg('baseurl')+this.cfg('services'));
};
this.setupCommsPanel=function(){
events.listen('LIB.RESOURCES:Resource_Fetched',function(data){
$('#panel_comms').val($('#panel_comms').val()+"\n\n"+(data.data));
lib.debug.inspect($.xml2json(data.data));
// $('#panel_comms').chili();
})
events.listen('comms_clear_cache',function(){
document.getElementById('panel_comms').value='';
lib.debug.info('cleared comms panel');
})
}
this.setupInspectors=function(){
events.listen('panel.document.info.show',site.event_handlers.document_panel_info_show,site.event_handlers);
events.listen('panel.document.edit.show',site.event_handlers.document_panel_edit_show,site.event_handlers);
events.listen('panel.document.action.save',site.event_handlers.document_action_save,site.event_handlers);
events.listen('panel.document.action.delete',site.event_handlers.document_action_delete,site.event_handlers);
events.listen('panel.document.action.checkout',site.event_handlers.document_action_checkout,site.event_handlers);
events.listen('panel.document.action.download',site.event_handlers.document_action_download,site.event_handlers);
events.listen('panel.folder.info.show',site.event_handlers.folder_panel_info_show,site.event_handlers);
events.listen('panel.folder.edit.show',site.event_handlers.folder_panel_edit_show,site.event_handlers);
events.listen('panel.folder.action.save',site.event_handlers.folder_action_save,site.event_handlers);
events.listen('panel.folder.action.move',site.event_handlers.folder_action_move,site.event_handlers);
events.listen('setup.getservicedoc',site.event_handlers.discovery,site.event_handlers);
events.listen('info.activate.folder',function(id){site.event_handlers.folder_panel_info_show(id);});
events.listen('info.activate.document',function(id){site.event_handlers.document_panel_info_show(id);});
events.listen('panel.clear',function(){
for(var i=0; i element with this ID.
initAjax: null, // Ajax options used to initialize the tree strucuture.
autoFocus: true, // Set focus to first child, when expanding or lazy-loading.
keyboard: true, // Support keyboard navigation.
persist: false, // Persist expand-status to a cookie
autoCollapse: false, // Automatically collapse all siblings, when a node is expanded.
clickFolderMode: 3, // 1:activate, 2:expand, 3:activate and expand
activeVisible: true, // Make sure, active nodes are visible (expanded).
checkbox: false, // Show checkboxes.
selectMode: 2, // 1:single, 2:multi, 3:multi-hier
fx: null, // Animations, e.g. null or { height: "toggle", duration: 200 }
// Low level event handlers: onEvent(dtnode, event): return false, to stop default processing
onClick: null, // null: generate focus, expand, activate, select events.
onDblClick: null, // (No default actions.)
onKeydown: null, // null: generate keyboard navigation (focus, expand, activate).
onKeypress: null, // (No default actions.)
onFocus: null, // null: handle focus.
onBlur: null, // null: handle unfocus.
// Pre-event handlers onQueryEvent(flag, dtnode): return false, to stop processing
onQueryActivate: null, // Callback(flag, dtnode) before a node is (de)activated.
onQuerySelect: null, // Callback(flag, dtnode) before a node is (de)selected.
onQueryExpand: null, // Callback(flag, dtnode) before a node is expanded/collpsed.
// High level event handlers
onPostInit: null, // Callback(isReloading, isError) when tree was (re)loaded.
onActivate: null, // Callback(dtnode) when a node is activated.
onDeactivate: null, // Callback(dtnode) when a node is deactivated.
onSelect: null, // Callback(flag, dtnode) when a node is (de)selected.
onExpand: null, // Callback(flag, dtnode) when a node is expanded.
onLazyRead: null, // Callback(dtnode) when a lazy node is expanded for the first time.
ajaxDefaults: { // Used by initAjax option
cache: false, // false: Append random '_' argument to the request url to prevent caching.
dataType: "json" // Expect json format and pass json object to callbacks.
},
strings: {
loading: "LoadingÂ…",
loadError: "Load error!"
},
idPrefix: "ui-dynatree-id-", // Used to generate node id's like .
cookieId: "ui-dynatree-cookie", // Choose a more unique name, to allow multiple trees.
cookie: { // Options passed to $.cookie (see jquery.cookie.js)
expires: null, // Days or Date; null: session cookie
path: undefined, // String; Defaults to current page
domain: undefined, // String; Defaults to creator's domain
secure: undefined // Boolean; Defaults to false
},
debugLevel: 1 // 0:quiet, 1:normal, 2:debug
*/
})
}
};