$(window).on('load', function () {
$(window).trigger('resize');
}); $(function () {
  var $window = $(window),
  isLoaded = false;   function resizeBg() {
    var winWidth = $window.width(),
      winHeight = $window.height(),
      viewportAspectRatio = winWidth / winHeight;     $('.full-bg').each(function (index, item) {
      var $bg = $(item),
      bgWidth = $bg.width(),
      bgHeight = $bg.height(),
      aspectRatio = bgWidth / bgHeight;         if (viewportAspectRatio < aspectRatio ) {
          $bg.removeClass('full-width')
            .addClass('full-height')
            .css({
               top: 0,
               left: -(winHeight * aspectRatio - winWidth) / 2
             });
        } else {
          $bg.removeClass('full-height')
            .addClass('full-width')
            .css({
              top: -(winWidth / aspectRatio - winHeight) / 2,
              left: 0
            });
        }
    });
  }
  $window.on('resize', resizeBg);   $('.full-bg').on('load', function () {
    $(window).trigger('resize');
  });
}); enquire.register('screen and (max-width: 760px)', {
  match: function () {
    $('.responsive-img').each(function () {
      var $img = $(this),
        src = $img.data('mobile-src');
      if (src) {
        $img.attr('src', src).show();
      } else {
        $img.hide();
      }
    });
  },
  unmatch: function () {
    $('.responsive-img').each(function () {
      var $img = $(this),
        src = $img.data('src');
      if (src) {
        $img.attr('src', src).show();
      } else {
        $img.hide();
      }
    });
  }
}); enquire.register('screen and (min-width: 761px)', {
  match: function () {
    $('.responsive-img').each(function () {
      var $img = $(this),
        src = $img.data('src');
      if (src) {
        $img.attr('src', src).show();
      } else {
        $img.hide();
      }
    });
  },
  unmatch: function () {
    $('.responsive-img').each(function () {
      var $img = $(this),
        src = $img.data('mobile-src');
      if (src) {
        $img.attr('src', src).show();
      } else {
        $img.hide();
      }
    });
  }
});

full-background.js的更多相关文章

  1. chrome插件background.js 和 popup.js 交互

    要实现background.js 和 popup.js 之间的交互,首先需要先配置好 manifest.json文件,如: "background":{ //"page& ...

  2. metamask源码学习-background.js

    这个就是浏览器后台所进行操作的地方了,它就是页面也区块链进行交互的中间部分. metamask-background描述了为web扩展单例的文件app/scripts/background.js.该上 ...

  3. Node.js异步处理CPU密集型任务

    Node.js异步处理CPU密集型任务 Node.js擅长数据密集型实时(data-intensive real-time)交互的应用场景.然而数据密集型实时应用程序并非仅仅有I/O密集型任务,当碰到 ...

  4. 转:Node.js异步处理CPU密集型任务的新思路

    原文来自于:http://www.infoq.com/cn/articles/new-idea-of-nodejs-asynchronous-processing-tasks?utm_source=i ...

  5. vue的测试(Vue.js devtool)

    1. 安装chrome插件:Vue.js devtools(https://chrome.google.com/webstore/detail/vuejs-devtools/nhdogjmejigli ...

  6. vue-devtools(vue 2.0)手动安装与使用 ? 如何处理Vue.js is detected on this page ?

    vue-devtools手动安装与使用   一.在github上下载压缩包,github下载地址:https://github.com/vuejs/vue-devtools 二.解压到本地的某盘 三. ...

  7. 【转】利用 three.js 开发微信小游戏的尝试

    前言 这是一次利用 three.js 开发微信小游戏的尝试,并不能算作是教程,只能算是一篇笔记吧. 微信 WeChat 6.6.1 开始引入了微信小游戏,初期上线了一批质量相当不错的小游戏.我在查阅各 ...

  8. Chrome插件开发,美化网页上的文件列表。chrome-extension,background

    上一篇文章 通过“content-scripts”的方式向页面注入js和css来美化页面,但是有一个弊端:一旦配置好需要注入的页面,之后如果这个页面地址以后发生变化,或者要新加一些URL进来,那么得修 ...

  9. metamask源码学习-ui/index.js

    The UI-即上图左下角metamask-ui部分,即其图形化界面 The MetaMask UI is essentially just a website that can be configu ...

  10. js:浏览器插件

    1.chrome background.js //chrome.webRequest.onBeforeRequest.addListener(function(info) { // chrome.ta ...

随机推荐

  1. The Love-Letter Mystery

    def numOperations(testStr): num = 0 n = len(testStr) for i in range(n / 2): num += abs(ord(testStr[i ...

  2. AngularJS 基础教程二:

    5.过滤器 过滤器的主要功能是格式化数据 可以使用Angular提供的过滤器,也可以自定义过滤器 Angular过滤器: currency(货币).date(日期).filter(子串匹配).json ...

  3. layout_weight

    最近写Demo,突然发现了Layout_weight这个属性,发现网上有很多关于这个属性的有意思的讨论,可是找了好多资料都没有找到一个能够说的清楚的,于是自己结合网上资料研究了一下,终于迎刃而解,写出 ...

  4. hdu 3832 Earth Hour

    http://acm.hdu.edu.cn/showproblem.php?pid=3832 #include <cstdio> #include <iostream> #in ...

  5. BZOJ 2661 连连看

    http://www.lydsy.com/JudgeOnline/problem.php?id=2661 思路:预处理出每个数字,然后若有x^2=y^2+z^2且z与y互质, s->x 1 ,0 ...

  6. 《Programming WPF》翻译 第5章 8.我们进行到哪里了?

    原文:<Programming WPF>翻译 第5章 8.我们进行到哪里了? 样式支持你定义一个策略来设置可视化元素的依赖属性.属性的设置可以被命名以及手动或者编程方式地通过名称应用,或者 ...

  7. android批量文件上传(android批量图片上传)

    项目中多处用到文件批量上传功能,今天正好解决了此问题,在此写出来,以便日后借鉴. 首先,以下架构下的批量文件上传可能会失败或者不会成功:   1.android客户端+springMVC服务端:服务端 ...

  8. GBT28181中的RTP

    国标中说h264数据按照RFC3984打包,但是国标的测试工具——SPVMN,却不支持RFC3984的打包方式.无奈之下直接用RFC3550的方式打包,其实就是分包,然后加上RTP头,对于一帧的结束, ...

  9. Longest Consecutive Sequence 解答

    Question Given an unsorted array of integers, find the length of the longest consecutive elements se ...

  10. Hibernate框架增删改查测试类归为一个类

    package cn.happy.test; import org.hibernate.Session; import org.hibernate.SessionFactory; import org ...