Created
January 20, 2017 06:23
-
-
Save dejancencelj/eb59c50ed501f2bfda02cfc53b2e37be to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| if (typeof RedactorPlugins === 'undefined') var RedactorPlugins = {}; | |
| RedactorPlugins.twitter = function () { | |
| return { | |
| init: function () { | |
| var that = this; | |
| var callback = $.proxy(function () { | |
| var tweet_url = $('#tweet_url').val(); | |
| $.get('https://api.twitter.com/1/statuses/oembed.json', { | |
| url: tweet_url, | |
| omit_script: false, | |
| maxwidth: 500, | |
| lang: 'sl', | |
| hide_media: false, | |
| hide_thread: true | |
| }, $.proxy(function (data) { | |
| var script = '<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>'; | |
| //console.log(data.html); | |
| if (data.html) this.code.set(data.html, false); | |
| that.modal.close(); | |
| }, this), 'jsonp'); | |
| }, this); | |
| var button = this.button.add('twitter', 'Twitter'); | |
| this.button.addCallback(button, function () { | |
| //this.code.showCode(); | |
| this.modal.addTemplate('twitter', this.twitter.getTemplate()); | |
| this.modal.load('twitter', 'Vdelaj Twitt...', 400); | |
| this.modal.createCancelButton(); | |
| var button = this.modal.createActionButton('Insert'); | |
| button.on('click', callback); | |
| this.selection.save(); | |
| this.modal.show(); | |
| $('#twitter-textarea').focus(); | |
| }); | |
| // toolbar button CSS | |
| $('.redactor-toolbar li a.redactor-btn-image').css('background', "url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAOBJREFUeNpi/P//PwOtARMDHcCoJSPUEhZcEiEhIQJr1qz5gE0cSCUAMYh+AFSzACrGgE09IZ/MB2pOwCK+H4j7gbgeqgbEPw/EAeQElwDUkPkwlwJpAyBlgKbOAar2AjmWLITSIN/cB1kGpONxqE0EBtUFkuMEzUBYPGAFQAs2kJu6CoH4AxGJ5wLZSRjq/YlEWDSR0nxyAJRM8fkClIQpsgRoAMiSRCDegCOYHMnOjNAk2w9N+wJYlIBcX4gr86EDRnyVFjRfIGcyUNAdABr+gJRihXG0Zhy1ZGhbAhBgADhGSuPgsW2jAAAAAElFTkSuQmCC') no-repeat"); | |
| }, | |
| getTemplate: function () { | |
| return '<div class="tweets-plugin"><section><p><label>Twitter embed url</label><input type="text" id="tweet_url" value="" placeholder="https://twitter.com/xy/status/398477578136461312" style="width: 100%" /></p>'; | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment