The forum of the forums

Would you like to react to this message? Create an account in a few clicks or log in to continue.
The forum of the forums
2 posters

    open images in a certain area in a popup window

    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved open images in a certain area in a popup window

    Post by _Twisted_Mods_ Sun 23 Nov 2014 - 11:23

    ok so i resized all images inside my #chatbox

    so now what i wanna do is if someone clicks on the img it will open the image in a popup window so they can see it fullsize... and i only ant it to effect the images inside of the #chatbox element


    yes i know more work for for you ange .. and ty for the script cause your probably only one on here who can do it


    Last edited by _Twisted_Mods_ on Mon 24 Nov 2014 - 2:20; edited 1 time in total
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: open images in a certain area in a popup window

    Post by Ange Tuteur Sun 23 Nov 2014 - 11:41

    Hello _twisted_mods_,

    Something like this ?
    open images in a certain area in a popup window Captur87

    Administration Panel > Modules > JavaScript codes management > Create a new script

    Title : Your choice
    Placement : In the homepage
    Code:
    $(function() {
     Â var fa_chat = document.getElementById('frame_chatbox'), frame, overlay = document.createElement('DIV'), image = document.createElement('IMG');
     Â if (!fa_chat) return;
     Â 
     Â overlay.onclick = function() { this.style.display = 'none' };
     Â overlay.setAttribute('style','display:none;position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.4);z-index:100000;text-align:center;');
     Â document.body.appendChild(overlay), overlay.appendChild(image);
     Â 
     Â fa_chat.onload = function() {    
     Â   if (fa_chat.contentDocument) frame = fa_chat.contentDocument;
     Â   else if (fa_chat.contentWindow) frame = fa_chat.contentWindow.document;
     Â   
     Â   
     Â   // kill the interval if archives are enabled
     Â   var a = frame.getElementsByTagName('A');
     Â   for (i=0; i<a.length; i++) if (/archives/.test(a[i].href)) a[i].onclick = function() { window.clearInterval(_chat_refresh) };

     Â   // execute code in an interval
     Â   _chat_refresh = window.setInterval(function() {
     Â     var img = frame.getElementById('chatbox').getElementsByTagName('IMG'),i;
     Â     for (i=0; i<img.length; i++) {
     Â       img[i].onclick = function() {
     Â         overlay.style.display = 'block';
     Â         image.src = this.src;
     Â       }
     Â     }
     Â   },100);
     Â }
    });
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: open images in a certain area in a popup window

    Post by _Twisted_Mods_ Sun 23 Nov 2014 - 13:42

    work awesome but is there a way to prevent it from reloading the img each times it clicked and it minimized back to the chatbox
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: open images in a certain area in a popup window

    Post by Ange Tuteur Mon 24 Nov 2014 - 0:52

    Could you explain what you mean ? From what I tried, the image was already loaded.
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: open images in a certain area in a popup window

    Post by _Twisted_Mods_ Mon 24 Nov 2014 - 0:55

    ok lets say i have a img in the chat box and i click it

    when it pops up it reloads the image in the overlay like it was never open

    then when i minimize it back to the chat box the img in the chatbox reloads like it was never open


    if you dont understand me from there ill try to take screenshots or something
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: open images in a certain area in a popup window

    Post by Ange Tuteur Mon 24 Nov 2014 - 1:00

    That's weird, it doesn't do that for me. Shocked

    Usually when you view an image, the data of that image is cached by its URL : https://2img.net/i/bl/logo.png So, wherever I view that image, it will be loaded already, unless I clear my cache.

    Did you make any changes to how data is saved for your browser ?
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: open images in a certain area in a popup window

    Post by _Twisted_Mods_ Mon 24 Nov 2014 - 1:14

    no but i use my phones internet and it its tethered to my pc using virtual network and a proxy so maybe thats the issue
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: open images in a certain area in a popup window

    Post by Ange Tuteur Mon 24 Nov 2014 - 1:32

    It must be, because I tested on IE, Chrome, and Firefox + Aurora. All reacted the same by caching the image.
    _Twisted_Mods_
    _Twisted_Mods_
    Helper
    Helper


    Male Posts : 2083
    Reputation : 336
    Language : English
    Location : Ms

    Solved Re: open images in a certain area in a popup window

    Post by _Twisted_Mods_ Mon 24 Nov 2014 - 2:19

    ok then this is

    solved

    as always thankyou for you help once again
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: open images in a certain area in a popup window

    Post by Ange Tuteur Mon 24 Nov 2014 - 2:59

    Anytime Smile

    Topic archived

      Current date/time is Wed 13 Nov 2024 - 19:21