Welcome to the LimeSurvey Community Forum

Ask the community, share ideas, and connect with other LimeSurvey users!

Custom Template: New image at end of each group

  • dweisser
  • dweisser's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 10 months ago #96002 by dweisser
Gents,
One more thing. Do you know of a preloader script that would be worthwhile to use?
Also, in what file would you put it?
Any advice you have would as always be appreciated.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 10 months ago - 10 years 10 months ago #96018 by tpartner
I have used this in the past:
Code:
$(document).ready(function(){  
  preload([
    'path/to/images/group_0.png',
    'path/to/images/group_1.png',
    'path/to/images/group_2.png',
    'path/to/images/group_3.png'
  ]);
});
 
function preload(arrayOfImages) {
  $(arrayOfImages).each(function(){
    $('<img/>')[0].src = this;
  });
}

(remember not to put a comma after the last image in the array)

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 10 years 10 months ago by tpartner.
The topic has been locked.
  • dweisser
  • dweisser's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 10 months ago #96034 by dweisser
In what file would you place it? At the end of template.js?
David
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 10 months ago #96038 by tpartner
That would work or you could wrap it in a <script> tag and place it in the question source.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • dweisser
  • dweisser's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 9 months ago #96253 by dweisser
Hi Tony,
I have implemented the follwoing in the template.js.

$(document).ready(function(){
preload([
' www.mydomain.com/survey/upload/templates...roupDemo/group_0.png ',
' www.mydomain.com/survey/upload/templates...roupDemo/group_1.png ',
' www.mydomain.com/survey/upload/templates...roupDemo/group_2.png ',
' www.mydomain.com/survey/upload/templates...roupDemo/group_3.png ',
]);
});

function preload(arrayOfImages) {
$(arrayOfImages).each(function(){
$('<img/>')[0].src = this;
});
}

As you can see i included the full path to the images.Is it possible this is not the right approach. I ask because the images don;t seem to preload. There is a delay before they are presented on the page.

Is there a chance there is another setting that needs to be changed?
Any thoughts you have are most appreciated.
David
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 9 months ago #96259 by tpartner
Does the path contain "http://"? I don't see it in your code.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • dweisser
  • dweisser's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 9 months ago #96260 by dweisser
Yes, the http;// are all there; I'm not sure why I pasted the code without them.
" www.springboltconsulting.com/survey/uplo...roupDemo/group_0.png ",

I am asking, because I am working on another issue related to script and images, and am wondering if there is something I am making a fundamental mistake on.

Thank you,
David
The topic has been locked.
  • dweisser
  • dweisser's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 9 months ago #96294 by dweisser
I have been working with Denis to insert images as button in the survey. We could not make it work. Until Denis realized I had an error in the CorrectPNG function. I fixed the error to no avail. I had to comment out the entire function to make it work - and that solved the image preloading issue I was having as well.

See: : www.limesurvey.org/en/forum/installation...buttons-images/96265 for the long story.

Thank you,
David
The topic has been locked.
  • dweisser
  • dweisser's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 9 months ago #96305 by dweisser
One more thing,
Is it possible that you know how to accomplish the hover effect with the images as buttons (detailed at the end of the post above). The css, if in fact it is still css, is simply beyond me. This is last detail in my quest to accomplish buttons as images on surveys. Any thoughts you have are greatly appreciated.
P.S. I became a Gold Donor this morning. ;)
Nebraska
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 9 months ago #96306 by DenisChenu
Replied by DenisChenu on topic Custom Template: New image at end of each group
Hello,

For hover : 2 manner.

1st : use css only for background without hover and with hover.
2nd: use .hover() jquery function to change img src url

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand , plugin development .
I don't answer to private message.
The topic has been locked.
  • dweisser
  • dweisser's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
10 years 9 months ago #96307 by dweisser
I think I have tried - and failed - method one. I don't know enough to know what I'm doing wrong.
And I haven't slightest idea of how to implement method 2.
I'm stuck without an example to work from,
David
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
10 years 9 months ago #96322 by tpartner
David,thanks for the gold!

See www.limesurvey.org/en/forum/installation...mages?start=10#96321 for an answer about hover effects.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose