@@ -144,15 +144,15 @@ $.fn.toast = function(parameters) {
144
144
create : {
145
145
container : function ( ) {
146
146
module . verbose ( 'Creating container' ) ;
147
- $context . append ( $ ( '<div/>' , { class : settings . position + ' ' + className . container } ) ) ;
147
+ $context . append ( $ ( '<div/>' , { class : settings . position + ' ' + className . container + ' ' + ( settings . horizontal ? className . horizontal : '' ) } ) ) ;
148
148
} ,
149
149
toast : function ( ) {
150
150
$toastBox = $ ( '<div/>' , { class : className . box } ) ;
151
+ var iconClass = module . get . iconClass ( ) ;
151
152
if ( ! isToastComponent ) {
152
153
module . verbose ( 'Creating toast' ) ;
153
154
$toast = $ ( '<div/>' ) ;
154
155
var $content = $ ( '<div/>' , { class : className . content } ) ;
155
- var iconClass = module . get . iconClass ( ) ;
156
156
if ( iconClass !== '' ) {
157
157
$toast . append ( $ ( '<i/>' , { class : iconClass + ' ' + className . icon } ) ) ;
158
158
}
@@ -170,7 +170,7 @@ $.fn.toast = function(parameters) {
170
170
} ) ) ;
171
171
}
172
172
173
- $content . append ( $ ( '<div/>' , { html : module . helpers . escape ( settings . message , settings . preserveHTML ) } ) ) ;
173
+ $content . append ( $ ( '<div/>' , { class : className . message , html : module . helpers . escape ( settings . message , settings . preserveHTML ) } ) ) ;
174
174
175
175
$toast
176
176
. addClass ( settings . class + ' ' + className . toast )
@@ -189,6 +189,18 @@ $.fn.toast = function(parameters) {
189
189
$toast = settings . cloneModule ? $module . clone ( ) . removeAttr ( 'id' ) : $module ;
190
190
$close = $toast . find ( '> i' + module . helpers . toClass ( className . close ) ) ;
191
191
settings . closeIcon = ( $close . length > 0 ) ;
192
+ if ( iconClass !== '' ) {
193
+ $toast . find ( selector . icon ) . attr ( 'class' , iconClass + ' ' + className . icon ) ;
194
+ }
195
+ if ( settings . showImage ) {
196
+ $toast . find ( selector . image ) . attr ( 'src' , settings . showImage ) ;
197
+ }
198
+ if ( settings . title !== '' ) {
199
+ $toast . find ( selector . title ) . html ( module . helpers . escape ( settings . title , settings . preserveHTML ) ) ;
200
+ }
201
+ if ( settings . message !== '' ) {
202
+ $toast . find ( selector . message ) . html ( module . helpers . escape ( settings . message , settings . preserveHTML ) ) ;
203
+ }
192
204
}
193
205
if ( $toast . hasClass ( className . compact ) ) {
194
206
settings . compact = true ;
@@ -391,7 +403,7 @@ $.fn.toast = function(parameters) {
391
403
if ( settings . transition . closeEasing !== '' ) {
392
404
if ( $toastBox ) {
393
405
$toastBox . css ( 'opacity' , 0 ) ;
394
- $toastBox . wrap ( '<div/>' ) . parent ( ) . slideUp ( 500 , settings . transition . closeEasing , function ( ) {
406
+ $toastBox . wrap ( '<div/>' ) . parent ( ) . hide ( settings . transition . closeDuration , settings . transition . closeEasing , function ( ) {
395
407
if ( $toastBox ) {
396
408
$toastBox . parent ( ) . remove ( ) ;
397
409
callback . call ( $toastBox ) ;
@@ -431,7 +443,7 @@ $.fn.toast = function(parameters) {
431
443
has : {
432
444
container : function ( ) {
433
445
module . verbose ( 'Determining if there is already a container' ) ;
434
- return ( $context . find ( module . helpers . toClass ( settings . position ) + selector . container ) . length > 0 ) ;
446
+ return ( $context . find ( module . helpers . toClass ( settings . position ) + selector . container + ( settings . horizontal ? module . helpers . toClass ( className . horizontal ) : '' ) ) . length > 0 ) ;
435
447
} ,
436
448
toast : function ( ) {
437
449
return ! ! module . get . toast ( ) ;
@@ -750,6 +762,7 @@ $.fn.toast.settings = {
750
762
context : 'body' ,
751
763
752
764
position : 'top right' ,
765
+ horizontal : false ,
753
766
class : 'neutral' ,
754
767
classProgress : false ,
755
768
classActions : false ,
@@ -780,7 +793,8 @@ $.fn.toast.settings = {
780
793
showDuration : 500 ,
781
794
hideMethod : 'scale' ,
782
795
hideDuration : 500 ,
783
- closeEasing : 'easeOutCubic' //Set to empty string to stack the closed toast area immediately (old behaviour)
796
+ closeEasing : 'easeOutCubic' , //Set to empty string to stack the closed toast area immediately (old behaviour)
797
+ closeDuration : 500
784
798
} ,
785
799
786
800
error : {
@@ -798,13 +812,15 @@ $.fn.toast.settings = {
798
812
visible : 'visible' ,
799
813
content : 'content' ,
800
814
title : 'ui header' ,
815
+ message : 'message' ,
801
816
actions : 'actions' ,
802
817
extraContent : 'extra content' ,
803
818
button : 'ui button' ,
804
819
buttons : 'ui buttons' ,
805
820
close : 'close icon' ,
806
821
image : 'ui image' ,
807
822
vertical : 'vertical' ,
823
+ horizontal : 'horizontal' ,
808
824
attached : 'attached' ,
809
825
inverted : 'inverted' ,
810
826
compact : 'compact' ,
@@ -828,6 +844,10 @@ $.fn.toast.settings = {
828
844
container : '.ui.toast-container' ,
829
845
box : '.toast-box' ,
830
846
toast : '.ui.toast' ,
847
+ title : '.header' ,
848
+ message : '.message:not(.ui)' ,
849
+ image : '> img.image, > .image > img' ,
850
+ icon : '> i.icon' ,
831
851
input : 'input:not([type="hidden"]), textarea, select, button, .ui.button, ui.dropdown' ,
832
852
approve : '.actions .positive, .actions .approve, .actions .ok' ,
833
853
deny : '.actions .negative, .actions .deny, .actions .cancel'
0 commit comments