Loading ...
Sorry, an error occurred while loading the content.

Re: [ydn-javascript] strange behaviour with push button -> inserthtml

Expand Messages
  • dav.glass@yahoo.com
    feister007 -- Here is an example that does this & works fine under IE 6: http://blog.davglass.com/files/yui/editor21/ The only thing I really changed from
    Message 1 of 2 , Oct 30, 2007
    • 0 Attachment
      feister007 --

      Here is an example that does this & works fine under IE 6:
      http://blog.davglass.com/files/yui/editor21/
       
      The only thing I really changed from yours is that I removed the table. Seems IE was giving a fit about stopping the event on the td.. That was what made IE loose the focus of the Editor window when you ran the inserthtml command. That would then force the Editor to refocus and place the cursor at the beginning..

      If you are seeing performance issues, please file a bug here (and include a working repro case):
      http://developer.yahoo.com/yui/editor#filingbugs

      Hope that helps :)
      Dav

      Dav Glass
      dav.glass@...
      blog.davglass.com
       
       
      + Windows: n. - The most successful computer virus, ever. +
      + A computer without a Microsoft operating system is like a dog
      without bricks tied to its head +
      + A Microsoft Certified Systems Engineer is to computing what a
      McDonalds Certified Food Specialist is to fine cuisine +


      ----- Original Message ----
      From: feister007 <cschluessel@...>
      To: ydn-javascript@yahoogroups.com
      Sent: Tuesday, October 30, 2007 2:32:02 AM
      Subject: [ydn-javascript] strange behaviour with push button -> inserthtml

      hello,

      I'm experiencing strange behaviours with the upper subject:
      I have set up an RT-editor like proposed under
      http://developer.yahoo.com/yui/examples/editor/icon_editor.html

      I'm not inserting icons though - I gave this up as sometimes it would
      work sometimes not(icon always at the beginning of editing area, no
      icon insertion at all). I'm using html entities instead to
      insert/display scientific special (greek)chars.

      now my problem is, in firefox it works kinda allright but MSIE(6.0+)
      always inserts the entity at the very first position of the editor's
      text area, no matter where I place the cursor ... this is the same for
      icon insertation with msie .... I'm not a fan of msie really but many
      people use it, so I have to adapt to it to some extent.
      second thing: performanc under msie(6.0+) is so damned slow.
      I post some of the relevant code below:

      //some of the entities to insert/display
      var entities = new Array('&fnof;', '&Alpha;', '&Beta;', '&Gamma;',
      '&Delta;','&Epsilon;', '&Zeta;', '&Eta;', '&Theta;', '&Iota;');

      // editor toolbar ...

          var Dom = YAHOO.util.Dom,
              Event = YAHOO.util.Event;
             
          var myConfig = {
              height: (screen.height-260) + 'px',
              width: '600px',
              dompath: true,
              animate: true,
              //focusAtStart: true,
              toolbar: {
                        // default toolbar config ...
                      }
              }    
         
              // event handling for entity's overlay
      YAHOO.util.Event.onAvailable('entityMenu', function() {
                  YAHOO.util.Event.on('entityMenu', 'click', function(ev) {
                      var tar = YAHOO.util.Event.getTarget(ev);
                      if (tar.tagName.toLowerCase() == 'b') {
                          selectedDate = tar.parentNode.innerHTML;                    
                      }
                      else if (tar.tagName.toLowerCase() == 'td') {
                          selectedDate = tar.innerHTML;                    
                      }
                      var _button =
      this.toolbar.getButtonByValue('insertentity'); 
                      this.toolbar.fireEvent('insertentityClick', { type:
      'insertentityClick', icon: selectedDate });
                      _button._menu.hide();
                      //YAHOO.util.Event.stopEvent(ev);
                  }, myEditor, true);
              });
         

          // init of entity's overlay
          myEditor.on('toolbarLoaded', function() {
              var entityConfig = {
                  type: 'push', //Using a standard push button
                  label: 'Sonderzeichen einf├╝gen', //The name/title of the
      button
                  value: 'insertentity', //The "Command" for the button   
             
                  menu: function() {
                      //Create the Overlay instance we are going to use for
      the menu           
                      var menu = new YAHOO.widget.Overlay('insertentity', {
                          visible: false
                      });
                      var estr = "<table border='1' cellspacing='2'
      cellpadding='2'>";
                      for (var b = 0; b < entities.length; b+=7) {
                          estr += "<tr>";
                          End: for (var z = 1; z < 8; z++) {
                              if ( entities.length > (b+z)) {
                                  estr += "<td valign='middle' align='center'
      width='19' height='19' class='ent'>"+entities[(b+z)]+"</td>";
                              }
                              else {
                                  estr += "<td valign='middle' align='center'
      width='19' height='19' class='ent'></td>";
                                  break End;
                              }
                          }
                          estr += "</tr>";
                      }
                      //Setting the body of the container to our list of
      images.
                      menu.setBody("<div id='entityMenu'>" + estr +
      "</table></div>");
                      menu.beforeShowEvent.subscribe(function() {
                          //Set the context to the bottom left corner of the
      Insert Icon button 
                          menu.cfg.setProperty('context', [
                           
      myEditor.toolbar.getButtonByValue('insertentity').get('element'),
                              'tl',
                              'bl'
                          ]);
                      });           
                      menu.render(document.body);
                      menu.element.style.visibility = 'hidden';
                      //return the Overlay instance here               
                      return menu;
                  }() //This fires the function right now to return the
      Overlay Instance to the menu property..           
              };
              //Add the new button to the Toolbar Group called insertitem.
           
              myEditor.toolbar.addButtonToGroup(entityConfig, 'sophist');

              myEditor.toolbar.on('insertentityClick', function(ev) {
                  var icon = '';
                  this._focusWindow();
                  if (ev.icon) {
                      icon = ev.icon;
                  }
                  this.execCommand('inserthtml', icon);
              }, myEditor, true);


      // that's it more or less, besides the standard editor code.

      can anybody give some advice here on performance and cross browser
      issues? I'd really like to user the inserticon feature as well but it
      hardly works in msie ... so some advice on that would be highly
      welcome as well.

      don't get confused by the naming of variables and stuff. I pasted some
      from the yui exampels. the app itself is working, no javascript errors
      it just has the listed problems.

      thanx in advance

      best regards



       





      Yahoo! Groups Links

      <*> To visit your group on the web, go to:
          http://groups.yahoo.com/group/ydn-javascript/

      <*> Your email settings:
          Individual Email | Traditional

      <*> To change settings online go to:
          http://groups.yahoo.com/group/ydn-javascript/join
          (Yahoo! ID required)

      <*> To change settings via email:
          mailto:ydn-javascript-digest@yahoogroups.com
          mailto:ydn-javascript-fullfeatured@yahoogroups.com

      <*> To unsubscribe from this group, send an email to:
          ydn-javascript-unsubscribe@yahoogroups.com

      <*> Your use of Yahoo! Groups is subject to:
          http://docs.yahoo.com/info/terms/


    Your message has been successfully submitted and would be delivered to recipients shortly.