2015-05-01 09:48:52 -04:00
|
|
|
/*
|
2015-05-02 18:34:16 -04:00
|
|
|
* Code Tabs Directive
|
2015-05-01 09:48:52 -04:00
|
|
|
*
|
2015-05-02 18:34:16 -04:00
|
|
|
* Creates a tabs code examples that
|
|
|
|
* displayed in the same container
|
2015-05-01 09:48:52 -04:00
|
|
|
*/
|
|
|
|
|
2015-05-02 18:34:16 -04:00
|
|
|
angularIO.directive('codeTabs', function($timeout) {
|
2015-05-01 09:48:52 -04:00
|
|
|
return {
|
2015-05-02 18:34:16 -04:00
|
|
|
restrict: 'E',
|
|
|
|
scope: {},
|
|
|
|
transclude: true,
|
|
|
|
replace: true,
|
|
|
|
|
|
|
|
controller: function ($scope) {
|
|
|
|
$scope.panes = [];
|
2015-05-01 09:48:52 -04:00
|
|
|
|
|
|
|
|
2015-05-02 18:34:16 -04:00
|
|
|
/*
|
|
|
|
* Add Code Pane List of Panes
|
|
|
|
*
|
|
|
|
*/
|
2015-05-01 09:48:52 -04:00
|
|
|
|
2015-05-02 18:34:16 -04:00
|
|
|
this.addPane = function(pane) {
|
|
|
|
if ($scope.panes.length === 0) {
|
|
|
|
$scope.showPane(pane);
|
|
|
|
}
|
2015-05-01 09:48:52 -04:00
|
|
|
|
2015-05-02 18:34:16 -04:00
|
|
|
$scope.panes.push(pane);
|
|
|
|
};
|
2015-05-01 09:48:52 -04:00
|
|
|
|
|
|
|
|
2015-05-02 18:34:16 -04:00
|
|
|
/*
|
|
|
|
* Show selected Code Examples
|
|
|
|
*
|
|
|
|
*/
|
2015-05-01 09:48:52 -04:00
|
|
|
|
2015-05-02 18:34:16 -04:00
|
|
|
$scope.showPane = function(pane) {
|
|
|
|
// RESET ALL EXAMPLES
|
|
|
|
angular.forEach($scope.panes, function(pane) {
|
|
|
|
pane.selected = false;
|
2015-05-01 09:48:52 -04:00
|
|
|
});
|
|
|
|
|
2015-05-02 18:34:16 -04:00
|
|
|
// SELECT CURRENT EXAMPLE
|
|
|
|
pane.selected = true;
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
|
|
|
template:
|
|
|
|
'<div class="code-box">' +
|
|
|
|
' <header class="code-box-header">' +
|
|
|
|
' <nav class="code-box-nav">' +
|
|
|
|
' <button ng-repeat="pane in panes" ng-click="showPane(pane)" class="button" ng-class="{selected:pane.selected}">' +
|
|
|
|
' {{pane.name}}' +
|
|
|
|
' </button>' +
|
|
|
|
' </nav>' +
|
|
|
|
' </header>' +
|
|
|
|
' <div class="code-box-examples" ng-transclude></div>' +
|
|
|
|
'</div>'
|
2015-05-01 09:48:52 -04:00
|
|
|
};
|
2015-05-02 18:34:16 -04:00
|
|
|
});
|