How do I add my own javascript?

Support Ticket

+status
answered
+tags
 

I wanted to see if I could get shadowbox to work, so I thought I'd add the javascript for it the same way that you have scripts attached to Default Layout. I made a card with the CoffeeScript type and then opened the shadowbox.js and copied in the contents. However, I get errors when I save that. The first one seems to not like the date in the commented section of javascript. (It was the only place with 05 in it.) So I deleted the commented information and tried saving that, and I get SyntaxError: [stdin]:1:2: reserved word "function"

 

So I think this clearly doesn't work the way I was expecting, which is that I just make a CoffeeScript card with the name of the script and then add it to the Script section of the layout card I intend for it to be used on.

 

That's pretty close to what I would expect. You are running a version of Wagn that has 'Machine' cards, right?

 

The other issue is whether the URI is correct for the JS. What does your browser's debug tool say about whether it tried and succeeds in loading the JS?

--Gerry Gleason.....2014-09-16 15:31:19 +0000

I'm running 1.13. Well I didn't get that far because of the error on the script card itself. I sort of figured it wouldn't work if I tried to go any farther with the implementation until the script card itself was happy.

--Lora Friedenthal.....2014-09-16 15:47:33 +0000

If you're using raw JavaScript, your cardtype should be JavaScript, not CoffeeScript.

--Ethan McCutchen.....2014-09-16 21:33:05 +0000

Apparently I am blind. Does the rest of it work like I thought? I have to add it to the Script line in the layout where I want it used? And then I can add the call to the script in the head portion of the Layout? (I don't know what adding it to the Script section actually does.) The other part is that I need to include their CSS stylesheet. Their code looks for shadowbox.css. If I make a CSS card under Customized Classic Skin and put all the contents there, what will it actually be named in the system? Does being a CSS card mean it appends ".css" to whatever the name of the card is?

--Lora Friedenthal.....2014-09-16 21:50:59 +0000

You know, the more I'm looking at this, the more I'm thinking that I can't actually achieve what I want. Shadowbox requires either an argument in the link tag to activate or a specific class to be applied to the image. But the way I have images on my pages, they're inclusions. There isn't a direct link anywhere to the original image. I'd have to dig out the full size image filename as it's stored in wagn and make a link to that... somehow. And I just don't think that's going to work. Ethan, is there a wishlist I can add to?

--Lora Friedenthal.....2014-09-16 22:20:11 +0000

Step 1: add it to a JavaScript card.

Step 2. add that card to the *script rule for cards where you want it to appear.

 

The CSS is similar, but you need a CSS card and the *style rule.

 

You should only need to mess with the layout if you're adding custom javascript calls.

 

If you name the card "shadowbox", then yes shadowbox.css will work, but you'll get much faster performance if you link to the full url.

 

Re the image thing, that's a good idea! The closest thing to a wishlist is the Idea cards.

 

--Ethan McCutchen.....2014-09-16 22:35:08 +0000