/*
Checks if Cordova 3D touch is present and loaded

@return   promise
10521
function () {
                var deferred = $q.defer();
                if (!window.cordova) {
                    deferred.reject('Not supported in browser');
                } else {
                    if (!window.ThreeDeeTouch) {
                        deferred.reject('Could not find 3D touch plugin');
                    } else {
                        window.ThreeDeeTouch.isAvailable(function (value) {
                            deferred.resolve(value);
                        }, function (err) {
                            deferred.reject(err);
                        });
                    }
                }

                return deferred.promise;
            }
1122066
function () {
            this.preload();

            $loadImgPromise.done(function loadImgSuccess(img) {
                if (!imageLoaded) {
                    imageLoaded = true;
                    $img = $(img).appendTo($el);
                }
            });

            $loadImgPromise.fail(function loadImgFail(error) {
                imageLoaded = false;
                if (error) {
                    scope.broadcast('asseterror', error);
                }
            });

            return $loadImgPromise;
        }
1203191
function InitDeviceScan()
   {
        //Save these properties to speed processing
        global $isWebkit, $isIphone, $isAndroid, $isAndroidPhone;
        $this->isWebkit = $this->DetectWebkit();
        $this->isIphone = $this->DetectIphone();
        $this->isAndroid = $this->DetectAndroid();
        $this->isAndroidPhone = $this->DetectAndroidPhone();
        
        //These tiers are the most useful for web development
        global $isMobilePhone, $isTierTablet, $isTierIphone;
        $this->isMobilePhone = $this->DetectMobileQuick();
        $this->isTierIphone = $this->DetectTierIphone();
        $this->isTierTablet = $this->DetectTierTablet();
        
        //Optional: Comment these out if you NEVER use them.
        global $isTierRichCss, $isTierGenericMobile;
        $this->isTierRichCss = $this->DetectTierRichCss();
        $this->isTierGenericMobile = $this->DetectTierOtherPhones();
        
        $this->initCompleted = $this->true;
   }
935604
function isAppInstalled(app, prefixes) {
  return new Promise((resolve) => {
    if (!(app in prefixes)) {
      return resolve(false)
    }

    Linking.canOpenURL(prefixes[app])
      .then((result) => {
        resolve(!!result)
      })
      .catch(() => resolve(false))
  })
}
31183
function isLoaded (eleOrWindow) {
  return !!(eleOrWindow.complete || eleOrWindow.readyState === 'complete' ||
    // If the passed in thing is a Window, infer loaded state from
    (eleOrWindow.document && eleOrWindow.document.readyState === 'complete'))
}
1099419
public function isMobileClient()
    {
        $request = $this->requestStack->getCurrentRequest();
        if ($request === null) {
            return false;
        }

        return preg_match(
            '/(android|blackberry|htc|iemobile|iphone|ipad|ipaq|ipod|nokia|playbook|smartphone)/i',
            $request->headers->get('User-Agent')
        );
    }
1236619
function DetectGamingHandheld()
   {
      if ((stripos($this->useragent, $this->devicePlaystation) > -1) &&
         (stripos($this->useragent, $this->devicePlaystationVita) > -1))
         return $this->true; 
      else
         return $this->false; 
   }
153442
function detect(eventData) {
      if(!this.current || this.stopped) {
        return;
      }

      // extend event data with calculations about scale, distance etc
      eventData = this.extendEventData(eventData);

      // instance options
      var inst_options = this.current.inst.options;

      // call ionic.Gestures.gesture handlers
      for(var g=0,len=this.gestures.length; g<len; g++) {
        var gesture = this.gestures[g];

        // only when the instance options have enabled this gesture
        if(!this.stopped && inst_options[gesture.name] !== false) {
          // if a handler returns false, we stop with the detection
          if(gesture.handler.call(gesture, eventData, this.current.inst) === false) {
            this.stopDetect();
            break;
          }
        }
      }

      // store as previous event event
      if(this.current) {
        this.current.lastEvent = eventData;
      }

      // endevent, but not the last touch, so dont stop
      if(eventData.eventType == ionic.Gestures.EVENT_END && !eventData.touches.length-1) {
        this.stopDetect();
      }

      return eventData;
    }
231886
function DetectBlackBerryTouch()
   {  
       if ((stripos($this->useragent, $this->deviceBBStorm) > -1) ||
		(stripos($this->useragent, $this->deviceBBTorch) > -1) ||
		(stripos($this->useragent, $this->deviceBBBoldTouch) > -1) ||
		(stripos($this->useragent, $this->deviceBBCurveTouch) > -1))
         return $this->true; 
       else
         return $this->false; 
   }
972221
protected function checkBrowserAndroidAcerA500()
    {
        if( stripos($this->_agent,'Android') !== false )
        {
            if( stripos($this->_agent,'A500 Build') !== false )
            {
                $this->setVersion(self::VERSION_UNKNOWN);
                $this->setMobile(true);
                $this->setBrowser(self::BROWSER_ACER_A500);
                return true;
            }
        }
        return false;
    }
1002441
function _checkImgCacheReady() {
      var defer = $q.defer();

      if (ImgCache.ready) {
        defer.resolve();
      }
      else{
        document.addEventListener('ImgCacheReady', function() { // eslint-disable-line
          defer.resolve();
        }, false);
      }

      return defer.promise;
    }
965573
function (boolActivateUnsecure) {
        if (cordova.platformId == 'android')
            cordova.exec(null, null, 'CertificatesPlugin', 'setUntrusted', [boolActivateUnsecure]);
        else
            cordova.exec(null, null, 'CDVCertificate', 'setUntrusted', [boolActivateUnsecure]);
    }
29336
function DetectAndroidPhone()
   {
      if ($this->initCompleted == $this->true ||
          $this->isAndroidPhone == $this->true)
         return $this->isAndroidPhone;
         
      //First, let's make sure we're on an Android device.
      if ($this->DetectAndroid() == $this->false)
         return $this->false; 

	  //If it's Android and has 'mobile' in it, Google says it's a phone.
      if (stripos($this->useragent, $this->mobile) > -1)
         return $this->true;
      
      //Special check for Android devices with Opera Mobile/Mini. They should report here.
      if (($this->DetectOperaMobile() == $this->true))
         return $this->true; 
      
      return $this->false; 
   }
746812
function hasTouchSupport() {
        var support = {}, events = ['touchstart', 'touchmove', 'touchend'],
            el = document.createElement('div'), i;

        try {
          for(i=0; i<events.length; i++) {
            var eventName = events[i];
            eventName = 'on' + eventName;
            var isSupported = (eventName in el);
            if (!isSupported) {
              el.setAttribute(eventName, 'return;');
              isSupported = typeof el[eventName] == 'function';
            }
            support[events[i]] = isSupported;
          }
          return support.touchstart && support.touchend && support.touchmove;
        }
        catch(err) {
          return false;
        }
      }
818749
function() {
            if ($cachedPromise) {
                return $cachedPromise;
            }

            var $promise = ajax.fetch(this.getURL(), Crocodoc.ASSET_REQUEST_RETRIES);

            // @NOTE: promise.then() creates a new promise, which does not copy
            // custom properties, so we need to create a futher promise and add
            // an object with the abort method as the new target
            $cachedPromise = $promise.then(processStylesheetContent).promise({
                abort: function () {
                    $promise.abort();
                    $cachedPromise = null;
                }
            });
            return $cachedPromise;
        }
292599
function isSupportHistoryAPIDetect(){
    var ua = global.navigator.userAgent;
    // We only want Android 2 and 4.0, stock browser, and not Chrome which identifies
    // itself as 'Mobile Safari' as well, nor Windows Phone (issue #1471).
    if ((ua.indexOf('Android 2.') !== -1 ||
      (ua.indexOf('Android 4.0') !== -1)) &&
      ua.indexOf('Mobile Safari') !== -1 &&
      ua.indexOf('Chrome') === -1 &&
      ua.indexOf('Windows Phone') === -1)
    {
      return false;
    }
    // Return the regular check
    return !!historyPushState;
  }
911259
public function sure()
    {
        if ($this->hasOption('start')) {
            $this->addOption('doNotSelfQlose');
        }
        if (empty($this->args[0])) {
            $this->args[0] = array();
        }
        switch ($this->called) {
        case 'jquery':
            $this->called = 'script';
            $this->args[0] = array_merge(
                array(
                    'type' => 'text/javascript',
                    'src' => 'https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js'
                ),
                $this->args[0]
            );

            return false;
        case 'jqueryui':
            $this->called = 'script';
            $this->args[0] = array_merge(
                array(
                    'type' => 'text/javascript',
                    'src' => 'https://ajax.googleapis.com/ajax/libs/jqueryui/1/jquery-ui.min.js'
                ),
                $this->args[0]
            );

            return false;
        default:
            $this->called = 'script';
            break;
        }

        if (empty($this->args[0])) {
            return false;
        }

        return is_array($this->args[0])
         || !(substr($this->args[0], 0, 4) == 'http'
         || substr($this->args[0], 0, 3) == '../'
         || substr($this->args[0], 0, 3) == '\./'
         || substr($this->args[0], 0, 2) == './'
         || substr($this->args[0], 0, 1) == '/'
        );
    }