i need a modfication in this js script

Go down

Solved i need a modfication in this js script

Post by alla13 on 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.forumotion.com

Description of problem




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


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
avatar
alla13
Forumember

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

http://alla-omar.forumotion.com

Back to top Go down

Solved Re: i need a modfication in this js script

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

up
avatar
alla13
Forumember

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

http://alla-omar.forumotion.com

Back to top Go down

Solved Re: i need a modfication in this js script

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

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


avatar
SarkZKalie
Support Moderator
Support Moderator

Male Posts : 940
Reputation : 157
Language : English

http://rotavn.forumotion.com

Back to top Go down

Solved Re: i need a modfication in this js script

Post by alla13 on 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
avatar
alla13
Forumember

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

http://alla-omar.forumotion.com

Back to top Go down

Solved Re: i need a modfication in this js script

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

up
avatar
alla13
Forumember

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

http://alla-omar.forumotion.com

Back to top Go down

Solved Re: i need a modfication in this js script

Post by pedxz on 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
avatar
pedxz
Forumember

Male Posts : 146
Reputation : 30
Language : speaker daemonium & português
Location : Portugal

https://ajuda.forumeiros.com/u62843

Back to top Go down

Solved Re: i need a modfication in this js script

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

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

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

http://alla-omar.forumotion.com

Back to top Go down

Solved Re: i need a modfication in this js script

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

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



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

Male Posts : 44345
Reputation : 3144
Language : English
Location : United States

http://fmthemesdesignteam.forumotion.com/

Back to top Go down

Back to top


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