Skip to content

Commit

Permalink
Update builds and bump version
Browse files Browse the repository at this point in the history
  • Loading branch information
chenlijun99 committed Dec 28, 2017
1 parent e2904c4 commit bfe4276
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 60 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-material-expansion-panel",
"version": "0.7.2",
"version": "0.8.0",
"description": "Material Design Expansion Panels.",
"main": [
"dist/md-expansion-panel.js",
Expand Down
136 changes: 79 additions & 57 deletions dist/md-expansion-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ function expansionPanelDirective() {
require: ['mdExpansionPanel', '?^^mdExpansionPanelGroup'],
scope: true,
compile: compile,
controller: ['$scope', '$element', '$attrs', '$window', '$$rAF', '$mdConstant', '$mdUtil', '$mdComponentRegistry', '$timeout', '$q', '$animate', '$parse', controller]
controller: ['$scope', '$element', '$attrs', '$window', '$$rAF', '$mdConstant', '$mdUtil', '$mdComponentRegistry', '$timeout', '$q', '$animate', '$parse', '$compile', controller]
};
return directive;

Expand Down Expand Up @@ -68,7 +68,7 @@ function expansionPanelDirective() {



function controller($scope, $element, $attrs, $window, $$rAF, $mdConstant, $mdUtil, $mdComponentRegistry, $timeout, $q, $animate, $parse) {
function controller($scope, $element, $attrs, $window, $$rAF, $mdConstant, $mdUtil, $mdComponentRegistry, $timeout, $q, $animate, $parse, $compile) {
/* jshint validthis: true */
var vm = this;

Expand Down Expand Up @@ -232,7 +232,7 @@ function expansionPanelDirective() {
options = options || {};

var deferred = $q.defer();
$scope.$emit("mdExpansionPanelExpanding", vm.componentId);
$scope.$emit("mdExpansionPanelExpanding", vm.componentId);

if (vm.epxansionPanelGroupCtrl) {
vm.epxansionPanelGroupCtrl.expandPanel(vm.componentId);
Expand All @@ -248,6 +248,13 @@ function expansionPanelDirective() {

initEvents();
collapsedCtrl.hide(options);

if (expandedCtrl.innerTemplate) {
expandedCtrl.$element.append(expandedCtrl.innerTemplate);
$compile(expandedCtrl.$element.children())($scope);
// set to null to that it gets compile only once
expandedCtrl.innerTemplate = null;
}
expandedCtrl.show(options);

if (headerCtrl) { headerCtrl.show(options); }
Expand Down Expand Up @@ -642,79 +649,94 @@ function expansionPanelCollapsedDirective($animateCss, $timeout) {
**/
expansionPanelExpandedDirective.$inject = ['$animateCss', '$timeout'];
function expansionPanelExpandedDirective($animateCss, $timeout) {

var directive = {
restrict: 'E',
require: '^^mdExpansionPanel',
link: link
compile: compile
};
return directive;

function compile(element, attrs) {
var innerTemplate;

function link(scope, element, attrs, expansionPanelCtrl) {
var setHeight = attrs.height || undefined;
if (setHeight !== undefined) { setHeight = setHeight.replace('px', '') + 'px'; }
if (attrs.lazyRender !== undefined) {
innerTemplate = element.html();
element.empty();
}

expansionPanelCtrl.registerExpanded({
show: show,
hide: hide,
setHeight: setHeight !== undefined,
$element: element
});
return link;

function link(scope, element, attrs, expansionPanelCtrl) {
var setHeight = attrs.height || undefined;
if (setHeight !== undefined) { setHeight = setHeight.replace('px', '') + 'px'; }

expansionPanelCtrl.registerExpanded({
show: show,
hide: hide,
setHeight: setHeight !== undefined,
$element: element,
innerTemplate: innerTemplate
});


function hide(options) {
var height = setHeight ? setHeight : element[0].scrollHeight + 'px';
element.addClass('md-hide md-overflow');
element.removeClass('md-show md-scroll-y');

var animationParams = {
from: {'max-height': height, opacity: 1},
to: {'max-height': '48px', opacity: 0}
};
if (options.animation === false) { animationParams.duration = 0; }
$animateCss(element, animationParams)
.start()
.then(function () {
element.css('display', 'none');
element.removeClass('md-hide');
});
}

function hide(options) {
var height = setHeight ? setHeight : element[0].scrollHeight + 'px';
element.addClass('md-hide md-overflow');
element.removeClass('md-show md-scroll-y');

function show(options) {
element.css('display', '');
element.addClass('md-show md-overflow');
// use passed in height or the contents height
var height = setHeight ? setHeight : element[0].scrollHeight + 'px';

var animationParams = {
from: {'max-height': '48px', opacity: 0},
to: {'max-height': height, opacity: 1}
};
if (options.animation === false) { animationParams.duration = 0; }
$animateCss(element, animationParams)
.start()
.then(function () {
var animationParams = {
from: {'max-height': height, opacity: 1},
to: {'max-height': '48px', opacity: 0}
};
if (options.animation === false) { animationParams.duration = 0; }
$animateCss(element, animationParams)
.start()
.then(function () {
element.css('display', 'none');
element.removeClass('md-hide');
});
}

// if height was passed in then set div to scroll
if (setHeight !== undefined) {
element.addClass('md-scroll-y');
} else {
// safari will animate the max-height if transition is not set to 0
element.css('transition', 'none');
element.css('max-height', 'none');
// remove transition block on next digest
$timeout(function () {
element.css('transition', '');
}, 0);
}

element.removeClass('md-overflow');
});
function show(options) {
element.css('display', '');
element.addClass('md-show md-overflow');
// use passed in height or the contents height
var height = setHeight ? setHeight : element[0].scrollHeight + 'px';

var animationParams = {
from: {'max-height': '48px', opacity: 0},
to: {'max-height': height, opacity: 1}
};
if (options.animation === false) { animationParams.duration = 0; }
$animateCss(element, animationParams)
.start()
.then(function () {

// if height was passed in then set div to scroll
if (setHeight !== undefined) {
element.addClass('md-scroll-y');
} else {
// safari will animate the max-height if transition is not set to 0
element.css('transition', 'none');
element.css('max-height', 'none');
// remove transition block on next digest
$timeout(function () {
element.css('transition', '');
}, 0);
}

element.removeClass('md-overflow');
});
}
}
}



}
}());
(function(){"use strict";angular
Expand Down
Loading

0 comments on commit bfe4276

Please sign in to comment.