Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11497 (new enhancement)

Opened 5 months ago

Last modified 5 months ago

Stylesheet helper $S(n).addCss(expression, cssText)

Reported by: poste9 Assigned to: sam
Priority: low Milestone: 2.x
Component: Prototype Version: edge
Severity: minor Keywords: prototype stylesheets cssrules selector css javascript
Cc: poste9@gmail.com

Description

This function I used to manipulate my CSS with JavaScript. Of course u can do it better than me, its just a suggestion.

Usage:

$S(0).addCSS('div#mydivid ul li ',
	     'width:270px;'
             'height:210px;'+
	     'float:left;'+
	     'margin-right:4px;');

$S(0) indicates document.styleSheets[0]

function $S(index) {
	index = document.styleSheets[index];
	Object.extend(index, {addCSS : function(seletor,rule) {
			if ( this.insertRule)
			this.insertRule(seletor + '{'+rule+'}', this.cssRules.length);
			else if ( this.addRule )
			this.addRule(seletor, rule, this.rules.length)
		}
	});
	return Element.extend(index);
}

Change History

04/03/08 00:41:43 changed by jdalton

  • summary changed from Suggestion of Function to Stylesheet helper $S(n),addCss(expression, cssText).

04/03/08 00:42:01 changed by jdalton

  • summary changed from Stylesheet helper $S(n),addCss(expression, cssText) to Stylesheet helper $S(n).addCss(expression, cssText).

04/03/08 13:19:33 changed by jdalton

04/03/08 13:20:43 changed by jdalton

  • priority changed from normal to low.
  • severity changed from normal to minor.