Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Chris!
Dec 2, 2004

E

caiman posted:

I'm trying to come up with a good IE8 fallback for inline SVG. For whatever reason IE8 doesn't simply ignore the <svg> tags, it throws a poo poo fit when it sees one and stops rendering the page correctly. So far I see two viable options.

The first one is outlined here. Conditional comments to block the <svg> tags from IE8 and load the fallback .png. Fine, but conditional comments are gross.

The second option is to use Modernizr (which I'm already using on the site for a couple other features). Basically, inject the <svg> into the page via JavaScript using Modernizr.inlinesvg. Supported browsers get the code, unsupported browsers get the fallback. This should work, but is it overkill?

Which of these is the better option?

I thankfully don't have to support IE8, but use SVG4Everybody for inline SVGs - https://github.com/jonathantneal/svg4everybody - it's very helpful for getting inline SVGs to wok cross browser, and provides PNG fallback for IE8.

Adbot
ADBOT LOVES YOU

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

Heskie posted:

I'm looking at SVG's at the moment and came across this fallback technique:

code:
<img src="image.svg" onerror="this.src=image.png">
or

code:
if (!Modernizr.svg) { $("img[src$='.svg']") .attr("src", $this.src.replace("svg","png")); }
Obviously this doesnt account for inline <svg> tags though. Do you have a good resource on handling svg sprites?

edit:
Found a CSS Tricks list of SVG information, pretty handy since all my Googling was filled with pages of SVG Icon sets rather than useful info.

Yeah, when using SVG as the src in an <img> or as the background-image in CSS, fallbacks seem simpler. Unfortunately I need the ability to style individual parts of the SVG, so it's gotta be inline for me. I've decided on the Modernizer/JS route. I implemented it last night and it's working great.

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

Chris! posted:

I thankfully don't have to support IE8, but use SVG4Everybody for inline SVGs - https://github.com/jonathantneal/svg4everybody - it's very helpful for getting inline SVGs to wok cross browser, and provides PNG fallback for IE8.

Ah, I've heard of this but wasn't entirely sure how it works. Looks like it has to be placed in the <head>. Any idea if it can be called via Modernizr.load()?

Chris!
Dec 2, 2004

E

caiman posted:

Ah, I've heard of this but wasn't entirely sure how it works. Looks like it has to be placed in the <head>. Any idea if it can be called via Modernizr.load()?

I think it could be (it's just a js file so I don't see why not) - but it's pretty useful for general IE fallbacking of inline SVGs.

There's a very useful article about it here: http://css-tricks.com/gotchas-on-getting-svg-into-production/

I was using inline SVGs, but they weren't being properly cached, using SVG for Everybody helped make that work cross browser.

jackpot
Aug 31, 2004

First cousin to the Black Rabbit himself. Such was Woundwort's monument...and perhaps it would not have displeased him.<
Can someone tell me if this is possible, before I spend a lot of brain cells trying to make it happen?

I have two selects with identical options inside an optgroup. If you choose an answer in the first select, I want that answer to be a) moved into a different optgroup in the second select, and b) set to disabled. Like if you were buying airline tickets, your origin and destination can't be the same city. Is there a name for what this is called?

Here's the basic, basic html I'm working with: http://jsfiddle.net/Jackpot/awwfbzzx/

kedo
Nov 27, 2007

jackpot posted:

Can someone tell me if this is possible, before I spend a lot of brain cells trying to make it happen?

I have two selects with identical options inside an optgroup. If you choose an answer in the first select, I want that answer to be a) moved into a different optgroup in the second select, and b) set to disabled. Like if you were buying airline tickets, your origin and destination can't be the same city. Is there a name for what this is called?

Here's the basic, basic html I'm working with: http://jsfiddle.net/Jackpot/awwfbzzx/

http://jsfiddle.net/szzvsgo5/1/

Could probably be written a lot nicer, but there's a proof of concept.

kedo fucked around with this message at 22:01 on Dec 10, 2014

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

jackpot posted:

Can someone tell me if this is possible, before I spend a lot of brain cells trying to make it happen?

I have two selects with identical options inside an optgroup. If you choose an answer in the first select, I want that answer to be a) moved into a different optgroup in the second select, and b) set to disabled. Like if you were buying airline tickets, your origin and destination can't be the same city. Is there a name for what this is called?

Here's the basic, basic html I'm working with: http://jsfiddle.net/Jackpot/awwfbzzx/

Do this: http://jsfiddle.net/awwfbzzx/3/

e:f;b by a mile =)

jackpot
Aug 31, 2004

First cousin to the Black Rabbit himself. Such was Woundwort's monument...and perhaps it would not have displeased him.<
I have so much love for this forum. :)

