spans 0.4.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/spans/engine.rb +0 -5
- data/lib/spans/importer.rb +14 -0
- data/lib/spans/spans.scss.erb +19 -0
- data/lib/spans/version.rb +1 -1
- data/lib/spans.rb +13 -0
- metadata +27 -13
- data/app/assets/javascripts/spans/hashgrid.js +0 -424
- data/app/assets/javascripts/spans.js.coffee +0 -49
- data/app/assets/stylesheets/spans/grid.css.scss +0 -25
- data/app/assets/stylesheets/spans.css.scss +0 -47
data/lib/spans/engine.rb
CHANGED
@@ -0,0 +1,19 @@
|
|
1
|
+
@import 'spaceless';
|
2
|
+
|
3
|
+
@mixin <%= name %>-spans {
|
4
|
+
@include spaceless;
|
5
|
+
margin-right: <%= name %>-gutter-x(-1);
|
6
|
+
|
7
|
+
& > * {
|
8
|
+
display: inline-block;
|
9
|
+
vertical-align: top;
|
10
|
+
margin-right: <%= name %>-gutter-x(1);
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
.<%= name %>-spans { @include <%= name %>-spans; }
|
15
|
+
|
16
|
+
@for $i from 1 through $<%= name %>-modules-x-count {
|
17
|
+
.<%= name %>-spans .span#{$i} { width: <%= name %>-modules-x($i); }
|
18
|
+
.<%= name %>-spans .gap#{$i} { padding-left: <%= name %>-modules-gap-x($i); }
|
19
|
+
}
|
data/lib/spans/version.rb
CHANGED
data/lib/spans.rb
CHANGED
@@ -1,5 +1,18 @@
|
|
1
1
|
require "spans/engine"
|
2
|
+
require 'spans/importer'
|
2
3
|
require "spans/version"
|
3
4
|
|
4
5
|
module Spans
|
6
|
+
# def self.load_paths
|
7
|
+
# [
|
8
|
+
# File.expand_path('../../app/assets/javascripts/', __FILE__),
|
9
|
+
# ]
|
10
|
+
# end
|
11
|
+
|
12
|
+
# if defined? Rails
|
13
|
+
# class Engine < ::Rails::Engine
|
14
|
+
# end
|
15
|
+
# end
|
16
|
+
|
17
|
+
Sass.load_paths << Importer.new('.')
|
5
18
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spans
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,40 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: spaceless
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- - '
|
19
|
+
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0
|
21
|
+
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- - '
|
27
|
+
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: grids
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.2'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.2'
|
30
46
|
description: Extremely simple scss grid system.
|
31
47
|
email:
|
32
48
|
- abc@oktoberliner.ru
|
@@ -34,11 +50,9 @@ executables: []
|
|
34
50
|
extensions: []
|
35
51
|
extra_rdoc_files: []
|
36
52
|
files:
|
37
|
-
- app/assets/javascripts/spans/hashgrid.js
|
38
|
-
- app/assets/javascripts/spans.js.coffee
|
39
|
-
- app/assets/stylesheets/spans/grid.css.scss
|
40
|
-
- app/assets/stylesheets/spans.css.scss
|
41
53
|
- lib/spans/engine.rb
|
54
|
+
- lib/spans/importer.rb
|
55
|
+
- lib/spans/spans.scss.erb
|
42
56
|
- lib/spans/version.rb
|
43
57
|
- lib/spans.rb
|
44
58
|
- MIT-LICENSE
|
@@ -58,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
72
|
version: '0'
|
59
73
|
segments:
|
60
74
|
- 0
|
61
|
-
hash:
|
75
|
+
hash: -892031560827161286
|
62
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
77
|
none: false
|
64
78
|
requirements:
|
@@ -67,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
81
|
version: '0'
|
68
82
|
segments:
|
69
83
|
- 0
|
70
|
-
hash:
|
84
|
+
hash: -892031560827161286
|
71
85
|
requirements: []
|
72
86
|
rubyforge_project:
|
73
87
|
rubygems_version: 1.8.23
|
@@ -1,424 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* hashgrid (jQuery version, adapters are on the way)
|
3
|
-
* http://github.com/dotjay/hashgrid
|
4
|
-
* Version 8, 06 Oct 2012
|
5
|
-
* Written by Jon Gibbins
|
6
|
-
*
|
7
|
-
* Contibutors:
|
8
|
-
* James Aitken, http://loonypandora.co.uk/
|
9
|
-
* Tom Arnold, http://www.tomarnold.de/
|
10
|
-
* Sean Coates, http://seancoates.com/
|
11
|
-
* Phil Dokas, http://jetless.org/
|
12
|
-
* Andrew Jaswa, http://andrewjaswa.com/
|
13
|
-
* Callum Macrae, http://lynx.io/
|
14
|
-
*/
|
15
|
-
|
16
|
-
/**
|
17
|
-
* @license Copyright 2011 Analog Coop Limited
|
18
|
-
*
|
19
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
20
|
-
* you may not use this file except in compliance with the License.
|
21
|
-
* You may obtain a copy of the License at
|
22
|
-
*
|
23
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
24
|
-
*
|
25
|
-
* Unless required by applicable law or agreed to in writing, software
|
26
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
27
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
28
|
-
* See the License for the specific language governing permissions and
|
29
|
-
* limitations under the License.
|
30
|
-
*/
|
31
|
-
|
32
|
-
/**
|
33
|
-
* Usage
|
34
|
-
*
|
35
|
-
* // The basic #grid setup looks like this
|
36
|
-
* var grid = new hashgrid();
|
37
|
-
*
|
38
|
-
* // But there are a whole bunch of additional options you can set
|
39
|
-
* var grid = new hashgrid({
|
40
|
-
* id: 'mygrid', // set a custom id for the grid container
|
41
|
-
* modifierKey: 'alt', // optional 'ctrl', 'alt' or 'shift'
|
42
|
-
* showGridKey: 's', // key to show the grid
|
43
|
-
* holdGridKey: 'enter', // key to hold the grid in place
|
44
|
-
* foregroundKey: 'f', // key to toggle foreground/background
|
45
|
-
* jumpGridsKey: 'd', // key to cycle through the grid classes
|
46
|
-
* numberOfGrids: 2, // number of grid classes used
|
47
|
-
* classPrefix: 'myclass', // prefix for the grid classes
|
48
|
-
* cookiePrefix: 'mygrid' // prefix for the cookie name
|
49
|
-
* });
|
50
|
-
*/
|
51
|
-
|
52
|
-
|
53
|
-
/**
|
54
|
-
* Make sure we have the library
|
55
|
-
* TODO: Use an adapter
|
56
|
-
*/
|
57
|
-
if (typeof jQuery == "undefined") {
|
58
|
-
alert("Hashgrid: jQuery not loaded. Make sure it's linked to your pages.");
|
59
|
-
}
|
60
|
-
|
61
|
-
|
62
|
-
/**
|
63
|
-
* hashgrid overlay
|
64
|
-
* @constructor
|
65
|
-
*/
|
66
|
-
spans = {};
|
67
|
-
spans.hashgrid = function(set) {
|
68
|
-
|
69
|
-
var options = {
|
70
|
-
id: 'grid', // id for the grid container
|
71
|
-
modifierKey: null, // optional 'ctrl', 'alt' or 'shift'
|
72
|
-
showGridKey: 'g', // key to show the grid
|
73
|
-
holdGridKey: 'h', // key to hold the grid in place
|
74
|
-
foregroundKey: 'f', // key to toggle foreground/background
|
75
|
-
jumpGridsKey: 'j', // key to cycle through the grid classes
|
76
|
-
numberOfGrids: 1, // number of grid classes used
|
77
|
-
classPrefix: 'grid-', // prefix for the grid classes
|
78
|
-
cookiePrefix: 'hashgrid', // prefix for the cookie name
|
79
|
-
container: $('body')
|
80
|
-
},
|
81
|
-
alreadyDown,
|
82
|
-
classNumber = 1,
|
83
|
-
gridLines,
|
84
|
-
gridWidth,
|
85
|
-
i,
|
86
|
-
line,
|
87
|
-
lineHeight,
|
88
|
-
numGridLines,
|
89
|
-
overlay,
|
90
|
-
overlayCookie,
|
91
|
-
overlayEl,
|
92
|
-
overlayOn = false,
|
93
|
-
overlayVert,
|
94
|
-
overlayZState = 'B',
|
95
|
-
overlayZBackground = -1,
|
96
|
-
overlayZForeground = 9999,
|
97
|
-
pageHeight,
|
98
|
-
setKey,
|
99
|
-
state,
|
100
|
-
sticky = false,
|
101
|
-
top;
|
102
|
-
|
103
|
-
// Apply options
|
104
|
-
if (typeof set == 'object') {
|
105
|
-
for (setKey in set) {
|
106
|
-
options[setKey] = set[setKey];
|
107
|
-
}
|
108
|
-
}
|
109
|
-
else if (typeof set == 'string') {
|
110
|
-
options.id = set;
|
111
|
-
}
|
112
|
-
|
113
|
-
// Remove any conflicting overlay
|
114
|
-
if ($('#' + options.id).length > 0) {
|
115
|
-
$('#' + options.id).remove();
|
116
|
-
}
|
117
|
-
|
118
|
-
// Create overlay, hidden before adding to DOM
|
119
|
-
overlayEl = $('<div></div>');
|
120
|
-
overlayEl
|
121
|
-
.attr('id', options.id)
|
122
|
-
.css({
|
123
|
-
display: 'none',
|
124
|
-
pointerEvents: 'none'
|
125
|
-
});
|
126
|
-
options.container.prepend(overlayEl);
|
127
|
-
overlay = $('#' + options.id);
|
128
|
-
|
129
|
-
// Unless a custom z-index is set, ensure the overlay will be behind everything
|
130
|
-
if (overlay.css('z-index') == 'auto') overlay.css('z-index', overlayZBackground);
|
131
|
-
|
132
|
-
// Override the default overlay height with the actual page height
|
133
|
-
pageHeight = parseFloat($(document).height());
|
134
|
-
overlay.height(pageHeight);
|
135
|
-
|
136
|
-
// Add the first grid line so that we can measure it
|
137
|
-
overlay.append('<div id="' + options.id + '-horiz" class="horiz first-line">');
|
138
|
-
|
139
|
-
// Position off-screen and display to calculate height
|
140
|
-
top = overlay.css("top");
|
141
|
-
overlay.css({
|
142
|
-
top: '-999px',
|
143
|
-
display: 'block'
|
144
|
-
});
|
145
|
-
|
146
|
-
// Calculate the number of grid lines needed
|
147
|
-
line = $('#' + options.id + '-horiz');
|
148
|
-
lineHeight = line.outerHeight();
|
149
|
-
|
150
|
-
// Hide and reset top
|
151
|
-
overlay.css({
|
152
|
-
display: 'none',
|
153
|
-
top: top
|
154
|
-
});
|
155
|
-
|
156
|
-
// Break on zero line height
|
157
|
-
if (lineHeight <= 0) {
|
158
|
-
return false;
|
159
|
-
}
|
160
|
-
|
161
|
-
// Add the remaining grid lines
|
162
|
-
numGridLines = Math.floor(pageHeight / lineHeight);
|
163
|
-
gridLines = '';
|
164
|
-
|
165
|
-
for (i = numGridLines - 1; i >= 1; i--) {
|
166
|
-
gridLines += '<div class="horiz"></div>';
|
167
|
-
}
|
168
|
-
overlay.append(gridLines);
|
169
|
-
|
170
|
-
// vertical grid
|
171
|
-
overlay.append($('<div class="vert-container"></div>'));
|
172
|
-
overlayVert = overlay.children('.vert-container');
|
173
|
-
gridWidth = overlay.width();
|
174
|
-
overlayVert.css({width: gridWidth, position: 'absolute', top: 0});
|
175
|
-
overlayVert.append('<div class="vert first-line"> </div>');
|
176
|
-
|
177
|
-
// 30 is an arbitrarily large number...
|
178
|
-
// can't calculate the margin width properly
|
179
|
-
gridLines = '';
|
180
|
-
for (i = 0; i < 30; i++) {
|
181
|
-
gridLines += '<div class="vert"> </div>';
|
182
|
-
}
|
183
|
-
overlayVert.append(gridLines);
|
184
|
-
overlayVert.children()
|
185
|
-
.height(pageHeight)
|
186
|
-
.css({ display: 'inline-block' });
|
187
|
-
|
188
|
-
// Check for saved state
|
189
|
-
overlayCookie = readCookie(options.cookiePrefix + options.id);
|
190
|
-
if (typeof overlayCookie == 'string') {
|
191
|
-
state = overlayCookie.split('-');
|
192
|
-
state[2] = Number(state[2]);
|
193
|
-
if ((typeof state[2] == 'number') && !isNaN(state[2])) {
|
194
|
-
classNumber = state[2].toFixed(0);
|
195
|
-
overlay.addClass(options.classPrefix + classNumber);
|
196
|
-
}
|
197
|
-
if (state[1] == 'F') {
|
198
|
-
overlayZState = 'F';
|
199
|
-
overlay.css('z-index', overlayZForeground);
|
200
|
-
}
|
201
|
-
if (state[0] == '1') {
|
202
|
-
overlayOn = true;
|
203
|
-
sticky = true;
|
204
|
-
showOverlay();
|
205
|
-
}
|
206
|
-
}
|
207
|
-
else {
|
208
|
-
overlay.addClass(options.classPrefix + classNumber);
|
209
|
-
}
|
210
|
-
|
211
|
-
// Keyboard controls
|
212
|
-
$(document).bind('keydown', keydownHandler);
|
213
|
-
$(document).bind('keyup', keyupHandler);
|
214
|
-
|
215
|
-
/**
|
216
|
-
* Helpers
|
217
|
-
*/
|
218
|
-
|
219
|
-
function getModifier(e) {
|
220
|
-
if (options.modifierKey == null) return true; // Bypass by default
|
221
|
-
var m = true;
|
222
|
-
switch(options.modifierKey) {
|
223
|
-
case 'ctrl':
|
224
|
-
m = (e.ctrlKey ? e.ctrlKey : false);
|
225
|
-
break;
|
226
|
-
|
227
|
-
case 'alt':
|
228
|
-
m = (e.altKey ? e.altKey : false);
|
229
|
-
break;
|
230
|
-
|
231
|
-
case 'shift':
|
232
|
-
m = (e.shiftKey ? e.shiftKey : false);
|
233
|
-
break;
|
234
|
-
}
|
235
|
-
return m;
|
236
|
-
}
|
237
|
-
|
238
|
-
function getKey(e) {
|
239
|
-
var k = false, c = (e.keyCode ? e.keyCode : e.which);
|
240
|
-
// Handle keywords
|
241
|
-
if (c == 13) k = 'enter';
|
242
|
-
// Handle letters
|
243
|
-
else k = String.fromCharCode(c).toLowerCase();
|
244
|
-
return k;
|
245
|
-
}
|
246
|
-
|
247
|
-
function saveState() {
|
248
|
-
createCookie(options.cookiePrefix + options.id, (sticky ? '1' : '0') + '-' + overlayZState + '-' + classNumber, 1);
|
249
|
-
}
|
250
|
-
|
251
|
-
function showOverlay() {
|
252
|
-
overlay.show();
|
253
|
-
overlayVert.css({width: overlay.width()});
|
254
|
-
// hide any vertical blocks that aren't at the top of the viewport
|
255
|
-
overlayVert.children('.vert').each(function () {
|
256
|
-
var vCol = $(this);
|
257
|
-
vCol.css('display','inline-block');
|
258
|
-
if (vCol.offset().top > vCol.parent().offset().top) {
|
259
|
-
vCol.hide();
|
260
|
-
}
|
261
|
-
});
|
262
|
-
}
|
263
|
-
|
264
|
-
/**
|
265
|
-
* Event handlers
|
266
|
-
*/
|
267
|
-
|
268
|
-
alreadyDown = {};
|
269
|
-
|
270
|
-
function keydownHandler(e) {
|
271
|
-
var k,
|
272
|
-
m,
|
273
|
-
source = e.target.tagName.toLowerCase();
|
274
|
-
|
275
|
-
if ((source == 'input') || (source == 'textarea') || (source == 'select')) {
|
276
|
-
return true;
|
277
|
-
}
|
278
|
-
|
279
|
-
m = getModifier(e);
|
280
|
-
if (!m) {
|
281
|
-
return true;
|
282
|
-
}
|
283
|
-
|
284
|
-
k = getKey(e);
|
285
|
-
if (!k) {
|
286
|
-
return true;
|
287
|
-
}
|
288
|
-
|
289
|
-
if (alreadyDown[k]) {
|
290
|
-
return true;
|
291
|
-
}
|
292
|
-
alreadyDown[k] = true;
|
293
|
-
|
294
|
-
switch(k) {
|
295
|
-
case options.showGridKey:
|
296
|
-
if (!overlayOn) {
|
297
|
-
showOverlay();
|
298
|
-
overlayOn = true;
|
299
|
-
}
|
300
|
-
else if (sticky) {
|
301
|
-
overlay.hide();
|
302
|
-
overlayOn = false;
|
303
|
-
sticky = false;
|
304
|
-
saveState();
|
305
|
-
}
|
306
|
-
break;
|
307
|
-
case options.holdGridKey:
|
308
|
-
if (overlayOn && !sticky) {
|
309
|
-
// Turn sticky overlay on
|
310
|
-
sticky = true;
|
311
|
-
saveState();
|
312
|
-
}
|
313
|
-
break;
|
314
|
-
case options.foregroundKey:
|
315
|
-
if (overlayOn) {
|
316
|
-
// Toggle sticky overlay z-index
|
317
|
-
if (overlay.css('z-index') == overlayZForeground) {
|
318
|
-
overlay.css('z-index', overlayZBackground);
|
319
|
-
overlayZState = 'B';
|
320
|
-
}
|
321
|
-
else {
|
322
|
-
overlay.css('z-index', overlayZForeground);
|
323
|
-
overlayZState = 'F';
|
324
|
-
}
|
325
|
-
saveState();
|
326
|
-
}
|
327
|
-
break;
|
328
|
-
case options.jumpGridsKey:
|
329
|
-
if (overlayOn && (options.numberOfGrids > 1)) {
|
330
|
-
// Cycle through the available grids
|
331
|
-
overlay.removeClass(options.classPrefix + classNumber);
|
332
|
-
classNumber++;
|
333
|
-
if (classNumber > options.numberOfGrids) classNumber = 1;
|
334
|
-
overlay.addClass(options.classPrefix + classNumber);
|
335
|
-
showOverlay();
|
336
|
-
if (/webkit/.test( navigator.userAgent.toLowerCase() )) {
|
337
|
-
forceRepaint();
|
338
|
-
}
|
339
|
-
saveState();
|
340
|
-
}
|
341
|
-
break;
|
342
|
-
}
|
343
|
-
|
344
|
-
return true;
|
345
|
-
}
|
346
|
-
|
347
|
-
function keyupHandler(e) {
|
348
|
-
var k,
|
349
|
-
m = getModifier(e);
|
350
|
-
|
351
|
-
if (!m) {
|
352
|
-
return true;
|
353
|
-
}
|
354
|
-
|
355
|
-
k = getKey(e);
|
356
|
-
alreadyDown[k] = false;
|
357
|
-
|
358
|
-
if (k && (k == options.showGridKey) && !sticky) {
|
359
|
-
overlay.hide();
|
360
|
-
overlayOn = false;
|
361
|
-
}
|
362
|
-
|
363
|
-
return true;
|
364
|
-
}
|
365
|
-
|
366
|
-
/**
|
367
|
-
* Cookie functions
|
368
|
-
*
|
369
|
-
* By Peter-Paul Koch:
|
370
|
-
* http://www.quirksmode.org/js/cookies.html
|
371
|
-
*/
|
372
|
-
function createCookie(name, value, days) {
|
373
|
-
var date,
|
374
|
-
expires = "";
|
375
|
-
|
376
|
-
if (days) {
|
377
|
-
date = new Date();
|
378
|
-
date.setTime( date.getTime() + (days*24*60*60*1000) );
|
379
|
-
expires = "; expires=" + date.toGMTString();
|
380
|
-
}
|
381
|
-
|
382
|
-
document.cookie = name + "=" + value + expires + "; path=/";
|
383
|
-
}
|
384
|
-
|
385
|
-
function readCookie(name) {
|
386
|
-
var c,
|
387
|
-
ca = document.cookie.split(';'),
|
388
|
-
i = 0,
|
389
|
-
len = ca.length,
|
390
|
-
nameEQ = name + "=";
|
391
|
-
|
392
|
-
for (; i < len; i++) {
|
393
|
-
c = ca[i];
|
394
|
-
|
395
|
-
while (c.charAt(0) == ' ') {
|
396
|
-
c = c.substring(1, c.length);
|
397
|
-
}
|
398
|
-
|
399
|
-
if (c.indexOf(nameEQ) == 0) {
|
400
|
-
return c.substring(nameEQ.length, c.length);
|
401
|
-
}
|
402
|
-
}
|
403
|
-
return null;
|
404
|
-
}
|
405
|
-
|
406
|
-
function eraseCookie(name) {
|
407
|
-
createCookie(name, "", -1);
|
408
|
-
}
|
409
|
-
|
410
|
-
/**
|
411
|
-
* Forces a repaint (because WebKit has issues)
|
412
|
-
* http://www.sitepoint.com/forums/showthread.php?p=4538763
|
413
|
-
* http://www.phpied.com/the-new-game-show-will-it-reflow/
|
414
|
-
*/
|
415
|
-
function forceRepaint() {
|
416
|
-
var ss = document.styleSheets[0];
|
417
|
-
try {
|
418
|
-
ss.addRule('.xxxxxx', 'position: relative');
|
419
|
-
ss.removeRule(ss.rules.length - 1);
|
420
|
-
} catch(e) {}
|
421
|
-
}
|
422
|
-
|
423
|
-
return {};
|
424
|
-
};
|
@@ -1,49 +0,0 @@
|
|
1
|
-
# = require spans/hashgrid
|
2
|
-
|
3
|
-
class spans.Helper
|
4
|
-
constructor: (options) -> @grid = new spans.hashgrid(options)
|
5
|
-
|
6
|
-
class spans.Flexgrid
|
7
|
-
constructor: (@sampleFontSize, @sampleAtomWidth, @sampleAtomHeight, @modulesXCount, @modulesYCount) ->
|
8
|
-
@ratio = (@modulesYCount * @sampleAtomHeight) / (@modulesXCount * @sampleAtomWidth)
|
9
|
-
@heightToFontSize = (@modulesYCount * @sampleAtomHeight) / @sampleFontSize
|
10
|
-
$(window).resize @newFontSize
|
11
|
-
@newFontSize()
|
12
|
-
|
13
|
-
newFontSize: =>
|
14
|
-
min = Math.min($(window).innerHeight(), $(window).innerWidth() * @ratio)
|
15
|
-
fontSize = min / @heightToFontSize
|
16
|
-
$('body').css(fontSize: "#{fontSize}px")
|
17
|
-
|
18
|
-
|
19
|
-
# new spans.ToWidthFitter(16 / 1024)
|
20
|
-
class spans.ToWidthFitter
|
21
|
-
constructor: (@sampleFontToSampleWidth) ->
|
22
|
-
$(window).resize @newFontSize
|
23
|
-
@newFontSize()
|
24
|
-
|
25
|
-
newFontSize: =>
|
26
|
-
|
27
|
-
console.log($(window).innerHeight() * @sampleFontToSampleWidth)
|
28
|
-
$('html').css(fontSize: "#{$(window).innerWidth() * @sampleFontToSampleWidth}px")
|
29
|
-
|
30
|
-
# new spans.ToHeightFitter(16 / 768)
|
31
|
-
class spans.ToHeightFitter
|
32
|
-
constructor: (@sampleFontToSampleHeight) ->
|
33
|
-
$(window).resize @newFontSize
|
34
|
-
@newFontSize()
|
35
|
-
|
36
|
-
newFontSize: =>
|
37
|
-
$('html').css(fontSize: "#{$(window).innerHeight() * @sampleFontToSampleHeight}px")
|
38
|
-
|
39
|
-
|
40
|
-
# new spans.ToWindowFitter(16 / 768, 1024 / 768)
|
41
|
-
class spans.ToWindowFitter
|
42
|
-
constructor: (@sampleFontToSampleHeight, @sampleWidthToSampleHeight) ->
|
43
|
-
$(window).resize @newFontSize
|
44
|
-
@newFontSize()
|
45
|
-
|
46
|
-
newFontSize: =>
|
47
|
-
min = Math.min($(window).innerHeight(), $(window).innerWidth() / @sampleWidthToSampleHeight)
|
48
|
-
fontSize = min * @sampleFontToSampleHeight
|
49
|
-
$('html').css(fontSize: "#{fontSize}px")
|
@@ -1,25 +0,0 @@
|
|
1
|
-
// based on http://hashgrid.com/
|
2
|
-
|
3
|
-
#grid {
|
4
|
-
width: modules-x($modules-x-count);
|
5
|
-
position: absolute;
|
6
|
-
top: 0;
|
7
|
-
left: 0;
|
8
|
-
overflow: hidden;
|
9
|
-
|
10
|
-
.vert-container {
|
11
|
-
@extend .spans;
|
12
|
-
}
|
13
|
-
.vert{
|
14
|
-
@extend .span1;
|
15
|
-
box-sizing: border-box;
|
16
|
-
background: rgba(255, 0, 0, 0.1);
|
17
|
-
}
|
18
|
-
|
19
|
-
.horiz{
|
20
|
-
height: y(1);
|
21
|
-
box-sizing: border-box;
|
22
|
-
background: rgba(255, 0, 0, 0.1);
|
23
|
-
margin-bottom: y(1);
|
24
|
-
}
|
25
|
-
}
|
@@ -1,47 +0,0 @@
|
|
1
|
-
@import 'inline-blocks';
|
2
|
-
|
3
|
-
@function x($t: 1) { @return $atom-x * $t; }
|
4
|
-
@function y($t: 1) { @return $atom-y * $t; }
|
5
|
-
@function gutter-x($t: 1) { @return $gutter-x * $t; }
|
6
|
-
@function gutter-y($t: 1) { @return $gutter-y * $t; }
|
7
|
-
@function modules-x($m) { @return x($module-width * $m) + gutter-x($m - 1); }
|
8
|
-
@function modules-y($m) { @return y($module-height * $m) + gutter-y($m - 1); }
|
9
|
-
@function modules-gap-x($m) { @return modules-x($m) + gutter-x(1); }
|
10
|
-
@function modules-gap-y($m) { @return modules-y($m) + gutter-y(1); }
|
11
|
-
@function full-page-width() { @return modules-x($modules-x-count) }
|
12
|
-
|
13
|
-
@mixin spans {
|
14
|
-
@include inline-blocks;
|
15
|
-
margin-right: -1 * gutter-x(1);
|
16
|
-
|
17
|
-
& > * {
|
18
|
-
@include inline-block;
|
19
|
-
margin-right: gutter-x(1);
|
20
|
-
}
|
21
|
-
}
|
22
|
-
|
23
|
-
@mixin size-scale($times) {
|
24
|
-
$atom-y: $atom-y / $times;
|
25
|
-
$atom-x: $atom-x / $times;
|
26
|
-
@content;
|
27
|
-
$atom-y: $atom-y * $times;
|
28
|
-
$atom-x: $atom-x * $times;
|
29
|
-
}
|
30
|
-
|
31
|
-
// deprecated
|
32
|
-
@mixin flex-grid-scale($times) {
|
33
|
-
font-size: #{$times}em;
|
34
|
-
@include size-scale { @content; }
|
35
|
-
}
|
36
|
-
|
37
|
-
.spans { @include spans; }
|
38
|
-
|
39
|
-
@for $i from 1 through $modules-x-count {
|
40
|
-
.spans .span#{$i} { width: modules-x($i); }
|
41
|
-
}
|
42
|
-
|
43
|
-
@for $i from 1 through $modules-x-count {
|
44
|
-
.spans .gap#{$i} { padding-left: modules-gap-x($i); }
|
45
|
-
}
|
46
|
-
|
47
|
-
@import 'spans/grid';
|