I managed to make this code for loading a button with the smileys. It gets data via ajax from the smilyes module, but this means that is also slow.
I am looking for a way of caching that data or at least not loading it on each usage of the button...

js:
editor.dialog.open(editor.buttons[E.bindex][0], '')
$.get('/live/smileys', function(data){ 
  html = data.replace('<div class="smileysWindowtext">Click to insert acronym. [<span class="smiley-class" id="closeSmileys">Close</span>]</div><div class="smileysWindow">', '<div id="dialogSmile" style="width:250px">');
  editor.dialog.open(editor.buttons[E.bindex][0], html)
  $('#dialogSmile').ready(function(){
    $('img.smiley-class').click(function(){
      editor.active.replaceSelection(this.alt);
      editor.dialog.close();
    })
  })
})

Comments

websites-development.com’s picture

with a little optimization:

js:
if ( window['loadsmilies'] !== undefined ) {
  editor.dialog.open(editor.buttons[E.bindex][0], window['loadsmilies'])
  $('#dialogSmile').ready(function(){
    $('img.smiley-class').click(function(){
      editor.active.replaceSelection(this.alt)
      editor.dialog.close()
    })
  })
} else {
  editor.dialog.open(editor.buttons[E.bindex][0], '')
  $.get('/live/smileys', function(data){ 
    window['loadsmilies'] = data.replace('<div class="smileysWindowtext">Click to insert acronym. [<span class="smiley-class" id="closeSmileys">Close</span>]</div><div class="smileysWindow">', '<div id="dialogSmile" style="width:250px">');
    editor.dialog.open(editor.buttons[E.bindex][0], window['loadsmilies'] )
    $('#dialogSmile').ready(function(){
      $('img.smiley-class').click(function(){
        editor.active.replaceSelection(this.alt)
        editor.dialog.close()
      })
    })
  })
}
websites-development.com’s picture

to get a loading icon:
instead of

editor.dialog.open(editor.buttons[E.bindex][0], '')

put

editor.dialog.open(editor.buttons[E.bindex][0], '<div style="width: 200px; height: 50px; background-image: url(/modules/system/../../misc/throbber.gif); background-position: 50% -18px; background-repeat: no-repeat"></div>')
websites-development.com’s picture

Status: Active » Needs review
Roulion’s picture

any port to 6.x version ?

gausarts’s picture

Version: 5.x-1.1 » 6.x-1.4

Doesn't seem to work. I tried both and got this:

TypeError: editor.buttons is undefined

BTW, where do you set that url $.get('/live/smileys', function(data){

Any hint to make it work with the latest stable?
Thanks

gausarts’s picture

Status: Needs review » Fixed

The solution was there all along, and have been there before but was forgotten. To others who may need it:

http://ufku.com/drupal/bueditor/contributions/smileys

Thanks

Oops! sorry to set it fixed. Now I can't cancel it :(

stevenpatz’s picture

Title: smilyes button » smileys button

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.