The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

i need a modfication in this js script

4 posters

Go down

Solved i need a modfication in this js script

Post by alla13 May 17th 2018, 7:22 pm

Technical Details

Forum version : #phpBB3
Position : Founder
Concerned browser(s) : Mozilla Firefox, Google Chrome, Internet Explorer, Opera, Safari, Other
Who the problem concerns : All members
Forum link : http://alla-omar.mo-rpg.com

Description of problem


i need a modfication in this js script 9pAkXu6

i want it to do the same act but with window to insert the img url

i need a modfication in this js script QjhwKt9
the code
Code:
$(function() {
  if ($.sceditor) {
    $.sceditor.command.set('tbl', {
 
      exec : function() {
        this.insert('[tbl=',']');
      },
 
      txtExec : function() {
        this.insert('[tbl=',']');
      },
 
      tooltip : 'خلفية الموضوع'
 
    });
 
    toolbar += ',tbl';
  }
 
  for (var a = $('.post .content'), i = 0, j = a.length; i < j; i++) {
    if (/\[tbl=.*?\]/i.test(a[i].innerHTML)) {
      a[i].innerHTML = a[i].innerHTML.replace(/\[tbl=(.*?)\]/i, function(M, $1) {
        a[i].style.backgroundImage = 'url(' + $1 + ')';
        return '';
      });
    }
  }
});


Last edited by alla13 on May 20th 2018, 4:59 pm; edited 1 time in total
alla13
alla13
Forumember

Posts : 91
Reputation : 6
Language : Arab5/5 Eng3/5 Fr2/5

http://alla-omar.mo-rpg.com

Back to top Go down

Solved Re: i need a modfication in this js script

Post by alla13 May 18th 2018, 6:30 pm

up
alla13
alla13
Forumember

Posts : 91
Reputation : 6
Language : Arab5/5 Eng3/5 Fr2/5

http://alla-omar.mo-rpg.com

Back to top Go down

Solved Re: i need a modfication in this js script

Post by SarkZKalie May 18th 2018, 7:41 pm

Can you explain your issue in more detail here? And where did you get this script?


i need a modfication in this js script Sarkzk10
SarkZKalie
SarkZKalie
Support Moderator
Support Moderator

Male Posts : 1447
Reputation : 220
Language : English

https://rotavn.forumotion.com/

Back to top Go down

Solved Re: i need a modfication in this js script

Post by alla13 May 18th 2018, 8:42 pm

SarkZKalie wrote:Can you explain your issue in more detail here? And where did you get this script?

there is no issue i just want a modification in the script

the script was made here in the help forum by ange the job of it is to make a background to the topic by the choice of the member

https://help.forumotion.com/t144461-help-me-with-this-java-scripte#987269

so instead of writing the url of the image and then click on the button 


i want a window to show and pste the url of the img in it
alla13
alla13
Forumember

Posts : 91
Reputation : 6
Language : Arab5/5 Eng3/5 Fr2/5

http://alla-omar.mo-rpg.com

Back to top Go down

Solved Re: i need a modfication in this js script

Post by alla13 May 19th 2018, 7:46 pm

up
alla13
alla13
Forumember

Posts : 91
Reputation : 6
Language : Arab5/5 Eng3/5 Fr2/5

http://alla-omar.mo-rpg.com

Back to top Go down

Solved Re: i need a modfication in this js script

Post by tikky May 20th 2018, 3:14 pm

Hey @alla13,
you can adapte this code: [AddOn] Criar botão no editor com lista de comandos by @Daemon.

Change your code to:
Code:
$(function() {
  if (!$.sceditor) return;
 
  $.sceditor.command.set('cmd', {
 
  dropDown : function(editor, caller, callback) {
 
    var content = $(
    '<div>' +
    '  <div>' +
    '    <label>URL</label>' +
    '    <input type="text" placeholder="bg image" id="cmdValue" value="" />' +
    '  </div>' +
    '  <div>' +
    '    <input type="button" class="button" value="ok!">' +
    '  </div>' +
    '</div>'
    );
            content.find('.button').click(function(e) {
                callback(content.find('select').val());
                editor.closeDropDown(true);
            });
            editor.createDropDown(caller, "cmd", content);
  },
  // WYSIWYG MODE
  exec : function(caller) {
  var editor = this;
      $.sceditor.command.get('cmd').dropDown(editor, caller, function(cmd) {
        var before = '[tbl]', title = $('#cmdValue').val();
        if(title !== '') {
          before = '[tbl=' + title + ']';
            editor.wysiwygEditorInsertHtml(before);
        }
      });
  },
  // SOURCE MODE
  txtExec : function(caller) {
  var editor = this;
      $.sceditor.command.get('cmd').dropDown(editor, caller, function(cmd) {
        var title = $('#cmdValue').val();
        if(title) {
            editor.insertText('[tbl=' + title + ']');
        } else {
            editor.insertText('[tbl=' + title + ']');
        }
      });
  }, tooltip: "خلفية الموضوع"});
 
    for (var a = $('.post .content'), i = 0, j = a.length; i < j; i++) {
    if (/\[tbl=.*?\]/i.test(a[i].innerHTML)) {
      a[i].innerHTML = a[i].innerHTML.replace(/\[tbl=(.*?)\]/i, function(M, $1) {
        a[i].style.backgroundImage = 'url(' + $1 + ')';
        return '';
      });
    }
  }
 
  toolbar = toolbar.replace(/image/,'cmd,image');
 
  $('head').append(
  '<style type="text/css">' +
  '.sceditor-button-cmd div {' +
  '  background:url(https://cdn2.iconfinder.com/data/icons/circle-icons-1/64/image-16.png) !important}' +
  '  .sceditor-cmd {' +
  '  width:auto;' +
  '  height:auto;' +
  '  overflow-y:auto;' +
  '}' +
  '.sceditor-cmd select {' +
  '  margin: 0 0 .75em;' +
  '}' +
  '</style>'
  );
});


best regards,
Humor
tikky
tikky
Forumember

Posts : 923
Reputation : 160
Language : 🇵🇹

https://www.forumotion.com/create-forum/modernbb

Back to top Go down

Solved Re: i need a modfication in this js script

Post by alla13 May 20th 2018, 4:56 pm

thank you @pedxz
the code is working
topic solved
alla13
alla13
Forumember

Posts : 91
Reputation : 6
Language : Arab5/5 Eng3/5 Fr2/5

http://alla-omar.mo-rpg.com

Back to top Go down

Solved Re: i need a modfication in this js script

Post by SLGray May 20th 2018, 9:27 pm

Problem solved & topic archived.
Please read our forum rules:  ESF General Rules


i need a modfication in this js script Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
SLGray
SLGray
Administrator
Administrator

Male Posts : 51576
Reputation : 3525
Language : English
Location : United States

https://forumsclub.com/gc/128-link-directory/

Back to top Go down

Back to top

- Similar topics

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