Welcome to the LimeSurvey Community Forum

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

insert javascript code in admin page

  • first
  • first's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
7 years 9 months ago - 7 years 9 months ago #137606 by first
Hi , I am insert some javascript code the source code of admin page. Please let me know which file I can place this code in or any other way to do this.

Admin page:

Survey Designer and Programmer
Last edit: 7 years 9 months ago by first.
The topic has been locked.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #137608 by tpartner
Replied by tpartner on topic insert javascript code in admin page
LS version?

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • first
  • first's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
7 years 9 months ago #137651 by first
Replied by first on topic insert javascript code in admin page
2.06

Survey Designer and Programmer
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #137658 by DenisChenu
Replied by DenisChenu on topic insert javascript code in admin page
In 2.06 : you need to use afterPluginLoad

See framagit.org/SondagePro-LimeSurvey-plugi...eUpdateAdmin.php#L34

In 2.50 or LimeSurvey-SondagesPro

It's better to use manual.limesurvey.org/BeforeControllerAction (because it happen only for web, and it's more easy to fn the admin controller).

Denis

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.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago - 7 years 9 months ago #137666 by tpartner
Replied by tpartner on topic insert javascript code in admin page
In 2.50, you can do it in your own admin template without the need for a plugin.

1) Copy one of the templates from /styles to /upload/admintheme/ and rename it (let's say "yourTheme").

2) Add a custom.js file to /upload/admintheme/yourTheme/scripts/

3) Modify /upload/admintheme/yourTheme/config.xml as follows:
- Change the name, description and any other <metadatas> you see fit
- Modify the <js> files to include your new custom.js
Code:
        <js>
            <filename>notify.js</filename>
            <filename>save.js</filename>
            <filename>panelclickable.js</filename>
            <filename>panelsanimation.js</filename>
            <filename>sidemenu.js</filename>
            <filename>bootstrap-switch.min.js</filename>
            <filename>jquery.jcarousel.min.js</filename>
            <filename>jcarousel.responsive.js</filename>
            <filename>custom.js</filename>
        </js>
4) Switch Global settings --> General --> Administration template to "yourTheme"

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 years 9 months ago by tpartner.
The following user(s) said Thank You: DenisChenu
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #137671 by DenisChenu
Replied by DenisChenu on topic insert javascript code in admin page
Thanks Tony, didn't know that :)

Did you start a own admin template ?

Denis

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.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #137681 by tpartner
Replied by tpartner on topic insert javascript code in admin page
Yes, I use my own admin template in all versions of LS to do things like hide elements that I don't use very often, resize textareas, etc.

The ability to insert JavaScript is a huge plus.

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago #137685 by DenisChenu
Replied by DenisChenu on topic insert javascript code in admin page
I like to do it in an external plugin for some fix : then no need to update when core template have fix :)

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.
  • tpartner
  • tpartner's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago - 7 years 9 months ago #137765 by tpartner
Replied by tpartner on topic insert javascript code in admin page
Playing around with Denis' suggestion for LS 2.06 (mostly cutting and pasting :) ), I have come up with this small plugin that inserts a custom JavaScript file in the admin interface.
  • Create your own admin template - in /styles/, copy and rename one of the core admin templates
  • In Global settings --> General, activate that template
  • Add a custom JavaScript file to your new template directory
  • Extract the attached "insertAdminJS" plugin folder in your /plugins directory
  • In Plugin manager, activate the "Insert Custom Admin JS File" plugin
  • If you have named your custom JS file something other than "custom.js", go to the plugin settings and enter the filename

Ta-da! Now you have a custom JS file to play with.


Plugin File:

File Attachment:

File Name: insertAdminJS.zip
File Size:1 KB

Cheers,
Tony Partner

Solutions, code and workarounds presented in these forums are given without any warranty, implied or otherwise.
Last edit: 7 years 9 months ago by tpartner.
The following user(s) said Thank You: DenisChenu, Ben_V
The topic has been locked.
  • DenisChenu
  • DenisChenu's Avatar
  • Offline
  • LimeSurvey Community Team
  • LimeSurvey Community Team
More
7 years 9 months ago - 7 years 9 months ago #137770 by DenisChenu
Replied by DenisChenu on topic insert javascript code in admin page
Quick updated version for 2.50 : framagit.org/Shnoulle/insertAdminJS/comm...2a6925043690531385ae

Less issue with command.

Seems strange but i need to add "/" for the url : a difference betwwen 2.06 and 2.50.

Next step : a js file + css file editor ;) and save it in plugiun directory, register with assets ;)

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.
Last edit: 7 years 9 months ago by DenisChenu. Reason: Next step
The topic has been locked.

Lime-years ahead

Online-surveys for every purse and purpose