Announcement

Do not use the forums to submit bug reports, feature requests or patches, submit a New Ticket instead.

#1 2010-09-07 14:58:51

bofett
New member
Registered: 2010-08-25
Posts: 5

Can you set toolbar buttons inside the textarea?

I am using the default button list in most areas but need to limit the buttons in a few spots on my site.  can I set the "xinha_config.toolbar" value in the textarea if needed?  Then have it default to the full list if its not specified? 

Thanks

Offline

#2 2010-09-07 19:52:35

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Can you set toolbar buttons inside the textarea?

Yes


James Sleeman

Offline

#3 2010-09-07 19:54:45

bofett
New member
Registered: 2010-08-25
Posts: 5

Re: Can you set toolbar buttons inside the textarea?

gogo wrote:

Yes

Great!   



How?

Offline

#4 2010-09-08 01:04:48

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Can you set toolbar buttons inside the textarea?

Exactly like you say, set xinha_config.toolbar ?


James Sleeman

Offline

#5 2010-09-09 23:25:17

bofett
New member
Registered: 2010-08-25
Posts: 5

Re: Can you set toolbar buttons inside the textarea?

Can you help with an example?

Offline

#6 2010-09-10 01:38:27

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Can you set toolbar buttons inside the textarea?

xinha_config.toolbar =
  [
    ["popupeditor"],
    ["separator","formatblock","fontname","fontsize","bold","italic","underline","strikethrough"],
    ["separator","forecolor","hilitecolor","textindicator"],
    ["separator","subscript","superscript"],
    ["linebreak","separator","justifyleft","justifycenter","justifyright","justifyfull"],
    ["separator","insertorderedlist","insertunorderedlist","outdent","indent"],
    ["separator","inserthorizontalrule","createlink","insertimage","inserttable"],
    ["linebreak","separator","undo","redo","selectall","print"], (Xinha.is_gecko ? [] : ["cut","copy","paste","overwrite","saveas"]),
    ["separator","killword","clearfonts","removeformat","toggleborders","splitblock","lefttoright", "righttoleft"],
    ["separator","htmlmode","showhelp","about"]
  ];

??


James Sleeman

Offline

#7 2010-10-22 17:01:07

bofett
New member
Registered: 2010-08-25
Posts: 5

Re: Can you set toolbar buttons inside the textarea?

I mean per instance.  Something like...

<textarea id="message" name="message" maxlength="300" cols=35 rows=10 style"xinha_config.toolbar =  [["popupeditor"],["separator","formatblock","fontname","fontsize","bold","italic","underline","strikethrough"]]"></textarea>

Offline

#8 2010-10-22 21:20:07

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Can you set toolbar buttons inside the textarea?

In your config.

  
/** STEP 5 ***************************************************************
   * If you want to change the configuration variables of any of the
   * editors,  this is the place to do that, for example you might want to
   * change the width and height of one of the editors, like this...
   *
   *   xinha_editors.myTextArea.config.width  = '640px';
   *   xinha_editors.myTextArea.config.height = '480px';
   *
   ************************************************************************/

James Sleeman

Offline

#9 2010-10-22 21:26:50

bofett
New member
Registered: 2010-08-25
Posts: 5

Re: Can you set toolbar buttons inside the textarea?

Back to my original question then the answer is no.  You can not set variables in for each instance in the textarea.  Right?  You have to do it in the config.  My problem is that when I try to assign different button layouts for different id's in the config, it fails to load.

Offline

#10 2010-10-23 00:36:45

gogo
Xinha Leader
From: New Zealand
Registered: 2005-02-11
Posts: 1,015
Website

Re: Can you set toolbar buttons inside the textarea?

Correct you can't set in the textarea html tag itself unless you write something to do it in your config step 5, like perhaps this...

      function merge_object(a,b)
      {     
        for(var j in b)
        {
          if(typeof a[j] != typeof b[j] || typeof b[j] != 'object')
          {
            a[j] = b[j]
          }
          else
          {
            merge_object(a[j], b[j]);
          }
        }
      }
      
       
      for(var o in xinha_editors)
      {      
        var xn_eval = "{ }";
        var xn_config = null;
        
        if(typeof xinha_editors[o]._textArea.hasAttribute != 'undefined')
        {
          if(xinha_editors[o]._textArea.hasAttribute('xinhaconfig'))
          {
            xn_eval = xinha_editors[o]._textArea.getAttribute('xinhaconfig');
          }
        }
        else if(typeof xinha_editors[o]._textArea.xinhaconfig != 'undefined')
        {
          xn_eval = xinha_editors[o]._textArea.xinhaconfig;
        }
       
          var xn_config = null;          

          try
          {
            if(!/^\{/.test(xn_eval)) //\}
            {
              eval("xn_config = {" + xn_eval + "}");  
            }
            else
            {
              eval("xn_config = " + xn_eval);
            }
          }
          catch(e)
          {
            try
            {
              xn_config = eval(xn_eval);  
            }
            catch(e)
            {
              continue;
            }
          }
          
          if(typeof xn_config == 'object')
          {
            if(typeof xn_config.toolbar != 'undefined' && xn_config.toolbar.length)
            {
              xinha_editors[o].config.toolbar = xn_config.toolbar;
              delete xn_config.toolbar;
            }
            merge_object(xinha_editors[o].config, xn_config);
          }
        }

then you could use

<textarea name="youreditor" xinhaconfig="{ toolbar: [
    ["popupeditor"],
    ["separator","formatblock","fontname","fontsize","bold","italic","underline","strikethrough"],
    ["separator","forecolor","hilitecolor","textindicator"],
    ["separator","subscript","superscript"],
    ["linebreak","separator","justifyleft","justifycenter","justifyright","justifyfull"],
    ["separator","insertorderedlist","insertunorderedlist","outdent","indent"],
    ["separator","inserthorizontalrule","createlink","insertimage","inserttable"],
    ["linebreak","separator","undo","redo","selectall","print"], (Xinha.is_gecko ? [] : ["cut","copy","paste","overwrite","saveas"]),
    ["separator","killword","clearfonts","removeformat","toggleborders","splitblock","lefttoright", "righttoleft"],
    ["separator","htmlmode","showhelp","about"]
  ] }"></textarea>

James Sleeman

Offline

Board footer

Powered by FluxBB