Created
February 28, 2015 00:18
-
-
Save andresmatasuarez/a3411b0fe66075280a3b to your computer and use it in GitHub Desktop.
AngularJS | Directive | Collapsable section
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
'use strict' | |
# Usage: | |
# <collapsable-section section="'Support pages settings *'" description="'Placeholders: {{c}} - Calendar name, {{n}} - Landing name, {{l}} - Landing title'" start-collapsed="true"> | |
# I am the content of this section! | |
# </collapsable-section> | |
app = angular.module 'app' | |
app.directive 'collapsableSection', -> | |
restrict : 'E' | |
replace : true | |
transclude : true | |
scope : | |
startCollapsed : '=' | |
section : '=' | |
description : '=' | |
template : [ | |
'<div>' | |
'<h4 ng-click="collapse = !collapse">' | |
'<i class="text-center fa" style="width: 25px" ng-class="{ \'fa-chevron-down\': !collapse, \'fa-chevron-right\': collapse }"></i>' | |
'{{ section }}' | |
'</h4>' | |
'<div class="help-block">' | |
'{{ description }}' | |
'</div>' | |
'<hr/>' | |
'<div collapse="collapse">' | |
'<ng-transclude></ng-transclude>' | |
'</div>' | |
'</div>' | |
].join('\n') | |
link: ($scope, element, attrs) -> | |
$scope.collapse = $scope.startCollapsed; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment