forked from elastic/kibana
-
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.
Merge pull request elastic#7591 from cjcenizal/refactor/remove-angula…
…r-bootstrap-dependency Remove angular-bootstrap dependency.
- Loading branch information
Showing
51 changed files
with
4,298 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
src/fixtures | ||
|
||
test/fixtures/scenarios | ||
optimize | ||
test/fixtures/scenarios |
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
10 changes: 10 additions & 0 deletions
10
src/ui/public/angular-bootstrap/accordion/accordion-group.html
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,10 @@ | ||
<div class="panel panel-default"> | ||
<div class="panel-heading"> | ||
<h4 class="panel-title"> | ||
<a href class="accordion-toggle" ng-click="toggleOpen()" accordion-transclude="heading"><span ng-class="{'text-muted': isDisabled}">{{heading}}</span></a> | ||
</h4> | ||
</div> | ||
<div class="panel-collapse" collapse="!isOpen"> | ||
<div class="panel-body" ng-transclude></div> | ||
</div> | ||
</div> |
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 @@ | ||
<div class="panel-group" ng-transclude></div> |
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,130 @@ | ||
angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse']) | ||
|
||
.constant('accordionConfig', { | ||
closeOthers: true | ||
}) | ||
|
||
.controller('AccordionController', ['$scope', '$attrs', 'accordionConfig', function ($scope, $attrs, accordionConfig) { | ||
|
||
// This array keeps track of the accordion groups | ||
this.groups = []; | ||
|
||
// Ensure that all the groups in this accordion are closed, unless close-others explicitly says not to | ||
this.closeOthers = function(openGroup) { | ||
var closeOthers = angular.isDefined($attrs.closeOthers) ? $scope.$eval($attrs.closeOthers) : accordionConfig.closeOthers; | ||
if ( closeOthers ) { | ||
angular.forEach(this.groups, function (group) { | ||
if ( group !== openGroup ) { | ||
group.isOpen = false; | ||
} | ||
}); | ||
} | ||
}; | ||
|
||
// This is called from the accordion-group directive to add itself to the accordion | ||
this.addGroup = function(groupScope) { | ||
var that = this; | ||
this.groups.push(groupScope); | ||
|
||
groupScope.$on('$destroy', function (event) { | ||
that.removeGroup(groupScope); | ||
}); | ||
}; | ||
|
||
// This is called from the accordion-group directive when to remove itself | ||
this.removeGroup = function(group) { | ||
var index = this.groups.indexOf(group); | ||
if ( index !== -1 ) { | ||
this.groups.splice(index, 1); | ||
} | ||
}; | ||
|
||
}]) | ||
|
||
// The accordion directive simply sets up the directive controller | ||
// and adds an accordion CSS class to itself element. | ||
.directive('accordion', function () { | ||
return { | ||
restrict:'EA', | ||
controller:'AccordionController', | ||
transclude: true, | ||
replace: false, | ||
templateUrl: 'template/accordion/accordion.html' | ||
}; | ||
}) | ||
|
||
// The accordion-group directive indicates a block of html that will expand and collapse in an accordion | ||
.directive('accordionGroup', function() { | ||
return { | ||
require:'^accordion', // We need this directive to be inside an accordion | ||
restrict:'EA', | ||
transclude:true, // It transcludes the contents of the directive into the template | ||
replace: true, // The element containing the directive will be replaced with the template | ||
templateUrl:'template/accordion/accordion-group.html', | ||
scope: { | ||
heading: '@', // Interpolate the heading attribute onto this scope | ||
isOpen: '=?', | ||
isDisabled: '=?' | ||
}, | ||
controller: function() { | ||
this.setHeading = function(element) { | ||
this.heading = element; | ||
}; | ||
}, | ||
link: function(scope, element, attrs, accordionCtrl) { | ||
accordionCtrl.addGroup(scope); | ||
|
||
scope.$watch('isOpen', function(value) { | ||
if ( value ) { | ||
accordionCtrl.closeOthers(scope); | ||
} | ||
}); | ||
|
||
scope.toggleOpen = function() { | ||
if ( !scope.isDisabled ) { | ||
scope.isOpen = !scope.isOpen; | ||
} | ||
}; | ||
} | ||
}; | ||
}) | ||
|
||
// Use accordion-heading below an accordion-group to provide a heading containing HTML | ||
// <accordion-group> | ||
// <accordion-heading>Heading containing HTML - <img src="..."></accordion-heading> | ||
// </accordion-group> | ||
.directive('accordionHeading', function() { | ||
return { | ||
restrict: 'EA', | ||
transclude: true, // Grab the contents to be used as the heading | ||
template: '', // In effect remove this element! | ||
replace: true, | ||
require: '^accordionGroup', | ||
link: function(scope, element, attr, accordionGroupCtrl, transclude) { | ||
// Pass the heading to the accordion-group controller | ||
// so that it can be transcluded into the right place in the template | ||
// [The second parameter to transclude causes the elements to be cloned so that they work in ng-repeat] | ||
accordionGroupCtrl.setHeading(transclude(scope, function() {})); | ||
} | ||
}; | ||
}) | ||
|
||
// Use in the accordion-group template to indicate where you want the heading to be transcluded | ||
// You must provide the property on the accordion-group controller that will hold the transcluded element | ||
// <div class="accordion-group"> | ||
// <div class="accordion-heading" ><a ... accordion-transclude="heading">...</a></div> | ||
// ... | ||
// </div> | ||
.directive('accordionTransclude', function() { | ||
return { | ||
require: '^accordionGroup', | ||
link: function(scope, element, attr, controller) { | ||
scope.$watch(function() { return controller[attr.accordionTransclude]; }, function(heading) { | ||
if ( heading ) { | ||
element.html(''); | ||
element.append(heading); | ||
} | ||
}); | ||
} | ||
}; | ||
}); |
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,7 @@ | ||
<div class="alert" ng-class="['alert-' + (type || 'warning'), closeable ? 'alert-dismissable' : null]" role="alert"> | ||
<button ng-show="closeable" type="button" class="close" ng-click="close()"> | ||
<span aria-hidden="true">×</span> | ||
<span class="sr-only">Close</span> | ||
</button> | ||
<div ng-transclude></div> | ||
</div> |
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,31 @@ | ||
angular.module('ui.bootstrap.alert', []) | ||
|
||
.controller('AlertController', ['$scope', '$attrs', function ($scope, $attrs) { | ||
$scope.closeable = 'close' in $attrs; | ||
this.close = $scope.close; | ||
}]) | ||
|
||
.directive('alert', function () { | ||
return { | ||
restrict:'EA', | ||
controller:'AlertController', | ||
templateUrl:'template/alert/alert.html', | ||
transclude:true, | ||
replace:true, | ||
scope: { | ||
type: '@', | ||
close: '&' | ||
} | ||
}; | ||
}) | ||
|
||
.directive('dismissOnTimeout', ['$timeout', function($timeout) { | ||
return { | ||
require: 'alert', | ||
link: function(scope, element, attrs, alertCtrl) { | ||
$timeout(function(){ | ||
alertCtrl.close(); | ||
}, parseInt(attrs.dismissOnTimeout, 10)); | ||
} | ||
}; | ||
}]); |
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,10 @@ | ||
angular.module('ui.bootstrap.bindHtml', []) | ||
|
||
.directive('bindHtmlUnsafe', function () { | ||
return function (scope, element, attr) { | ||
element.addClass('ng-binding').data('$binding', attr.bindHtmlUnsafe); | ||
scope.$watch(attr.bindHtmlUnsafe, function bindHtmlUnsafeWatchAction(value) { | ||
element.html(value || ''); | ||
}); | ||
}; | ||
}); |
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,74 @@ | ||
angular.module('ui.bootstrap.buttons', []) | ||
|
||
.constant('buttonConfig', { | ||
activeClass: 'active', | ||
toggleEvent: 'click' | ||
}) | ||
|
||
.controller('ButtonsController', ['buttonConfig', function(buttonConfig) { | ||
this.activeClass = buttonConfig.activeClass || 'active'; | ||
this.toggleEvent = buttonConfig.toggleEvent || 'click'; | ||
}]) | ||
|
||
.directive('btnRadio', function () { | ||
return { | ||
require: ['btnRadio', 'ngModel'], | ||
controller: 'ButtonsController', | ||
link: function (scope, element, attrs, ctrls) { | ||
var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1]; | ||
|
||
//model -> UI | ||
ngModelCtrl.$render = function () { | ||
element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, scope.$eval(attrs.btnRadio))); | ||
}; | ||
|
||
//ui->model | ||
element.bind(buttonsCtrl.toggleEvent, function () { | ||
var isActive = element.hasClass(buttonsCtrl.activeClass); | ||
|
||
if (!isActive || angular.isDefined(attrs.uncheckable)) { | ||
scope.$apply(function () { | ||
ngModelCtrl.$setViewValue(isActive ? null : scope.$eval(attrs.btnRadio)); | ||
ngModelCtrl.$render(); | ||
}); | ||
} | ||
}); | ||
} | ||
}; | ||
}) | ||
|
||
.directive('btnCheckbox', function () { | ||
return { | ||
require: ['btnCheckbox', 'ngModel'], | ||
controller: 'ButtonsController', | ||
link: function (scope, element, attrs, ctrls) { | ||
var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1]; | ||
|
||
function getTrueValue() { | ||
return getCheckboxValue(attrs.btnCheckboxTrue, true); | ||
} | ||
|
||
function getFalseValue() { | ||
return getCheckboxValue(attrs.btnCheckboxFalse, false); | ||
} | ||
|
||
function getCheckboxValue(attributeValue, defaultValue) { | ||
var val = scope.$eval(attributeValue); | ||
return angular.isDefined(val) ? val : defaultValue; | ||
} | ||
|
||
//model -> UI | ||
ngModelCtrl.$render = function () { | ||
element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, getTrueValue())); | ||
}; | ||
|
||
//ui->model | ||
element.bind(buttonsCtrl.toggleEvent, function () { | ||
scope.$apply(function () { | ||
ngModelCtrl.$setViewValue(element.hasClass(buttonsCtrl.activeClass) ? getFalseValue() : getTrueValue()); | ||
ngModelCtrl.$render(); | ||
}); | ||
}); | ||
} | ||
}; | ||
}); |
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,8 @@ | ||
<div ng-mouseenter="pause()" ng-mouseleave="play()" class="carousel" ng-swipe-right="prev()" ng-swipe-left="next()"> | ||
<ol class="carousel-indicators" ng-show="slides.length > 1"> | ||
<li ng-repeat="slide in slides track by $index" ng-class="{active: isActive(slide)}" ng-click="select(slide)"></li> | ||
</ol> | ||
<div class="carousel-inner" ng-transclude></div> | ||
<a class="left carousel-control" ng-click="prev()" ng-show="slides.length > 1"><span class="glyphicon glyphicon-chevron-left"></span></a> | ||
<a class="right carousel-control" ng-click="next()" ng-show="slides.length > 1"><span class="glyphicon glyphicon-chevron-right"></span></a> | ||
</div> |
Oops, something went wrong.