javascript code work with members but doesn't with visiteurs

Go down

Solved javascript code work with members but doesn't with visiteurs

Post by alla13 on Wed 30 May - 20:46

hello there i hope you are doing well
i have this code made to me by @ Ange Tuteur
and modified a bit by @pedxz
i did post this issue in the arabic forum support and no one could solve it
so here i am
with members the code work just fine
the issue is that the code doesn't work with visteur
a video to show the issue



the code
Code:


$(function() {
  if (!$.sceditor) return;
 
  $.sceditor.command.set('cmd', {
 
  dropDown : function(editor, caller, callback) {
 
    var content = $(
    '<div>' +
    '  <div>' +
    '    <label>رابط</label>' +
    '    <input type="text" placeholder="رابط الخلفية" id="cmdValue" value="" />' +
    '  </div>' +
    '  <div>' +
    '    <input type="button" class="button" value="ادخال الخلفية">' +
    '  </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>'
  );
});


Last edited by alla13 on Thu 31 May - 16:49; 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: javascript code work with members but doesn't with visiteurs

Post by SLGray on Wed 30 May - 22:53

So the issue is that a code appears when you are a visitor?



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

Solved Re: javascript code work with members but doesn't with visiteurs

Post by alla13 on Thu 31 May - 1:41

yes, instead of a background the code shows up like the java does not work
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: javascript code work with members but doesn't with visiteurs

Post by Wecoc on Thu 31 May - 3:43

Everything (SCEditor button and the tag effect) is in the same function. That function is aborted in the very start if the SCEditor text area is not found, which happens in guest mode but also in closed topics, etc. That's where this bug comes from. You can simply change it to 2 different functions, so only de button function is aborted.

Code:
$(function() {
  if (!$.sceditor) return;
  $.sceditor.command.set('cmd', {
  dropDown : function(editor, caller, callback) {
    var content = $(
    '<div>' +
    '  <div>' +
    '    <label>رابط</label>' +
    '    <input type="text" placeholder="رابط الخلفية" id="cmdValue" value="" />' +
    '  </div>' +
    '  <div>' +
    '    <input type="button" class="button" value="ادخال الخلفية">' +
    '  </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: "خلفية الموضوع"});
  toolbar = toolbar.replace(/image/,'cmd,image');
});

$(function() {
  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 '';
      });
    }
  }
 
  $('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>'
  );
});

This should work Smile
avatar
Wecoc
Forumember

Male Posts : 136
Reputation : 98
Language : Catalan, Spanish, English

http://www.mundo-maker.com/

Back to top Go down

Solved Re: javascript code work with members but doesn't with visiteurs

Post by alla13 on Thu 31 May - 16:32

@Wecoc
thank you very much topic solved
but another problem show up
the guest can't reply now
even when i give them permission

nevermind i solved the issue
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: javascript code work with members but doesn't with visiteurs

Post by SLGray on Thu 31 May - 21:12

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