Development

#1677 ([PATCH] IE Conditionals for stylesheets and JavaScript)

You must first sign up to be able to contribute.

Ticket #1677 (closed enhancement: fixed)

Opened 2 years ago

Last modified 4 months ago

[PATCH] IE Conditionals for stylesheets and JavaScript

Reported by: notjosh Assigned to: fabien
Priority: minor Milestone: 1.2.0 RC1
Component: view Version: 1.2.0 DEV
Keywords: conditional Cc: notjosh@gmail.com, Stephen.Ostrow
Qualification: Ready for core team

Description

In this patch, I have added IE conditionals. It's pretty basic, but allows addition of conditional parameters for stylesheets and javascripts (in view.yml and addStylesheet() etc). This was the result of a conversation in the IRC channel, so I suppose that small demand justifies the inclusion of this functionality, right? ;]

USAGE (in view.yml):

moduleSuccess:
  stylesheets: [cssFileWithConditions: { condition: gte IE 5 }, standardStyleSheet]
  javascripts: [standardJavaScript, jsFileWithConditions: { condition: IE 5.5 }]

Hrrm, I've tried creating the patch via SVK - not sure how well it worked, but I'll attach it anyway. If you need any more info, give me a shout!

Attachments

patch.txt (2.7 kB) - added by notjosh on 04/16/07 15:39:33.
SVK generated patch.
conditionals.diff (2.1 kB) - added by notjosh on 04/16/07 23:25:52.
SVN diff, in additional to SVK patch..
ie-css-conditionals-sf10.patch (4.1 kB) - added by Kris.Wallsmith on 05/15/08 21:27:44.
[1.0] adds ie_condition option to stylesheets value in view.yml
ie-css-conditionals-sf11.patch (3.9 kB) - added by Kris.Wallsmith on 05/15/08 21:28:21.
[1.1] adds ie_condition option to stylesheets value in view.yml

Change History

04/16/07 15:39:33 changed by notjosh

  • attachment patch.txt added.

SVK generated patch.

04/16/07 23:25:52 changed by notjosh

  • attachment conditionals.diff added.

SVN diff, in additional to SVK patch..

04/17/07 01:51:42 changed by notjosh

  • summary changed from IE Conditionals for stylesheets and JavaScript to [PATCH] IE Conditionals for stylesheets and JavaScript.

04/18/07 18:46:44 changed by fabien

  • milestone deleted.

06/06/07 00:00:14 changed by dwhittle

  • status changed from new to closed.
  • resolution set to fixed.

(In [4166]) dwhittle: applied a few patches, fixed some helpers, closes #1677, #1661, #1540, #1531

06/06/07 00:01:07 changed by dwhittle

  • status changed from closed to reopened.
  • resolution deleted.

not committed to trunk yet...

10/01/07 08:00:33 changed by dwhittle

  • qualification set to Design decision.

This is resolved in dwhittle branch changeset #5133.

01/03/08 00:08:49 changed by Chris.Hoover

This never made it to trunk, seems to be in limbo...

01/03/08 00:20:32 changed by dwhittle

  • version changed from 1.0.2 to 1.0.0.

I think this should be in 1.1, fabien?

02/14/08 20:56:40 changed by cristianbaciu

  • priority changed from minor to major.
  • type changed from enhancement to defect.
  • milestone set to 1.0.12.

02/21/08 17:21:20 changed by fabien

  • priority changed from major to minor.
  • type changed from defect to enhancement.
  • milestone deleted.

04/22/08 23:02:54 changed by dwhittle

I think this has been discussed and decided that if it is needed that you can add to layout directly. Otherwise, I will add tests and merge to 1.1 branch.

05/15/08 17:56:14 changed by fabien

  • status changed from reopened to closed.
  • resolution set to wontfix.

I'm with dwhittle on this issue. This is not the kind of things that need to be packaged in a helper. You can put those things directly in the layout.

05/15/08 21:27:44 changed by Kris.Wallsmith

  • attachment ie-css-conditionals-sf10.patch added.

[1.0] adds ie_condition option to stylesheets value in view.yml

05/15/08 21:28:21 changed by Kris.Wallsmith

  • attachment ie-css-conditionals-sf11.patch added.

[1.1] adds ie_condition option to stylesheets value in view.yml

05/15/08 21:29:15 changed by Kris.Wallsmith

I've attached my patches for this same issue...

05/23/08 14:15:24 changed by notjosh

I don't agree at all that you just 'put it in the layout'.

The use case I have in mind, is where you have a CSS file for a particular module. I don't want to put IE conditionals around a CSS include inside of the template (implying inside of <body>). No, I want to have the <link> in the head, defined in view.yml, with all of my other CSS includes. I just want to have some IE rules associated.

And, there's still moderately frequently people asking about this on IRC that I notice. I still think it belongs in core.

