668 | | |
| 668 | == Media queries [''since 6970''] == |
| 669 | |
| 670 | Media queries are used to skip a section of the style under certain conditions. Typically you want to use a feature which is introduced in a newer version of JOSM, but like to have a fall back style for users of older JOSM clients. Example: |
| 671 | {{{ |
| 672 | #!mapcss |
| 673 | @media (min-josm-version: 9789) { |
| 674 | way[highway] { |
| 675 | width: 4; |
| 676 | color: orange; |
| 677 | } |
| 678 | /* fancy new stuff */ |
| 679 | /* ... */ |
| 680 | } |
| 681 | |
| 682 | @media (max-josm-version: 9788) { |
| 683 | way[highway] { |
| 684 | width: 4; |
| 685 | color: blue; |
| 686 | } |
| 687 | /* fall back mode, using more simple features */ |
| 688 | /* ... */ |
| 689 | } |
| 690 | }}} |
| 691 | |
| 692 | The syntax closely matches the official [http://www.w3.org/TR/css3-mediaqueries/#syntax css syntax]. The following conditions are supported: |
| 693 | |
| 694 | {{{#!th |
| 695 | '''Media condition''' |
| 696 | }}} |
| 697 | {{{#!th |
| 698 | '''Description''' |
| 699 | }}} |
| 700 | |- |
| 701 | {{{#!td |
| 702 | (min-josm-version: ''<number>'') |
| 703 | }}} |
| 704 | {{{#!td |
| 705 | Only include {{{@media}}} section when the current version of JOSM is greater than or equal to the specified number. |
| 706 | }}} |
| 707 | |- |
| 708 | {{{#!td |
| 709 | (max-josm-version: ''<number>'') |
| 710 | }}} |
| 711 | {{{#!td |
| 712 | Only include {{{@media}}} section when the current version of JOSM is lower than or equal to the specified number. |
| 713 | }}} |
| 714 | |- |
| 715 | {{{#!td |
| 716 | (user-agent: ''<string>'') |
| 717 | }}} |
| 718 | {{{#!td |
| 719 | Only include {{{@media}}} section when the name of the editor / renderer matches the given string. In JOSM, the only accepted value is {{{josm}}}. |
| 720 | }}} |
| 721 | |
| 722 | Conditions can be combined with {{{and}}}: |
| 723 | |
| 724 | {{{ |
| 725 | #!mapcss |
| 726 | @media (min-josm-version: 6970) and (max-josm-version: 7014) { |
| 727 | /* only for JOSM versions 6970 to 7014 */ |
| 728 | } |
| 729 | }}} |
| 730 | |
| 731 | Multiple combined conditions can be chained with a comma (logical ''or''): |
| 732 | |
| 733 | {{{ |
| 734 | #!mapcss |
| 735 | @media (min-josm-version: 6970) and (max-josm-version: 7014), (user-agent: myEditor) { |
| 736 | /* for JOSM version 6970 to 7014 and for the editor called "myEditor" */ |
| 737 | } |
| 738 | }}} |
| 739 | |
| 740 | {{{#!comment |
| 741 | There is also the {{{not}}} keyword (see the linked css doc for details). |
| 742 | This is implemented, but probably not very useful. Feel free to add documentation. |
| 743 | }}} |