Skip to content

Commit

Permalink
Port to plain JS
Browse files Browse the repository at this point in the history
  • Loading branch information
Fil Mackay committed Apr 30, 2013
1 parent 51e6b7a commit e1de93c
Show file tree
Hide file tree
Showing 62 changed files with 6,688 additions and 15 deletions.
17 changes: 2 additions & 15 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,17 +1,3 @@
# Dart Excludes #
#################
*~
*.js
*.js_
.children
.project
.gitmodules
*.map
*.lock
*.tmp
packages/
out/

# Compiled source #
###################
*.com
Expand Down Expand Up @@ -48,8 +34,9 @@ out/
ehthumbs.db
Icon?
Thumbs.db
.idea/

# Binary directories #
######################
bin/
obj/
obj/
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@

Ali Akbar <[email protected]>
Marius Volkhart <[email protected]>
Fil Mackay <[email protected]>
14 changes: 14 additions & 0 deletions dart/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Dart Excludes #
#################

*~
*.js
*.js_
.children
.project
.gitmodules
*.map
*.lock
*.tmp
packages/
out/
14 changes: 14 additions & 0 deletions dart_web_ui/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Dart Excludes #
#################

*~
*.js
*.js_
.children
.project
.gitmodules
*.map
*.lock
*.tmp
packages/
out/
Empty file removed js/.empty
Empty file.
1 change: 1 addition & 0 deletions js/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules/
2 changes: 2 additions & 0 deletions js/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
REM Smash .js files together: npm install smash
node node_modules/smash/smash lib/combine.js > out/js/dockspawn.js
14 changes: 14 additions & 0 deletions js/lib/combine.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(function()
{
dockspawn = {version: "0.0.1"};

import "tab/";
import "dialog/";
import "decorators/";
import "dock/";
import "containers/";
import "splitter/";
import "serialization/";
import "utils/";

})();
66 changes: 66 additions & 0 deletions js/lib/containers/DocumentManagerContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import "FillDockContainer";

/**
* The document manager is then central area of the dock layout hierarchy.
* This is where more important panels are placed (e.g. the text editor in an IDE,
* 3D view in a modelling package etc
*/
dockspawn.DocumentManagerContainer = function(dockManager)
{
dockspawn.FillDockContainer.call(this, dockManager, dockspawn.TabHost.DIRECTION_TOP);
this.minimumAllowedChildNodes = 0;
this.element.classList.add("document-manager");
this.tabHost.createTabPage = this._createDocumentTabPage;
this.tabHost.displayCloseButton = true;
};
dockspawn.DocumentManagerContainer.prototype = new dockspawn.FillDockContainer();
dockspawn.DocumentManagerContainer.prototype.constructor = dockspawn.DocumentManagerContainer;

dockspawn.DocumentManagerContainer.prototype._createDocumentTabPage = function(tabHost, container)
{
return new dockspawn.DocumentTabPage(tabHost, container);
};

dockspawn.DocumentManagerContainer.prototype.saveState = function(state)
{
dockspawn.FillDockContainer.prototype.saveState.call(this, state);
state.documentManager = true;
};

/** Returns the selected document tab */
dockspawn.DocumentManagerContainer.prototype.selectedTab = function()
{
return this.tabHost.activeTab;
};

/**
* Specialized tab page that doesn't display the panel's frame when docked in a tab page
*/
dockspawn.DocumentTabPage = function(host, container)
{
dockspawn.TabPage.call(this, host, container);

// If the container is a panel, extract the content element and set it as the tab's content
if (this.container.containerType == "panel")
{
this.panel = container;
this.containerElement = this.panel.elementContent;

// detach the container element from the panel's frame.
// It will be reattached when this tab page is destroyed
// This enables the panel's frame (title bar etc) to be hidden
// inside the tab page
removeNode(this.containerElement);
}
};
dockspawn.DocumentTabPage.prototype = new dockspawn.TabPage();
dockspawn.DocumentTabPage.prototype.constructor = dockspawn.DocumentTabPage;

dockspawn.DocumentTabPage.prototype.destroy = function()
{
dockspawn.TabPage.prototype.destroy.call(this);

// Restore the panel content element back into the panel frame
removeNode(this.containerElement);
this.panel.elementContentHost.appendChild(this.containerElement);
};
67 changes: 67 additions & 0 deletions js/lib/containers/FillDockContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import "../tab/TabHost";

dockspawn.FillDockContainer = function(dockManager, tabStripDirection)
{
if (arguments.length == 0)
return;

if (tabStripDirection === undefined)
tabStripDirection = dockspawn.TabHost.DIRECTION_BOTTOM;

this.dockManager = dockManager;
this.tabOrientation = tabStripDirection;
this.name = getNextId("fill_");
this.element = document.createElement("div");
this.containerElement = this.element;
this.containerType = "fill";
this.minimumAllowedChildNodes = 2;
this.element.classList.add("dock-container");
this.element.classList.add("dock-container-fill");
this.tabHost = new dockspawn.TabHost(this.tabOrientation);
this.element.appendChild(this.tabHost.hostElement);
}

dockspawn.FillDockContainer.prototype.setActiveChild = function(child)
{
this.tabHost.setActiveTab(child);
};

dockspawn.FillDockContainer.prototype.resize = function(width, height)
{
this.element.style.width = width + "px";
this.element.style.height = height + "px";
this.tabHost.resize(width, height);
};

dockspawn.FillDockContainer.prototype.performLayout = function(children)
{
this.tabHost.performLayout(children);
};

dockspawn.FillDockContainer.prototype.destroy = function()
{
if (removeNode(this.element))
delete this.element;
};

dockspawn.FillDockContainer.prototype.saveState = function(state)
{
state.width = this.width;
state.height = this.height;
};

dockspawn.FillDockContainer.prototype.loadState = function(state)
{
this.width = state.width;
this.height = state.height;
};

Object.defineProperty(dockspawn.FillDockContainer.prototype, "width", {
get: function() { return this.element.clientWidth; },
set: function(value) { this.element.style.width = value + "px" }
});

Object.defineProperty(dockspawn.FillDockContainer.prototype, "height", {
get: function() { return this.element.clientHeight; },
set: function(value) { this.element.style.height = value + "px" }
});
10 changes: 10 additions & 0 deletions js/lib/containers/HorizontalDockContainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import "SplitterDockContainer";

dockspawn.HorizontalDockContainer = function(dockManager, childContainers)
{
this.stackedVertical = false;
dockspawn.SplitterDockContainer.call(this, getNextId("horizontal_splitter_"), dockManager, childContainers);
this.containerType = "horizontal";
};
dockspawn.HorizontalDockContainer.prototype = new dockspawn.SplitterDockContainer();
dockspawn.HorizontalDockContainer.prototype.constructor = dockspawn.HorizontalDockContainer;
Loading

0 comments on commit e1de93c

Please sign in to comment.