wrgem 0.0.50 → 0.0.51
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.DS_Store +0 -0
- data/lib/.DS_Store +0 -0
- data/lib/generators/.DS_Store +0 -0
- data/lib/generators/wrstart/.DS_Store +0 -0
- data/lib/generators/wrstart/template/.DS_Store +0 -0
- data/lib/generators/wrstart/template/Gemfile +13 -6
- data/lib/generators/wrstart/template/javascripts/.DS_Store +0 -0
- data/lib/generators/wrstart/template/stylesheets/.DS_Store +0 -0
- data/lib/generators/wrstart/template/stylesheets/_requirements.sass +10 -24
- data/lib/generators/wrstart/template/stylesheets/application.css.sass +68 -32
- data/lib/generators/wrstart/template/stylesheets/base/_base.page.sass +3 -3
- data/lib/generators/wrstart/template/stylesheets/base/_base.type.sass +66 -0
- data/lib/generators/wrstart/template/stylesheets/components/_components.buttons.sass +23 -0
- data/lib/generators/wrstart/template/stylesheets/generic/{.keep → _generic.example.sass} +0 -0
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.containers.sass +4 -3
- data/lib/generators/wrstart/template/stylesheets/settings/_settings.colors.sass +32 -56
- data/lib/generators/wrstart/template/stylesheets/settings/_settings.fonts.sass +11 -48
- data/lib/generators/wrstart/template/stylesheets/settings/_settings.global.sass +9 -0
- data/lib/generators/wrstart/template/stylesheets/settings/_settings.grid.sass +3 -3
- data/lib/generators/wrstart/template/stylesheets/tools/_tools.intrinsic-ratio.sass +2 -2
- data/lib/generators/wrstart/template/stylesheets/tools/_tools.mediaqueries.sass +4 -3
- data/lib/generators/wrstart/template/stylesheets/tools/_tools.mixins.sass +5 -8
- data/lib/generators/wrstart/template/stylesheets/trumps/{.keep → _trumps.example.sass} +0 -0
- data/lib/generators/wrstart/template/vendor/.DS_Store +0 -0
- data/lib/generators/wrstart/template/vendor/assets/.DS_Store +0 -0
- data/lib/generators/wrstart/template/vendor/assets/components/.DS_Store +0 -0
- data/lib/generators/wrstart/template/vendor/assets/components/enquire/.bower.json +25 -0
- data/lib/generators/wrstart/template/vendor/assets/components/enquire/.gitignore +53 -0
- data/lib/generators/wrstart/template/vendor/assets/components/enquire/.jshintrc +29 -0
- data/lib/generators/wrstart/template/vendor/assets/components/enquire/CONTRIBUTING.md +141 -0
- data/lib/generators/wrstart/template/vendor/assets/components/enquire/bower.json +13 -0
- data/lib/generators/wrstart/template/vendor/assets/components/enquire/dist/enquire.js +296 -0
- data/lib/generators/wrstart/template/vendor/assets/components/enquire/dist/enquire.min.js +7 -0
- data/lib/generators/wrstart/template/vendor/assets/components/enquire/package.json +42 -0
- data/lib/generators/wrstart/template/vendor/assets/components/enquire/readme.md +85 -0
- data/lib/wrgem/version.rb +1 -1
- metadata +26 -26
- data/lib/generators/wrstart/template/stylesheets/_base.sass +0 -12
- data/lib/generators/wrstart/template/stylesheets/_components.sass +0 -6
- data/lib/generators/wrstart/template/stylesheets/_generic.sass +0 -11
- data/lib/generators/wrstart/template/stylesheets/_objects.sass +0 -15
- data/lib/generators/wrstart/template/stylesheets/_settings.sass +0 -23
- data/lib/generators/wrstart/template/stylesheets/_tools.sass +0 -12
- data/lib/generators/wrstart/template/stylesheets/_trumps.sass +0 -8
- data/lib/generators/wrstart/template/stylesheets/components/_components.header.sass +0 -42
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.alerts.sass +0 -33
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.buttons_settings.sass +0 -228
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.form-files.sass +0 -79
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.form-selects.sass +0 -80
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.forms.sass +0 -297
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.lists.sass +0 -89
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.progressbar.sass +0 -92
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.rows.sass +0 -12
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.tables.sass +0 -49
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.tabs.sass +0 -59
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.text-effects.sass +0 -34
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.tooltips.sass +0 -56
- data/lib/generators/wrstart/template/stylesheets/objects/_objects.videos.sass +0 -39
- data/lib/generators/wrstart/template/stylesheets/settings/_settings.borders.sass +0 -9
@@ -0,0 +1,25 @@
|
|
1
|
+
{
|
2
|
+
"name": "enquire",
|
3
|
+
"description": "Awesome Media Queries in JavaScript",
|
4
|
+
"version": "2.1.2",
|
5
|
+
"main": [
|
6
|
+
"./dist/enquire.js"
|
7
|
+
],
|
8
|
+
"ignore": [
|
9
|
+
"functional-test/",
|
10
|
+
"spec",
|
11
|
+
"src/",
|
12
|
+
"Gruntfile.js",
|
13
|
+
".travis.yml"
|
14
|
+
],
|
15
|
+
"homepage": "https://github.com/WickyNilliams/enquire.js",
|
16
|
+
"_release": "2.1.2",
|
17
|
+
"_resolution": {
|
18
|
+
"type": "version",
|
19
|
+
"tag": "v2.1.2",
|
20
|
+
"commit": "cb63611d114a0d584c9233bf6c81601971b80d0b"
|
21
|
+
},
|
22
|
+
"_source": "git://github.com/WickyNilliams/enquire.js.git",
|
23
|
+
"_target": "~2.1.2",
|
24
|
+
"_originalSource": "enquire"
|
25
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
_SpecRunner.html
|
2
|
+
|
3
|
+
# Numerous always-ignore extensions
|
4
|
+
*.diff
|
5
|
+
*.err
|
6
|
+
*.orig
|
7
|
+
*.log
|
8
|
+
*.rej
|
9
|
+
*.swo
|
10
|
+
*.swp
|
11
|
+
*.vi
|
12
|
+
*~
|
13
|
+
*.sass-cache
|
14
|
+
|
15
|
+
# OS or Editor folders
|
16
|
+
.DS_Store
|
17
|
+
._*
|
18
|
+
Thumbs.db
|
19
|
+
.cache
|
20
|
+
.project
|
21
|
+
.settings
|
22
|
+
.tmproj
|
23
|
+
nbproject
|
24
|
+
*.sublime-project
|
25
|
+
*.sublime-workspace
|
26
|
+
|
27
|
+
# Dreamweaver added files
|
28
|
+
_notes
|
29
|
+
dwsync.xml
|
30
|
+
|
31
|
+
# Komodo
|
32
|
+
*.komodoproject
|
33
|
+
.komodotools
|
34
|
+
|
35
|
+
# Espresso
|
36
|
+
*.esproj
|
37
|
+
*.espressostorage
|
38
|
+
|
39
|
+
# Rubinius
|
40
|
+
*.rbc
|
41
|
+
|
42
|
+
# Folders to ignore
|
43
|
+
.hg
|
44
|
+
.svn
|
45
|
+
.CVS
|
46
|
+
intermediate
|
47
|
+
publish
|
48
|
+
.idea
|
49
|
+
node_modules
|
50
|
+
|
51
|
+
# build script local files
|
52
|
+
build/buildinfo.properties
|
53
|
+
build/config/buildinfo.properties
|
@@ -0,0 +1,29 @@
|
|
1
|
+
{
|
2
|
+
"browser": true,
|
3
|
+
"es5": true,
|
4
|
+
"esnext": true,
|
5
|
+
"expr" : true,
|
6
|
+
"bitwise": true,
|
7
|
+
"camelcase": true,
|
8
|
+
"curly": true,
|
9
|
+
"eqeqeq": true,
|
10
|
+
"immed": true,
|
11
|
+
"latedef": true,
|
12
|
+
"newcap": true,
|
13
|
+
"noarg": true,
|
14
|
+
"quotmark": "single",
|
15
|
+
"regexp": true,
|
16
|
+
"undef": true,
|
17
|
+
"unused": true,
|
18
|
+
"trailing": true,
|
19
|
+
"smarttabs": true,
|
20
|
+
"globals": {
|
21
|
+
"matchMedia": false,
|
22
|
+
"each": true,
|
23
|
+
"isArray": true,
|
24
|
+
"isFunction": true,
|
25
|
+
"QueryHandler": false,
|
26
|
+
"MediaQuery": false,
|
27
|
+
"MediaQueryDispatch": false
|
28
|
+
}
|
29
|
+
}
|
@@ -0,0 +1,141 @@
|
|
1
|
+
# Contributing to this project
|
2
|
+
|
3
|
+
Please take a moment to review this document in order to make the contribution
|
4
|
+
process easy and effective for everyone involved.
|
5
|
+
|
6
|
+
Following these guidelines helps to communicate that you respect the time of
|
7
|
+
the developers managing and developing this open source project. In return,
|
8
|
+
they should reciprocate that respect in addressing your issue or assessing
|
9
|
+
patches and features.
|
10
|
+
|
11
|
+
|
12
|
+
## Using the issue tracker
|
13
|
+
|
14
|
+
The issue tracker is the preferred channel for [bug reports](#bugs),
|
15
|
+
[features requests](#features) and [submitting pull
|
16
|
+
requests](#pull-requests), but please respect the following restrictions:
|
17
|
+
|
18
|
+
* Please **do not** use the issue tracker for personal support requests (use
|
19
|
+
[Stack Overflow](http://stackoverflow.com)).
|
20
|
+
|
21
|
+
* Please **do not** derail or troll issues. Keep the discussion on topic and
|
22
|
+
respect the opinions of others.
|
23
|
+
|
24
|
+
|
25
|
+
## Bug reports
|
26
|
+
|
27
|
+
A bug is a _demonstrable problem_ that is caused by the code in the repository.
|
28
|
+
Good bug reports are extremely helpful - thank you!
|
29
|
+
|
30
|
+
Guidelines for bug reports:
|
31
|
+
|
32
|
+
1. **Use the GitHub issue search** — check if the issue has already been
|
33
|
+
reported.
|
34
|
+
|
35
|
+
2. **Check if the issue has been fixed** — try to reproduce it using the
|
36
|
+
latest `master` or development branch in the repository.
|
37
|
+
|
38
|
+
3. **Isolate the problem** — ideally create a [reduced test
|
39
|
+
case](http://css-tricks.com/6263-reduced-test-cases/) and a live example.
|
40
|
+
|
41
|
+
A good bug report shouldn't leave others needing to chase you up for more
|
42
|
+
information. Please try to be as detailed as possible in your report. What is
|
43
|
+
your environment? What steps will reproduce the issue? What browser(s) and OS
|
44
|
+
experience the problem? What would you expect to be the outcome? All these
|
45
|
+
details will help people to fix any potential bugs.
|
46
|
+
|
47
|
+
Example:
|
48
|
+
|
49
|
+
> Short and descriptive example bug report title
|
50
|
+
>
|
51
|
+
> A summary of the issue and the browser/OS environment in which it occurs. If
|
52
|
+
> suitable, include the steps required to reproduce the bug.
|
53
|
+
>
|
54
|
+
> 1. This is the first step
|
55
|
+
> 2. This is the second step
|
56
|
+
> 3. Further steps, etc.
|
57
|
+
>
|
58
|
+
> `<url>` - a link to the reduced test case
|
59
|
+
>
|
60
|
+
> Any other information you want to share that is relevant to the issue being
|
61
|
+
> reported. This might include the lines of code that you have identified as
|
62
|
+
> causing the bug, and potential solutions (and your opinions on their
|
63
|
+
> merits).
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
## Feature requests
|
68
|
+
|
69
|
+
Feature requests are welcome. But take a moment to find out whether your idea
|
70
|
+
fits with the scope and aims of the project. It's up to *you* to make a strong
|
71
|
+
case to convince the project's developers of the merits of this feature. Please
|
72
|
+
provide as much detail and context as possible.
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
## Pull requests
|
77
|
+
|
78
|
+
Good pull requests - patches, improvements, new features - are a fantastic
|
79
|
+
help. They should remain focused in scope and avoid containing unrelated
|
80
|
+
commits.
|
81
|
+
|
82
|
+
**Please ask first** before embarking on any significant pull request (e.g.
|
83
|
+
implementing features, refactoring code, porting to a different language),
|
84
|
+
otherwise you risk spending a lot of time working on something that the
|
85
|
+
project's developers might not want to merge into the project.
|
86
|
+
|
87
|
+
Please adhere to the coding conventions used throughout a project (indentation,
|
88
|
+
accurate comments, etc.) and any other requirements (such as test coverage).
|
89
|
+
|
90
|
+
Adhering to the following this process is the best way to get your work
|
91
|
+
included in the project:
|
92
|
+
|
93
|
+
1. [Fork](http://help.github.com/fork-a-repo/) the project, clone your fork,
|
94
|
+
and configure the remotes:
|
95
|
+
|
96
|
+
```bash
|
97
|
+
# Clone your fork of the repo into the current directory
|
98
|
+
git clone https://github.com/<your-username>/<repo-name>
|
99
|
+
# Navigate to the newly cloned directory
|
100
|
+
cd <repo-name>
|
101
|
+
# Assign the original repo to a remote called "upstream"
|
102
|
+
git remote add upstream https://github.com/<upstream-owner>/<repo-name>
|
103
|
+
```
|
104
|
+
|
105
|
+
2. If you cloned a while ago, get the latest changes from upstream:
|
106
|
+
|
107
|
+
```bash
|
108
|
+
git checkout <dev-branch>
|
109
|
+
git pull upstream <dev-branch>
|
110
|
+
```
|
111
|
+
|
112
|
+
3. Create a new topic branch (off the main project development branch) to
|
113
|
+
contain your feature, change, or fix:
|
114
|
+
|
115
|
+
```bash
|
116
|
+
git checkout -b <topic-branch-name>
|
117
|
+
```
|
118
|
+
|
119
|
+
4. Commit your changes in logical chunks. Please adhere to these [git commit
|
120
|
+
message guidelines](http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
|
121
|
+
or your code is unlikely be merged into the main project. Use Git's
|
122
|
+
[interactive rebase](https://help.github.com/articles/interactive-rebase)
|
123
|
+
feature to tidy up your commits before making them public.
|
124
|
+
|
125
|
+
5. Locally merge (or rebase) the upstream development branch into your topic branch:
|
126
|
+
|
127
|
+
```bash
|
128
|
+
git pull [--rebase] upstream <dev-branch>
|
129
|
+
```
|
130
|
+
|
131
|
+
6. Push your topic branch up to your fork:
|
132
|
+
|
133
|
+
```bash
|
134
|
+
git push origin <topic-branch-name>
|
135
|
+
```
|
136
|
+
|
137
|
+
7. [Open a Pull Request](https://help.github.com/articles/using-pull-requests/)
|
138
|
+
with a clear title and description.
|
139
|
+
|
140
|
+
**IMPORTANT**: By submitting a patch, you agree to allow the project owner to
|
141
|
+
license your work under the same license as that used by the project.
|
@@ -0,0 +1,296 @@
|
|
1
|
+
/*!
|
2
|
+
* enquire.js v2.1.2 - Awesome Media Queries in JavaScript
|
3
|
+
* Copyright (c) 2014 Nick Williams - http://wicky.nillia.ms/enquire.js
|
4
|
+
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
|
5
|
+
*/
|
6
|
+
|
7
|
+
;(function (name, context, factory) {
|
8
|
+
var matchMedia = window.matchMedia;
|
9
|
+
|
10
|
+
if (typeof module !== 'undefined' && module.exports) {
|
11
|
+
module.exports = factory(matchMedia);
|
12
|
+
}
|
13
|
+
else if (typeof define === 'function' && define.amd) {
|
14
|
+
define(function() {
|
15
|
+
return (context[name] = factory(matchMedia));
|
16
|
+
});
|
17
|
+
}
|
18
|
+
else {
|
19
|
+
context[name] = factory(matchMedia);
|
20
|
+
}
|
21
|
+
}('enquire', this, function (matchMedia) {
|
22
|
+
|
23
|
+
'use strict';
|
24
|
+
|
25
|
+
/*jshint unused:false */
|
26
|
+
/**
|
27
|
+
* Helper function for iterating over a collection
|
28
|
+
*
|
29
|
+
* @param collection
|
30
|
+
* @param fn
|
31
|
+
*/
|
32
|
+
function each(collection, fn) {
|
33
|
+
var i = 0,
|
34
|
+
length = collection.length,
|
35
|
+
cont;
|
36
|
+
|
37
|
+
for(i; i < length; i++) {
|
38
|
+
cont = fn(collection[i], i);
|
39
|
+
if(cont === false) {
|
40
|
+
break; //allow early exit
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
* Helper function for determining whether target object is an array
|
47
|
+
*
|
48
|
+
* @param target the object under test
|
49
|
+
* @return {Boolean} true if array, false otherwise
|
50
|
+
*/
|
51
|
+
function isArray(target) {
|
52
|
+
return Object.prototype.toString.apply(target) === '[object Array]';
|
53
|
+
}
|
54
|
+
|
55
|
+
/**
|
56
|
+
* Helper function for determining whether target object is a function
|
57
|
+
*
|
58
|
+
* @param target the object under test
|
59
|
+
* @return {Boolean} true if function, false otherwise
|
60
|
+
*/
|
61
|
+
function isFunction(target) {
|
62
|
+
return typeof target === 'function';
|
63
|
+
}
|
64
|
+
|
65
|
+
/**
|
66
|
+
* Delegate to handle a media query being matched and unmatched.
|
67
|
+
*
|
68
|
+
* @param {object} options
|
69
|
+
* @param {function} options.match callback for when the media query is matched
|
70
|
+
* @param {function} [options.unmatch] callback for when the media query is unmatched
|
71
|
+
* @param {function} [options.setup] one-time callback triggered the first time a query is matched
|
72
|
+
* @param {boolean} [options.deferSetup=false] should the setup callback be run immediately, rather than first time query is matched?
|
73
|
+
* @constructor
|
74
|
+
*/
|
75
|
+
function QueryHandler(options) {
|
76
|
+
this.options = options;
|
77
|
+
!options.deferSetup && this.setup();
|
78
|
+
}
|
79
|
+
QueryHandler.prototype = {
|
80
|
+
|
81
|
+
/**
|
82
|
+
* coordinates setup of the handler
|
83
|
+
*
|
84
|
+
* @function
|
85
|
+
*/
|
86
|
+
setup : function() {
|
87
|
+
if(this.options.setup) {
|
88
|
+
this.options.setup();
|
89
|
+
}
|
90
|
+
this.initialised = true;
|
91
|
+
},
|
92
|
+
|
93
|
+
/**
|
94
|
+
* coordinates setup and triggering of the handler
|
95
|
+
*
|
96
|
+
* @function
|
97
|
+
*/
|
98
|
+
on : function() {
|
99
|
+
!this.initialised && this.setup();
|
100
|
+
this.options.match && this.options.match();
|
101
|
+
},
|
102
|
+
|
103
|
+
/**
|
104
|
+
* coordinates the unmatch event for the handler
|
105
|
+
*
|
106
|
+
* @function
|
107
|
+
*/
|
108
|
+
off : function() {
|
109
|
+
this.options.unmatch && this.options.unmatch();
|
110
|
+
},
|
111
|
+
|
112
|
+
/**
|
113
|
+
* called when a handler is to be destroyed.
|
114
|
+
* delegates to the destroy or unmatch callbacks, depending on availability.
|
115
|
+
*
|
116
|
+
* @function
|
117
|
+
*/
|
118
|
+
destroy : function() {
|
119
|
+
this.options.destroy ? this.options.destroy() : this.off();
|
120
|
+
},
|
121
|
+
|
122
|
+
/**
|
123
|
+
* determines equality by reference.
|
124
|
+
* if object is supplied compare options, if function, compare match callback
|
125
|
+
*
|
126
|
+
* @function
|
127
|
+
* @param {object || function} [target] the target for comparison
|
128
|
+
*/
|
129
|
+
equals : function(target) {
|
130
|
+
return this.options === target || this.options.match === target;
|
131
|
+
}
|
132
|
+
|
133
|
+
};
|
134
|
+
/**
|
135
|
+
* Represents a single media query, manages it's state and registered handlers for this query
|
136
|
+
*
|
137
|
+
* @constructor
|
138
|
+
* @param {string} query the media query string
|
139
|
+
* @param {boolean} [isUnconditional=false] whether the media query should run regardless of whether the conditions are met. Primarily for helping older browsers deal with mobile-first design
|
140
|
+
*/
|
141
|
+
function MediaQuery(query, isUnconditional) {
|
142
|
+
this.query = query;
|
143
|
+
this.isUnconditional = isUnconditional;
|
144
|
+
this.handlers = [];
|
145
|
+
this.mql = matchMedia(query);
|
146
|
+
|
147
|
+
var self = this;
|
148
|
+
this.listener = function(mql) {
|
149
|
+
self.mql = mql;
|
150
|
+
self.assess();
|
151
|
+
};
|
152
|
+
this.mql.addListener(this.listener);
|
153
|
+
}
|
154
|
+
MediaQuery.prototype = {
|
155
|
+
|
156
|
+
/**
|
157
|
+
* add a handler for this query, triggering if already active
|
158
|
+
*
|
159
|
+
* @param {object} handler
|
160
|
+
* @param {function} handler.match callback for when query is activated
|
161
|
+
* @param {function} [handler.unmatch] callback for when query is deactivated
|
162
|
+
* @param {function} [handler.setup] callback for immediate execution when a query handler is registered
|
163
|
+
* @param {boolean} [handler.deferSetup=false] should the setup callback be deferred until the first time the handler is matched?
|
164
|
+
*/
|
165
|
+
addHandler : function(handler) {
|
166
|
+
var qh = new QueryHandler(handler);
|
167
|
+
this.handlers.push(qh);
|
168
|
+
|
169
|
+
this.matches() && qh.on();
|
170
|
+
},
|
171
|
+
|
172
|
+
/**
|
173
|
+
* removes the given handler from the collection, and calls it's destroy methods
|
174
|
+
*
|
175
|
+
* @param {object || function} handler the handler to remove
|
176
|
+
*/
|
177
|
+
removeHandler : function(handler) {
|
178
|
+
var handlers = this.handlers;
|
179
|
+
each(handlers, function(h, i) {
|
180
|
+
if(h.equals(handler)) {
|
181
|
+
h.destroy();
|
182
|
+
return !handlers.splice(i,1); //remove from array and exit each early
|
183
|
+
}
|
184
|
+
});
|
185
|
+
},
|
186
|
+
|
187
|
+
/**
|
188
|
+
* Determine whether the media query should be considered a match
|
189
|
+
*
|
190
|
+
* @return {Boolean} true if media query can be considered a match, false otherwise
|
191
|
+
*/
|
192
|
+
matches : function() {
|
193
|
+
return this.mql.matches || this.isUnconditional;
|
194
|
+
},
|
195
|
+
|
196
|
+
/**
|
197
|
+
* Clears all handlers and unbinds events
|
198
|
+
*/
|
199
|
+
clear : function() {
|
200
|
+
each(this.handlers, function(handler) {
|
201
|
+
handler.destroy();
|
202
|
+
});
|
203
|
+
this.mql.removeListener(this.listener);
|
204
|
+
this.handlers.length = 0; //clear array
|
205
|
+
},
|
206
|
+
|
207
|
+
/*
|
208
|
+
* Assesses the query, turning on all handlers if it matches, turning them off if it doesn't match
|
209
|
+
*/
|
210
|
+
assess : function() {
|
211
|
+
var action = this.matches() ? 'on' : 'off';
|
212
|
+
|
213
|
+
each(this.handlers, function(handler) {
|
214
|
+
handler[action]();
|
215
|
+
});
|
216
|
+
}
|
217
|
+
};
|
218
|
+
/**
|
219
|
+
* Allows for registration of query handlers.
|
220
|
+
* Manages the query handler's state and is responsible for wiring up browser events
|
221
|
+
*
|
222
|
+
* @constructor
|
223
|
+
*/
|
224
|
+
function MediaQueryDispatch () {
|
225
|
+
if(!matchMedia) {
|
226
|
+
throw new Error('matchMedia not present, legacy browsers require a polyfill');
|
227
|
+
}
|
228
|
+
|
229
|
+
this.queries = {};
|
230
|
+
this.browserIsIncapable = !matchMedia('only all').matches;
|
231
|
+
}
|
232
|
+
|
233
|
+
MediaQueryDispatch.prototype = {
|
234
|
+
|
235
|
+
/**
|
236
|
+
* Registers a handler for the given media query
|
237
|
+
*
|
238
|
+
* @param {string} q the media query
|
239
|
+
* @param {object || Array || Function} options either a single query handler object, a function, or an array of query handlers
|
240
|
+
* @param {function} options.match fired when query matched
|
241
|
+
* @param {function} [options.unmatch] fired when a query is no longer matched
|
242
|
+
* @param {function} [options.setup] fired when handler first triggered
|
243
|
+
* @param {boolean} [options.deferSetup=false] whether setup should be run immediately or deferred until query is first matched
|
244
|
+
* @param {boolean} [shouldDegrade=false] whether this particular media query should always run on incapable browsers
|
245
|
+
*/
|
246
|
+
register : function(q, options, shouldDegrade) {
|
247
|
+
var queries = this.queries,
|
248
|
+
isUnconditional = shouldDegrade && this.browserIsIncapable;
|
249
|
+
|
250
|
+
if(!queries[q]) {
|
251
|
+
queries[q] = new MediaQuery(q, isUnconditional);
|
252
|
+
}
|
253
|
+
|
254
|
+
//normalise to object in an array
|
255
|
+
if(isFunction(options)) {
|
256
|
+
options = { match : options };
|
257
|
+
}
|
258
|
+
if(!isArray(options)) {
|
259
|
+
options = [options];
|
260
|
+
}
|
261
|
+
each(options, function(handler) {
|
262
|
+
if (isFunction(handler)) {
|
263
|
+
handler = { match : handler };
|
264
|
+
}
|
265
|
+
queries[q].addHandler(handler);
|
266
|
+
});
|
267
|
+
|
268
|
+
return this;
|
269
|
+
},
|
270
|
+
|
271
|
+
/**
|
272
|
+
* unregisters a query and all it's handlers, or a specific handler for a query
|
273
|
+
*
|
274
|
+
* @param {string} q the media query to target
|
275
|
+
* @param {object || function} [handler] specific handler to unregister
|
276
|
+
*/
|
277
|
+
unregister : function(q, handler) {
|
278
|
+
var query = this.queries[q];
|
279
|
+
|
280
|
+
if(query) {
|
281
|
+
if(handler) {
|
282
|
+
query.removeHandler(handler);
|
283
|
+
}
|
284
|
+
else {
|
285
|
+
query.clear();
|
286
|
+
delete this.queries[q];
|
287
|
+
}
|
288
|
+
}
|
289
|
+
|
290
|
+
return this;
|
291
|
+
}
|
292
|
+
};
|
293
|
+
|
294
|
+
return new MediaQueryDispatch();
|
295
|
+
|
296
|
+
}));
|
@@ -0,0 +1,7 @@
|
|
1
|
+
/*!
|
2
|
+
* enquire.js v2.1.2 - Awesome Media Queries in JavaScript
|
3
|
+
* Copyright (c) 2014 Nick Williams - http://wicky.nillia.ms/enquire.js
|
4
|
+
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
|
5
|
+
*/
|
6
|
+
|
7
|
+
!function(a,b,c){var d=window.matchMedia;"undefined"!=typeof module&&module.exports?module.exports=c(d):"function"==typeof define&&define.amd?define(function(){return b[a]=c(d)}):b[a]=c(d)}("enquire",this,function(a){"use strict";function b(a,b){var c,d=0,e=a.length;for(d;e>d&&(c=b(a[d],d),c!==!1);d++);}function c(a){return"[object Array]"===Object.prototype.toString.apply(a)}function d(a){return"function"==typeof a}function e(a){this.options=a,!a.deferSetup&&this.setup()}function f(b,c){this.query=b,this.isUnconditional=c,this.handlers=[],this.mql=a(b);var d=this;this.listener=function(a){d.mql=a,d.assess()},this.mql.addListener(this.listener)}function g(){if(!a)throw new Error("matchMedia not present, legacy browsers require a polyfill");this.queries={},this.browserIsIncapable=!a("only all").matches}return e.prototype={setup:function(){this.options.setup&&this.options.setup(),this.initialised=!0},on:function(){!this.initialised&&this.setup(),this.options.match&&this.options.match()},off:function(){this.options.unmatch&&this.options.unmatch()},destroy:function(){this.options.destroy?this.options.destroy():this.off()},equals:function(a){return this.options===a||this.options.match===a}},f.prototype={addHandler:function(a){var b=new e(a);this.handlers.push(b),this.matches()&&b.on()},removeHandler:function(a){var c=this.handlers;b(c,function(b,d){return b.equals(a)?(b.destroy(),!c.splice(d,1)):void 0})},matches:function(){return this.mql.matches||this.isUnconditional},clear:function(){b(this.handlers,function(a){a.destroy()}),this.mql.removeListener(this.listener),this.handlers.length=0},assess:function(){var a=this.matches()?"on":"off";b(this.handlers,function(b){b[a]()})}},g.prototype={register:function(a,e,g){var h=this.queries,i=g&&this.browserIsIncapable;return h[a]||(h[a]=new f(a,i)),d(e)&&(e={match:e}),c(e)||(e=[e]),b(e,function(b){d(b)&&(b={match:b}),h[a].addHandler(b)}),this},unregister:function(a,b){var c=this.queries[a];return c&&(b?c.removeHandler(b):(c.clear(),delete this.queries[a])),this}},new g});
|
@@ -0,0 +1,42 @@
|
|
1
|
+
{
|
2
|
+
"name": "enquire.js",
|
3
|
+
"version": "2.1.2",
|
4
|
+
"main": "./dist/enquire.js",
|
5
|
+
"description": "Awesome Media Queries in JavaScript",
|
6
|
+
"homepage": "http://wicky.nillia.ms/enquire.js",
|
7
|
+
"author": {
|
8
|
+
"name": "Nick Williams",
|
9
|
+
"url": "http://wicky.nillia.ms"
|
10
|
+
},
|
11
|
+
"keywords": [
|
12
|
+
"media query",
|
13
|
+
"media queries",
|
14
|
+
"matchMedia",
|
15
|
+
"enquire",
|
16
|
+
"enquire.js"
|
17
|
+
],
|
18
|
+
"repository": {
|
19
|
+
"type": "git",
|
20
|
+
"url": "git://github.com/WickyNilliams/enquire.js.git"
|
21
|
+
},
|
22
|
+
"bugs": {
|
23
|
+
"url": "https://github.com/WickyNilliams/enquire.js/issues"
|
24
|
+
},
|
25
|
+
"licenses": [
|
26
|
+
{
|
27
|
+
"type": "MIT",
|
28
|
+
"url": "http://www.opensource.org/licenses/mit-license.php"
|
29
|
+
}
|
30
|
+
],
|
31
|
+
"scripts": {
|
32
|
+
"test": "grunt test --verbose"
|
33
|
+
},
|
34
|
+
"devDependencies": {
|
35
|
+
"grunt": "~0.4.1",
|
36
|
+
"grunt-contrib-jasmine": "~0.4.1",
|
37
|
+
"grunt-contrib-jshint": "~0.3.0",
|
38
|
+
"grunt-contrib-uglify": "~0.2.0",
|
39
|
+
"grunt-contrib-watch": "~0.3.1",
|
40
|
+
"grunt-rigger": "~0.5.0"
|
41
|
+
}
|
42
|
+
}
|