Download BBCode
Page 1 of 1
Download BBCode
Download BBCode
Good evening,
Some time ago a user (from romanian support forum) asked for a tutorial how to create a new BBCode for download.
Now I've found the perfect solution, the code works perfectly, new editor integration, easy to use, easy to customize and very useful to stop using tags and PM to link.
Step 1:
Administration panel > MODULES > HTML & JAVASCRIPT > JavaScript Code Management > JavaScript Codes > Create a New JavaScript Code:
Title * : Download BBCode
Location : All Pages
JavaScript code * :
- Code:
(function($) {
document.write('<script type="text/javascript" src="https://use.fontawesome.com/141c9eaa90.js"></script>');
var Required_Post = 70,
Open_Type = true,
Show_ERROR_Message = 'You do not have the necessary messages to download';
$(function() {
$(function() {
$('body').append('<div id="download" class="sceditor-dropdown sceditor-download" style="visibility:hidden;width:auto;text-align:left;"><div><label for="linkdownload" unselectable="on">URL</label> <input type="text" id="linksrc" class="url" placeholder="http://" value=""></div><div><input type="button" class="button" value="inserare"></div></div>');
$('.sceditor-group:last-child').after('<div class="sceditor-group" id="download_link"><a class="sceditor-button" title="Download BBCode" onclick="selectWysiwyg(this, \'download\');"><div style="background:url(https://i.servimg.com/u/f62/19/70/74/92/if_dow13.png) no-repeat center;"></div></a></div>');
$('div input[value="inserare"]', $('#download')).live("click", function(e) {
$('textarea#text_editor_textarea').sceditor('instance').insert('[download='+ $('#linksrc', $('#download')).val() +']');
$('#linksrc', $('#download')).val('');
$('#download').css({'visibility':'hidden'});
});
for(var i = 0, j = $('.post'); i <= j.length; i++) {
if(/\/t(\d+)-|\/t(\d*)p(\d+)-/g.test(window.location.href)) {
if(_userdata.user_posts <= Required_Post) {
j[i].innerHTML = j[i].innerHTML.replace(/\[download=(.*?)\]/g, '<div id="download-link" class="error">'+ Show_ERROR_Message +'</div>');
}
else if(_userdata.user_posts >= Required_Post) {
(Open_Type == true) ? j[i].innerHTML = j[i].innerHTML.replace(/\[download=(.*?)\]/g, "<div id="download-link"><i class="fa fa-download" aria-hidden="true"></i><a href="$1" target="_blank">Download</a></div>") : j[i].innerHTML = j[i].innerHTML.replace(/\[download=(.*?)\]/g, "<div id="download-link"><i class="fa fa-download" aria-hidden="true"></i><a href="$1">Download</a></div>");
}
}
}
});
});
}(jQuery));
Step 2:
Administration panel > DISPLAY > Images & Colors > Colors > CSS Style Sheet:
- Code:
div#download-link {
background: #f1c444;
width: auto;
display: inline-block;
padding: 5px 10px;
border: 1px solid rgba(171, 153, 26, 0.21);
border-radius: 2px;
}
div#download-link > a {
color: #231d1d;
text-decoration: none;
font-size: 14px;
}
i.fa.fa-download {
margin-right: 5px;
font-size: 14px;
}
div#download-link.error {
background: #e44343;
color: wheat;
}
Personalization:
Required_Post = 30 // Here is the required number of messages per user to display the download button.
Open_Type = true // True = opens a new page to the download link || False = the link to the download page opens
Show_ERROR_Message= 'You do not have the necessary messages to download.' // Here is the message that will appear if it does not have the required number of messages posted
Demo:
https://imgur.com/a/AfKtF
TonnyKamper and صبرا جميلا like this post
![-](https://2img.net/i/empty.gif)
» How can add the BBCode Button on the title bar of BBCode Table?
» BBcode
» bbcode
» How to add bbcode?
» Vine BBCode
» BBcode
» bbcode
» How to add bbcode?
» Vine BBCode
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum