0

I need to modify a javascript file which I'm currently using to display images (it's a standard lightbox JS). This is the part of the script that I need to modify:

settings : function() {
    var t = this, s = shutterSettings;

    t.imageCount = s.imageCount || 0;
    t.msgLoading = s.msgLoading || 'L O A D I N G';
    t.msgClose = s.msgClose || 'Click to Close';
},

Basically I need to replace the word 'LOADING' in the script with a loading-bar gif. Could someone point me in the right direction (link to a tutorial, manual etc.) on how to do this? I tried to replace the word with an <img> or <div> tag but that didn't worked.

4
  • You can't replace a word with a gif. You can replace some markup with other markup that displays a gif, but t doesn't look like an element to me. Commented Oct 31, 2012 at 15:17
  • This change must be done inside the lightbox plugin. Can you give us a link to it? Commented Oct 31, 2012 at 15:22
  • This is the link: redflexmedia.com/portfolio/portfolio/photography Enter any gallery, click on an image and while the image is loading you will see that a big red "Loading" will appear briefly. I need to replace that word with an image. Commented Oct 31, 2012 at 15:25
  • Check my answer, it should work Commented Oct 31, 2012 at 15:36

2 Answers 2

1

You need to make this replacement inside the lightbox plugin, not in its settings.

The msgLoading is very likely considered to be given as a string and the string received is set as the text of a div, p or span element.

If you post a link to the lighbox plugin's js file or tell us the name of the plugin or the site where you downloaded it, maybe I can give you a more precise answer. The fact that it's a standard lightbox JS is not exactly helpful

[edit]So it seems you are using Shutter Reloaded for NextGEN Gallery If you look inside the plugin's js file (here, in your case), you will see that the innerHTML is set, so using an img should work.

loading : function() {
        var t = this, S, WB, W;
        if ( (W = t.I('shWrap')) && W.style.visibility == 'visible' ) return;
        if ( ! (S = t.I('shShutter')) ) return;
        if ( t.I('shWaitBar') ) return;
        WB = document.createElement('div');
        WB.setAttribute('id','shWaitBar');
        WB.style.top = t.Top + 'px';
        WB.style.marginTop =(t.pgHeight/2) + 'px'
        WB.innerHTML = t.msgLoading;
        S.appendChild(WB);
    },

Try with these settings:

var shutterSettings = {"msgLoading":"<img src=\"http://redflexmedia.com/loading.gif\">","msgClose":"Click to Close","imageCount":"1"};

[edit]The code above must be placed inside the HTML file, in the head section, NOT the plugin.

That means you must replace this part

<script type='text/javascript'>
/* <![CDATA[ */
var shutterSettings = {"msgLoading":"<img src=\"http://redflexmedia.com/loading.gif\">","msgClose":"Click to Close","imageCount":"1"};
/* ]]> */
</script>

with

<script type='text/javascript'>
/* <![CDATA[ */
var shutterSettings = {"msgLoading":"L O A D I N G","msgClose":"Click to Close","imageCount":"1"};
/* ]]> */
</script>
Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for helping! I tried but now I see the word 'undefined' instead of the image.
Did you put the settings in the html file? You should use it there, not inside the plugin. Looking at the source here redflexmedia.com/portfolio/portfolio/photography I can still see the old var settings
@GeorgeGrigorita I took a look at your site and caught you in the act, you were editing in the wrong place. Check the edit on my post, please
If you want to edit the plugin directly, you can do it like this: t.msgLoading = '<img src="http://example.com/loading.gif">'; I believe you were not escaping the quotes the first time you edited the plugin and that's why I think it didn't work
Yes, that was the problem. Now it works and the file which outputs the shutterSettings in the final HTML is nggallery.php (for future references - if anyone has this problem). Thanks for your help, I really appreciated it!
|
1

http://lokeshdhakar.com/projects/lightbox/ see if the 3rd point helps ...

If you would like to show the user a 'loading' graphic, like the animated progress bar in the examples above, specify its location at the top of the lightbox.js file:

var loadingImage = 'loading.gif';

2 Comments

@George Grigorita can you plz direct us to the lightbox.js file you are using...it will help us to dig in more..
Thanks both for helping, I'm using Shutter Reloaded for NextGEN Gallery: redflexmedia.com/portfolio/wp-content/plugins/nextgen-gallery/…

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.