All pastes #455944 Raw Edit

Gurpartap Singh

public javascript v1 · immutable
#455944 ·published 2007-04-24 15:49 UTC
rendered paste body
Drupal.smileysAutoAttach = function() {  $('#showSmileysWindow').oneclick(function() {    $('<div id="smileysWindow"></div>').appendTo('body').load(location.protocol + '//'+location.host + (location.port ? ':' + location.port : '') + location.pathname + '?q=live/smileys', Drupal.smileysAttach).hide();    smileysWindow();  }).click(function() {    $('#smileysWindow').toggle("slow");  });  $(window).scroll(smileysWindow).resize(smileysWindow);  Drupal.smileysAttach();}Drupal.smileysAttach = function() {  $('#closeSmileys').click(function() {    $('#smileysWindow').hide("slow");  });  $('img.smiley-class', this).click(function(){    var smiley = ' ' + this.alt + ' ';    $('textarea#edit-body, textarea#edit-comment').each(function() {      if (document.selection) {        this.focus();        document.selection.createRange().text = smiley;      }       else if (this.selectionStart || this.selectionStart == '0') {        var cursorPos = this.selectionEnd + smiley.length;        this.value = this.value.substring(0, this.selectionStart) + smiley + this.value.substring(this.selectionEnd);        this.selectionStart = this.selectionEnd = cursorPos;      }      else {        this.value = this.value + smiley;      }      this.focus();    });  });}function smileysWindow() {  var width = 0, height = 0;  if (typeof(window.innerWidth) == 'number' ) {    width = window.innerWidth;    height = window.innerHeight;  } //Non-IE  else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {    width = document.documentElement.clientWidth;    height = document.documentElement.clientHeight;  } //IE 6+ in 'standards compliant mode'  else if (document.body && (document.body.clientWidth || document.body.clientHeight)) {    width = document.body.clientWidth;    height = document.body.clientHeight;  } //IE 4 compatible  var left = 0, top = 0;  if (typeof(window.pageYOffset) == 'number') {    top = window.pageYOffset;    left = window.pageXOffset;  } //Netscape compliant  else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {    top = document.body.scrollTop;    left = document.body.scrollLeft;  } //DOM compliant  else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {    //IE6 standards compliant mode    top = document.documentElement.scrollTop;    left = document.documentElement.scrollLeft;  }  $('#smileysWindow').css({'position' : 'absolute', 'z-index' : 1000, 'top': top+(height/2)-(250/2)+'px', 'left': left+(width/2)-(275/2)+'px'});}if (Drupal.jsEnabled) {  $(document).ready(Drupal.smileysAutoAttach);}