在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):Aly-ve/Mastodon-share-button开源软件地址(OpenSource Url):https://github.com/Aly-ve/Mastodon-share-button开源编程语言(OpenSource Language):HTML 95.1%开源软件介绍(OpenSource Introduction):Mastodon share buttonAs the same way than Facebook or Twitter, this "plugin" allows developers to append a button to share content to Mastodon. You just need to append Create the elementsTo create elements in page's DOM, you have to create a div with For example: <div
class="mastodon-share-button"
data-target="https://framapiaf.org"
data-name="Framapiaf"
data-buttonstyle="btn btn-secondary"
data-text="Share on Mastodon"
></div> Some explanations
Adapt Mastodon Share Button to your designTo open a homogenious modal, get the instance's address field [etc], you need to put a variable with your preferences. This variable contains callback to open and close modal and/or dialog, the id of the button to share and close modal. IntegrationBootstrap or your own modalIn the example, var msbConfig = {
openModal: function () {
$('#exampleModal').modal('show');
},
closeModal: function () {
$('#exampleModal').modal('hide');
},
addressFieldSelector: '#mbs-address',
buttonModalSelector: '#modalShareButton',
memorizeFieldId: 'msb-memorize-instance',
buttonDisplayText: false,
buttonIconHtml: '<i class="fa fa-mastodon" aria-hidden="true"></i>'
};
$('#exampleModal').on('shown.bs.modal', function() {
$('#msb-address').focus();
}); Alertify.jsFirst of all, you have to write your own confirm's content yourself <div id="mastodon-share-button">
<div class="form-group">
<label for="msb-address">Enter your instance's address </label>
<input type="text" class="form-control" id="msb-address" placeholder="https://framapiaf.org">
</div>
<div class="form-check">
<input type="checkbox" class="form-check-input" id="msb-memorize-instance">
<label class="form-check-label" for="msb-memorize-instance">Memorize my instance</label>
</div>
</div> var msbConfig = {
openModal: function (name, target) {
alertify.confirm('Share on Mastodon', document.querySelector('#mastodon-share-button'), () => msbOnShare(name, target), function())
},
addressFieldSelector: '.ajs-body input#msb-address',
buttonModalSelector: '.ajs-button ajs-ok',
memorizeFieldId: 'msb-memorize-instance',
buttonIconHtml: '<i class="fa fa-mastodon" aria-hidden="true"></i>'
}; Explainations
Too see an concrete example, please see the Github Pages at the root of this repository. And it creates all elements by itself. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论