yairEO / fancyInput

Makes typing in input fields fun with CSS3 effects
1.93k stars 283 forks source link

New Public Events API #25

Closed GianlucaGuarini closed 11 years ago

GianlucaGuarini commented 11 years ago

New API to get the plugin events from the outside

yairEO commented 11 years ago

why is the appendIndex wrong? it seems to be working pretty good

GianlucaGuarini commented 11 years ago

It was buggy together with public API returning wrong values https://github.com/GianlucaGuarini/fancyInput/blob/0b7a853e2895a795781acd42ae2d4c3e5c91bbe3/fancyInput.js#L117

yairEO commented 11 years ago

I'm sorry I just don't understand your answer. what is this thing which you call Public API? and what is the bug? what steps would I need to take to reproduce it?

GianlucaGuarini commented 11 years ago

Having a public plugin API means that you can use the plugin events also outside of it for example:

var fancyInput = this.$el.find('textarea').fancyInput();

fancyInput.on('fi.addLetter',function(e,data){
  console.log(data);
  // a letter has been added
  // data.index: letter index
  // data.val: letter
});
fancyInput.on('fi.deleteLetter',function(e,data){
  console.log(data);
  // a letter has been deleted
  // data.index: letter index
  // data.val: letter
});
fancyInput.on('fi.linebreak',function(e){
  // there's a new line break
});
fancyInput.on('fi.space',function(e,data){
  // space clicked
});

With previous appendIndex code the data.index value was wrong but now everything works fine. Just download my version of your script and try yourself the public API and switching the appendIndex code to your old version to see the bug

yairEO commented 11 years ago

but why would anyone need callbacks? there aren't any callbacks for such things since the dawn of computers, why now?

GianlucaGuarini commented 11 years ago

:smile: mine was just a proposal. I had to use your plugin on another project and I extended it to achieve my goal.. I think it could be useful but that's your business! :walking:

yairEO commented 11 years ago

no..don't be insulted man, I'm sure your code was splendid! I just didn't have the time to actually test it, I wanted to get to it though