How to use current-device - 10 common examples

To help you get started, we’ve selected a few current-device examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github metasfresh / metasfresh-webui-frontend / src / utils / documentListHelper.js View on Github external
? getSelection({
        state,
        windowType: props.parentWindowType,
        viewId: props.parentDefaultViewId,
      })
    : NO_SELECTION,
  modal: state.windowHandler.modal,
});

const NO_SELECTION = [];
const NO_VIEW = {};
const PANEL_WIDTHS = ['1', '.2', '4'];
const GEO_PANEL_STATES = ['grid', 'all', 'map'];

// for mobile devices we only want to show either map or grid
if (currentDevice.type === 'mobile' || currentDevice.type === 'tablet') {
  GEO_PANEL_STATES.splice(1, 1);
}

const filtersToMap = function(filtersArray) {
  let filtersMap = Map();

  if (filtersArray && filtersArray.length) {
    filtersArray.forEach(filter => {
      filtersMap = filtersMap.set(filter.filterId, filter);
    });
  }
  return filtersMap;
};

const doesSelectionExist = function({
  data,
github metasfresh / metasfresh-webui-frontend / src / components / app / DocumentList.js View on Github external
constructor(props) {
    super(props);

    const { defaultViewId, defaultPage, defaultSort } = props;

    this.pageLength =
      currentDevice.type === 'mobile' || currentDevice.type === 'tablet'
        ? 9999
        : 100;
    this.supportAttribute = false;

    this.state = {
      data: null, // view result (result, firstRow, pageLength etc)
      layout: null,
      pageColumnInfosByFieldName: null,
      toggleWidth: 0,
      viewId: defaultViewId,
      page: defaultPage || 1,
      sort: defaultSort,
      filtersActive: Map(),
      initialValuesNulled: Map(),
      clickOutsideLock: true,
      isShowIncluded: false,
github aliyunvideo / AliyunPlayer_Web / customComponents / src / components / VideoADComponent / index.js View on Github external
// 播放视频广告
  playVideoAd () {
    this.setAdInterval()
    this.player.play()
  }

  // 暂停视频广告 
  pauseVideoAd () {
    this.clearAdInterval()
    this.player.pause()
  }
}

let defaultComponent = VideoAdComponent

if (device.mobile()) {
  defaultComponent = MbVideoAdComponent
}

export default defaultComponent
github kotarella1110 / cordova-plugin-webpack / src / www / injectCordovaScript.ts View on Github external
const existingScriptEl = document.querySelector(
    'script[src="cordova.js"]',
  );
  if (existingScriptEl) existingScriptEl.remove();

  const scriptEl = document.createElement('script');
  scriptEl.setAttribute('type', 'text/javascript');
  scriptEl.setAttribute('src', `${platform}/cordova.js`);
  document.body.appendChild(scriptEl);

  console.log(`Injected cordova.js of ${platform} platform.`);
};

if (!isWebview(navigator.userAgent)) {
  injectCordovaScript('browser');
} else if (currentDevice.android()) {
  injectCordovaScript('android');
} else if (currentDevice.ios()) {
  injectCordovaScript('ios');
}
github caiobiodere / cordova-template-framework7-vue-webpack / template_src / webpack / dev_helpers / CordovaDeviceRouter.js View on Github external
const deviceJs = require('current-device').default;

function bodyPrepend(platform) {
  let body = document.querySelector("body"),
    script = document.createElement("script");

  script.onload = function () {
    console.log("Cordova script loaded!");
  };

  script.src = `platform_cordova_files/${platform}/cordova.js`;
  body.appendChild(script);


  console.log(`${platform} platform cordova.js injected.`);
}
github caiobiodere / cordova-template-framework7-vue-webpack / template_src / webpack / dev_helpers / CordovaDeviceRouter.js View on Github external
function bodyPrepend(platform) {
  let body = document.querySelector("body"),
    script = document.createElement("script");

  script.onload = function () {
    console.log("Cordova script loaded!");
  };

  script.src = `platform_cordova_files/${platform}/cordova.js`;
  body.appendChild(script);


  console.log(`${platform} platform cordova.js injected.`);
}

if (deviceJs.android())
  bodyPrepend("android");
else if (deviceJs.ios())
  bodyPrepend("ios");
else
  bodyPrepend("browser");
github caiobiodere / cordova-template-framework7-vue-webpack / template_src / webpack / dev_helpers / CordovaDeviceRouter.js View on Github external
script = document.createElement("script");

  script.onload = function () {
    console.log("Cordova script loaded!");
  };

  script.src = `platform_cordova_files/${platform}/cordova.js`;
  body.appendChild(script);


  console.log(`${platform} platform cordova.js injected.`);
}

if (deviceJs.android())
  bodyPrepend("android");
else if (deviceJs.ios())
  bodyPrepend("ios");
else
  bodyPrepend("browser");
github kotarella1110 / cordova-plugin-webpack / src / www / injectCordovaScript.ts View on Github external
);
  if (existingScriptEl) existingScriptEl.remove();

  const scriptEl = document.createElement('script');
  scriptEl.setAttribute('type', 'text/javascript');
  scriptEl.setAttribute('src', `${platform}/cordova.js`);
  document.body.appendChild(scriptEl);

  console.log(`Injected cordova.js of ${platform} platform.`);
};

if (!isWebview(navigator.userAgent)) {
  injectCordovaScript('browser');
} else if (currentDevice.android()) {
  injectCordovaScript('android');
} else if (currentDevice.ios()) {
  injectCordovaScript('ios');
}
github metasfresh / metasfresh-webui-frontend / src / components / app / QRCode.js View on Github external
constructor(props) {
    super(props);

    let val = 400;

    if (currentDevice.type === 'mobile') {
      val = 300;
    }

    this.width = val;
    this.height = val;
  }
  componentDidMount() {
github metasfresh / metasfresh-webui-frontend / src / components / widget / BarcodeScanner / BarcodeScannerWidget.js View on Github external
onClose={val => {
                const value = typeof val !== 'undefined' ? val : false;
                this.scanBarcode(value);

                if (currentDevice.type === 'mobile') {
                  closeOverlay();
                }
              }}
            />

current-device

The easiest way to write conditional CSS and/or JavaScript based on device operating system (iOS, Android, Blackberry, Windows, Firefox OS, MeeGo, AppleTV, etc), orientation (Portrait vs. Landscape), and type (Tablet vs. Mobile).

MIT
Latest version published 4 years ago

Package Health Score

64 / 100
Full package analysis