I am tyring to list a table full of Unicode characters to insert from. I can work with the smiley button code listed here: http://ufku.com/drupal/bueditor/contributions/smileys

But I need to replace the list of smiley with the list of unicode characters. I converted the following code for smiley for my use. But it's not working! Not what I am doing wrong! :(

php:
if (!function_exists('_smileys_list')) return;
$L = drupal_to_js(_smileys_list());
$P = base_path();
drupal_add_js("(function($){
var click = function() {
  BUE.active.replaceSelection(this.firstChild.alt, 'end');
  return false;
};
var map = function(s) {
return $('<a href=\"#\" title=\"'+ s.description +'\"><img src=\"$P'+ s.image +'\" alt=\" '+ s.acronyms.split(' ')[0] +' \" /></a>').css('margin', '0.5em').click(click)[0];
};
BUE.smlyWrap = function() {
  if (!BUE.\$smlyWrap) {
    var links = $.map($L, map);
    BUE.\$smlyWrap = $('<div style=\"width:200px\" class=\"bue-smiley-wrapper\"></div>').append(links);
  }
  return BUE.\$smlyWrap.clone(true);
};
})(jQuery);", 'inline');
return 'js: E.quickPop.open(BUE.smlyWrap());';

My code

js:
var L=[ "a", "b" ];
(function($){
var click = function() {
  BUE.active.replaceSelection(this.firstChild.alt, 'end');
  return false;
};
var map = function(s) {
return ('<a href=\"#\" title=\"'+ s +'\">s</a>').css('margin', '0.5em').click(click)[0];
};
BUE.banglaWrap = function() {
  if (!BUE.banglaWrap) {
    var links = .map(L, map);
    BUE.banglaWrap = ('<div style=\"width:200px\" class=\"bue-smiley-wrapper\"></div>').append(links);
  }
  return BUE.banglaWrap.clone(true);
};
})(jQuery);
E.quickPop.open(BUE.banglaWrap());

Comments

ufku’s picture

udvranto’s picture

Wow! That's it!

But what if I want to show an abbreviated name instead of the character but insert the character instead? For example, the Unicode character ZWNJ (zero width non joiner) is an invisible character. To have it included I need to display either the string ZWNJ or an image containing ZWNJ/representative symbol and on click I need to actually insert it.

ufku’s picture

Then you need to create the chars and links this way:

var chars = {'CHAR1': 'CHAR1 NAME', 'CHAR2': 'CHAR2 NAME'};
var links = '';
for (var chr in chars) {
  links += '<a href="#" title="'+ chr +'">'+ chars[chr] +'</a>';
}
....
udvranto’s picture

Status: Active » Closed (fixed)

Thanks this works! I am closing this issue.