Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Support for click on Toast #171

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
package-lock.json
yarn.lock
.idea/
11 changes: 8 additions & 3 deletions dist/js/iziToast.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
onOpening: function () {},
onOpened: function () {},
onClosing: function () {},
onClosed: function () {}
onClosed: function () {},
onClick: function () {}
};

//
Expand Down Expand Up @@ -727,7 +728,11 @@
$DOM.toastCapsule.classList.add(PLUGIN_NAME+'-capsule');
$DOM.toastBody.classList.add(PLUGIN_NAME + '-body');
$DOM.toastTexts.classList.add(PLUGIN_NAME + '-texts');

$DOM.toast.addEventListener('click', function(){
settings.onClick();
var event = new CustomEvent(PLUGIN_NAME+'-clicked', {detail: settings});
document.dispatchEvent(event);
});
if(ISMOBILE || window.innerWidth <= MOBILEWIDTH){
if(settings.transitionInMobile)
$DOM.toast.classList.add(settings.transitionInMobile);
Expand Down Expand Up @@ -1289,4 +1294,4 @@


return $iziToast;
});
});
7 changes: 1 addition & 6 deletions dist/js/iziToast.min.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ var uglify = require( 'gulp-uglify' );
var csso = require( 'gulp-csso' );

var catchError = function(err) {
console.log(err.toString())
console.log(err.toString());
this.emit('end')
}
};

/**
* Styl task
Expand All @@ -35,6 +35,8 @@ gulp.task( 'scripts', function() {
return gulp.src( './src/js/iziToast.js' )
.pipe( jshint() )
.pipe( jshint.reporter('default') )
.pipe(concat('iziToast.js'))
.pipe(gulp.dest('./dist/js'))
.pipe( concat( 'iziToast.min.js' ) )
.pipe( uglify( { mangle: true } ) )
.pipe( gulp.dest( './dist/js' ) )
Expand All @@ -46,9 +48,9 @@ gulp.task( 'scripts', function() {
* Watch task
**/
gulp.task('watch', ['styl','scripts'], function() {
gulp.watch('./src/css/**/*.styl', [ 'styl' ]) // watch for changes and run the css task
gulp.watch('./src/css/**/*.styl', [ 'styl' ]); // watch for changes and run the css task
gulp.watch('./src/js/**/*.js', [ 'scripts' ]) // watch for changes and run the js task
})
});

/**
* Default task
Expand Down
11 changes: 8 additions & 3 deletions src/js/iziToast.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@
onOpening: function () {},
onOpened: function () {},
onClosing: function () {},
onClosed: function () {}
onClosed: function () {},
onClick: function () {}
};

//
Expand Down Expand Up @@ -727,7 +728,11 @@
$DOM.toastCapsule.classList.add(PLUGIN_NAME+'-capsule');
$DOM.toastBody.classList.add(PLUGIN_NAME + '-body');
$DOM.toastTexts.classList.add(PLUGIN_NAME + '-texts');

$DOM.toast.addEventListener('click', function(){
settings.onClick();
var event = new CustomEvent(PLUGIN_NAME+'-clicked', {detail: settings});
document.dispatchEvent(event);
});
if(ISMOBILE || window.innerWidth <= MOBILEWIDTH){
if(settings.transitionInMobile)
$DOM.toast.classList.add(settings.transitionInMobile);
Expand Down Expand Up @@ -1289,4 +1294,4 @@


return $iziToast;
});
});