Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

CSS, jquery into velocity template.

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013

I want to add jquery in css into velcoity templates and i follow below syntax:

<link href='../cal/printer.css' rel='stylesheet' media='print' />

<script src='../jquery/jquery-1.9.1.min.js'></script>

<script>

..

</script"

Does it work correct in velocity template..

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
moxin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013

try putting both css and js in templates folder.

about the second one no it would not impact as same syntax

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013

i have directly put all files under templates folder.

and again executed atlas-run command. still no effect.

i have just kept alert('msg'), prompt('msg') under "$(document).ready(function() { alert ..}

to test but not work..

moxin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013

how are you calling VM file? the script you are trying to run will not be called directly unless the VM file is called.

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013

my file is reside in project directory then,

what to keep "type="download"

how it refers, resource/templates/file.vm ?

will it be applicable to all templates in in project.

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013

Ya, i have added webwork and linked to that template .

i able to see my alert message just above "$(document).ready(function() { alert ..} inside <script> tag.

but not work under $(document)..

kept all files at same place where VM template file is resides.

moxin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013

if you want to directly run a JS file or insert CSS you can do it like this

&lt;web-resource key="1-resource" name="1 Web Resource"&gt;
		&lt;dependency&gt;jira.webresources:global-static&lt;/dependency&gt;
		&lt;dependency&gt;com.atlassian.auiplugin:ajs&lt;/dependency&gt;
		&lt;dependency&gt;jira.webresources:jira-global&lt;/dependency&gt;
		&lt;dependency&gt;jira.web.resources:ajs&lt;/dependency&gt;
		&lt;dependency&gt;jira.web.resources:jquery&lt;/dependency&gt;
		&lt;dependency&gt;confluence.web.resources:ajs&lt;/dependency&gt;
		&lt;dependency&gt;confluence.web.resources:jquery&lt;/dependency&gt;
        
        &lt;description&gt;JavaScript&lt;/description&gt;
        
        &lt;resource type="download" name="1.css" location="/css/1.css"/&gt;
        &lt;resource type="download" name="1.js" location="/js/1.js"/&gt;
        &lt;resource type="download" name="images/" location="/images"/&gt;

        &lt;context&gt;dashboard&lt;/context&gt;
        &lt;context&gt;jira.dashboard&lt;/context&gt;
		&lt;context&gt;atl.dashboard&lt;/context&gt;
		&lt;context&gt;atl.general&lt;/context&gt;
        &lt;context&gt;atl.admin&lt;/context&gt;
        &lt;context&gt;atl.userprofile&lt;/context&gt;
        &lt;context&gt;atl.popup&lt;/context&gt;
    &lt;/web-resource&gt;

moxin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013

try this:
AJS.$(document).ready(function() { alert('hello World!'); });

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013

Thanks Moxin.

it's work. so, instead of $ have to use AJS.$.

i have removed including script file then also it works. so, looks like JQUERY is already included by JIRA.

but, CSS, not work.. looking there.

Thanks.

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013

we can also use - "jQuery" instead of AJS.$.

example: jQuery(document).ready(function() { jQuery('#dv').html() });

0 votes
moxin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013
dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013

It's not working. looks like, refer wrong location.

File locations is as follow:

Resource/Templates/ tplfile.vm

Resource/cal/printer.css

Resource/jquery/file.js

please suggest me , what should be the location while include the file in .vm.

../cal/printer.css , not working.

cal/printer.css , not working.

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 20, 2013

jquery object "$(document)" and also velocity variables access with $

it could impact as same syntax ...?

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2013

Hi Moxin,

I have added my js files and css files as below but it did not work.

Can you correct me , what is wrong here..

my files are locat at below location:

src/main/Resource/templates/js files

src/main/Resource/templates/cs files

code:

<web-resource name="Admin Web Resources" key="resources">

<dependency>com.atlassian.auiplugin:ajs</dependency>

<resource type="download" name="admin.js" location="admin.js"/>

<!-- added below js files -->

<resource type="download" name="jquery-1.9.1.min.js" location="templates/jquery-1.9.1.min.js" />

<resource type="download" name="jquery-ui-1.10.2.custom.min.js" location="templates/jquery-ui-1.10.2.custom.min.js" />

<!-- end js files -->

</web-resource>

<!-- css files -->

<web-resource key="example-resources" name="Web Resources for Content in Editor">

<resource name="fullcalendar.css" type="download" location="templates/fullcalendar.css"/>

<resource name="fullcalendar.print.css" type="download" location="templates/fullcalendar.print.css"/>

<context>editor-content</context>

</web-resource>

moxin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2013

Where do you want to use VM cause there are context on which JS is going to work.
https://developer.atlassian.com/display/JIRADEV/Web+Resource+Plugin+Module#WebResourcePluginModule-WebResourceContextsinJIRA

moxin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2013

you don't have to add jQuery use the builtin jQuery Atlassian provide.
all you have to do is use AJS.$........
Google AJS and AUI

http://www.j-tricks.com/1/post/2012/02/some-ajs-tricks.html

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2013

I am not adding JQUERY. it is done.

I have some other JS files and CSS files which needs to include to achieve some feature.

for that , i need to include those files into velcoity template.

so, i follow the syntax as last comment.. so, please share me, how it could be included.

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2013

Actually,

i have added one webwork page at this location "system.top.navigation.bar"

on that particular link's screen, i need to use those script.

moxin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2013

try adding these:

&lt;context&gt;atl.general&lt;/context&gt;
&lt;context&gt;atl.popup&lt;/context&gt;

Use alert() to check if JS is working.

dhaval soni
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 21, 2013

Excellent Moxin. Thanks for your help. it works for me.

For location, i need to refer as follow -

"cal/ [JS file]" instead of "Resource/cal/[JS File]"

(my files under "src/main/resource/cal/[JS file]"

<web-resource name="Resources" key="resourcesfullCalendar">

<resource name="cal.min.js" type="download"location="cal/cal.min.js">

</resource>

<resource name="cal.css" type="download" location="cal/cal.css">

</resource>

</web-resource>

TAGS
AUG Leaders

Atlassian Community Events