add a button in the non-wysiwyg editor

Random stuff about serendipity. Discussion, Questions, Paraphernalia.
lordcoffee
Regular
Posts: 308
Joined: Tue Nov 29, 2005 10:22 pm
Location: Munich - Germany
Contact:

add a button in the non-wysiwyg editor

Post by lordcoffee »

Hi!

Is it possible to add a button in the "non-wysiwyg" editor to add this code into the textfield?

Code: Select all

<object type="application/x-shockwave-flash" data="flvplayer.swf?file=movies/video.flv&clicktext=Klicken zum abspielen!" width="400" height="170">
  <param name="movie" value="flvplayer.swf?file=movies/video.flv&clicktext=Klicken zum abspielen!">
  <param name="wmode" value="transparent" />
</object>
Thanks, Lordcoffee
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: add a button in the non-wysiwyg editor

Post by garvinhicking »

Hi!

You could modify the "typesetbuttons" plugin for that, or build your own plugin that listens on the toolbar-hook?

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
lordcoffee
Regular
Posts: 308
Joined: Tue Nov 29, 2005 10:22 pm
Location: Munich - Germany
Contact:

Post by lordcoffee »

I treid to edit the typeset_plugin and I replaced the code for the "space" button with this:

Code: Select all

            <input type="button" class="serendipityPrettyButton" name="insSpace" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SPACE_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'], "<object type="application/x-shockwave-flash" data="flvplayer.swf?file=movies/XXX.flv&clicktext=Klicken zum abspielen!" width="320" height="240"><param name="movie" value="flvplayer.swf?file=movies/XXX.flv&clicktext=Klicken zum abspielen!"><param name="wmode" value="transparent" /></object>" />
and now I have a Video player directly in my text-editor. I know I did something wrong :oops: But what?

Edit:
Image
Thanks Lordcoffee
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

You need to escape tags inside the wrap-selected, you need to use single quotes within it, else your browser will interpret the first " as a closing value="" tag, and show the rest als interpreted HTML.

HTH,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
lordcoffee
Regular
Posts: 308
Joined: Tue Nov 29, 2005 10:22 pm
Location: Munich - Germany
Contact:

Post by lordcoffee »

Now the "Player inside the Editor" is gone but the button does not insert any code. Here's what I edited:

Code: Select all

            <input type="button" class="serendipityPrettyButton" name="insSpace" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SPACE_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'], '<object type='application/x-shockwave-flash' data='flvplayer.swf?file=movies/XXX.flv&clicktext=Klicken zum abspielen!' width='320' height='240'><param name='movie' value='flvplayer.swf?file=movies/XXX.flv&clicktext=Klicken zum abspielen!'><param name='wmode' value='transparent'></object>')" />
Thanks again!!!
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Code: Select all

<input type="button" class="serendipityPrettyButton" name="insSpace" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SPACE_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'], '<object type=\'application/x-shockwave-flash\' data=\'flvplayer.swf?file=movies/XXX.flv&clicktext=Klicken zum abspielen!\' width=\'320\' height=\'240\'><param name=\'movie\' value=\'flvplayer.swf?file=movies/XXX.flv&clicktext=Klicken zum abspielen!\'><param name=\'wmode\' value=\'transparent\'></' + 'object>')" />
You must take care of escaping single quotes occuring inside within single quotes, or you'll have the same "break out of quoting" problem :)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
lordcoffee
Regular
Posts: 308
Joined: Tue Nov 29, 2005 10:22 pm
Location: Munich - Germany
Contact:

Post by lordcoffee »

Garvin you're Great!

There's one little Thing...
Behind the inserted code there stands an "undefined" :?: Has this something to do witth the "+"?

Lordcoffee
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Where is that undefined exactly?

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
lordcoffee
Regular
Posts: 308
Joined: Tue Nov 29, 2005 10:22 pm
Location: Munich - Germany
Contact:

Post by lordcoffee »

When I push the button it inserts:

Code: Select all

<object type='application/x-shockwave-flash' data='flvplayer.swf?file=movies/XXX.flv&clicktext=Klicken zum abspielen!' width='320' height='240'><param name='movie' value='flvplayer.swf?file=movies/XXX.flv&clicktext=Klicken zum abspielen!'><param name='wmode' value='transparent'></object>undefined
It's the last word "undefined".

Lordcoffee
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

The JS wrapselection also needs a "right" parameter for what to wrap on the "right" side of your cursor:

Code: Select all

<input type="button" class="serendipityPrettyButton" name="insSpace" value="<?php echo PLUGIN_EVENT_TYPESETBUTTONS_SPACE_BUTTON ?>" onclick="wrapSelection(document.forms['serendipityEntry']['<?php echo $txtarea ?>'], '<object type=\'application/x-shockwave-flash\' data=\'flvplayer.swf?file=movies/XXX.flv&clicktext=Klicken zum abspielen!\' width=\'320\' height=\'240\'><param name=\'movie\' value=\'flvplayer.swf?file=movies/XXX.flv&clicktext=Klicken zum abspielen!\'><param name=\'wmode\' value=\'transparent\'></' + 'object>', '')" /> 
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
lordcoffee
Regular
Posts: 308
Joined: Tue Nov 29, 2005 10:22 pm
Location: Munich - Germany
Contact:

Post by lordcoffee »

Thanks!!! Now it works fine!

Lordcoffee
lordcoffee
Regular
Posts: 308
Joined: Tue Nov 29, 2005 10:22 pm
Location: Munich - Germany
Contact:

Post by lordcoffee »

Hmmm...

Now I had an Idea... In the code we added there are some placeholders called "XXX". Is it possible to enter a kind of variabel-thing so when I push the button in the editor a popup apears wich asks me for the name for that variable. Like the url button does.

Lordcoffee
lordcoffee
Regular
Posts: 308
Joined: Tue Nov 29, 2005 10:22 pm
Location: Munich - Germany
Contact:

Post by lordcoffee »

Hmmm...

Now I had an Idea... In the code we added there are some placeholders called "XXX". Is it possible to enter a kind of variabel-thing so when I push the button in the editor a popup apears wich asks me for the name for that variable. Like the url button does.

Lordcoffee
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!

Yes, you can do that. It requires javascripting, of course. Have a look at how the URL button does it. :)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
carl_galloway
Regular
Posts: 1331
Joined: Sun Dec 04, 2005 5:43 pm
Location: Andalucia, Spain
Contact:

Post by carl_galloway »

lordcoffee, when you've got this working the way you want it, could I suggest you write a tutorial with your complete code snippet and post it on the wiki. I think a lot of our users would really want this function. Good work!
Post Reply