This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(speedDial): ability to use ng-repeat for the items
you can now use ng-repeat for the speed dial's action items also updated docs to have fewer but more complex examples closes #3224
- Loading branch information
1 parent
06b2e77
commit 312b688
Showing
14 changed files
with
204 additions
and
254 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
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,50 @@ | ||
ddescribe('<md-fab-actions> directive', function() { | ||
|
||
beforeEach(module('material.components.fabActions')); | ||
|
||
var pageScope, element, controller; | ||
|
||
function compileAndLink(template) { | ||
inject(function($compile, $rootScope) { | ||
pageScope = $rootScope.$new(); | ||
element = $compile(template)(pageScope); | ||
controller = element.controller('mdFabActions'); | ||
|
||
pageScope.$apply(); | ||
}); | ||
} | ||
|
||
it('supports static children', inject(function() { | ||
compileAndLink( | ||
'<md-fab-speed-dial>' + | ||
' <md-fab-actions>' + | ||
' <md-button>1</md-button>' + | ||
' <md-button>2</md-button>' + | ||
' <md-button>3</md-button>' + | ||
' </md-fab-actions>' + | ||
'</md-fab-speed-dial>' | ||
); | ||
|
||
expect(element.find("md-fab-actions").children().length).toBe(3); | ||
expect(element.find("md-fab-actions").children()).toHaveClass('md-fab-action-item'); | ||
})); | ||
|
||
it('supports actions created by ng-repeat', inject(function() { | ||
compileAndLink( | ||
'<md-fab-speed-dial ng-init="nums=[1,2,3]">' + | ||
' <md-fab-actions>' + | ||
' <div ng-repeat="i in nums"><md-button>{{i}}</md-button></div>' + | ||
' </md-fab-actions>' + | ||
'</md-fab-speed-dial>' | ||
); | ||
|
||
expect(element.find("md-fab-actions").children().length).toBe(3); | ||
expect(element.find("md-fab-actions").children()).toHaveClass('md-fab-action-item'); | ||
|
||
pageScope.$apply('nums=[1,2,3,4]'); | ||
|
||
expect(element.find("md-fab-actions").children().length).toBe(4); | ||
expect(element.find("md-fab-actions").children()).toHaveClass('md-fab-action-item'); | ||
})); | ||
|
||
}); |
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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,93 @@ | ||
<div layout="column" ng-controller="DemoCtrl as demo"> | ||
<md-content class="md-padding" layout="column"> | ||
<p> | ||
The speed dial supports many advanced usage scenarios. This demo shows many of them mixed | ||
together. | ||
</p> | ||
|
||
<div class="lock-size" layout="row" layout-align="center center"> | ||
<md-fab-speed-dial ng-hide="demo.hidden" md-direction="down" class="md-fling"> | ||
<md-fab-trigger> | ||
<md-button aria-label="menu" class="md-fab md-warn"> | ||
<md-tooltip md-direction="top">Menu</md-tooltip> | ||
<md-icon md-svg-src="img/icons/menu.svg"></md-icon> | ||
</md-button> | ||
</md-fab-trigger> | ||
|
||
<md-fab-actions> | ||
<div ng-repeat="item in demo.items"> | ||
<md-button aria-label="{{item.name}}" class="md-fab md-raised md-mini" | ||
ng-click="demo.openDialog($event, item)"> | ||
<md-tooltip md-direction="{{item.direction}}">{{item.name}}</md-tooltip> | ||
<md-icon md-svg-src="{{item.icon}}"></md-icon> | ||
</md-button> | ||
</div> | ||
</md-fab-actions> | ||
</md-fab-speed-dial> | ||
</div> | ||
</md-content> | ||
|
||
<md-content class="md-padding" layout="row"> | ||
<div> | ||
<h3>Tooltips</h3> | ||
|
||
<p> | ||
Each action item supports a tooltip using the standard approach as can be seen above. | ||
</p> | ||
</div> | ||
|
||
<div> | ||
<h3>ngHide</h3> | ||
|
||
<p> | ||
The speed dial also supports hiding using the standard <code>ng-hide</code> attribute. | ||
|
||
<md-checkbox ng-model="demo.hidden"> | ||
Hide the speed dial. | ||
</md-checkbox> | ||
</p> | ||
</div> | ||
</md-content> | ||
|
||
<md-content class="md-padding" layout="row"> | ||
<div> | ||
<h3>ngRepeat</h3> | ||
|
||
<p> | ||
You can easily use <code>ng-repeat</code> with the speed dial, but it requires a slightly | ||
different HTML structure in order to support the necessary DOM changes/styling. | ||
</p> | ||
|
||
<p> | ||
Simply ensure that your <code>ng-repeat</code> is on a <code>div</code> (or any other tag) | ||
that wraps your items. | ||
</p> | ||
</div> | ||
|
||
<div> | ||
<h3>$mdDialog</h3> | ||
|
||
<p> | ||
You can also use the buttons to open a dialog. When clicked, the buttons above will open a | ||
dialog showing a message which item was clicked. | ||
</p> | ||
</div> | ||
</md-content> | ||
|
||
<script type="text/ng-template" id="dialog.html"> | ||
<md-dialog> | ||
<md-dialog-content>Hello User! You clicked {{dialog.item.name}}.</md-dialog-content> | ||
|
||
<div class="md-actions"> | ||
<md-button aria-label="Close dialog" ng-click="dialog.close()" class="md-primary"> | ||
Close Greeting | ||
</md-button> | ||
|
||
<md-button aria-label="Submit dialog" ng-click="dialog.submit()" class="md-primary"> | ||
Submit | ||
</md-button> | ||
</div> | ||
</md-dialog> | ||
</script> | ||
|
||
</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,38 @@ | ||
(function() { | ||
'use strict'; | ||
|
||
angular.module('fabSpeedDialDemoMoreOptions', ['ngMaterial']) | ||
.controller('DemoCtrl', function($mdDialog) { | ||
var self = this; | ||
|
||
self.hidden = false; | ||
|
||
self.items = [ | ||
{name: "Twitter", icon: "img/icons/twitter.svg", direction: "left" }, | ||
{name: "Facebook", icon: "img/icons/facebook.svg", direction: "right" }, | ||
{name: "Google Hangout", icon: "img/icons/hangout.svg", direction: "left" } | ||
]; | ||
|
||
self.openDialog = function($event, item) { | ||
// Show the dialog | ||
$mdDialog.show({ | ||
clickOutsideToClose: true, | ||
controller: function($mdDialog) { | ||
// Save the clicked item | ||
this.item = item; | ||
|
||
// Setup some handlers | ||
this.close = function() { | ||
$mdDialog.cancel(); | ||
}; | ||
this.submit = function() { | ||
$mdDialog.hide(); | ||
}; | ||
}, | ||
controllerAs: 'dialog', | ||
templateUrl: 'dialog.html', | ||
targetEvent: $event | ||
}); | ||
} | ||
}); | ||
})(); |
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
Oops, something went wrong.