├── .gitignore
├── README.md
├── _config.yml
├── package.json
├── scaffolds
├── draft.md
├── page.md
└── post.md
├── scripts
├── generate-alphabet.js
├── generate-titles.js
└── render-markdown.js
├── source
├── _posts
│ ├── ajax.md
│ ├── amd.md
│ ├── arity.md
│ ├── babel.md
│ ├── bus-factor.md
│ ├── canvas.md
│ ├── commonjs.md
│ ├── coroutine.md
│ ├── design-pattern.md
│ ├── dom.md
│ ├── electron.md
│ ├── fetch-api.md
│ ├── high-order-function.md
│ ├── http-451.md
│ ├── http2.md
│ ├── left-pad.md
│ ├── page-rank.md
│ ├── sfc.md
│ ├── surge-sh.md
│ ├── surge.md
│ ├── vue.md
│ ├── webpack.md
│ └── yin-lang.md
└── about.md
├── themes
├── bw
│ ├── layout
│ │ ├── alphabet.jade
│ │ ├── base.jade
│ │ ├── index.jade
│ │ ├── mixins.jade
│ │ └── post.jade
│ └── source
│ │ ├── css
│ │ ├── main.styl
│ │ ├── markdown.styl
│ │ ├── prism.styl
│ │ └── responsive.styl
│ │ └── js
│ │ ├── app.js
│ │ └── post.js
└── landscape
│ ├── .gitignore
│ ├── Gruntfile.js
│ ├── LICENSE
│ ├── README.md
│ ├── _config.yml
│ ├── languages
│ ├── default.yml
│ ├── fr.yml
│ ├── nl.yml
│ ├── no.yml
│ ├── ru.yml
│ ├── zh-CN.yml
│ └── zh-TW.yml
│ ├── layout
│ ├── _partial
│ │ ├── after-footer.ejs
│ │ ├── archive-post.ejs
│ │ ├── archive.ejs
│ │ ├── article.ejs
│ │ ├── footer.ejs
│ │ ├── google-analytics.ejs
│ │ ├── head.ejs
│ │ ├── header.ejs
│ │ ├── mobile-nav.ejs
│ │ ├── post
│ │ │ ├── category.ejs
│ │ │ ├── date.ejs
│ │ │ ├── gallery.ejs
│ │ │ ├── nav.ejs
│ │ │ ├── tag.ejs
│ │ │ └── title.ejs
│ │ └── sidebar.ejs
│ ├── _widget
│ │ ├── archive.ejs
│ │ ├── category.ejs
│ │ ├── recent_posts.ejs
│ │ ├── tag.ejs
│ │ └── tagcloud.ejs
│ ├── archive.ejs
│ ├── category.ejs
│ ├── index.ejs
│ ├── layout.ejs
│ ├── page.ejs
│ ├── post.ejs
│ └── tag.ejs
│ ├── package.json
│ ├── scripts
│ └── fancybox.js
│ └── source
│ ├── css
│ ├── _extend.styl
│ ├── _partial
│ │ ├── archive.styl
│ │ ├── article.styl
│ │ ├── comment.styl
│ │ ├── footer.styl
│ │ ├── header.styl
│ │ ├── highlight.styl
│ │ ├── mobile.styl
│ │ ├── sidebar-aside.styl
│ │ ├── sidebar-bottom.styl
│ │ └── sidebar.styl
│ ├── _util
│ │ ├── grid.styl
│ │ └── mixin.styl
│ ├── _variables.styl
│ ├── fonts
│ │ ├── FontAwesome.otf
│ │ ├── fontawesome-webfont.eot
│ │ ├── fontawesome-webfont.svg
│ │ ├── fontawesome-webfont.ttf
│ │ └── fontawesome-webfont.woff
│ ├── images
│ │ └── banner.jpg
│ └── style.styl
│ ├── fancybox
│ ├── blank.gif
│ ├── fancybox_loading.gif
│ ├── fancybox_loading@2x.gif
│ ├── fancybox_overlay.png
│ ├── fancybox_sprite.png
│ ├── fancybox_sprite@2x.png
│ ├── helpers
│ │ ├── fancybox_buttons.png
│ │ ├── jquery.fancybox-buttons.css
│ │ ├── jquery.fancybox-buttons.js
│ │ ├── jquery.fancybox-media.js
│ │ ├── jquery.fancybox-thumbs.css
│ │ └── jquery.fancybox-thumbs.js
│ ├── jquery.fancybox.css
│ ├── jquery.fancybox.js
│ └── jquery.fancybox.pack.js
│ └── js
│ └── script.js
└── yarn.lock
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 | Thumbs.db
3 | db.json
4 | *.log
5 | node_modules/
6 | public/
7 | .deploy*/
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # 简明编程术语
2 |
3 | 简明编程术语是由社区驱动的编程知识分享网站,主要提供各类编程专业术语的解释。
4 |
5 | ## 贡献
6 |
7 | 请提交 Pull Request 添加词条,具体格式可以参考目录 [/source/_posts](/source/_posts) 中的现有词条格式。
8 |
9 | ## 开发
10 |
11 | ```bash
12 | # 预览网站
13 | $ npm run dev
14 |
15 | # 添加词条
16 | $ ./node_modules/.bin/hexo new post {item_name}
17 | ```
18 |
19 | ## 内容共享
20 |
21 | 词条以 CC-BY-NC 4.0 协议授权,代码以 MIT 协议授权。
22 |
--------------------------------------------------------------------------------
/_config.yml:
--------------------------------------------------------------------------------
1 | # Hexo Configuration
2 | ## Docs: https://hexo.io/docs/configuration.html
3 | ## Source: https://github.com/hexojs/hexo/
4 |
5 | # Site
6 | title: 简明编程术语
7 | subtitle: Code Jargon
8 | description: 简明编程术语是由社区驱动的编程知识分享网站
9 | author: EGOIST
10 | language: zh-CN
11 | timezone:
12 | version: 0.3.0
13 |
14 | # URL
15 | ## If your site is put in a subdirectory, set url as 'http://yoursite.com/child' and root as '/child/'
16 | url: http://codejargon.net
17 | root: /
18 | permalink: jargon/:title/
19 | permalink_defaults:
20 |
21 | # Directory
22 | source_dir: source
23 | public_dir: public
24 | tag_dir: tags
25 | archive_dir: archives
26 | category_dir: categories
27 | code_dir: downloads/code
28 | i18n_dir: :lang
29 | skip_render:
30 |
31 | # Writing
32 | new_post_name: :title.md # File name of new posts
33 | default_layout: post
34 | titlecase: false # Transform title into titlecase
35 | external_link: true # Open external links in new tab
36 | filename_case: 0
37 | render_drafts: false
38 | post_asset_folder: false
39 | relative_link: false
40 | future: true
41 | highlight:
42 | enable: false
43 | line_number: false
44 | auto_detect: false
45 | tab_replace:
46 |
47 | # Category & Tag
48 | default_category: uncategorized
49 | category_map:
50 | tag_map:
51 |
52 | # Date / Time format
53 | ## Hexo uses Moment.js to parse and display date
54 | ## You can customize the date format as defined in
55 | ## http://momentjs.com/docs/#/displaying/format/
56 | date_format: YYYY-MM-DD
57 | time_format: HH:mm:ss
58 |
59 | # Pagination
60 | ## Set per_page to 0 to disable pagination
61 | per_page: 50
62 | pagination_dir: page
63 |
64 | # Extensions
65 | ## Plugins: https://hexo.io/plugins/
66 | ## Themes: https://hexo.io/themes/
67 | theme: bw
68 |
69 | # Deployment
70 | ## Docs: https://hexo.io/docs/deployment.html
71 | deploy:
72 | type: git
73 | repo: git@git.coding.net:egoist/codejargon.git
74 | branch: coding-pages
75 |
76 | stylus:
77 | compress: true
78 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "hexo-site",
3 | "version": "0.0.0",
4 | "private": true,
5 | "hexo": {
6 | "version": "3.3.7"
7 | },
8 | "scripts": {
9 | "build": "hexo g",
10 | "deploy": "hexo g && hexo d",
11 | "dev": "hexo s --watch"
12 | },
13 | "dependencies": {
14 | "hexo": "^3.2.0",
15 | "hexo-deployer-git": "^0.3.0",
16 | "hexo-generator-archive": "^0.1.4",
17 | "hexo-generator-async": "^0.1.1",
18 | "hexo-generator-category": "^0.1.3",
19 | "hexo-generator-index": "^0.2.0",
20 | "hexo-generator-tag": "^0.2.0",
21 | "hexo-pagination": "^0.1.0",
22 | "hexo-renderer-buble": "^0.3.0",
23 | "hexo-renderer-ejs": "^0.3.0",
24 | "hexo-renderer-jade": "^0.4.1",
25 | "hexo-renderer-stylus": "^0.3.1",
26 | "hexo-server": "^0.2.0",
27 | "markdown-it": "^8.3.1",
28 | "markdown-it-footnote": "^3.0.1",
29 | "markdown-it-prettier": "^1.0.2",
30 | "prismjs": "^1.6.0"
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/scaffolds/draft.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: {{ title }}
3 | tags:
4 | ---
5 |
--------------------------------------------------------------------------------
/scaffolds/page.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: {{ title }}
3 | date: {{ date }}
4 | ---
5 |
--------------------------------------------------------------------------------
/scaffolds/post.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: {{ title }}
3 | date: {{ date }}
4 | tags:
5 | categories:
6 | summary:
7 | ---
8 |
--------------------------------------------------------------------------------
/scripts/generate-alphabet.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const path = require('path')
3 | const pagination = require('hexo-pagination')
4 |
5 | hexo.extend.generator.register('generate-alphabet', function (locals) {
6 | const config = {
7 | perPage: hexo.config.per_page || 50,
8 | base: path.join(path.sep, 'alphabet', path.sep),
9 | url: hexo.config.url
10 | }
11 | const alphabetList = 'abcdefghijklmnopqrstuvwxyz'.split('')
12 | return locals.categories.filter(v => alphabetList.indexOf(v.slug) !== -1).reduce((result, category) => {
13 | if (!category.length) return result
14 | const posts = category.posts.sort('slug')
15 | const data = pagination(path.join(config.base, category.slug), posts, {
16 | perPage: 10,
17 | layout: ['alphabet', 'index'],
18 | data: {
19 | category: category.name,
20 | alphabet: true,
21 | alphabetList
22 | }
23 | })
24 | return result.concat(data)
25 | }, [])
26 | })
27 |
--------------------------------------------------------------------------------
/scripts/generate-titles.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 | const path = require('path')
3 |
4 | hexo.extend.generator.register('generate-title', function (locals) {
5 | const titles = locals.posts.data.map(p => p.title.toLowerCase())
6 | return {
7 | path: path.join(path.sep, 'async', path.sep, 'title.json'),
8 | data: JSON.stringify(titles)
9 | }
10 | })
11 |
--------------------------------------------------------------------------------
/scripts/render-markdown.js:
--------------------------------------------------------------------------------
1 | const Prism = require('prismjs')
2 | const MD = require('markdown-it')
3 |
4 | require('prismjs/components/prism-javascript')
5 |
6 | const md = new MD({
7 | html: true,
8 | linkify: true,
9 | typographer: true,
10 | highlight(str, lang) {
11 | return Prism.highlight(str, Prism.languages[lang] || Prism.languages.markup)
12 | }
13 | })
14 |
15 | md.use(require('markdown-it-prettier'), {
16 | singleQuote: true,
17 | semi: false
18 | })
19 | md.use(require('markdown-it-footnote'))
20 |
21 | function renderer(data, options) {
22 | return md.render(data.text)
23 | }
24 |
25 | hexo.extend.renderer.register('md', 'html', renderer, true)
--------------------------------------------------------------------------------
/source/_posts/ajax.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: AJAX
3 | date: 2016-06-19 17:50:45
4 | categories:
5 | - a
6 | tags:
7 | - javascript
8 | - network
9 | - ajax
10 | summary: 异步 HTTP 请求技术。
11 | ---
12 |
13 | AJAX 是一项用过异步数据传输来实现服务器与客户端之间交互操作的技术。使用 AJAX 更新页面部分内容而不是传统地刷新整个页面,这样极大提升了客户端与服务器之间的数据通信效率。
14 |
15 | 实例,使用 jQuery 提供的 AJAX 方法更新添加评论后的新评论列表:
16 |
17 | ```js
18 | $.post('/add-comment', {comment}, function (err, addedComment) {
19 | $('.comment-list').append(`
`)
20 | })
21 | ```
22 |
23 | ## 外部链接
24 |
25 | - [MDN 上关于 AJAX 的介绍](https://developer.mozilla.org/zh-CN/docs/AJAX/Getting_Started)
26 |
--------------------------------------------------------------------------------
/source/_posts/amd.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: AMD
3 | date: 2016-06-20 03:36:27
4 | tags:
5 | - amd
6 | - javascript
7 | categories:
8 | - a
9 | summary: 一种异步加载 JavaScript 库或模块的规范。
10 | ---
11 | AMD 全称为 Asynchronous Module Definition(异步模块定义),主要针对浏览器端 JS 模块的异步加载。
12 |
13 | 类似的 CommonJS 规范主要用于 Node.js 等服务器端环境,由于其加载机制决定无法在浏览器端使用(依赖网络请求),从而有了 AMD 规范的诞生。
14 |
15 | ## 外部链接
16 |
17 | - [AMD 中文版](https://github.com/amdjs/amdjs-api/wiki/AMD-(%E4%B8%AD%E6%96%87%E7%89%88))
18 | - [Javascript模块化编程(二):AMD规范](http://www.ruanyifeng.com/blog/2012/10/asynchronous_module_definition.html)
19 |
--------------------------------------------------------------------------------
/source/_posts/arity.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Arity
3 | date: 2016-06-20 11:35:48
4 | tags:
5 | - javascript
6 | categories:
7 | - a
8 | summary: 代指一个函数的参数数量。
9 | ---
10 | 你可能会在计算机领域遇到这个概念,已废弃的 API `Function.arity` 是其具体实现,现已被 `Function.length` 替代。
11 |
12 | 实例:
13 |
14 | ```js
15 | function foo(a, b, c) {}
16 |
17 | console.log(foo.length)
18 | //=> 3
19 | ```
20 |
21 | ## 外部链接
22 |
23 | - [Function.arity](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Function/arity)
24 | - [Function.length](https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Function/length)
25 |
--------------------------------------------------------------------------------
/source/_posts/babel.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Babel
3 | date: 2016-06-19 18:04:19
4 | categories:
5 | - b
6 | tags:
7 | - javascript
8 | - babel
9 | - transpiler
10 | summary: 一个 ES6 代码转换器。
11 | ---
12 |
13 | Babel 最开始是一个 ES6 到 ES5 的代码转换器,经过发展现在可以借用其 AST 结构实现更多的代码转换需求。
14 |
15 | ## 外部链接
16 |
17 | - [Babel 官方网站](http://babeljs.io/)
18 | - [在线运行 ES6 代码](http://babeljs.io/repl/)
19 | - [Babel 插件编写手册](https://github.com/thejameskyle/babel-handbook)
20 |
--------------------------------------------------------------------------------
/source/_posts/bus-factor.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Bus factor
3 | date: 2017-06-07 20:48:01
4 | tags:
5 | categories: b
6 | summary: 用于衡量团队中信息不对等所造成的风险。
7 | ---
8 |
9 | 如果你的团队中失去至少 Y 人就可能导致项目由于缺乏有能力的人而失败,那么这里的 Y 就是所谓的 Bus factor,抑或译为「公交因子」。
10 |
11 | Bus factor 是从「hit by a bus」衍生来的,代指由于一切不确定的因素而离开团队,并不一定非得被车撞。原因也可以是某个成员「找到了新工作」、「生孩子」或者「生活方式改变了」。
12 |
13 | 另外一个对 Bus factor 的解释是:指代一个团队中不可或缺的人数。
14 |
15 | ## 外部链接
16 |
17 | - [Bus factor (维基百科)](https://en.wikipedia.org/wiki/Bus_factor)
--------------------------------------------------------------------------------
/source/_posts/canvas.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Canvas
3 | date: 2016-06-20 15:10:04
4 | tags:
5 | - html
6 | - graphic
7 | categories:
8 | - c
9 | summary: 用于绘制 2D/3D 界面的 HTML 元素。
10 | ---
11 | Canvas 的 API 能让你通过 WebGL 绘制 3D 图像、通过 [CanvasRenderingContext2D](https://developer.mozilla.org/zh-CN/docs/Web/API/CanvasRenderingContext2D) 绘制 2D 图像。
12 |
--------------------------------------------------------------------------------
/source/_posts/commonjs.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: CommonJS
3 | date: 2016-06-20 03:48:10
4 | tags:
5 | - commonjs
6 | - cjs
7 | - javascript
8 | categories:
9 | - c
10 | summary: 以单文件作为单独模块的 JavaScript 模块规范。
11 | ---
12 | CommonJS 是以在浏览器环境之外构建 JavaScript 生态系统为目标而产生的项目,比如在服务器和桌面环境中。
13 |
14 | ## 历史
15 |
16 | 这个项目最开始是由 Mozilla 的工程师 Kevin Dangoor 在2009年1月创建的,当时的名字是 ServerJS。
17 |
18 | > 我在这里描述的并不是一个技术问题,而是一件重大的事情,让大家走到一起来做决定,迈出第一步,来建立一个更大更酷的东西。 —— Kevin Dangoor's [What Server Side JavaScript needs](http://www.blueskyonmars.com/2009/01/29/what-server-side-javascript-needs/)
19 |
20 | 2009年8月,这个项目改名为 CommonJS,以显示其 API 的更广泛实用性。CommonJS 是一套规范,它的创建和核准是开放的。这个规范已经有很多版本和具体实现。CommonJS 并不是属于 ECMAScript TC39 小组的工作,但 TC39 中的一些成员参与 CommonJS 的制定。2013年5月,Node.js 的包管理器 NPM 的作者 Isaac Z. Schlueter 说 [CommonJS 已经过时,Node.js 的内核开发者已经废弃了该规范](https://github.com/nodejs/node-v0.x-archive/issues/5132#issuecomment-15432598)。
21 |
22 | CommonJS 规范是为了解决 JavaScript 的作用域问题而定义的模块形式,可以使每个模块它自身的命名空间中执行。该规范的主要内容是,模块必须通过 `module.exports` 导出对外的变量或接口,通过 `require()` 来导入其他模块的输出到当前模块作用域中。
23 |
24 | 一个直观的例子:
25 |
26 | ```js
27 | // moduleA.js
28 | module.exports = function( value ){
29 | return value * 2;
30 | }
31 | ```
32 |
33 | ```js
34 | // moduleB.js
35 | var multiplyBy2 = require('./moduleA');
36 | var result = multiplyBy2(4);
37 | ```
38 |
39 | CommonJS 是同步地加载模块,但其实也有浏览器端的实现,其原理是现将所有模块都定义好并通过 id 索引,这样就可以方便的在浏览器环境中解析了,可以参考 [require1k](https://github.com/Stuk/require1k) 和 [tiny-browser-require](https://github.com/ruanyf/tiny-browser-require) 的源码来理解其解析 `resolve` 的过程。
40 |
41 | ## 外部链接
42 |
43 | - [CommonJS 规范](http://javascript.ruanyifeng.com/nodejs/module.html)
44 | - [Node.js modules](https://nodejs.org/docs/latest/api/modules.html)
45 |
--------------------------------------------------------------------------------
/source/_posts/coroutine.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Coroutine
3 | date: 2016-06-21 15:56:02
4 | tags:
5 | - coroutine
6 | categories:
7 | - c
8 | summary: 协作式的用户态线程。
9 | ---
10 |
11 | 中文译作「协程」,根据协程的各种不同实现,协程起着不同的作用:
12 |
13 | - 状态机: 控制过程当前的出口/入口点,有助于将异步、回调方式的代码用同步的方式写出来,增强可读性。
14 | - 角色模型: 并行的角色模型,例如计算机游戏。每个角色有自己的过程(这又在逻辑上分离了代码),但他们自愿地向顺序执行各角色过程的中央调度器交出控制(这是合作式多任务的一种形式)。
15 | - 产生器: 它有助于输入/输出和对数据结构的通用遍历。
16 |
17 | ## 外部链接
18 |
19 | - [协程(维基百科)](https://zh.wikipedia.org/wiki/%E5%8D%8F%E7%A8%8B)
20 | - [怎么理解coroutine?(知乎)](https://www.zhihu.com/question/21483863)
21 |
--------------------------------------------------------------------------------
/source/_posts/design-pattern.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 设计模式
3 | date: 2016-06-20 22:14:51
4 | tags:
5 | - design-pattern
6 | category:
7 | - d
8 | summary: 在软件开发中对于常见问题的解决方案。
9 | ---
10 | 设计模式常常和「最佳实践」一起出现,它是前人经过相当长的一段时间的试验和错误总结出来的。
11 |
12 | ## 外部链接
13 |
14 | - [设计模式(维基百科)](https://zh.wikipedia.org/zh/%E8%AE%BE%E8%AE%A1%E6%A8%A1%E5%BC%8F_(%E8%AE%A1%E7%AE%97%E6%9C%BA))
15 | - [什么是设计模式(知乎)](https://www.zhihu.com/question/19558521)
16 |
--------------------------------------------------------------------------------
/source/_posts/dom.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: DOM
3 | date: 2016-06-20 23:33:10
4 | tags:
5 | - javascript
6 | - browser
7 | categories:
8 | - d
9 | summary: HTML 和 XML 文档的编程接口。
10 | ---
11 |
12 |
13 | 一个网页就是一个文档,而 DOM 给文档(结构树)提供了一个结构化的表述并且定义了一种方式 —— 程序可以对结构树进行访问,以改变文档的结构,样式和内容。
14 |
15 | DOM 不是一种编程语言而是一个标准,它有很多具体实现,比如在各个浏览器 JS 引擎上的实现,尽管遵循统一标准,你可以通过相同的 API 接口访问,但各种实现也存在着些许差异。
16 |
17 | 实例代码,使用 DOM 操作元素:
18 |
19 | ```js
20 | const p = document.querySelector('p')
21 | p.innerHTML = 'hack by codejargon'
22 | ```
23 |
24 | ## 外部链接
25 |
26 | - [DOM 概述](https://developer.mozilla.org/zh-CN/docs/Web/API/Document_Object_Model/Introduction)
27 | - [DOM 接口](https://developer.mozilla.org/zh-CN/docs/Web/API/Document_Object_Model#DOM_接口)
28 |
--------------------------------------------------------------------------------
/source/_posts/electron.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Electron
3 | date: 2016-06-20 22:27:20
4 | tags:
5 | - node.js
6 | - javascript
7 | - desktop
8 | - chrome
9 | categories:
10 | - e
11 | summary: 基于 HTML/CSS/JS 技术开发跨平台桌面应用的框架。
12 | ---
13 | Electron 由 GitHub 公司基于 Node.js 和 Chromium 开发,被很多流行应用比如 Atom、VSCode 编辑器使用。
14 |
15 | 你可以从官方[快速上手](https://github.com/electron/electron-quick-start)项目开始了解:
16 |
17 | {% codeblock lang:bash %}
18 | # Clone the Quick Start repository
19 | $ git clone https://github.com/electron/electron-quick-start
20 |
21 | # Go into the repository
22 | $ cd electron-quick-start
23 |
24 | # Install the dependencies and run
25 | $ npm install && npm start
26 | {% endcodeblock %}
27 |
28 | 有开发者把 Electron 更抽象地封装成一个 [menubar](https://github.com/maxogden/menubar) 模块,方便用户快速创建桌面 menubar(状态栏/菜单栏) 应用。
29 |
30 | ## 外部链接
31 |
32 | - [Electron 官网](http://electron.atom.io/)
33 | - [Atom 编辑器](https://atom.io/)
34 |
--------------------------------------------------------------------------------
/source/_posts/fetch-api.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Fetch API
3 | date: 2016-06-20 22:42:50
4 | tags:
5 | - javascript
6 | - network
7 | categories:
8 | - f
9 | summary: 更现代化的浏览器网络请求接口,相比 XMLHttpRequest 增加了灵活性并使用了 Promise 技术。
10 | ---
11 | `fetch()` 接受一个资源路径作为第一个参数,无论请求成功与否,它都返回一个 `Promise` 对象。
12 |
13 | 第二个参数是配置项,你可以指定提交类型比如 `POST` 或者 `GET`,或者指定需要传递的 header 参数等等。
14 |
15 | 实例代码:
16 |
17 | ```js
18 | const body = JSON.stringify({
19 | title: 'New Post'
20 | })
21 |
22 | fetch('/posts', {type: 'POST', body})
23 | .then(data => data.json())
24 | .then(data => console.log(data))
25 | ```
26 |
27 | ## 浏览器兼容性
28 |
29 | 基于 [caniuse](http://caniuse.com/#feat=fetch) 的结果:
30 |
31 | IE ✘
32 | Edge ✘
33 | Firefox ✘ 2+ ✘ 34+¹ ✔ 39+⁴ ✔ 40+
34 | Chrome ✘ 4+ ◒ 40+² ◒ 41+² ✔ 42+
35 | Safari ✘
36 | Opera ✘ 9+ ◒ 27+² ◒ 28+² ✔ 29+
37 |
38 | 不过已经有相关 polyfill 让 Fetch API 能够运行在大部分浏览器和服务器端环境上。
39 |
40 | ## 外部链接
41 |
42 | - [Fetch API 在 MDN 上的介绍](https://developer.mozilla.org/zh-CN/docs/Web/API/Fetch_API)
43 | - [服务器端 Fetch API polyfill](https://github.com/bitinn/node-fetch)
44 | - [浏览器端 Fetch API polyfill](https://github.com/github/fetch)
45 |
--------------------------------------------------------------------------------
/source/_posts/high-order-function.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: 高阶函数
3 | date: 2016-06-20 15:23:13
4 | tags:
5 | - function
6 | - high-order-function
7 | categories:
8 | - h
9 | summary: 以函数作为参数或返回值的函数。
10 | ---
11 | 英文 Higher order function,在 JavaScript 中,`[].map` 就是一个高阶函数:
12 |
13 | ```js
14 | // 以一个箭头函数作为参数
15 | [1, 2, 3].map(v => v * 2)
16 | ```
17 |
18 | ```js
19 | // 返回一个函数
20 | function divideBy(n) {
21 | return function (d) {
22 | return n / d
23 | }
24 | }
25 |
26 | divideBy(10)(2)
27 | //=> 5
28 | ```
29 |
30 | JavaScript 的回调函数就是典型的高阶函数,在 Web 编程中网络请求往往可以带有一个回调函数,可以在成功获得返回结果时执行回调函数来处理结果:
31 |
32 | ```js
33 | $.get('/url', function (err, data) {
34 | console.log(data)
35 | })
36 | ```
37 |
38 | ## 外部链接
39 |
40 | - [Higher-Order Functions in JavaScript](http://www.sitepoint.com/higher-order-functions-javascript/)
41 |
--------------------------------------------------------------------------------
/source/_posts/http-451.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: HTTP 451
3 | date: 2016-06-27 22:41:05
4 | tags:
5 | - 451
6 | - http
7 | categories:
8 | - h
9 | summary: 因法律原因不可用时服务器返回的状态码。
10 | ---
11 | 在电脑网络领域中,HTTP 451 因法律原因不可用(英语:HTTP 451 Unavailable For Legal Reasons)是一种 HTTP 协议的错误状态代码,当用户请求访问某个经政府审核等查核方法后认定不合法的来源时,就会显示这个错误代码。
12 |
13 | ## 外部链接
14 |
15 | - [HTTP 451(维基百科)](https://zh.wikipedia.org/zh/HTTP_451)
16 | - [HTTP状态码451:基于法律上的原因,我不能向你展示网页内容](https://zhuanlan.zhihu.com/p/21432458)
17 |
--------------------------------------------------------------------------------
/source/_posts/http2.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: HTTP/2
3 | date: 2016-06-19 23:02:44
4 | categories:
5 | - h
6 | tags:
7 | - http
8 | - network
9 | - server
10 | summary: HTTP 协议的的第二个主要版本,其最为显著的新特性「多路复用」让请求相互独立,一个请求不会阻塞其它请求。
11 | ---
12 |
13 | HTTP/2 协议基于 SPDY 演化而来,在保证与 HTTP 1.1 的语义兼容的进行了多项改进:
14 |
15 | - 多路复用: 单个连接上可以并行交错的请求和响应,之间互不干扰
16 | - 优先级请求: 可以在请求中设置优先值,确保最重要的请求优先获得处理
17 | - 服务器推送: 服务器能推送消息给客户端
18 | - 头部压缩: 压缩头部(HEAD)减少请求和响应的大小
19 |
20 | ## 外部链接
21 |
22 | - [HTTP/2 讲解](https://ye11ow.gitbooks.io/http2-explained/content/)
23 |
--------------------------------------------------------------------------------
/source/_posts/left-pad.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: left-pad
3 | date: 2016-06-20 12:48:39
4 | tags:
5 | - left-pad
6 | - npm
7 | - javascript
8 | - node.js
9 | categories:
10 | - l
11 | summary: 一个开发者对 NPM 公司不满,unpublish 了自己的所有模块,其中包括被广泛使用的 left-pad。
12 | ---
13 |
14 | Azer 在《[I’ve Just Liberated My Modules](https://medium.com/@azerbike/i-ve-just-liberated-my-modules-9045c06be67c)》一文中写道:
15 |
16 | > 几个星期前有位专利律师给我发了一封电子邮件,要求我取消发布 NPM 上的 “KIK” 模块。我的回答是“不”,于是他回复我说:“I don’t wanna be dick about it(这句就不翻译了,你只需要知道 dick 是什么意思就够了),但 “KIK” 是我们的注册品牌,并且我们的律师遍布世界各地。”
2 |
3 | <%- partial('post/date', {class_name: 'article-date', date_format: null}) %>
4 | <%- partial('post/category') %>
5 |
6 |
7 | <%- partial('post/gallery') %>
8 | <% if (post.link || post.title){ %>
9 |
10 | <%- partial('post/title', {class_name: 'article-title'}) %>
11 |
12 | <% } %>
13 |
14 | <% if (post.excerpt && index){ %>
15 | <%- post.excerpt %>
16 | <% if (theme.excerpt_link){ %>
17 |
18 | <%= theme.excerpt_link %>
19 |
20 | <% } %>
21 | <% } else { %>
22 | <%- post.content %>
23 | <% } %>
24 |
25 |
32 |
33 | <% if (!index){ %>
34 | <%- partial('post/nav') %>
35 | <% } %>
36 |
37 |
38 | <% if (!index && post.comments && config.disqus_shortname){ %>
39 |
44 | <% } %>
--------------------------------------------------------------------------------
/themes/landscape/layout/_partial/footer.ejs:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/themes/landscape/layout/_partial/google-analytics.ejs:
--------------------------------------------------------------------------------
1 | <% if (theme.google_analytics){ %>
2 |
3 |
13 |
14 | <% } %>
15 |
--------------------------------------------------------------------------------
/themes/landscape/layout/_partial/head.ejs:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
3 | <%- list_categories(post.categories, {
4 | show_count: false,
5 | class: 'article-category',
6 | style: 'none',
7 | separator: '►'
8 | }) %>
9 |
10 | <% } %>
--------------------------------------------------------------------------------
/themes/landscape/layout/_partial/post/date.ejs:
--------------------------------------------------------------------------------
1 | The requested content cannot be loaded.
Please try again later.
',
144 | closeBtn : '').html(content).find(current.selector);
1107 |
1108 | } else if (isQuery(content)) {
1109 | if (!content.data(placeholder)) {
1110 | content.data(placeholder, $('
').insertAfter( content ).hide() );
1111 | }
1112 |
1113 | content = content.show().detach();
1114 |
1115 | current.wrap.bind('onReset', function () {
1116 | if ($(this).find(content).length) {
1117 | content.hide().replaceAll( content.data(placeholder) ).data(placeholder, false);
1118 | }
1119 | });
1120 | }
1121 | break;
1122 |
1123 | case 'image':
1124 | content = current.tpl.image.replace(/\{href\}/g, href);
1125 | break;
1126 |
1127 | case 'swf':
1128 | content = '
';
1137 | break;
1138 | }
1139 |
1140 | if (!(isQuery(content) && content.parent().is(current.inner))) {
1141 | current.inner.append( content );
1142 | }
1143 |
1144 | // Give a chance for helpers or callbacks to update elements
1145 | F.trigger('beforeShow');
1146 |
1147 | // Set scrolling before calculating dimensions
1148 | current.inner.css('overflow', scrolling === 'yes' ? 'scroll' : (scrolling === 'no' ? 'hidden' : scrolling));
1149 |
1150 | // Set initial dimensions and start position
1151 | F._setDimension();
1152 |
1153 | F.reposition();
1154 |
1155 | F.isOpen = false;
1156 | F.coming = null;
1157 |
1158 | F.bindEvents();
1159 |
1160 | if (!F.isOpened) {
1161 | $('.fancybox-wrap').not( current.wrap ).stop(true).trigger('onReset').remove();
1162 |
1163 | } else if (previous.prevMethod) {
1164 | F.transitions[ previous.prevMethod ]();
1165 | }
1166 |
1167 | F.transitions[ F.isOpened ? current.nextMethod : current.openMethod ]();
1168 |
1169 | F._preloadImages();
1170 | },
1171 |
1172 | _setDimension: function () {
1173 | var viewport = F.getViewport(),
1174 | steps = 0,
1175 | canShrink = false,
1176 | canExpand = false,
1177 | wrap = F.wrap,
1178 | skin = F.skin,
1179 | inner = F.inner,
1180 | current = F.current,
1181 | width = current.width,
1182 | height = current.height,
1183 | minWidth = current.minWidth,
1184 | minHeight = current.minHeight,
1185 | maxWidth = current.maxWidth,
1186 | maxHeight = current.maxHeight,
1187 | scrolling = current.scrolling,
1188 | scrollOut = current.scrollOutside ? current.scrollbarWidth : 0,
1189 | margin = current.margin,
1190 | wMargin = getScalar(margin[1] + margin[3]),
1191 | hMargin = getScalar(margin[0] + margin[2]),
1192 | wPadding,
1193 | hPadding,
1194 | wSpace,
1195 | hSpace,
1196 | origWidth,
1197 | origHeight,
1198 | origMaxWidth,
1199 | origMaxHeight,
1200 | ratio,
1201 | width_,
1202 | height_,
1203 | maxWidth_,
1204 | maxHeight_,
1205 | iframe,
1206 | body;
1207 |
1208 | // Reset dimensions so we could re-check actual size
1209 | wrap.add(skin).add(inner).width('auto').height('auto').removeClass('fancybox-tmp');
1210 |
1211 | wPadding = getScalar(skin.outerWidth(true) - skin.width());
1212 | hPadding = getScalar(skin.outerHeight(true) - skin.height());
1213 |
1214 | // Any space between content and viewport (margin, padding, border, title)
1215 | wSpace = wMargin + wPadding;
1216 | hSpace = hMargin + hPadding;
1217 |
1218 | origWidth = isPercentage(width) ? (viewport.w - wSpace) * getScalar(width) / 100 : width;
1219 | origHeight = isPercentage(height) ? (viewport.h - hSpace) * getScalar(height) / 100 : height;
1220 |
1221 | if (current.type === 'iframe') {
1222 | iframe = current.content;
1223 |
1224 | if (current.autoHeight && iframe.data('ready') === 1) {
1225 | try {
1226 | if (iframe[0].contentWindow.document.location) {
1227 | inner.width( origWidth ).height(9999);
1228 |
1229 | body = iframe.contents().find('body');
1230 |
1231 | if (scrollOut) {
1232 | body.css('overflow-x', 'hidden');
1233 | }
1234 |
1235 | origHeight = body.outerHeight(true);
1236 | }
1237 |
1238 | } catch (e) {}
1239 | }
1240 |
1241 | } else if (current.autoWidth || current.autoHeight) {
1242 | inner.addClass( 'fancybox-tmp' );
1243 |
1244 | // Set width or height in case we need to calculate only one dimension
1245 | if (!current.autoWidth) {
1246 | inner.width( origWidth );
1247 | }
1248 |
1249 | if (!current.autoHeight) {
1250 | inner.height( origHeight );
1251 | }
1252 |
1253 | if (current.autoWidth) {
1254 | origWidth = inner.width();
1255 | }
1256 |
1257 | if (current.autoHeight) {
1258 | origHeight = inner.height();
1259 | }
1260 |
1261 | inner.removeClass( 'fancybox-tmp' );
1262 | }
1263 |
1264 | width = getScalar( origWidth );
1265 | height = getScalar( origHeight );
1266 |
1267 | ratio = origWidth / origHeight;
1268 |
1269 | // Calculations for the content
1270 | minWidth = getScalar(isPercentage(minWidth) ? getScalar(minWidth, 'w') - wSpace : minWidth);
1271 | maxWidth = getScalar(isPercentage(maxWidth) ? getScalar(maxWidth, 'w') - wSpace : maxWidth);
1272 |
1273 | minHeight = getScalar(isPercentage(minHeight) ? getScalar(minHeight, 'h') - hSpace : minHeight);
1274 | maxHeight = getScalar(isPercentage(maxHeight) ? getScalar(maxHeight, 'h') - hSpace : maxHeight);
1275 |
1276 | // These will be used to determine if wrap can fit in the viewport
1277 | origMaxWidth = maxWidth;
1278 | origMaxHeight = maxHeight;
1279 |
1280 | if (current.fitToView) {
1281 | maxWidth = Math.min(viewport.w - wSpace, maxWidth);
1282 | maxHeight = Math.min(viewport.h - hSpace, maxHeight);
1283 | }
1284 |
1285 | maxWidth_ = viewport.w - wMargin;
1286 | maxHeight_ = viewport.h - hMargin;
1287 |
1288 | if (current.aspectRatio) {
1289 | if (width > maxWidth) {
1290 | width = maxWidth;
1291 | height = getScalar(width / ratio);
1292 | }
1293 |
1294 | if (height > maxHeight) {
1295 | height = maxHeight;
1296 | width = getScalar(height * ratio);
1297 | }
1298 |
1299 | if (width < minWidth) {
1300 | width = minWidth;
1301 | height = getScalar(width / ratio);
1302 | }
1303 |
1304 | if (height < minHeight) {
1305 | height = minHeight;
1306 | width = getScalar(height * ratio);
1307 | }
1308 |
1309 | } else {
1310 | width = Math.max(minWidth, Math.min(width, maxWidth));
1311 |
1312 | if (current.autoHeight && current.type !== 'iframe') {
1313 | inner.width( width );
1314 |
1315 | height = inner.height();
1316 | }
1317 |
1318 | height = Math.max(minHeight, Math.min(height, maxHeight));
1319 | }
1320 |
1321 | // Try to fit inside viewport (including the title)
1322 | if (current.fitToView) {
1323 | inner.width( width ).height( height );
1324 |
1325 | wrap.width( width + wPadding );
1326 |
1327 | // Real wrap dimensions
1328 | width_ = wrap.width();
1329 | height_ = wrap.height();
1330 |
1331 | if (current.aspectRatio) {
1332 | while ((width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight) {
1333 | if (steps++ > 19) {
1334 | break;
1335 | }
1336 |
1337 | height = Math.max(minHeight, Math.min(maxHeight, height - 10));
1338 | width = getScalar(height * ratio);
1339 |
1340 | if (width < minWidth) {
1341 | width = minWidth;
1342 | height = getScalar(width / ratio);
1343 | }
1344 |
1345 | if (width > maxWidth) {
1346 | width = maxWidth;
1347 | height = getScalar(width / ratio);
1348 | }
1349 |
1350 | inner.width( width ).height( height );
1351 |
1352 | wrap.width( width + wPadding );
1353 |
1354 | width_ = wrap.width();
1355 | height_ = wrap.height();
1356 | }
1357 |
1358 | } else {
1359 | width = Math.max(minWidth, Math.min(width, width - (width_ - maxWidth_)));
1360 | height = Math.max(minHeight, Math.min(height, height - (height_ - maxHeight_)));
1361 | }
1362 | }
1363 |
1364 | if (scrollOut && scrolling === 'auto' && height < origHeight && (width + wPadding + scrollOut) < maxWidth_) {
1365 | width += scrollOut;
1366 | }
1367 |
1368 | inner.width( width ).height( height );
1369 |
1370 | wrap.width( width + wPadding );
1371 |
1372 | width_ = wrap.width();
1373 | height_ = wrap.height();
1374 |
1375 | canShrink = (width_ > maxWidth_ || height_ > maxHeight_) && width > minWidth && height > minHeight;
1376 | canExpand = current.aspectRatio ? (width < origMaxWidth && height < origMaxHeight && width < origWidth && height < origHeight) : ((width < origMaxWidth || height < origMaxHeight) && (width < origWidth || height < origHeight));
1377 |
1378 | $.extend(current, {
1379 | dim : {
1380 | width : getValue( width_ ),
1381 | height : getValue( height_ )
1382 | },
1383 | origWidth : origWidth,
1384 | origHeight : origHeight,
1385 | canShrink : canShrink,
1386 | canExpand : canExpand,
1387 | wPadding : wPadding,
1388 | hPadding : hPadding,
1389 | wrapSpace : height_ - skin.outerHeight(true),
1390 | skinSpace : skin.height() - height
1391 | });
1392 |
1393 | if (!iframe && current.autoHeight && height > minHeight && height < maxHeight && !canExpand) {
1394 | inner.height('auto');
1395 | }
1396 | },
1397 |
1398 | _getPosition: function (onlyAbsolute) {
1399 | var current = F.current,
1400 | viewport = F.getViewport(),
1401 | margin = current.margin,
1402 | width = F.wrap.width() + margin[1] + margin[3],
1403 | height = F.wrap.height() + margin[0] + margin[2],
1404 | rez = {
1405 | position: 'absolute',
1406 | top : margin[0],
1407 | left : margin[3]
1408 | };
1409 |
1410 | if (current.autoCenter && current.fixed && !onlyAbsolute && height <= viewport.h && width <= viewport.w) {
1411 | rez.position = 'fixed';
1412 |
1413 | } else if (!current.locked) {
1414 | rez.top += viewport.y;
1415 | rez.left += viewport.x;
1416 | }
1417 |
1418 | rez.top = getValue(Math.max(rez.top, rez.top + ((viewport.h - height) * current.topRatio)));
1419 | rez.left = getValue(Math.max(rez.left, rez.left + ((viewport.w - width) * current.leftRatio)));
1420 |
1421 | return rez;
1422 | },
1423 |
1424 | _afterZoomIn: function () {
1425 | var current = F.current;
1426 |
1427 | if (!current) {
1428 | return;
1429 | }
1430 |
1431 | F.isOpen = F.isOpened = true;
1432 |
1433 | F.wrap.css('overflow', 'visible').addClass('fancybox-opened').hide().show(0);
1434 |
1435 | F.update();
1436 |
1437 | // Assign a click event
1438 | if ( current.closeClick || (current.nextClick && F.group.length > 1) ) {
1439 | F.inner.css('cursor', 'pointer').bind('click.fb', function(e) {
1440 | if (!$(e.target).is('a') && !$(e.target).parent().is('a')) {
1441 | e.preventDefault();
1442 |
1443 | F[ current.closeClick ? 'close' : 'next' ]();
1444 | }
1445 | });
1446 | }
1447 |
1448 | // Create a close button
1449 | if (current.closeBtn) {
1450 | $(current.tpl.closeBtn).appendTo(F.skin).bind('click.fb', function(e) {
1451 | e.preventDefault();
1452 |
1453 | F.close();
1454 | });
1455 | }
1456 |
1457 | // Create navigation arrows
1458 | if (current.arrows && F.group.length > 1) {
1459 | if (current.loop || current.index > 0) {
1460 | $(current.tpl.prev).appendTo(F.outer).bind('click.fb', F.prev);
1461 | }
1462 |
1463 | if (current.loop || current.index < F.group.length - 1) {
1464 | $(current.tpl.next).appendTo(F.outer).bind('click.fb', F.next);
1465 | }
1466 | }
1467 |
1468 | F.trigger('afterShow');
1469 |
1470 | // Stop the slideshow if this is the last item
1471 | if (!current.loop && current.index === current.group.length - 1) {
1472 |
1473 | F.play( false );
1474 |
1475 | } else if (F.opts.autoPlay && !F.player.isActive) {
1476 | F.opts.autoPlay = false;
1477 |
1478 | F.play(true);
1479 | }
1480 | },
1481 |
1482 | _afterZoomOut: function ( obj ) {
1483 | obj = obj || F.current;
1484 |
1485 | $('.fancybox-wrap').trigger('onReset').remove();
1486 |
1487 | $.extend(F, {
1488 | group : {},
1489 | opts : {},
1490 | router : false,
1491 | current : null,
1492 | isActive : false,
1493 | isOpened : false,
1494 | isOpen : false,
1495 | isClosing : false,
1496 | wrap : null,
1497 | skin : null,
1498 | outer : null,
1499 | inner : null
1500 | });
1501 |
1502 | F.trigger('afterClose', obj);
1503 | }
1504 | });
1505 |
1506 | /*
1507 | * Default transitions
1508 | */
1509 |
1510 | F.transitions = {
1511 | getOrigPosition: function () {
1512 | var current = F.current,
1513 | element = current.element,
1514 | orig = current.orig,
1515 | pos = {},
1516 | width = 50,
1517 | height = 50,
1518 | hPadding = current.hPadding,
1519 | wPadding = current.wPadding,
1520 | viewport = F.getViewport();
1521 |
1522 | if (!orig && current.isDom && element.is(':visible')) {
1523 | orig = element.find('img:first');
1524 |
1525 | if (!orig.length) {
1526 | orig = element;
1527 | }
1528 | }
1529 |
1530 | if (isQuery(orig)) {
1531 | pos = orig.offset();
1532 |
1533 | if (orig.is('img')) {
1534 | width = orig.outerWidth();
1535 | height = orig.outerHeight();
1536 | }
1537 |
1538 | } else {
1539 | pos.top = viewport.y + (viewport.h - height) * current.topRatio;
1540 | pos.left = viewport.x + (viewport.w - width) * current.leftRatio;
1541 | }
1542 |
1543 | if (F.wrap.css('position') === 'fixed' || current.locked) {
1544 | pos.top -= viewport.y;
1545 | pos.left -= viewport.x;
1546 | }
1547 |
1548 | pos = {
1549 | top : getValue(pos.top - hPadding * current.topRatio),
1550 | left : getValue(pos.left - wPadding * current.leftRatio),
1551 | width : getValue(width + wPadding),
1552 | height : getValue(height + hPadding)
1553 | };
1554 |
1555 | return pos;
1556 | },
1557 |
1558 | step: function (now, fx) {
1559 | var ratio,
1560 | padding,
1561 | value,
1562 | prop = fx.prop,
1563 | current = F.current,
1564 | wrapSpace = current.wrapSpace,
1565 | skinSpace = current.skinSpace;
1566 |
1567 | if (prop === 'width' || prop === 'height') {
1568 | ratio = fx.end === fx.start ? 1 : (now - fx.start) / (fx.end - fx.start);
1569 |
1570 | if (F.isClosing) {
1571 | ratio = 1 - ratio;
1572 | }
1573 |
1574 | padding = prop === 'width' ? current.wPadding : current.hPadding;
1575 | value = now - padding;
1576 |
1577 | F.skin[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) ) );
1578 | F.inner[ prop ]( getScalar( prop === 'width' ? value : value - (wrapSpace * ratio) - (skinSpace * ratio) ) );
1579 | }
1580 | },
1581 |
1582 | zoomIn: function () {
1583 | var current = F.current,
1584 | startPos = current.pos,
1585 | effect = current.openEffect,
1586 | elastic = effect === 'elastic',
1587 | endPos = $.extend({opacity : 1}, startPos);
1588 |
1589 | // Remove "position" property that breaks older IE
1590 | delete endPos.position;
1591 |
1592 | if (elastic) {
1593 | startPos = this.getOrigPosition();
1594 |
1595 | if (current.openOpacity) {
1596 | startPos.opacity = 0.1;
1597 | }
1598 |
1599 | } else if (effect === 'fade') {
1600 | startPos.opacity = 0.1;
1601 | }
1602 |
1603 | F.wrap.css(startPos).animate(endPos, {
1604 | duration : effect === 'none' ? 0 : current.openSpeed,
1605 | easing : current.openEasing,
1606 | step : elastic ? this.step : null,
1607 | complete : F._afterZoomIn
1608 | });
1609 | },
1610 |
1611 | zoomOut: function () {
1612 | var current = F.current,
1613 | effect = current.closeEffect,
1614 | elastic = effect === 'elastic',
1615 | endPos = {opacity : 0.1};
1616 |
1617 | if (elastic) {
1618 | endPos = this.getOrigPosition();
1619 |
1620 | if (current.closeOpacity) {
1621 | endPos.opacity = 0.1;
1622 | }
1623 | }
1624 |
1625 | F.wrap.animate(endPos, {
1626 | duration : effect === 'none' ? 0 : current.closeSpeed,
1627 | easing : current.closeEasing,
1628 | step : elastic ? this.step : null,
1629 | complete : F._afterZoomOut
1630 | });
1631 | },
1632 |
1633 | changeIn: function () {
1634 | var current = F.current,
1635 | effect = current.nextEffect,
1636 | startPos = current.pos,
1637 | endPos = { opacity : 1 },
1638 | direction = F.direction,
1639 | distance = 200,
1640 | field;
1641 |
1642 | startPos.opacity = 0.1;
1643 |
1644 | if (effect === 'elastic') {
1645 | field = direction === 'down' || direction === 'up' ? 'top' : 'left';
1646 |
1647 | if (direction === 'down' || direction === 'right') {
1648 | startPos[ field ] = getValue(getScalar(startPos[ field ]) - distance);
1649 | endPos[ field ] = '+=' + distance + 'px';
1650 |
1651 | } else {
1652 | startPos[ field ] = getValue(getScalar(startPos[ field ]) + distance);
1653 | endPos[ field ] = '-=' + distance + 'px';
1654 | }
1655 | }
1656 |
1657 | // Workaround for http://bugs.jquery.com/ticket/12273
1658 | if (effect === 'none') {
1659 | F._afterZoomIn();
1660 |
1661 | } else {
1662 | F.wrap.css(startPos).animate(endPos, {
1663 | duration : current.nextSpeed,
1664 | easing : current.nextEasing,
1665 | complete : F._afterZoomIn
1666 | });
1667 | }
1668 | },
1669 |
1670 | changeOut: function () {
1671 | var previous = F.previous,
1672 | effect = previous.prevEffect,
1673 | endPos = { opacity : 0.1 },
1674 | direction = F.direction,
1675 | distance = 200;
1676 |
1677 | if (effect === 'elastic') {
1678 | endPos[ direction === 'down' || direction === 'up' ? 'top' : 'left' ] = ( direction === 'up' || direction === 'left' ? '-' : '+' ) + '=' + distance + 'px';
1679 | }
1680 |
1681 | previous.wrap.animate(endPos, {
1682 | duration : effect === 'none' ? 0 : previous.prevSpeed,
1683 | easing : previous.prevEasing,
1684 | complete : function () {
1685 | $(this).trigger('onReset').remove();
1686 | }
1687 | });
1688 | }
1689 | };
1690 |
1691 | /*
1692 | * Overlay helper
1693 | */
1694 |
1695 | F.helpers.overlay = {
1696 | defaults : {
1697 | closeClick : true, // if true, fancyBox will be closed when user clicks on the overlay
1698 | speedOut : 200, // duration of fadeOut animation
1699 | showEarly : true, // indicates if should be opened immediately or wait until the content is ready
1700 | css : {}, // custom CSS properties
1701 | locked : !isTouch, // if true, the content will be locked into overlay
1702 | fixed : true // if false, the overlay CSS position property will not be set to "fixed"
1703 | },
1704 |
1705 | overlay : null, // current handle
1706 | fixed : false, // indicates if the overlay has position "fixed"
1707 | el : $('html'), // element that contains "the lock"
1708 |
1709 | // Public methods
1710 | create : function(opts) {
1711 | var parent;
1712 |
1713 | opts = $.extend({}, this.defaults, opts);
1714 |
1715 | if (this.overlay) {
1716 | this.close();
1717 | }
1718 |
1719 | parent = F.coming ? F.coming.parent : opts.parent;
1720 |
1721 | this.overlay = $('
').appendTo( parent && parent.lenth ? parent : 'body' );
1722 | this.fixed = false;
1723 |
1724 | if (opts.fixed && F.defaults.fixed) {
1725 | this.overlay.addClass('fancybox-overlay-fixed');
1726 |
1727 | this.fixed = true;
1728 | }
1729 | },
1730 |
1731 | open : function(opts) {
1732 | var that = this;
1733 |
1734 | opts = $.extend({}, this.defaults, opts);
1735 |
1736 | if (this.overlay) {
1737 | this.overlay.unbind('.overlay').width('auto').height('auto');
1738 |
1739 | } else {
1740 | this.create(opts);
1741 | }
1742 |
1743 | if (!this.fixed) {
1744 | W.bind('resize.overlay', $.proxy( this.update, this) );
1745 |
1746 | this.update();
1747 | }
1748 |
1749 | if (opts.closeClick) {
1750 | this.overlay.bind('click.overlay', function(e) {
1751 | if ($(e.target).hasClass('fancybox-overlay')) {
1752 | if (F.isActive) {
1753 | F.close();
1754 | } else {
1755 | that.close();
1756 | }
1757 |
1758 | return false;
1759 | }
1760 | });
1761 | }
1762 |
1763 | this.overlay.css( opts.css ).show();
1764 | },
1765 |
1766 | close : function() {
1767 | W.unbind('resize.overlay');
1768 |
1769 | if (this.el.hasClass('fancybox-lock')) {
1770 | $('.fancybox-margin').removeClass('fancybox-margin');
1771 |
1772 | this.el.removeClass('fancybox-lock');
1773 |
1774 | W.scrollTop( this.scrollV ).scrollLeft( this.scrollH );
1775 | }
1776 |
1777 | $('.fancybox-overlay').remove().hide();
1778 |
1779 | $.extend(this, {
1780 | overlay : null,
1781 | fixed : false
1782 | });
1783 | },
1784 |
1785 | // Private, callbacks
1786 |
1787 | update : function () {
1788 | var width = '100%', offsetWidth;
1789 |
1790 | // Reset width/height so it will not mess
1791 | this.overlay.width(width).height('100%');
1792 |
1793 | // jQuery does not return reliable result for IE
1794 | if (IE) {
1795 | offsetWidth = Math.max(document.documentElement.offsetWidth, document.body.offsetWidth);
1796 |
1797 | if (D.width() > offsetWidth) {
1798 | width = D.width();
1799 | }
1800 |
1801 | } else if (D.width() > W.width()) {
1802 | width = D.width();
1803 | }
1804 |
1805 | this.overlay.width(width).height(D.height());
1806 | },
1807 |
1808 | // This is where we can manipulate DOM, because later it would cause iframes to reload
1809 | onReady : function (opts, obj) {
1810 | var overlay = this.overlay;
1811 |
1812 | $('.fancybox-overlay').stop(true, true);
1813 |
1814 | if (!overlay) {
1815 | this.create(opts);
1816 | }
1817 |
1818 | if (opts.locked && this.fixed && obj.fixed) {
1819 | obj.locked = this.overlay.append( obj.wrap );
1820 | obj.fixed = false;
1821 | }
1822 |
1823 | if (opts.showEarly === true) {
1824 | this.beforeShow.apply(this, arguments);
1825 | }
1826 | },
1827 |
1828 | beforeShow : function(opts, obj) {
1829 | if (obj.locked && !this.el.hasClass('fancybox-lock')) {
1830 | if (this.fixPosition !== false) {
1831 | $('*').filter(function(){
1832 | return ($(this).css('position') === 'fixed' && !$(this).hasClass("fancybox-overlay") && !$(this).hasClass("fancybox-wrap") );
1833 | }).addClass('fancybox-margin');
1834 | }
1835 |
1836 | this.el.addClass('fancybox-margin');
1837 |
1838 | this.scrollV = W.scrollTop();
1839 | this.scrollH = W.scrollLeft();
1840 |
1841 | this.el.addClass('fancybox-lock');
1842 |
1843 | W.scrollTop( this.scrollV ).scrollLeft( this.scrollH );
1844 | }
1845 |
1846 | this.open(opts);
1847 | },
1848 |
1849 | onUpdate : function() {
1850 | if (!this.fixed) {
1851 | this.update();
1852 | }
1853 | },
1854 |
1855 | afterClose: function (opts) {
1856 | // Remove overlay if exists and fancyBox is not opening
1857 | // (e.g., it is not being open using afterClose callback)
1858 | if (this.overlay && !F.coming) {
1859 | this.overlay.fadeOut(opts.speedOut, $.proxy( this.close, this ));
1860 | }
1861 | }
1862 | };
1863 |
1864 | /*
1865 | * Title helper
1866 | */
1867 |
1868 | F.helpers.title = {
1869 | defaults : {
1870 | type : 'float', // 'float', 'inside', 'outside' or 'over',
1871 | position : 'bottom' // 'top' or 'bottom'
1872 | },
1873 |
1874 | beforeShow: function (opts) {
1875 | var current = F.current,
1876 | text = current.title,
1877 | type = opts.type,
1878 | title,
1879 | target;
1880 |
1881 | if ($.isFunction(text)) {
1882 | text = text.call(current.element, current);
1883 | }
1884 |
1885 | if (!isString(text) || $.trim(text) === '') {
1886 | return;
1887 | }
1888 |
1889 | title = $('
' + text + '
');
1890 |
1891 | switch (type) {
1892 | case 'inside':
1893 | target = F.skin;
1894 | break;
1895 |
1896 | case 'outside':
1897 | target = F.wrap;
1898 | break;
1899 |
1900 | case 'over':
1901 | target = F.inner;
1902 | break;
1903 |
1904 | default: // 'float'
1905 | target = F.skin;
1906 |
1907 | title.appendTo('body');
1908 |
1909 | if (IE) {
1910 | title.width( title.width() );
1911 | }
1912 |
1913 | title.wrapInner('
');
1914 |
1915 | //Increase bottom margin so this title will also fit into viewport
1916 | F.current.margin[2] += Math.abs( getScalar(title.css('margin-bottom')) );
1917 | break;
1918 | }
1919 |
1920 | title[ (opts.position === 'top' ? 'prependTo' : 'appendTo') ](target);
1921 | }
1922 | };
1923 |
1924 | // jQuery plugin initialization
1925 | $.fn.fancybox = function (options) {
1926 | var index,
1927 | that = $(this),
1928 | selector = this.selector || '',
1929 | run = function(e) {
1930 | var what = $(this).blur(), idx = index, relType, relVal;
1931 |
1932 | if (!(e.ctrlKey || e.altKey || e.shiftKey || e.metaKey) && !what.is('.fancybox-wrap')) {
1933 | relType = options.groupAttr || 'data-fancybox-group';
1934 | relVal = what.attr(relType);
1935 |
1936 | if (!relVal) {
1937 | relType = 'rel';
1938 | relVal = what.get(0)[ relType ];
1939 | }
1940 |
1941 | if (relVal && relVal !== '' && relVal !== 'nofollow') {
1942 | what = selector.length ? $(selector) : that;
1943 | what = what.filter('[' + relType + '="' + relVal + '"]');
1944 | idx = what.index(this);
1945 | }
1946 |
1947 | options.index = idx;
1948 |
1949 | // Stop an event from bubbling if everything is fine
1950 | if (F.open(what, options) !== false) {
1951 | e.preventDefault();
1952 | }
1953 | }
1954 | };
1955 |
1956 | options = options || {};
1957 | index = options.index || 0;
1958 |
1959 | if (!selector || options.live === false) {
1960 | that.unbind('click.fb-start').bind('click.fb-start', run);
1961 |
1962 | } else {
1963 | D.undelegate(selector, 'click.fb-start').delegate(selector + ":not('.fancybox-item, .fancybox-nav')", 'click.fb-start', run);
1964 | }
1965 |
1966 | this.filter('[data-fancybox-start=1]').trigger('click');
1967 |
1968 | return this;
1969 | };
1970 |
1971 | // Tests that need a body at doc ready
1972 | D.ready(function() {
1973 | var w1, w2;
1974 |
1975 | if ( $.scrollbarWidth === undefined ) {
1976 | // http://benalman.com/projects/jquery-misc-plugins/#scrollbarwidth
1977 | $.scrollbarWidth = function() {
1978 | var parent = $('
').appendTo('body'),
1979 | child = parent.children(),
1980 | width = child.innerWidth() - child.height( 99 ).innerWidth();
1981 |
1982 | parent.remove();
1983 |
1984 | return width;
1985 | };
1986 | }
1987 |
1988 | if ( $.support.fixedPosition === undefined ) {
1989 | $.support.fixedPosition = (function() {
1990 | var elem = $('
').appendTo('body'),
1991 | fixed = ( elem[0].offsetTop === 20 || elem[0].offsetTop === 15 );
1992 |
1993 | elem.remove();
1994 |
1995 | return fixed;
1996 | }());
1997 | }
1998 |
1999 | $.extend(F.defaults, {
2000 | scrollbarWidth : $.scrollbarWidth(),
2001 | fixed : $.support.fixedPosition,
2002 | parent : $('body')
2003 | });
2004 |
2005 | //Get real width of page scroll-bar
2006 | w1 = $(window).width();
2007 |
2008 | H.addClass('fancybox-lock-test');
2009 |
2010 | w2 = $(window).width();
2011 |
2012 | H.removeClass('fancybox-lock-test');
2013 |
2014 | $("").appendTo("head");
2015 | });
2016 |
2017 | }(window, document, jQuery));
--------------------------------------------------------------------------------
/themes/landscape/source/fancybox/jquery.fancybox.pack.js:
--------------------------------------------------------------------------------
1 | /*! fancyBox v2.1.5 fancyapps.com | fancyapps.com/fancybox/#license */
2 | (function(s,H,f,w){var K=f("html"),q=f(s),p=f(H),b=f.fancybox=function(){b.open.apply(this,arguments)},J=navigator.userAgent.match(/msie/i),C=null,t=H.createTouch!==w,u=function(a){return a&&a.hasOwnProperty&&a instanceof f},r=function(a){return a&&"string"===f.type(a)},F=function(a){return r(a)&&0
',image:'The requested content cannot be loaded.
Please try again later.
',closeBtn:'