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 another button beside wdt-emoji-picker #37

Open
himadrinath opened this issue Sep 18, 2017 · 2 comments
Open

add another button beside wdt-emoji-picker #37

himadrinath opened this issue Sep 18, 2017 · 2 comments

Comments

@himadrinath
Copy link

himadrinath commented Sep 18, 2017

@needim i want to add other buttons with my wdt-emoji-picker inside form-group wdt-emoji-picker-parent

like this

text

do u have any method for that?

@needim
Copy link
Owner

needim commented Sep 18, 2017

Currently, it appends picker as a child to input's parent.

Here is a quick solution;

1- Add a parameter to init function named "container";

wdtEmojiBundle.init = function (selector) {

wdtEmojiBundle.init = function (selector, container) {

2- Pass this parameter to addPicker function on line 138;

self.addPicker(self.elements[i]);

self.addPicker(self.elements[i], container); 

2- Select correct container in addPicker function.

  wdtEmojiBundle.addPicker = function (element, container) {

    container = container || false;

    var self = this;
    if (!hasClass(element, 'wdt-emoji-picker-ready')) {
      var p = document.createElement('div');
      addClass(p, 'wdt-emoji-picker');
      p.innerHTML = self.emoji.replace_colons(':smile:');
      p.addEventListener('click', wdtEmojiBundle.openPicker);

      var parent = element.parentNode;
      addClass(parent, 'wdt-emoji-picker-parent');

      if (container) {
          parent.querySelector(container).appendChild(p);
      } else {
          parent.appendChild(p);
      }

      if (hasClass(element, 'wdt-emoji-open-on-colon')) {
        parent.addEventListener('keyup', wdtEmojiBundle.onKeyup)
      }
      addClass(element, 'wdt-emoji-picker-ready');
    }
  };

@needim
Copy link
Owner

needim commented Sep 18, 2017

Usage should be like this;

wdtEmojiBundle.init('.your-inputs-selector', '.your-container');

Container must be child of input's parent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants