Move mobile device detection into global function
authorJoey Schulze <joey@infodrom.org>
Thu, 11 Jul 2019 19:48:54 +0000 (21:48 +0200)
committerJoey Schulze <joey@infodrom.org>
Thu, 11 Jul 2019 19:53:26 +0000 (21:53 +0200)
src/Infodrom/calendar/index.wml
src/infodrom.js

index f3eb637..558e86c 100644 (file)
@@ -417,7 +417,7 @@ $(function(){
        }
     });
     if (document.location.href.indexOf('month=normal') == -1) {
-       if (navigator.userAgent.indexOf('Android') > -1) {
+        if (is_mobile()) {
            $('<meta name="viewport" content="width=device-width, initial-scale=0.75" />').insertAfter('title');
            $('#view').val('onemonth');
            $.invoke('Calendar/OneMonth', {month: '<?=date('Y-m')?>'}, month_actions);
index 42bf6b7..1311c89 100644 (file)
@@ -72,6 +72,13 @@ function site_url(path)
     return SERVICE_ROOT + path;
 }
 
+function is_mobile()
+{
+    return navigator.userAgent.indexOf('Android') > -1
+       || navigator.userAgent.indexOf('iPhone') > -1
+       || navigator.userAgent.indexOf('iPad') > -1;
+}
+
 (function($){
     $.fn.ltag = function() {
        return this.prop("tagName").toLowerCase();