Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

Commit

Permalink
fix(toast): switch content to textContent to unify w/ dialog. Dep…
Browse files Browse the repository at this point in the history
…recate `content`
  • Loading branch information
rschmukler committed Nov 19, 2015
1 parent b9dae8d commit 1eeafee
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/components/toast/demoBasicUsage/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ angular.module('toastDemo1', ['ngMaterial'])
$scope.showSimpleToast = function() {
$mdToast.show(
$mdToast.simple()
.content('Simple Toast!')
.textContent('Simple Toast!')
.position($scope.getToastPosition())
.hideDelay(3000)
);
};

$scope.showActionToast = function() {
var toast = $mdToast.simple()
.content('Action Toast!')
.textContent('Action Toast!')
.action('OK')
.highlightAction(false)
.position($scope.getToastPosition());
Expand Down
19 changes: 11 additions & 8 deletions src/components/toast/toast.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function MdToastDirective($mdToast) {
* var app = angular.module('app', ['ngMaterial']);
* app.controller('MyController', function($scope, $mdToast) {
* $scope.openToast = function($event) {
* $mdToast.show($mdToast.simple().content('Hello!'));
* $mdToast.show($mdToast.simple().textContent('Hello!'));
* // Could also do $mdToast.showSimple('Hello');
* };
* });
Expand Down Expand Up @@ -84,7 +84,7 @@ function MdToastDirective($mdToast) {
* _**Note:** These configuration methods are provided in addition to the methods provided by
* the `build()` and `show()` methods below._
*
* - `.content(string)` - Sets the toast content to the specified string.
* - `.textContent(string)` - Sets the toast content to the specified string.
*
* - `.action(string)` - Adds an action button. If clicked, the promise (returned from `show()`)
* will resolve with the value `'ok'`; otherwise, it is resolved with `true` after a `hideDelay`
Expand All @@ -102,7 +102,7 @@ function MdToastDirective($mdToast) {

/**
* @ngdoc method
* @name $mdToast#updateContent
* @name $mdToast#updateTextContent
*
* @description
* Updates the content of an existing toast. Useful for updating things like counts, etc.
Expand Down Expand Up @@ -206,8 +206,8 @@ function MdToastProvider($$interimElementProvider) {
options: toastDefaultOptions
})
.addPreset('simple', {
argOption: 'content',
methods: ['content', 'action', 'highlightAction', 'theme', 'parent'],
argOption: 'textContent',
methods: ['textContent', 'content', 'action', 'highlightAction', 'theme', 'parent'],
options: /* @ngInject */ function($mdToast, $mdTheming) {
var opts = {
template: [
Expand All @@ -234,9 +234,12 @@ function MdToastProvider($$interimElementProvider) {
return opts;
}
})
.addMethod('updateContent', function(newContent) {
.addMethod('updateTextContent', updateTextContent)
.addMethod('updateContent', updateTextContent);

function updateTextContent(newContent) {
activeToastContent = newContent;
});
}

return $mdToast;

Expand All @@ -252,7 +255,7 @@ function MdToastProvider($$interimElementProvider) {
};

function onShow(scope, element, options) {
activeToastContent = options.content;
activeToastContent = options.textContent || options.content; // support deprecated #content method

element = $mdUtil.extractElementByName(element, 'md-toast', true);
options.onSwipe = function(ev, gesture) {
Expand Down

0 comments on commit 1eeafee

Please sign in to comment.