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)

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 : http://gamemunity.team-talk.net/


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:
Code:
$(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\/|youtu.be\/)(.{11})/);
            if (matches) {
              val = matches[1]
            }
            if (/^[a-zA-Z0-9_\-]{11}$/.test(val)) {
              handleIdFunc(val)
            } else {
              alert(editor._('Invalid YouTube video'))
            }
          }
          editor.closeDropDown(true);
          e.preventDefault()
        });
        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="http://www.youtube.com/embed/' + 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
Forumember

Posts : 53
Reputation : 1
Language : Poruguese

http://gamemunity.team-talk.net/

Back to top Go down

Back to top


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