$(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. python之6-4装饰器.md

    装饰器看的说实话真心郁闷,群里一伙计说了好一会,听得一愣一愣的,查了点资料,又自己试了下,算是明白了一些,记录记录=.=更郁闷的是,博客园的markdown标记支持怎么和为知的不匹配,这转过来的文章很 ...

  2. Hdu1095

    #include <stdio.h> int main() { int a,b; while(scanf("%d %d",&a,&b)!=EOF){ p ...

  3. SVN上传代码时代码失败

    Description : You are not authorized to access the files in the repository.Suggestion : You might be ...

  4. Cstring获取第N个字符

    void CTestaDlg::GetCStringItemAt(CString strin,CString & strout,int nindex) { ); ; ]={'\0'}; whi ...

  5. Form表单插件jquery.form.js

    常常使用到这个插件,但是老忘记怎么使用,现在对大家写的进行一定的整合. 使用插件实例: 一般的使用方法 <!-- 引入jquery文件 --> <script src="h ...

  6. 实用的VIM配置文件

    VIM配置文件名为.vimrc,默认在用户根目录下,或者在命令模式下输入:version可以获取配置文件路径. 在VIM命令行下输入options,然后回车,可以查看VIM所有的参数选项. 双引号&q ...

  7. UVa12096.The SetStack Computer

    题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  8. [转] Hive 内置函数

    原文见:https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF 1.内置运算符1.1关系运算符 运算符 类型 说明 A ...

  9. linux下部署svn服务器

    系统Linux debian 2.6.32-5-686 先安装svn工具:apt-get install subversion,耐心等待安装完成.安装完成后svn客户端.服务器都有了. 接者建立svn ...

  10. FZU 2108(dfs模拟,大数取余)

     K Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Submit Status Pr ...