Lumpy, yours is great because it uses .attr('disabled','disabled') to disable whatever's appended to that optgroup. One thing I notice it's doing is it never stops; if in that first dropdown I choose atlanta, new york, and chicago, all three are in the deselected optgroup in the second select. Do I want to use something like refresh() to rebuild that second select every time I choose an option in the first select? It's hard to see how I don't end up negating all my picks in the second select if I do it that way.

kedo
Nov 27, 2007

jackpot posted:

One thing I notice it's doing is it never stops; if in that first dropdown I choose atlanta, new york, and chicago, all three are in the deselected optgroup in the second select. Do I want to use something like refresh() to rebuild that second select every time I choose an option in the first select? It's hard to see how I don't end up negating all my picks in the second select if I do it that way.

I feel like whenever I see these the second select is always created after the first selection is made, and I would assume this is why. That's a pretty easy solution.

Otherwise on change you could look at the disabled options in the second select, check if they have the same value as the selected option, and if not remove them before adding the new one in.

e: If your original markup is in HTML and isn't being generated by JS I'd probably go with the second option.

Kobayashi
Aug 13, 2004

by Nyc_Tattoo
I really don't understand why Grunt and Gulp exist. It seems like it is a constant struggle to get those tools to do anything I want them to. On the other hand, after playing around with NPM's "scripts" for a few hours, I was able to get asset linting/compilation, live reloading with a static server and watch directories, and version syncing between package.json and bower.json working. It seems so much easier to work with than other tools.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

jackpot posted:

I have so much love for this forum. :)

Lumpy, yours is great because it uses .attr('disabled','disabled') to disable whatever's appended to that optgroup. One thing I notice it's doing is it never stops; if in that first dropdown I choose atlanta, new york, and chicago, all three are in the deselected optgroup in the second select. Do I want to use something like refresh() to rebuild that second select every time I choose an option in the first select? It's hard to see how I don't end up negating all my picks in the second select if I do it that way.

Move the stuff out of the disabled optgroup before you move a new one in. So yes, a 'rebuild' method or "removeDisabled' would be nice. If you keep an object or array with the original order around, you can do an inefficient but probably plenty fast enough for less than 1000 things rebuild.

I whipped up a poorly coded Proof of Concept that appears to keep selection: http://jsfiddle.net/awwfbzzx/4/

I left removing the selection of the TO item if you pick it in the FROM to you.

Lumpy fucked around with this message at 01:46 on Dec 11, 2014

jackpot
Aug 31, 2004

First cousin to the Black Rabbit himself. Such was Woundwort's monument...and perhaps it would not have displeased him.<

Lumpy posted:

I left removing the selection of the TO item if you pick it in the FROM to you.
Beautiful, thank you.
And actually, if I'm understanding you correctly, to keep people from screwing this up I'm hiding the TO select until you pick a FROM value. That prevents people from answering the TO field first, then answering the FROM, then having to go back and answer TO again (without knowing they have to). From a user's standpoint, this thing would be confusing as hell if I had the logic working both ways.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

jackpot posted:

Beautiful, thank you.
And actually, if I'm understanding you correctly, to keep people from screwing this up I'm hiding the TO select until you pick a FROM value. That prevents people from answering the TO field first, then answering the FROM, then having to go back and answer TO again (without knowing they have to). From a user's standpoint, this thing would be confusing as hell if I had the logic working both ways.

What I meant by that was: I pick New York in the FROM. I pick Chicago in the TO. I then realize I am an idiot (which if the user is me, is true) and that I did it backwards. I then pick Chicago in the FROM. My selected Chicago in the TO is still selected, but now it is disabled. This could be confusing to users.

As to your point, I would not hide the TO. At most, disable it until FROM is picked. If it is not there, you may make users thing it is missing / broken. User testing will tell you the least worse solution.

Pilsner
Nov 23, 2002

Ranting: Who got the bright idea to make the web like it was back in 2000 with regards to popups? Granted they're lightboxes/overlays now, but every other website I enter these days puts a huge lightbox in my face, asking me to sign up, follow or subscribe to their poo poo. It's absolutely infuriating. Add the EU cookie warning (which I have to click through on 5-6 different devices every month or so on every page) and we're in hell. MotherFFFFFFFFF :argh:

revmoo
May 25, 2006

#basta
Yeah definitely a bit of history repeating there. I often just click away and go do something else. Curious to see a study on the bounce rates caused by those things.

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

Pilsner posted:

Ranting: Who got the bright idea to make the web like it was back in 2000 with regards to popups? Granted they're lightboxes/overlays now, but every other website I enter these days puts a huge lightbox in my face, asking me to sign up, follow or subscribe to their poo poo. It's absolutely infuriating. Add the EU cookie warning (which I have to click through on 5-6 different devices every month or so on every page) and we're in hell. MotherFFFFFFFFF :argh:

