Skip to content
This repository has been archived by the owner on Apr 3, 2022. It is now read-only.

Commit

Permalink
Fix handling one items group
Browse files Browse the repository at this point in the history
  • Loading branch information
pkrp committed Jul 14, 2016
1 parent f0cf8b2 commit c1d3040
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
7 changes: 5 additions & 2 deletions dist/cytoscape-actionbar.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
angular.module('cytoscape.actionbar', []).directive('cytoscapeActionbar', ["$timeout", function($timeout) {
return {
template: "<div class=\"cytoscape-graph-actionbar\" style=\"right: 0; left: 0; position: absolute; z-index: 1000\">\n <div ng-repeat=\"group in options.itemGroups\" ng-class=\"group.itemGroupClass\">\n <button ng-repeat=\"item in group.items\" ng-click='item.action(cy, item)'\n ng-disabled='!item.enabled()' ng-if='item.visible()'\n ng-class='[options.actionItemClass, icon, item.icon]' data-container='body' bs-tooltip='item.tooltip'>\n </button>\n </div>\n</div>",
template: "<div class=\"cytoscape-graph-actionbar\" style=\"right: 1.5%; left: 1.5%; position: absolute; z-index: 1000\">\n <div ng-repeat=\"group in options.itemGroups\" ng-class=\"group.itemsClass\">\n <button ng-repeat=\"item in group.items\" ng-click='item.action(cy, item)'\n ng-disabled='!item.enabled()' ng-if='item.visible()'\n ng-class='[options.actionItemClass, icon, item.icon]' data-container='body' bs-tooltip='item.tooltip'>\n </button>\n </div>\n</div>",
link: function(scope) {
return cytoscape('core', 'actionbar', function(options) {
var defaults, digestEvent, digestTimeout, group, i, item, j, k, len, len1, len2, ref, ref1, ref2, runDigestAfterEvent;
defaults = {
itemGroups: [],
itemGroups: {},
actionItemClass: 'action-item'
};
angular.extend(defaults, options);
if (options.itemGroups.itemsClass) {
options.itemGroups = [options.itemGroups];
}
ref = options.itemGroups;
for (i = 0, len = ref.length; i < len; i++) {
group = ref[i];
Expand Down
2 changes: 1 addition & 1 deletion dist/cytoscape-actionbar.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 6 additions & 3 deletions src/CytoscapeActionbar.coffee
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
angular.module('cytoscape.actionbar', []).directive 'cytoscapeActionbar', ($timeout) ->
template: """
<div class="cytoscape-graph-actionbar" style="right: 0; left: 0; position: absolute; z-index: 1000">
<div ng-repeat="group in options.itemGroups" ng-class="group.itemGroupClass">
<div class="cytoscape-graph-actionbar" style="right: 1.5%; left: 1.5%; position: absolute; z-index: 1000">
<div ng-repeat="group in options.itemGroups" ng-class="group.itemsClass">
<button ng-repeat="item in group.items" ng-click='item.action(cy, item)'
ng-disabled='!item.enabled()' ng-if='item.visible()'
ng-class='[options.actionItemClass, icon, item.icon]' data-container='body' bs-tooltip='item.tooltip'>
Expand All @@ -15,10 +15,13 @@ angular.module('cytoscape.actionbar', []).directive 'cytoscapeActionbar', ($time
'actionbar',
(options) ->
defaults =
itemGroups: []
itemGroups: {}
actionItemClass: 'action-item' # set a class name for a toolbar item to help with styling
angular.extend(defaults, options)

if options.itemGroups.itemsClass
options.itemGroups = [options.itemGroups]

for group in options.itemGroups
for item in group.items
item.visible ?= -> true
Expand Down

0 comments on commit c1d3040

Please sign in to comment.