0

I am looking for any lightweight, expressive, intuitive, or eloquent way to select CSS themes dynamically for the Goratch library.

I would love something from AngularJs, such as ng-include if etc.

CDN links

http://cdnjs.com/libraries/ratchet
Daryl Bennett
  • 462
  • 10
  • 22
user2727195
  • 7,122
  • 17
  • 70
  • 118

1 Answers1

1

I went with this option. If you're running PHP

function userAgent() {
    $iPod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");
    $iPhone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
    $iPad = strpos($_SERVER['HTTP_USER_AGENT'],"iPad");
    $android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");

    if($iPad||$iPhone||$iPod) {
        return 'ios';
    } else if($android) {
        return 'android';
    } else {
        return 'pc';
    }
}

Then something like:

<?php if(userAgent() == 'android') { ?>
    <link rel="stylesheet" href="/web/css/ratchet-theme-android.min.css">
<?php } else { // etc...?>
    <link rel="stylesheet" href="/web/css/ratchet-theme-ios.min.css">
<? } ?>