a.af-api4-action-idle {
cursor: pointer;
}
+
+.af-block.af-layout-cols {
+ display: flex;
+}
+.af-block.af-layout-cols > * {
+ flex: 1;
+}
+.af-block.af-layout-inline > * {
+ display: inline-block;
+ margin-right: .5em;
+}
left: 4px;
top: 5px;
}
+
+#afGuiEditor .af-gui-layout-icon {
+ width: 12px;
+ height: 11px;
+ display: block;
+ background-image: url('../images/icons.png');
+ background-repeat: no-repeat;
+ margin: 4px 1px;
+}
+#afGuiEditor .af-gui-layout-icon.af-layout-cols {
+ background-position: -12px 0;
+}
+#afGuiEditor .af-gui-layout-icon.af-layout-rows {
+ background-position: -24px 0;
+}
+
+#afGuiEditor .af-gui-layout.af-layout-cols {
+ display: flex;
+}
+#afGuiEditor .af-gui-layout.af-layout-cols > div {
+ flex: 1;
+}
+#afGuiEditor .af-gui-layout.af-layout-inline > div {
+ display: inline-block;
+ width: 300px;
+}
function initialize(afform) {
$scope.afform = afform;
+ // Remove empty text nodes, they just create clutter
+ removeRecursive($scope.afform.layout, function(item) {
+ return ('#text' in item) && _.trim(item['#text']).length === 0;
+ });
$scope.layout = getTags($scope.afform.layout, 'af-form')[0];
evaluate($scope.layout['#children']);
$scope.entities = getTags($scope.layout['#children'], 'af-entity', 'name');
fieldset: ts('Fieldset')
};
+ $scope.layouts = {
+ 'af-layout-rows': ts('Contents display as rows'),
+ 'af-layout-cols': ts('Contents are evenly-spaced columns'),
+ 'af-layout-inline': ts('Contents are arranged inline')
+ };
+
+ $scope.getLayout = function() {
+ return _.intersection(splitClass($scope.node['class']), _.keys($scope.layouts))[0] || 'af-layout-rows';
+ };
+
+ $scope.setLayout = function(val) {
+ var classes = ['af-block'];
+ if (val !== 'af-layout-rows') {
+ classes.push(val);
+ }
+ $scope.block.modifyClasses($scope.node, _.keys($scope.layouts), classes);
+ };
+
}
};
});
};
$scope.getAlign = function() {
- return _.intersection(splitClass($scope.node['class']), _.keys($scope.alignments))[0];
+ return _.intersection(splitClass($scope.node['class']), _.keys($scope.alignments))[0] || 'text-left';
};
$scope.setAlign = function(val) {
- $scope.block.modifyClasses($scope.node, _.keys($scope.alignments), val);
+ $scope.block.modifyClasses($scope.node, _.keys($scope.alignments), val === 'text-left' ? null : val);
};
}
};
<select class="pull-right" ng-model="node['#tag']">
<option ng-repeat="(opt, label) in tags" value="{{ opt }}">{{ label }}</option>
</select>
+ <div class="btn-group btn-group-xs pull-right" role="group">
+ <button type="button" class="btn btn-default" ng-class="{active: opt === getLayout()}" ng-repeat="(opt, label) in layouts" ng-click="setLayout(opt)" title="{{ label }}">
+ <i class="af-gui-layout-icon {{ opt }}" ></i>
+ </button>
+ </div>
</div>
-<div ui-sortable="{handle: '.af-gui-bar', connectWith: '[ui-sortable]'}" ng-model="node['#children']">
- <div ng-repeat="item in node['#children']">
+<div ui-sortable="{handle: '.af-gui-bar', connectWith: '[ui-sortable]'}" ng-model="node['#children']" class="af-gui-layout {{ getLayout() }}">
+ <div ng-repeat="item in node['#children']" ng-show="block.getNodeType(item)">
<div ng-switch="block.getNodeType(item)">
<div ng-switch-when="fieldset" af-gui-block="item" class="af-gui-block af-gui-fieldset" ng-class="{'af-entity-selected': isSelectedFieldset(item['af-fieldset'])}" entity-name="item['af-fieldset']" data-entity="{{ item['af-fieldset'] }}" />
<div ng-switch-when="block" af-gui-block="item" class="af-gui-block" entity-name="entityName" />
<option ng-repeat="(opt, label) in tags" value="{{ opt }}">{{ label }}</option>
</select>
<div class="btn-group btn-group-xs pull-right" role="group">
- <button type="button" class="btn btn-default" ng-class="{active: (opt === getAlign()) || (opt === 'text-left' && !getAlign())}" ng-repeat="(opt, label) in alignments" ng-click="setAlign(opt)" title="{{ label }}">
+ <button type="button" class="btn btn-default" ng-class="{active: opt === getAlign()}" ng-repeat="(opt, label) in alignments" ng-click="setAlign(opt)" title="{{ label }}">
<i class="crm-i fa-{{ opt.replace('text', 'align') }}" ></i>
</button>
</div>
<fieldset af-fieldset="parent">
<legend class="af-text">About You</legend>
- <div class="af-block">
+ <div class="af-block af-layout-inline">
<af-field name="first_name" />
<af-field name="last_name" />
</div>