FM Themes
Welcome to FM Themes
where you can share your ModernBB, 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.
Share
View previous topicGo downView next topic
avatar
Administrator
Posts : 3898
Points : 1775
Reputation : 309
View user profilehttps://www.fmthemes.net

Complete Add Topic Icons to the Quick Reply Editor

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.]
avatar
Posts : 303
Points : 9165
Reputation : 207
View user profilehttp://fmdesign.forumotion.com/

Complete Re: Add Topic Icons to the Quick Reply Editor

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);
    }
  }
});
avatar
Administrator
Posts : 3898
Points : 1775
Reputation : 309
View user profilehttps://www.fmthemes.net

Complete Re: Add Topic Icons to the Quick Reply Editor

on Wed Sep 30, 2015 2:45 pm
Thanks. It worked perfectly.
View previous topicBack to topView next topic
Permissions in this forum:
You cannot reply to topics in this forum