The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.

Create a free forum like this one.

New button on sceditor (facebook Videos)

View previous topic View next topic Go down

New button on sceditor (facebook Videos)

Post by Luis Ferreira on January 2nd 2016, 4:59 pm

Forum version :Phpbb2
Position :Administrator
Concerned browser(s) :Google Chrome
Who the problem concerns :all
Forum link :

So i want similar to youtube button but i want to add html code because youtube videos so i made this code but its kinda wrong ( im learning javascript im not that good xD) so here's the code i have:
$(function() {
  if ($.sceditor) {
    $.sceditor.command.set("vid-facebook", {
      // drop down
      _dropDown: function(editor, caller, handleIdFunc) {
        var matches, content = $('<div><div><label for="youtubeurl">' + editor._("URL:") + '</label> <input type="text" id="youtubeurl" class="url" placeholder="http://" value="" /></div><div><input type="button" value="' + editor._("Insert") + '" class="button"></div>');
        content.find('.button').click(function(e) {
          var val = content.find("#youtubeurl").val().replace("http://", "");
          if (val !== "") {
            matches = val.match(/(?:v=|v\/|embed\/|\/)(.{11})/);
            if (matches) {
              val = matches[1]
            if (/^[a-zA-Z0-9_\-]{11}$/.test(val)) {
            } else {
              alert(editor._('Invalid YouTube video'))
        editor.createDropDown(caller, "insertlink", content)
      // wysiwyg mode
      exec: function(caller) {
        var editor = this;
        $.sceditor.command.get('vid-facebook')._dropDown(editor, caller, function(id) {
          editor.wysiwygEditorInsertHtml('<iframe width="560" height="315" src="' + id + '?wmode=opaque" data-youtube-id="' + id + '" frameborder="0" allowfullscreen></iframe>')
      // source mode
      txtExec : function(caller) {
        var editor = this;
        $.sceditor.command.get('vid-facebook')._dropDown(editor, caller, function(id) {
          editor.insert('[youtube]' + id + '[/youtube]')
      tooltip: "Insert a YouTube video"
    // add button to editor toolbar
    toolbar += ',vid-facebook';

I need some help to finish Sad

Luis Ferreira

Posts : 53
Reputation : 1
Language : Poruguese

Back to top Go down

View previous topic View next topic Back to top

Permissions in this forum:
You cannot reply to topics in this forum