05/23/08 14:33:41 changed by FabianLange

  • status changed from closed to reopened.
  • version changed from 1.0.0 to 1.1.0 DEV.
  • resolution deleted.

i agree with josh here. there is the media attribute existing as well which is basically also acting as a conditional switch. As the majority of customers has IE we have to be able to target that. When a plugin adds an js or when js is just in certain modules its not that easy to make this condition for it. As for the decision: i cant find a mail on users or dev list that is a decision. The only thing that I found is a "you can make it in the layout", but that doesn't answer this fully. Actually i could do everything in the layout and bypass symfony :-)

So please forgive but I dare to reopen and asking as well for including this small feature in 1.1

06/12/08 18:42:12 changed by Dannyrulez

This is really needed if you are going to create a plugin with a helper where you can't add anything to the <HEAD> tag in the layout

06/12/08 22:01:05 changed by Kris.Wallsmith

I agree. Microsoft is throwing us a bone here... let's put this in the core already.

06/12/08 23:20:53 changed by dwhittle

Due to overwhelming demand, if fabien is alright with adding this for 1.1. I will merge the change. Otherwise...

06/18/08 23:06:39 changed by fabien

  • milestone set to 1.2.0.

06/23/08 04:56:25 changed by dwhittle

  • qualification changed from Design decision to Ready for core team.

07/08/08 17:16:01 changed by Stephen.Ostrow

  • milestone changed from 1.2.0 to 1.0.18.

I was about to put in a new ticket as well as throw in a patch I had written but found this and another ticket before submitting mine.

I wanted to throw in my support as well as elaborate on the fact that you cannot accomplish the same thing through putting it in the layout.

Javascript and Stylesheets or automatically bound to the </head> tag. This means you cannot put another stylesheet along with it's conditionals between the stylesheets entered through the view.yml file and the closing </head> tag.

The only option would be to put all stylsheets directly in the layout (another bad idea) or put the stylesheet with the conditional below the <body> tag. (even worse).

As we all know order does matter when it comes to css and most html/css developers do something similar to the below which is currently impossible to implement cleanly in symfony

A timely application of the above path to both the 1.0 and 1.1 branches would be extremely helpful.

Thanks.

07/08/08 17:17:09 changed by Stephen.Ostrow

For some reason it trac didn't display my example so here it is again:

<link rel="stylesheet" href="css/screen.css" type="text/css" media="screen" />
<!--[if lte IE 7]>
	<link rel="stylesheet" href="css/ie6.css" type="text/css" media="screen" />	
<![endif]-->

07/10/08 22:23:43 changed by Stephen.Ostrow

  • cc changed from notjosh@gmail.com to notjosh@gmail.com, sostrow@sowebdesigns.com.

08/11/08 11:38:30 changed by FabianLange

  • milestone changed from 1.0.18 to 1.2.0.

New features like this will not be applied to stable releases. this is clearly no bugfix, but a feature that is not adressed up to now.

11/18/08 07:58:24 changed by Kris.Wallsmith

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [13097]) [1.2] added support for conditional comments to stylesheets and javascripts (closes #1677)

11/18/08 07:59:31 changed by Kris.Wallsmith

  • version changed from 1.1.0 DEV to 1.2.0 DEV.
  • milestone changed from 1.2.0 to 1.2.0 RC1.

11/18/08 08:05:48 changed by Stephen.Ostrow

  • cc changed from notjosh@gmail.com, sostrow@sowebdesigns.com to notjosh@gmail.com, Stephen.Ostrow.

(follow-up: ↓ 28 ) 03/13/09 00:30:57 changed by drake

"Javascript and Stylesheets or automatically bound to the </head> tag. This means you cannot put another stylesheet along with it's conditionals between the stylesheets entered through the view.yml file and the closing </head> tag."

Can you explain what you mean in more detail and better english? My experience is that you can put these specialized IE only conditional comments in the head. They are comments after all and I've tested doing this specifically and it works just fine...

(in reply to: ↑ 27 ) 03/13/09 00:49:55 changed by Stephen.Ostrow

Replying to drake:

"Javascript and Stylesheets or automatically bound to the </head> tag. This means you cannot put another stylesheet along with it's conditionals between the stylesheets entered through the view.yml file and the closing </head> tag." Can you explain what you mean in more detail and better english? My experience is that you can put these specialized IE only conditional comments in the head. They are comments after all and I've tested doing this specifically and it works just fine...

I've since stopped using sf1.0 and moved on to sf1.2 so it's not a big deal. Also you can use conditionals with sf1.0, you just have to not use /app/frontend/config/view.yml at all for stylesheets. What I was saying is that when you use the view.yml file the stylesheets are inserted by binding them to the </head> tag. This means that there is no way to put your normal stylesheet in view.yml and the conditional stylesheet after, but still inside the </head> tag. You can however put both in the template just fine.

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.