techatspree/jquery-toastmessage-plugin

jQuery fn

sambenne opened this issue · 5 comments

You are doing $.fn.toastmessage which means that you have to do $().toastmessage. But if you remove .fn then you can remove the (). Since you are not attaching it to anything.

I think I remember seeing a way of doing both. Will have to find that out again.

Also, it is a bad practice to create bunch of anonymous functions on each 'toast message'. The good way is to use javascript prototypes. It could reduce memory usage by 5-15 times.
I've forked jquery toastmessage six months ago and improved it much (also added desktop notification support), see:
https://github.com/pbagwl/tire/blob/5daa5946420f20c5921e220d78162af4d777d7ec/js/tire.js#L218
Fork's syntax is: $.notification('message') / $.notification('message', 'warning') etc.

Thanks for improving this, I was about to open an issue for the $() too.

@paulmillr your link is broken

@akquinet If you want people to pass in something ie. special dom element to use for a Toast message you would use something like this:

$.toastmessage({ dom: 'domElement' });
$.fn.toastmessage = function(){
  $.toastmessage({ dom: this })
}

Thanks, did you write it in Coffeescript for kicks n' giggles or was it useful to do so?

As it was already rewritten by me in javascript, CoffeeScript version was made just for fun, yup.
I got tired from JS as a development language two months ago so I decided to learn CS and now I'm using it at work (with backbone.js). Great language, it eliminates many disadvantages of javascript or adds features, that would be available only in future (ecmascript harmony).