Come on now... you know you really want to download their mobile app.

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

Pilsner posted:

Ranting: Who got the bright idea to make the web like it was back in 2000 with regards to popups? Granted they're lightboxes/overlays now, but every other website I enter these days puts a huge lightbox in my face, asking me to sign up, follow or subscribe to their poo poo. It's absolutely infuriating. Add the EU cookie warning (which I have to click through on 5-6 different devices every month or so on every page) and we're in hell. MotherFFFFFFFFF :argh:

I have a rule of thumb that if a lightbox popup interrupts what I was reading on the page, I immediately exit the page and add the site to my mental blacklist. Whatever I was reading wasn't worth spending one extra second one a lovely site. Yes, these things are a sign of lovely UX, plain and simple.

The Merkinman
Apr 22, 2007

I sell only quality merkins. What is a merkin you ask? Why, it's a wig for your genitals!
How do you feel about lightbox/modal windows that you clicked something to bring up? Personally I'd much rather add the content inline, than via modal.

Lumpy posted:

Come on now... you know you really want to download their mobile app.
Sign up for our newsletter!

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

The Merkinman posted:

How do you feel about lightbox/modal windows that you clicked something to bring up? Personally I'd much rather add the content inline, than via modal.

If it's a response to something I did, then it's all good.

revmoo
May 25, 2006

#basta
I have a big project getting deployed in the next couple weeks. What's the best way to force everyone's browser to redownload the JS/CSS? Is there even a consistent way?

Lumpy
Apr 26, 2002

La! La! La! Laaaa!



College Slice

revmoo posted:

I have a big project getting deployed in the next couple weeks. What's the best way to force everyone's browser to redownload the JS/CSS? Is there even a consistent way?

src="myScipt.js?lol=sadfweqr"

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

revmoo posted:

I have a big project getting deployed in the next couple weeks. What's the best way to force everyone's browser to redownload the JS/CSS? Is there even a consistent way?

I think if you append a string to the end of the file name, the browser will be forced to get the new version. Like style.css?v=2

e:beaten

Raskolnikov2089
Nov 3, 2006

Schizzy to the matic

Pilsner posted:

Ranting: Who got the bright idea to make the web like it was back in 2000 with regards to popups?

Hint: Their major begins with "Market" and ends with "ing".

revmoo
May 25, 2006

#basta

Lumpy posted:

src="myScipt.js?lol=sadfweqr"

Ahh perfect, I knew there had to be some trick to do it. Thanks!

jackpot
Aug 31, 2004

First cousin to the Black Rabbit himself. Such was Woundwort's monument...and perhaps it would not have displeased him.<

caiman posted:

If it's a response to something I did, then it's all good.
But for gently caress's sake, give me an easy way to close it. There are few things more irritating than a modal window on mobile where the close button is a 5x5px box in the corner.

Maluco Marinero
Jan 18, 2001

Damn that's a
fine elephant.
Popup ads are so much dreck. The fact that infuriates me is they slow JavaScript down so much, that the only time I click on the is I go to interact or scroll and they popup as I'm doing that because the site loads like molasses. Web ain't broken, we break it with out design and dev.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

If you make a website with one of those, I'm going to stalk you in real life and wait for the opportune time to push you down the stairs.

My Rhythmic Crotch
Jan 13, 2011

Can anybody tell me if there is a generally accepted best practice for securing cookies with session IDs? I've been reading OWASP and other stuff, but it seems like every method recommended is still insecure.

Alternatively, is there some new fangled clustering scheme for back-end servers that would allow them to share session data so that session IDs through cookies are no longer needed?

Chris!
Dec 2, 2004

E
I have some SVG icons I want to animate when their container div is hovered over. I want to animate specific elements inside the SVG. There are only 3 SVGs, they're pretty simple and only appear on 1 page, so it's not the biggest problem in the world to have them inline rather than linked externally, if it helped.

I was planning on just animating them with jquery, but jquery seems to be able to animate the individual elements for some things (fading the opacity to 0 for example) but doesn't seemingly let me animate the position at all, which is what I need to do.

I know there are libraries that handle this, like snap.js, I'd rather avoid an external library but if there's no option I'll use one. Any ideas or recommendations?

RobertKerans
Aug 25, 2006

There is a heppy lend
Fur, fur aw-a-a-ay.
CSS transforms work just fine, with either transition or animate depending upon what effect you want.

yoyomama
Dec 28, 2008
This guide on css tricks seems good: http://css-tricks.com/guide-svg-animations-smil/

Spatulater bro!
Aug 19, 2003

Punch! Punch! Punch!

