Page 1 of 2
add a button in the non-wysiwyg editor
Posted: Fri Sep 15, 2006 10:54 am
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
Re: add a button in the non-wysiwyg editor
Posted: Fri Sep 15, 2006 11:02 am
by garvinhicking
Hi!
You could modify the "typesetbuttons" plugin for that, or build your own plugin that listens on the toolbar-hook?
HTH,
Garvin
Posted: Fri Sep 15, 2006 11:42 am
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

But what?
Edit:

Thanks Lordcoffee
Posted: Fri Sep 15, 2006 11:51 am
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
Posted: Fri Sep 15, 2006 12:09 pm
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!!!
Posted: Fri Sep 15, 2006 12:19 pm
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
Posted: Fri Sep 15, 2006 12:27 pm
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
Posted: Fri Sep 15, 2006 12:38 pm
by garvinhicking
Hi!
Where is that undefined exactly?
Regards,
Garvin
Posted: Fri Sep 15, 2006 12:50 pm
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
Posted: Fri Sep 15, 2006 1:02 pm
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>', '')" />
Posted: Fri Sep 15, 2006 1:09 pm
by lordcoffee
Thanks!!! Now it works fine!
Lordcoffee
Posted: Fri Sep 15, 2006 2:49 pm
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
Posted: Fri Sep 15, 2006 2:50 pm
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
Posted: Fri Sep 15, 2006 3:06 pm
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
Posted: Fri Sep 15, 2006 7:54 pm
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!