var Mjs = {
Dialogs : {},
Models : {},
Collections: {},
Views : {},
onload: function() {
Mjs.Views.mainView.initPage();
// initialize the dialogs we'll see
Mjs.Dialogs.CreateCodeline.init();
Mjs.Dialogs.CreateConnector.init();
Mjs.Dialogs.ConfirmDelete.init();
Mjs.Dialogs.BrowseBranches.init();
Mjs.Dialogs.ExportGraph.init();
Mjs.Dialogs.ImportGraph.init();
Mjs.Dialogs.ClearGraph.init();
// setup our collections for the application
Mjs.Collections.connectorCollection =
new Mjs.Models.ConnectorCollection();
Mjs.Collections.codelineCollection =
new Mjs.Models.CodelineCollection();
Mjs.Views.mainView.init(Mjs.Collections.connectorCollection,
Mjs.Collections.codelineCollection);
},
jsPlumbDiagram : {
init :function() {
jsPlumb.importDefaults({
Endpoint: "Blank",
PaintStyle: {lineWidth:2,strokeStyle:"black"},
Anchor: "Continuous",
Connector: "StateMachine"
});
},
initEndpoints: function() {
$(".ep").each(function(i,e) {
var p = $(e).parent();
jsPlumb.makeSource($(e), {
parent:p,
isSource: true,
});
});
jsPlumb.makeTarget($(".w"), {
dropOptions:{ hoverClass:"dragHover" },
anchor:"Continuous",
isTarget: true,
beforeDrop: function(params) {
// Don't allow recursive connections
if (params.sourceId === params.targetId){
return false;
} else {
Mjs.Dialogs.CreateConnector.open(params.sourceId,
params.targetId);
}
}
});
}
}
};
$(document).ready(Mjs.onload);