Back To Top
Login
Register
Visit Us At TwitterVisit Us At YouTubeVisit Us At Facebook
KandiChat is in Beta Release. Try It Out
HomeHome  
  • UpdatesUpdates  
  • SearchSearch  
  • Latest imagesLatest images  
  • RegisterRegister  
  • Log inLog in  
  • April 2024
    MonTueWedThuFriSatSun
    1234567
    891011121314
    15161718192021
    22232425262728
    2930     

    Calendar Calendar

    Search
     
     

    Display results as :
     


    Rechercher Advanced Search

    Similar topics
    Who is online?
    In total there are 3 users online :: 0 Registered, 0 Hidden and 3 Guests

    None

    Most users ever online was 140 on July 4th 2021, 2:03 pm
    RSS feeds


    Poll
    Top posting users this week
    No user


    View previous topic View next topic Go down  Message [Page 1 of 1]

    Mr.EasyBB

    The Doc Uploader on the New Editor!

    Mr.EasyBB
    06/12/2013
    Ok guys, so to add that awesome doc uploader from FilePicker.io we have a new code for you. It's easier and we are not instantiating the init sceditor twice now! 

    Easy, just create a new JavaScript file, then add this code

    Code:
    $(function() {
    var ifit = $('#text_editor_textarea');
    if(ifit.length){
      $.sceditor.command.set("servimg", {
        exec: function(caller) {
          var editor = this,
              data = $('#text_editor_textarea').data('sceditor'),
              source = data.inSourceMode();
          if(!editor.initalised) {
            filepicker.setKey('API KEY');
            filepicker.pick({
              mimetypes: ['application/msword','text/*','image/*'],
              services:['COMPUTER','GOOGLE_DRIVE','DROPBOX','FACEBOOK','PICASA','FLICKR','WEBCAM','URL','INSTAGRAM','IMAGE_SEARCH']
            }, function(FPFile) {
              var docFile = FPFile.url,
                  type= FPFile.mimetype;
              if(/^.*text.*$/.test(type)) { data.insert('[url]'+FPFile.url+'+'+FPFile.filename.replace(/\s/g,"")+'[/url]');
                                          }
              else if(/^.*image.*$/.test(type)) { data.insert('[img]'+FPFile.url+'+'+FPFile.filename.replace(/\s/g,"")+'[/img]');
                                                }
             });
            }
          }
        });
    }
      });









    Save it and you should be done.
    Share this post on: reddit

    Puppycheese889
    This doesn't seem to work for me here is the code I am using. It should work I can't see any errors with it.

    Code:
    $(document).ready(function() {
    $.sceditor.command.set("filepicker", {
      exec: function() {
    var editor = this;
    filepicker.setKey('MY API KEY');
      filepicker.pick({mimetypes: ['application/msword','text/*','image/*'],
                      services:['COMPUTER','GOOGLE_DRIVE','DROPBOX','FACEBOOK','PICASA','FLICKR','WEBCAM','URL','INSTAGRAM','IMAGE_SEARCH']
                      },function(FPFile) {
                        var docFile = FPFile.url,
                        textArea = $('#toolbar textarea'),
                        type= FPFile.mimetype;
    if(/^.*text.*$/.test(type)) {

    editor.insert('[url]'+FPFile.url+'+'+FPFile.filename.replace(/\s/g,"")+'[/url]');

    } else if(/^.*image.*$/.test(type)) {

    editor.insert('[img]'+FPFile.url+'+'+FPFile.filename.replace(/\s/g,"")+'[/img]');
    }
    });
      },
      tooltip: "Upload File"
    });

    WHat did I do wrong here?

    Post June 13th 2013, 10:27 pm by Puppycheese889

    Mr.EasyBB
    Well that alone won't work because you didn't add it I have one that you don't need the entire template. You should really read the entire tutorial.


    This will replace the servimg button

    Code:
    $.sceditor.command.set("servimg", {
      exec: function(caller) {
    var editor = this,
     data = $('#text_editor_textarea').data('sceditor'),
     source = data.inSourceMode();
    if(!editor.initalised)
    {
    filepicker.setKey('AQIrUGd1FTuSBxvGURzGlz');
      filepicker.pick({mimetypes: ['text/*','image/*'],
                      services:['COMPUTER','FACEBOOK']
                      },function(FPFile) {
                        var docFile = FPFile.url,
                        type= FPFile.mimetype;
    if(/^.*text.*$/.test(type)) {
    data.insert('[url]'+FPFile.url+'+'+FPFile.filename.replace(/\s/g,"")+'[/url]');
    } else if(/^.*image.*$/.test(type)) {
    data.insert('[img]'+FPFile.url+'+'+FPFile.filename.replace(/\s/g,"")+'[/img]');
    }
    });
    }
      },
      tooltip: "Upload File"
    });

    Post June 13th 2013, 11:39 pm by Mr.EasyBB

    Puppycheese889
    Ok what am i missing this time? It's not working still! This doesn't require the template correct? 



    Code:
    $.sceditor.command.set("servimg", {
    exec: function(caller) {
    var editor = this,
    data = $('#text_editor_textarea').data('sceditor'),
    source = data.inSourceMode();
    if(!editor.initalised)
    {
    filepicker.setKey('AJvmKUvCHRdOJVGEf4JSuz');
    filepicker.pick({mimetypes: ['application/msword','text/*','image/*'],
    services:['COMPUTER','GOOGLE_DRIVE','DROPBOX','FACEBOOK','PICASA','FLICKR','WEBCAM','URL','INSTAGRAM','IMAGE_SEARCH']
    },function(FPFile) {
    var docFile = FPFile.url,
    type= FPFile.mimetype;
    if(/^.*text.*$/.test(type)) {
    data.insert('[url=+FPFile.url+'+'+FPFile.filename.replace(/s/g,"")+]'+FPFile.url+'+'+FPFile.filename.replace(/\s/g,"")+'[/url]');
    } else if(/^.*image.*$/.test(type)) {
    data.insert('[img]'+FPFile.url+'+'+FPFile.filename.replace(/\s/g,[/img]');
    }
    });
    }
    },
    tooltip: "Upload File"
    });

    Post June 13th 2013, 11:56 pm by Puppycheese889

    Mr.EasyBB
    Did you wrap that in a function???

    EX:
    Code:
    $(function() {
    //code
    });

    Post June 13th 2013, 11:57 pm by Mr.EasyBB

    Puppycheese889
    no but I just did that and it's not working for me... the toolbar disappears when I add the function part.

    Code:
    $(function() {
    $.sceditor.command.set("servimg", {
    exec: function(caller) {
    var editor = this,
    data = $('#text_editor_textarea').data('sceditor'),
    source = data.inSourceMode();
    if(!editor.initalised)
    {
    filepicker.setKey('AJvmKUvCHRdOJVGEf4JSuz');
    filepicker.pick({mimetypes: ['application/msword','text/*','image/*'],
    services:['COMPUTER','GOOGLE_DRIVE','DROPBOX','FACEBOOK','PICASA','FLICKR','WEBCAM','URL','INSTAGRAM','IMAGE_SEARCH']
    },function(FPFile) {
    var docFile = FPFile.url,
    type= FPFile.mimetype;
    if(/^.*text.*$/.test(type)) {
    data.insert('[url]'+FPFile.url+'+'+FPFile.filename.replace(/\s/g,"")+'[/url]');
    } else if(/^.*image.*$/.test(type)) {
    data.insert('[img]'+FPFile.url+'+'+FPFile.filename.replace(/\s/g,"")+'[/img]');
    }
    });
    }
    },
    tooltip: "Upload File"
    });
    });

    Post June 14th 2013, 12:02 am by Puppycheese889

    bob77707
    I'd definitely consider myself a noob when it comes to this stuff, so sorry if this is a stupid question. I read the original tutorial, got my API Key, put it in the code you provided in this post, but when I click on the Host an Image button, it still brings up ServImg. Is there anything that needs to be done in addition to adding the code you posted to a javascript page and checking the "In the Topics" button?

    PS: Thanks for putting these tutorials together. They add a lot to our forums!

    Post June 18th 2013, 10:06 pm by bob77707

    Mr.EasyBB
    Liked
    Bob

    Code:
    Code: Select Code
    $.sceditor.command.set("servimg", {
    exec: function(caller) {
    var editor = this,
    data = $('#text_editor_textarea').data('sceditor'),
    source = data.inSourceMode();
    if(!editor.initalised)
    {
    filepicker.setKey('API KEY');
    filepicker.pick({mimetypes: ['text/*','image/*'],
    services:['COMPUTER','FACEBOOK']
    },function(FPFile) {
    var docFile = FPFile.url,
    type= FPFile.mimetype;
    if(/^.*text.*$/.test(type)) {
    data.insert('[url]'+FPFile.url+'+'+FPFile.filename.replace(/\s/g,"")+'[/url]');
    } else if(/^.*image.*$/.test(type)) {
    data.insert('[img]'+FPFile.url+'+'+FPFile.filename.replace(/\s/g,"")+'[/img]');
    }
    });
    }
    },
    tooltip: "Upload File"
    });

    That should work for you, also please read the Dawn of an Era. We are shutting down, we will be moving to AvacWeb, I've already started transferring the tutorials over there just cleaning them up. Support will be provided by myself and other staff.

    Thank you

    Post June 18th 2013, 11:05 pm by Mr.EasyBB

    bob77707
    Thanks for the quick response.

    I read the Dawn of an Era. That's awesome that you guys are teaming up!

    I tried the code you gave me. I wrapped it in a function. The only part that obviously went through was the tooltip. When I hover over the button it successfully changed from saying "Host an Image" to "Upload File." This only happened when I ticked "All pages".

    I still get ServImg when I click on the button, though. Any other thoughts on what I am doing wrong?

    Post June 19th 2013, 12:33 am by bob77707

    bob77707
    A couple of after thoughts if they help. On my error console, it says that $.sceditor is undefined. Also I am using phpbb2. Looking at the code, it doesn't look like that would make a difference, but again, I'm a noob, so I am not sure.

    Post June 19th 2013, 5:29 pm by bob77707

    Post  by Sponsored content

    View previous topic View next topic Back to top  Message [Page 1 of 1]