FM Themes
Welcome to FM Themes
where you can share your punBB, phpBB 2, Invision, & phpBB 3 themes for Forumotion forums.

You are viewing the forum as a guest, so you will not be able to use the full forum. To use all the features of the forum, you need to log in or create a FREE account by registering.

Add Topic Icons to the Quick Reply Editor

View previous topic View next topic Go down

SLGray
Administrator
Reputation : 290
Points : 1514
Posts : 3644
View user profile http://fmthemes.forumotion.com

PostSLGray on Sun Sep 27, 2015 9:39 am

I was wondering how to add the topic icons to the quick reply editor.  When I say topic icon, I mean these topic icons:  solved, complete, Pro Admin, etc.

Forum Version: [You must be registered and logged in to see this link.]
Forum Link: [You must be registered and logged in to see this link.]
Ange Tuteur
Themer
Reputation : 204
Points : 9161
Posts : 303
View user profile http://fmdesign.forumotion.com/

PostAnge Tuteur on Wed Sep 30, 2015 5:04 am

This script should do the trick. Just place it in the topics ^^
Code:
$(function() {
  var config = {
    modonly : 1, // determines who can use the icons. 0 = members / mods ; 1 = mods only
    label : 'Topic Icon : ', // label text
    cache : 1*60*60*1000 // time icons are cached
  };
 
  if (config.modonly && !_userdata.user_level) return;
  var a = document.createElement('DIV'), storage = window.localStorage, b;
 
  // few styles for our topic icon container
  a.style.width = '60%';
  a.style.padding = '3px 0';
  a.style.margin = '3px auto';
  a.style.textAlign = 'center';
 
  if (storage && storage.faTopicIcons && storage.faTopicIconsExp > +new Date - config.cache) prepareIcons(storage.faTopicIcons);
  else {
    $.get('/privmsg?mode=post', function(d) {
      b = $('#postingbox fieldset > dl:has(#post_icon_0) dd', d);
      prepareIcons('<strong style="float:left;color:#1675BC;font-size:11px;margin-top:4px;">' + config.label + '</strong>' + (b.length ? b[0].innerHTML : ''));
     
      // good browsers allow us to store the icons
      if (storage) {
        storage.faTopicIcons = a.innerHTML;
        storage.faTopicIconsExp = +new Date;
      }
    });
  }

  // helps us apply the HTML and do some checking
  function prepareIcons(html) {
    a.innerHTML = html;
    if (!a.getElementsByTagName('LABEL').length) {
      a.innerHTML = 'No icons :(';
      a.style.display = 'none'; // no icons = no reason to see this
    } else {
      // perform icon check if a match is found, match will contain our img element
      for (var img = a.getElementsByTagName('IMG'), src = $('.post:first h2.topic-title img').attr('src'), i = 0, j = img.length, match; i<j; i++) {
        if (src == img[i].src) {
          match = img[i];
          break;
        }
      }
      var node = document.getElementById('quick_reply');
      node && node.insertBefore(a, node.firstChild); // add list to the top of quick reply
      match && (match.parentNode.previousSibling.previousSibling.checked = 1);
      (!match && document.getElementById('post_icon_0')) && (document.getElementById('post_icon_0').checked = 1);
    }
  }
});
SLGray
Administrator
Reputation : 290
Points : 1514
Posts : 3644
View user profile http://fmthemes.forumotion.com

PostSLGray on Wed Sep 30, 2015 2:45 pm

Thanks. It worked perfectly.

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

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