Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #26781

Re: Parse CSS styles and swap background position value

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail
From Thomas 'PointedEars' Lahn <PointedEars@web.de>
Newsgroups comp.lang.javascript
Subject Re: Parse CSS styles and swap background position value
Date Tue, 03 Feb 2015 12:44:56 +0100
Organization PointedEars Software (PES)
Lines 26
Message-ID <2049578.4vjSuc16jt@PointedEars.de> (permalink)
References <8be9bcae-a221-46e1-8e0f-ec41632517a4@googlegroups.com> <54cf68f5$0$2870$e4fe514c@news2.news.xs4all.nl> <1609092.d9bYY2oEu8@PointedEars.de> <54cf7dfa$0$2962$e4fe514c@news2.news.xs4all.nl> <7622963.yZKU775dzf@PointedEars.de>
Reply-To Thomas 'PointedEars' Lahn <cljs@PointedEars.de>
Mime-Version 1.0
Content-Type text/plain; charset="UTF-8"
Content-Transfer-Encoding 8Bit
X-Trace solani.org 1422963936 32259 eJwNyMkBwCAIBMCW5FjAcgy4/Zdg5jmwkOj0QDgIevtec8LORVGtMam3ZYocqYSC1JG/9rcyHyYbEWo= (3 Feb 2015 11:45:36 GMT)
X-Complaints-To abuse@news.solani.org
NNTP-Posting-Date Tue, 3 Feb 2015 11:45:36 +0000 (UTC)
User-Agent KNode/4.14.2
X-User-ID eJwNy8EBwCAMAsCVgiRox6Fq9h+hvf8VBe2ZKmV1tZGi7QgTTvveMcnFXj37YNQjnNOBP0bAr7U3GXhz5R0fUXgVKA==
Cancel-Lock sha1:aY+3iXS+n80RGUGyfeyXI23DVWQ=
X-NNTP-Posting-Host eJwFwQkBwDAIA0BLpSSUyeH1L2F3VBOrB6OBy03VRlkW0m3aP+TC1/XeMwJJZavwTLyI4Pwi6RFU
Xref csiph.com comp.lang.javascript:26781

Show key headers only | View raw


Thomas 'PointedEars' Lahn wrote:

> […] Again, *iff* you can make sure that *all* percentages in the matched 
> property values relate to horizontal background-position (which usually is 
> _not_ the case: […]), then you could use
> 
>   … = value.replace(/\b(?:(left)|(right)|(\d+)%)\b/gi,
>     function (match, left, right, percentage) {
>       return (left
>         ? "right"
>         : (right ? "left" : (100 - percentage) + "%")));
                                                        ^
>     });
> 
> But this does not work already in the case of
> 
>   background: url(example1.png) repeat-x right 50%;

Bad example :)  It would work here (after the extra parenthesis was 
removed), but only because of 100 − 50 = 50.

-- 
PointedEars
FAQ: <http://PointedEars.de/faq> | SVN: <http://PointedEars.de/wsvn/>
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-matrix>
Please do not cc me. / Bitte keine Kopien per E-Mail.

Back to comp.lang.javascript | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Parse CSS styles and swap background position value Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2015-01-31 10:39 -0800
  Re: Parse CSS styles and swap background position value Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-02-02 13:09 +0100
    Re: Parse CSS styles and swap background position value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-02 14:01 +0100
      Re: Parse CSS styles and swap background position value Erwin Moller <erwinmollerusenet@xs4all.nl> - 2015-02-02 14:39 +0100
        Re: Parse CSS styles and swap background position value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-02 18:17 +0100
          Re: Parse CSS styles and swap background position value Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2015-02-03 01:59 -0800
            Re: Parse CSS styles and swap background position value "Evertjan." <exxjxw.hannivoort@inter.nl.net> - 2015-02-03 11:39 +0100
            Re: Parse CSS styles and swap background position value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-03 15:37 +0100
              Re: Parse CSS styles and swap background position value Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2015-02-04 08:55 +0100
              Re: Parse CSS styles and swap background position value John Harris <niam@jghnorth.org.uk.invalid> - 2015-02-04 15:09 +0000
                Re: Parse CSS styles and swap background position value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-04 16:19 +0100
          Re: Parse CSS styles and swap background position value Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2015-02-03 12:44 +0100

csiph-web