Latest topics
» Forumactif Edge - Releases
by Ange Tuteur Tue 03 Sep 2019, 11:49
» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21
» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28
» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15
» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11
» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24
» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58
» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50
» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22
» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12
» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10
» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51
» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11
» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19
» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34
by Ange Tuteur Tue 03 Sep 2019, 11:49
» GIFActif - Giphy Button for the Editor
by Ange Tuteur Wed 08 May 2019, 17:21
» Forum Closure
by Ange Tuteur Mon 01 Jan 2018, 01:28
» Chit Chat Thread
by Valoish Sun 31 Dec 2017, 19:15
» Font/Text background color.
by Valoish Sun 31 Dec 2017, 19:11
» Forumactif Messenger - Instant Message Application for Forumotion
by Wolfuryo Sun 31 Dec 2017, 18:24
» [GAME] Count to One Million!
by brandon_g Fri 29 Dec 2017, 18:58
» Post Cards
by manikbiradar Wed 20 Dec 2017, 07:50
» [GAME] Countdown from 200,000
by Valoish Wed 13 Dec 2017, 23:22
» GeekPolice Tech Support Forums - GeekPolice.net
by Dr Jay Mon 11 Dec 2017, 19:12
» Asking about some plugin for Forumotion
by Dr Jay Mon 11 Dec 2017, 19:10
» [GAME] What are you thinking right now?
by Van-Helsing Sat 09 Dec 2017, 14:51
» Widget : Similar topics
by ranbac Wed 06 Dec 2017, 18:11
» Change the Background of the Forum and put an image and how to make prefixs?
by Clement Wed 06 Dec 2017, 15:19
» Hello from Western Australia
by SarkZKalie Wed 06 Dec 2017, 05:34
Recent Tutorials
Top posting users this month
Top Achievers
Who is online?
In total there are 12 users online :: 0 Registered, 0 Hidden and 12 Guests :: 1 Bot
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
None
Most users ever online was 515 on Tue 14 Sep 2021, 15:24
[SOLVED] Javascript question
Page 1 of 1 • Share
- Wolfuryo
- Gender :
Posts : 256
Points : 3598
Reputation : 81
Language : Romanian and English
Browser : Forum Version :
Hello, everyone!
I made a little code that adds a button in the editor which once clicked will add some text in the editor according to what forum you are making a topic in. The code is:
I want to add a line brake between Predefinited and model(look and the variable f). I tried using
and
, but it is not working.
I made a little code that adds a button in the editor which once clicked will add some text in the editor according to what forum you are making a topic in. The code is:
- Code:
$(function(){
$(function(){
var f='No predefinited model';
if (location.pathname == "/post" && location.search == "?f=2&mode=newtopic") {
var f='Predefinited model';
}
$('<a class="sceditor-button" unselectable="on" title="Insert predefinited model">
<div unselectable="on" style="background:url(http://i1370.photobucket.com/albums/ag257/AppleDrink/attention-sign%201.png)"></div>
</a>').insertBefore('.sceditor-button-size').click(function(){
$('#text_editor_textarea').sceditor("instance").insertText(f)})
});
})
I want to add a line brake between Predefinited and model(look and the variable f). I tried using
|
|
Hey,
To insert a line break in a string use the "\n" character. Like this for example :
Also, you should try using
to define new buttons. Here's an example :
There's a bunch of docs on it here if you're interested.
To insert a line break in a string use the "\n" character. Like this for example :
- Code:
var string = 'Hello\nworld\n!';
Also, you should try using
|
- Code:
location.search == "?f=2&mode=newtopic" && $(function() {
// TEXT TO INSERT
window.scePredefinitedModel = ['[b]EXAMPLE', '[/b]\n\n[i]EXAMPLE 2[/i]'];
if ($.sceditor) {
// SET THE NEW SCEDITOR COMMAND
$.sceditor.command.set('predefinited-model', {
// WYSIWYG METHOD
exec : function() {
this.insert(scePredefinitedModel[0], scePredefinitedModel[1]);
},
// SOURCE CODE METHOD
txtExec : function() {
this.insert(scePredefinitedModel[0], scePredefinitedModel[1]);
},
tooltip : 'Insert predefinited model' // BUTTON TOOLTIP
});
toolbar = toolbar.replace(/code/, 'code,predefinited-model'); // INSERT BUTTON INTO TOOLBAR
}
});
// BUTTON IMAGE
document.write('<style type="text/css">.sceditor-button-predefinited-model div{background-image:url(http://i1370.photobucket.com/albums/ag257/AppleDrink/attention-sign%201.png)!important}</style>');
There's a bunch of docs on it here if you're interested.
- Wolfuryo
- Gender :
Posts : 256
Points : 3598
Reputation : 81
Language : Romanian and English
Browser : Forum Version :
Thank you, sloved it now. I found the link you posted usefull(http://www.sceditor.com/documentation/getting-started/).
- Wolfuryo
- Gender :
Posts : 256
Points : 3598
Reputation : 81
Language : Romanian and English
Browser : Forum Version :
I think you forget theAnge Tuteur wrote:
- Code:
location.search == "?f=2&mode=newtopic" && $(function() {
// TEXT TO INSERT
window.scePredefinitedModel = ['[b]EXAMPLE', '[/b]\n\n[i]EXAMPLE 2[/i]'];
if ($.sceditor) {
// SET THE NEW SCEDITOR COMMAND
$.sceditor.command.set('predefinited-model', {
// WYSIWYG METHOD
exec : function() {
this.insert(scePredefinitedModel[0], scePredefinitedModel[1]);
},
// SOURCE CODE METHOD
txtExec : function() {
this.insert(scePredefinitedModel[0], scePredefinitedModel[1]);
},
tooltip : 'Insert predefinited model' // BUTTON TOOLTIP
});
toolbar = toolbar.replace(/code/, 'code,predefinited-model'); // INSERT BUTTON INTO TOOLBAR
}
});
// BUTTON IMAGE
document.write('<style type="text/css">.sceditor-button-predefinited-model div{background-image:url(http://i1370.photobucket.com/albums/ag257/AppleDrink/attention-sign%201.png)!important}</style>');
|
No problem.Andrei34 wrote:Thank you, sloved it now. I found the link you posted usefull(http://www.sceditor.com/documentation/getting-started/).
Oh, are you talking about this ?Andrei34 wrote:I think you forget the.
- Code:
if
- Code:
location.search == "?f=2&mode=newtopic" &&
If
|
|
It's more of a shorthand condition like :
- Code:
_userdata.user_level ? 'Staff' : 'Member';
The equivalent is :
- Code:
if (_userdata.user_level) {
'Staff';
} else {
'Member';
}
This has some shorthand examples too :
http://www.sitepoint.com/shorthand-javascript-techniques/
They're useful, however sometimes it's best to stick with the good old if .. else because they're easier to read.
- Wolfuryo
- Gender :
Posts : 256
Points : 3598
Reputation : 81
Language : Romanian and English
Browser : Forum Version :
OK. Thank you for answering my questions.
- Sponsored content
Similar topics
Create an account or log in to leave a reply
You need to be a member in order to leave a reply.
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|