[Tutorial] Smiles integrado a janela no chatbox

Ver o tópico anterior Ver o tópico seguinte Ir para baixo

Admin
Admin
Administrador
Tempo Online : 250d 6h 21m 59s
Mensagens : 693
Reputação : 4
https://bestweb.forumeiro.com

MensagemAdmin Sex Set 30, 2016 12:56 pm

Informações:
Autor:
JScript
Funcionalidade: Todas as Versões




Acesse:
Painel de Controle Modulos Html e Javascript Gestão dos codigos Javascript
E Crie um novo Javascript com investimento no indice com esse codigo:
Código:

$(function() {
   if (_userdata.session_logged_in) {
      // Here will be checked if the chat is within the object tag, if it is, changes to iframe!
      if (jQuery('object#frame_chatbox').length) {
         jQuery('#frame_chatbox').replaceWith('<iframe src="/chatbox/index.forum?archives" id="frame_chatbox" scrolling="yes" width="100%" height="100%" type="text/html" style="border: 0px;" />');
      }
   }
});

$(window).load(function() {
   if (_userdata.session_logged_in) {
      // Calls the customization feature of the chat...
      chatFunction();

      // Here is the solution to a problem: When the iframe is changed, the function is called again!
      $('#frame_chatbox').load(function() {
         chatFunction();
      });
   }
});

// Function for customizing the chat.
function chatFunction() {
   var oIframe = (document.getElementById("frame_chatbox").contentWindow.document || document.getElementById("frame_chatbox").contentDocument),
      script = oIframe.createElement("script"),
      chatbox_script = function() {
         window.smile = {
            Load: function() {
               jQuery.ajax({
                  url: "/post?mode=smilies",
                  cache: true,
                  type: "get",
                  dataType: "text",
                  success: function(response, status, xhr) {
                     if (xhr.status == 200) {
                        var htmlSmile = $("<div>" + response + "</div>");
                        htmlSmile.find("#smilies_categ, p, span").remove();
                        var oTarget = htmlSmile.find("a"),
                           oThis, patt, regex;
                        for (var i = 0, len = oTarget.length; i < len; i++) {
                           oThis = $(oTarget[i]);
                           patt = /\('(.*?)'\)/i.exec(oThis.attr("href"))[1];
                           oThis.attr({
                              href: "#",
                              onclick: "smile.Insert('" + patt + "');return false;"
                           });
                        }
                        /*var aSmiles = [
                              "☎", "★", "♥", "♪", "✓",
                              "⧉", "©", "𝒥𝒮", "█", "▓",
                              "◯", "☆", "♣", "✗", "ℱℳ"
                           ],
                           sSmiles = "<p>";
                        for (var i = 0, len = aSmiles.length; i < len; i++) {
                           sSmiles += "<a href='#' onclick='smile.Insert(\"" + aSmiles[i] + "\");return false;'>" + aSmiles[i] + "</a>";
                        }*/
                        jQuery("#chat-smiles-show").html(
                           htmlSmile.find("#simple-wrap, tbody:last").html()
                        );
                     }
                  }
               });
               jQuery("head").append(
                  "<style type='text/css'>" +
                  "#chat-smiles-show {" +
                  "   background: none no-repeat scroll center center rgb(255, 255, 255);" +
                  "   border: 2px solid #d2d2d2;" +
                  "   height: 250px;" +
                  "   overflow: auto;" +
                  "   padding-top: 6px;" +
                  "   position: absolute;" +
                  "   width: 225px;" +
                  "   z-index: 99999;" +
                  "}" +
                  "#chat-smiles-show > p {" +
                  "   margin: 0;" +
                  "}" +
                  "#chat-smiles-show p a {" +
                  "   margin-bottom: 14px;" +
                  "}" +
                  "#chat-smiles-show a {" +
                  "   display: inline-block;" +
                  "   font-size: 18px;" +
                  "   margin-bottom: 5px;" +
                  "   margin-left: 10px;" +
                  "   text-decoration: none;" +
                  "}" +
                  "</style>"
               );
               jQuery("body").append("<div id='chat-smiles-show' style='display: none;'></div>");
            },

            Show: function(event) {
               var elenPos = jQuery("#divsmilies"),
                  target = jQuery("#chat-smiles-show");
               target.css({
                  "left": (elenPos.offset().left + elenPos.outerWidth()) - target.outerWidth(),
                  "top": elenPos.offset().top - target.outerHeight()
               });
               return (target[0].style.display == "none") ? target.fadeIn("fast") : target.fadeOut("fast");
            },

            Insert: function(smile) {
               var id = document.getElementById("message");
               id.focus();
               id.value += " " + smile + " ";
               document.getElementById("chat-smiles-show").style.display = "none";
            }
         };

         smile.Load();

         $("#divsmilies").unbind("click").bind("click", function (event) {
            smile.Show(event);
         });
      };
   script.type = "text/javascript";
   script.innerHTML = "(" + chatbox_script.toString() + ")();";
   oIframe.getElementsByTagName("head")[0].appendChild(script);
}

Resultado:
[Tutorial] Smiles integrado a janela no chatbox SsrzQ1N

Ver o tópico anterior Ver o tópico seguinte Ir para o topo

Cria uma conta ou logue para postar uma mensagem.

Você precisa ser um membro, para poder postar uma resposta.

Criar conta

Participe de nossa comunidade, basta se registrar. É Fácil!


Criar uma conta

Logar

Já tem uma conta? Sem problemas, Logue agora.


Logar-se

 
Permissões neste sub-fórum
Não podes responder a tópicos