1 // https://civicrm.org/licensing
2 (function(angular
, $, _
) {
5 // Menu item to control the border property of a node
6 angular
.module('afGuiEditor').component('afGuiMenuItemBorder', {
7 templateUrl
: '~/afGuiEditor/afGuiMenuItemBorder.html',
11 controller: function($scope
, afGui
) {
12 var ts
= $scope
.ts
= CRM
.ts(),
15 $scope
.getSetBorderWidth = function(width
) {
16 return getSetBorderProp(ctrl
.node
, 0, arguments
.length
? width
: null);
19 $scope
.getSetBorderStyle = function(style
) {
20 return getSetBorderProp(ctrl
.node
, 1, arguments
.length
? style
: null);
23 $scope
.getSetBorderColor = function(color
) {
24 return getSetBorderProp(ctrl
.node
, 2, arguments
.length
? color
: null);
27 function getSetBorderProp(node
, idx
, val
) {
28 var border
= getBorder(node
) || ['1px', '', '#000000'];
33 afGui
.setStyle(node
, 'border', val
? border
.join(' ') : null);
36 function getBorder(node
) {
37 var border
= _
.map((afGui
.getStyles(node
).border
|| '').split(' '), _
.trim
);
38 return border
.length
> 2 ? border
: null;
43 })(angular
, CRM
.$, CRM
._
);