Somebody recently asked about SVG sprites. Here's a good article on them.

darthbob88
Oct 13, 2011

YOSPOS
I have a rendering problem. On this page, and similar product pages, div.PD14T and div.PD24T have different ideas of what width:100% means. Specifically, .PD14T limits its width to the outer container, while .PD24T will overflow given the chance. They have (roughly) the same content, the only difference is that .PD14T is an immediate child of form#vCSS_mainform, while .PD24T is in a table within #vCSS_mainform. Is there something about tables that they'll fit their contents rather than their wrappers? Is there an easy way to adjust .PD24T to fix this?

ETA: Have a JSFiddle. I've stripped out everything irrelevant to the problem and added a blue border to make the problem slightly more obvious.

darthbob88 fucked around with this message at 05:54 on Dec 17, 2014

Depressing Box
Jun 27, 2010

Half-price sideshow.
The only way I know to make a table respect a maximum width is with "table-layout: fixed". This prevents the table from resizing to fit its contents, though, so check that it doesn't break something else.

The ideal long-term solution is not using tables for layout.

EDIT: With a fixed layout you can remove the "max-width: 1150px" from .PD24T and let it fill the whole container, like so:

Depressing Box fucked around with this message at 04:49 on Dec 17, 2014

darthbob88
Oct 13, 2011

YOSPOS
Dammit, took too long to edit in that JSFiddle. Yeah, I'd like to move away from table design, and some of our newer clients have gone to responsive and semantic div-based things, but some people stick with tables. To be fair, this client is enterprise, so of course they'll be reluctant to change something that's worked fine for so long. Looks like "table-layout: fixed" will fix things, and yeah, will do some more testing to make sure it doesn't break anything.

Brave GNU World
Nov 1, 2013

by Cyrano4747

Thermopyle posted:

Rant follows.

So I'm wanting to use Facebook's Flux and React on a project. I'm part way in to it and using RequireJS.

I haven't used Flux before, so I'm learning as I go.

I go to download their Dispatcher.js file. Oops, Facebook uses Browserify and the ES6 class statement. I dig around for a bit and realize I've got to clone the repo and do an npm install to build a de-sugarified version. Good to go now...

Oh wait, it also depends on invariant.js. Ok, I'll just add that to my RequireJS-style require statement.

Oh no, won't work, Dispatcher.js and invariant.js both use CommonJS-style require and module.exports. I've got to wrap them with RequireJS's code for handling CommonJS modules.

I loving hate javascript tooling and modules and bleh. The people who came up with this house of cards should be ashamed.

I could have switched everything over to using browserify, but man this is just a constant on-going pain. I don't really want to use browserify anyway, as this is a complex single page app and there's like 2MB of js that I don't want to load all at once. I'm not sure if it's one of those things where it's irritating because I don't do it enough and I'd think the same thing about...say...python's import statement, if I wasn't really familiar with python.

Use Webpack, make a common bundle and whatever other bundles you need, then load the extra bundles depending on the route or whatever, here's a handy guide by one of the facebook/instagram guys: https://github.com/petehunt/webpack-howto

sector_corrector
Jan 18, 2012

by Nyc_Tattoo
Does anyone here have experience with jquery-ui? I'm having some problems with (I think) the CSS formatting of a nested elements. My main problem is that I'm trying to nest a tab div within an accordion div, and there's way too much padding space below the tab div. I've tried editing a few padding values in the style-sheet, but I can't seem to find what's causing the problem. I can post code, if need be.

Jimlit
Jun 30, 2005



sector_corrector posted:

Does anyone here have experience with jquery-ui? I'm having some problems with (I think) the CSS formatting of a nested elements. My main problem is that I'm trying to nest a tab div within an accordion div, and there's way too much padding space below the tab div. I've tried editing a few padding values in the style-sheet, but I can't seem to find what's causing the problem. I can post code, if need be.

You should definitely post the code.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Brave GNU World posted:

Use Webpack, make a common bundle and whatever other bundles you need, then load the extra bundles depending on the route or whatever, here's a handy guide by one of the facebook/instagram guys: https://github.com/petehunt/webpack-howto

I just gave in and used browserify.

Thanks for that guide though, I might switch to webpack. I considered it before I started using browserify but browserify is simpler and seems to have better docs (because its simpler) and I was already irritated with the whole thing...

Adbot
ADBOT LOVES YOU

sector_corrector
Jan 18, 2012

by Nyc_Tattoo

Jimlit posted:

You should definitely post the code.

Ok, here are two pastebins...

Here's the page,
http://pastebin.com/FWNp61Q0

Here's the remote CSS for Jquery-UI, although I'm pretty sure that I haven't changed anything in there,
http://pastebin.com/SsKgWXjr

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply