forked from fex-team/kityminder
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
84 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
utils.extend(KityMinder, { | ||
_templates: {}, | ||
registerTemplate: function(name, supports) { | ||
KityMinder._templates[name] = supports; | ||
} | ||
}); | ||
|
||
kity.extendClass(Minder, (function() { | ||
var originGetTheme = Minder.prototype.getTheme; | ||
return { | ||
useTemplate: function(name) { | ||
this._template = name; | ||
|
||
this.getRoot().traverse(function(node) { | ||
node.render(); | ||
}); | ||
|
||
this.layout(300); | ||
}, | ||
|
||
getTemplateSupports: function() { | ||
return KityMinder._templates[this._template] || null; | ||
}, | ||
|
||
getTheme: function(node) { | ||
var supports = this.getTemplateSupports(); | ||
if (supports && supports.getTheme) { | ||
return supports.getTheme(node); | ||
} | ||
return originGetTheme.call(this, node); | ||
} | ||
}; | ||
})()); | ||
|
||
|
||
kity.extendClass(MinderNode, (function() { | ||
var originGetLayout = MinderNode.prototype.getLayout; | ||
return { | ||
getLayout: function() { | ||
var supports = this.getMinder().getTemplateSupports(); | ||
if (supports && supports.getLayout) { | ||
return supports.getLayout(this); | ||
} | ||
return originGetLayout.call(this); | ||
} | ||
}; | ||
})()); | ||
|
||
KityMinder.registerModule('TemplateModule', { | ||
commands: { | ||
'template': kity.createClass('TemplateCommand', { | ||
base: Command, | ||
|
||
execute: function(minder, name) { | ||
minder.useTemplate(name); | ||
}, | ||
|
||
queryCommandValue: function(minder) { | ||
return minder._template; | ||
} | ||
}) | ||
} | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
KityMinder.registerTemplate('bottom', { | ||
|
||
getLayout: function(node) { | ||
|
||
if (node.getData('layout')) return node.getData('layout'); | ||
if (node.isRoot()) return 'bottom'; | ||
|
||
return 'filetree'; | ||
}, | ||
|
||
getTheme: function(node) { | ||
return node.isRoot() ? 'bottom' : 'filetree'; | ||
} | ||
}); |