foundation-rails 5.0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/app/controllers/foundation/rails/styleguide_controller.rb +10 -0
- data/app/views/foundation/rails/styleguide/show.html.erb +134 -0
- data/config/routes.rb +3 -0
- data/foundation-rails.gemspec +25 -0
- data/lib/foundation-rails.rb +1 -0
- data/lib/foundation/rails.rb +3 -0
- data/lib/foundation/rails/engine.rb +7 -0
- data/lib/foundation/rails/generators/install_generator.rb +56 -0
- data/lib/foundation/rails/templates/application.html.erb +19 -0
- data/lib/foundation/rails/templates/application.html.haml +18 -0
- data/lib/foundation/rails/templates/application.html.slim +17 -0
- data/lib/foundation/rails/version.rb +5 -0
- data/test/dummy/.gitignore +16 -0
- data/test/dummy/Gemfile +47 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +8 -0
- data/test/dummy/app/assets/stylesheets/application.css +4 -0
- data/test/dummy/app/assets/stylesheets/foundation_and_overrides.scss +4 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/controllers/styleguide_controller.rb +4 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/helpers/styleguide_helper.rb +2 -0
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +19 -0
- data/test/dummy/app/views/styleguide/show.html.erb +109 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +4 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +29 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +36 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +12 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/db/seeds.rb +7 -0
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/lib/tasks/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +58 -0
- data/test/dummy/public/422.html +58 -0
- data/test/dummy/public/500.html +57 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/public/robots.txt +5 -0
- data/test/dummy/test/controllers/.keep +0 -0
- data/test/dummy/test/controllers/styleguide_controller_test.rb +9 -0
- data/test/dummy/test/fixtures/.keep +0 -0
- data/test/dummy/test/helpers/.keep +0 -0
- data/test/dummy/test/helpers/styleguide_helper_test.rb +4 -0
- data/test/dummy/test/integration/.keep +0 -0
- data/test/dummy/test/mailers/.keep +0 -0
- data/test/dummy/test/models/.keep +0 -0
- data/test/dummy/test/test_helper.rb +15 -0
- data/test/dummy/vendor/assets/javascripts/.keep +0 -0
- data/test/dummy/vendor/assets/stylesheets/.keep +0 -0
- data/vendor/_settings.scss +992 -0
- data/vendor/assets/javascripts/foundation.js +15 -0
- data/vendor/assets/javascripts/foundation/foundation.abide.js +201 -0
- data/vendor/assets/javascripts/foundation/foundation.accordion.js +41 -0
- data/vendor/assets/javascripts/foundation/foundation.alert.js +34 -0
- data/vendor/assets/javascripts/foundation/foundation.clearing.js +450 -0
- data/vendor/assets/javascripts/foundation/foundation.dropdown.js +184 -0
- data/vendor/assets/javascripts/foundation/foundation.interchange.js +304 -0
- data/vendor/assets/javascripts/foundation/foundation.joyride.js +839 -0
- data/vendor/assets/javascripts/foundation/foundation.js +416 -0
- data/vendor/assets/javascripts/foundation/foundation.magellan.js +118 -0
- data/vendor/assets/javascripts/foundation/foundation.offcanvas.js +37 -0
- data/vendor/assets/javascripts/foundation/foundation.orbit.js +434 -0
- data/vendor/assets/javascripts/foundation/foundation.reveal.js +347 -0
- data/vendor/assets/javascripts/foundation/foundation.tab.js +37 -0
- data/vendor/assets/javascripts/foundation/foundation.tooltip.js +202 -0
- data/vendor/assets/javascripts/foundation/foundation.topbar.js +380 -0
- data/vendor/assets/javascripts/vendor/modernizr.js +4 -0
- data/vendor/assets/stylesheets/foundation.scss +38 -0
- data/vendor/assets/stylesheets/foundation/_functions.scss +75 -0
- data/vendor/assets/stylesheets/foundation/_settings.scss +992 -0
- data/vendor/assets/stylesheets/foundation/components/_accordion.scss +49 -0
- data/vendor/assets/stylesheets/foundation/components/_alert-boxes.scss +113 -0
- data/vendor/assets/stylesheets/foundation/components/_block-grid.scss +83 -0
- data/vendor/assets/stylesheets/foundation/components/_breadcrumbs.scss +123 -0
- data/vendor/assets/stylesheets/foundation/components/_button-groups.scss +97 -0
- data/vendor/assets/stylesheets/foundation/components/_buttons.scss +234 -0
- data/vendor/assets/stylesheets/foundation/components/_clearing.scss +233 -0
- data/vendor/assets/stylesheets/foundation/components/_dropdown-buttons.scss +125 -0
- data/vendor/assets/stylesheets/foundation/components/_dropdown.scss +159 -0
- data/vendor/assets/stylesheets/foundation/components/_flex-video.scss +47 -0
- data/vendor/assets/stylesheets/foundation/components/_forms.scss +472 -0
- data/vendor/assets/stylesheets/foundation/components/_functions.scss +70 -0
- data/vendor/assets/stylesheets/foundation/components/_global.scss +387 -0
- data/vendor/assets/stylesheets/foundation/components/_grid.scss +234 -0
- data/vendor/assets/stylesheets/foundation/components/_inline-lists.scss +52 -0
- data/vendor/assets/stylesheets/foundation/components/_joyride.scss +220 -0
- data/vendor/assets/stylesheets/foundation/components/_keystrokes.scss +57 -0
- data/vendor/assets/stylesheets/foundation/components/_labels.scss +100 -0
- data/vendor/assets/stylesheets/foundation/components/_magellan.scss +30 -0
- data/vendor/assets/stylesheets/foundation/components/_offcanvas.scss +360 -0
- data/vendor/assets/stylesheets/foundation/components/_orbit.scss +353 -0
- data/vendor/assets/stylesheets/foundation/components/_pagination.scss +145 -0
- data/vendor/assets/stylesheets/foundation/components/_panels.scss +87 -0
- data/vendor/assets/stylesheets/foundation/components/_pricing-tables.scss +146 -0
- data/vendor/assets/stylesheets/foundation/components/_progress-bars.scss +75 -0
- data/vendor/assets/stylesheets/foundation/components/_reveal.scss +165 -0
- data/vendor/assets/stylesheets/foundation/components/_side-nav.scss +83 -0
- data/vendor/assets/stylesheets/foundation/components/_split-buttons.scss +187 -0
- data/vendor/assets/stylesheets/foundation/components/_sub-nav.scss +118 -0
- data/vendor/assets/stylesheets/foundation/components/_switch.scss +314 -0
- data/vendor/assets/stylesheets/foundation/components/_tables.scss +93 -0
- data/vendor/assets/stylesheets/foundation/components/_tabs.scss +95 -0
- data/vendor/assets/stylesheets/foundation/components/_thumbs.scss +71 -0
- data/vendor/assets/stylesheets/foundation/components/_tooltips.scss +121 -0
- data/vendor/assets/stylesheets/foundation/components/_top-bar.scss +590 -0
- data/vendor/assets/stylesheets/foundation/components/_type.scss +447 -0
- data/vendor/assets/stylesheets/foundation/components/_visibility.scss +661 -0
- data/vendor/assets/stylesheets/normalize.scss +410 -0
- metadata +292 -0
@@ -0,0 +1,184 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.dropdown = {
|
5
|
+
name : 'dropdown',
|
6
|
+
|
7
|
+
version : '5.0.0',
|
8
|
+
|
9
|
+
settings : {
|
10
|
+
active_class: 'open',
|
11
|
+
is_hover: false,
|
12
|
+
opened: function(){},
|
13
|
+
closed: function(){}
|
14
|
+
},
|
15
|
+
|
16
|
+
init : function (scope, method, options) {
|
17
|
+
Foundation.inherit(this, 'throttle');
|
18
|
+
|
19
|
+
this.bindings(method, options);
|
20
|
+
},
|
21
|
+
|
22
|
+
events : function (scope) {
|
23
|
+
var self = this;
|
24
|
+
|
25
|
+
$(this.scope)
|
26
|
+
.off('.dropdown')
|
27
|
+
.on('click.fndtn.dropdown', '[data-dropdown]', function (e) {
|
28
|
+
var settings = $(this).data('dropdown-init');
|
29
|
+
e.preventDefault();
|
30
|
+
|
31
|
+
if (!settings.is_hover || Modernizr.touch) self.toggle($(this));
|
32
|
+
})
|
33
|
+
.on('mouseenter.fndtn.dropdown', '[data-dropdown], [data-dropdown-content]', function (e) {
|
34
|
+
var $this = $(this);
|
35
|
+
clearTimeout(self.timeout);
|
36
|
+
|
37
|
+
if ($this.data('dropdown')) {
|
38
|
+
var dropdown = $('#' + $this.data('dropdown')),
|
39
|
+
target = $this;
|
40
|
+
} else {
|
41
|
+
var dropdown = $this;
|
42
|
+
target = $("[data-dropdown='" + dropdown.attr('id') + "']");
|
43
|
+
}
|
44
|
+
|
45
|
+
var settings = target.data('dropdown-init');
|
46
|
+
if (settings.is_hover) self.open.apply(self, [dropdown, target]);
|
47
|
+
})
|
48
|
+
.on('mouseleave.fndtn.dropdown', '[data-dropdown], [data-dropdown-content]', function (e) {
|
49
|
+
var $this = $(this);
|
50
|
+
self.timeout = setTimeout(function () {
|
51
|
+
if ($this.data('dropdown')) {
|
52
|
+
var settings = $this.data('dropdown-init');
|
53
|
+
if (settings.is_hover) self.close.call(self, $('#' + $this.data('dropdown')));
|
54
|
+
} else {
|
55
|
+
var target = $('[data-dropdown="' + $(this).attr('id') + '"]'),
|
56
|
+
settings = target.data('dropdown-init');
|
57
|
+
if (settings.is_hover) self.close.call(self, $this);
|
58
|
+
}
|
59
|
+
}.bind(this), 150);
|
60
|
+
})
|
61
|
+
.on('click.fndtn.dropdown', function (e) {
|
62
|
+
var parent = $(e.target).closest('[data-dropdown-content]');
|
63
|
+
|
64
|
+
if ($(e.target).data('dropdown') || $(e.target).parent().data('dropdown')) {
|
65
|
+
return;
|
66
|
+
}
|
67
|
+
if (!($(e.target).data('revealId')) &&
|
68
|
+
(parent.length > 0 && ($(e.target).is('[data-dropdown-content]') ||
|
69
|
+
$.contains(parent.first()[0], e.target)))) {
|
70
|
+
e.stopPropagation();
|
71
|
+
return;
|
72
|
+
}
|
73
|
+
|
74
|
+
self.close.call(self, $('[data-dropdown-content]'));
|
75
|
+
})
|
76
|
+
.on('opened.fndtn.dropdown', '[data-dropdown-content]', this.settings.opened)
|
77
|
+
.on('closed.fndtn.dropdown', '[data-dropdown-content]', this.settings.closed);
|
78
|
+
|
79
|
+
$(window)
|
80
|
+
.off('.dropdown')
|
81
|
+
.on('resize.fndtn.dropdown', self.throttle(function () {
|
82
|
+
self.resize.call(self);
|
83
|
+
}, 50)).trigger('resize');
|
84
|
+
},
|
85
|
+
|
86
|
+
close: function (dropdown) {
|
87
|
+
var self = this;
|
88
|
+
dropdown.each(function () {
|
89
|
+
if ($(this).hasClass(self.settings.active_class)) {
|
90
|
+
$(this)
|
91
|
+
.css(Foundation.rtl ? 'right':'left', '-99999px')
|
92
|
+
.removeClass(self.settings.active_class);
|
93
|
+
$(this).trigger('closed');
|
94
|
+
}
|
95
|
+
});
|
96
|
+
},
|
97
|
+
|
98
|
+
open: function (dropdown, target) {
|
99
|
+
this
|
100
|
+
.css(dropdown
|
101
|
+
.addClass(this.settings.active_class), target);
|
102
|
+
dropdown.trigger('opened');
|
103
|
+
},
|
104
|
+
|
105
|
+
toggle : function (target) {
|
106
|
+
var dropdown = $('#' + target.data('dropdown'));
|
107
|
+
if (dropdown.length === 0) {
|
108
|
+
// No dropdown found, not continuing
|
109
|
+
return;
|
110
|
+
}
|
111
|
+
|
112
|
+
this.close.call(this, $('[data-dropdown-content]').not(dropdown));
|
113
|
+
|
114
|
+
if (dropdown.hasClass(this.settings.active_class)) {
|
115
|
+
this.close.call(this, dropdown);
|
116
|
+
} else {
|
117
|
+
this.close.call(this, $('[data-dropdown-content]'))
|
118
|
+
this.open.call(this, dropdown, target);
|
119
|
+
}
|
120
|
+
},
|
121
|
+
|
122
|
+
resize : function () {
|
123
|
+
var dropdown = $('[data-dropdown-content].open'),
|
124
|
+
target = $("[data-dropdown='" + dropdown.attr('id') + "']");
|
125
|
+
|
126
|
+
if (dropdown.length && target.length) {
|
127
|
+
this.css(dropdown, target);
|
128
|
+
}
|
129
|
+
},
|
130
|
+
|
131
|
+
css : function (dropdown, target) {
|
132
|
+
var offset_parent = dropdown.offsetParent(),
|
133
|
+
position = target.offset();
|
134
|
+
|
135
|
+
position.top -= offset_parent.offset().top;
|
136
|
+
position.left -= offset_parent.offset().left;
|
137
|
+
|
138
|
+
if (this.small()) {
|
139
|
+
dropdown.css({
|
140
|
+
position : 'absolute',
|
141
|
+
width: '95%',
|
142
|
+
'max-width': 'none',
|
143
|
+
top: position.top + target.outerHeight()
|
144
|
+
});
|
145
|
+
dropdown.css(Foundation.rtl ? 'right':'left', '2.5%');
|
146
|
+
} else {
|
147
|
+
if (!Foundation.rtl && $(window).width() > dropdown.outerWidth() + target.offset().left) {
|
148
|
+
var left = position.left;
|
149
|
+
if (dropdown.hasClass('right')) {
|
150
|
+
dropdown.removeClass('right');
|
151
|
+
}
|
152
|
+
} else {
|
153
|
+
if (!dropdown.hasClass('right')) {
|
154
|
+
dropdown.addClass('right');
|
155
|
+
}
|
156
|
+
var left = position.left - (dropdown.outerWidth() - target.outerWidth());
|
157
|
+
}
|
158
|
+
|
159
|
+
dropdown.attr('style', '').css({
|
160
|
+
position : 'absolute',
|
161
|
+
top: position.top + target.outerHeight(),
|
162
|
+
left: left
|
163
|
+
});
|
164
|
+
}
|
165
|
+
|
166
|
+
return dropdown;
|
167
|
+
},
|
168
|
+
|
169
|
+
small : function () {
|
170
|
+
return matchMedia(Foundation.media_queries.small).matches &&
|
171
|
+
!matchMedia(Foundation.media_queries.medium).matches;
|
172
|
+
},
|
173
|
+
|
174
|
+
off: function () {
|
175
|
+
$(this.scope).off('.fndtn.dropdown');
|
176
|
+
$('html, body').off('.fndtn.dropdown');
|
177
|
+
$(window).off('.fndtn.dropdown');
|
178
|
+
$('[data-dropdown-content]').off('.fndtn.dropdown');
|
179
|
+
this.settings.init = false;
|
180
|
+
},
|
181
|
+
|
182
|
+
reflow : function () {}
|
183
|
+
};
|
184
|
+
}(jQuery, this, this.document));
|
@@ -0,0 +1,304 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
Foundation.libs.interchange = {
|
5
|
+
name : 'interchange',
|
6
|
+
|
7
|
+
version : '5.0.0',
|
8
|
+
|
9
|
+
cache : {},
|
10
|
+
|
11
|
+
images_loaded : false,
|
12
|
+
nodes_loaded : false,
|
13
|
+
|
14
|
+
settings : {
|
15
|
+
load_attr : 'interchange',
|
16
|
+
|
17
|
+
named_queries : {
|
18
|
+
'default' : Foundation.media_queries.small,
|
19
|
+
small : Foundation.media_queries.small,
|
20
|
+
medium : Foundation.media_queries.medium,
|
21
|
+
large : Foundation.media_queries.large,
|
22
|
+
xlarge : Foundation.media_queries.xlarge,
|
23
|
+
xxlarge: Foundation.media_queries.xxlarge,
|
24
|
+
landscape : 'only screen and (orientation: landscape)',
|
25
|
+
portrait : 'only screen and (orientation: portrait)',
|
26
|
+
retina : 'only screen and (-webkit-min-device-pixel-ratio: 2),' +
|
27
|
+
'only screen and (min--moz-device-pixel-ratio: 2),' +
|
28
|
+
'only screen and (-o-min-device-pixel-ratio: 2/1),' +
|
29
|
+
'only screen and (min-device-pixel-ratio: 2),' +
|
30
|
+
'only screen and (min-resolution: 192dpi),' +
|
31
|
+
'only screen and (min-resolution: 2dppx)'
|
32
|
+
},
|
33
|
+
|
34
|
+
directives : {
|
35
|
+
replace: function (el, path, trigger) {
|
36
|
+
// The trigger argument, if called within the directive, fires
|
37
|
+
// an event named after the directive on the element, passing
|
38
|
+
// any parameters along to the event that you pass to trigger.
|
39
|
+
//
|
40
|
+
// ex. trigger(), trigger([a, b, c]), or trigger(a, b, c)
|
41
|
+
//
|
42
|
+
// This allows you to bind a callback like so:
|
43
|
+
// $('#interchangeContainer').on('replace', function (e, a, b, c) {
|
44
|
+
// console.log($(this).html(), a, b, c);
|
45
|
+
// });
|
46
|
+
|
47
|
+
if (/IMG/.test(el[0].nodeName)) {
|
48
|
+
var orig_path = el[0].src;
|
49
|
+
|
50
|
+
if (new RegExp(path, 'i').test(orig_path)) return;
|
51
|
+
|
52
|
+
el[0].src = path;
|
53
|
+
|
54
|
+
return trigger(el[0].src);
|
55
|
+
}
|
56
|
+
var last_path = el.data('interchange-last-path');
|
57
|
+
|
58
|
+
if (last_path == path) return;
|
59
|
+
|
60
|
+
return $.get(path, function (response) {
|
61
|
+
el.html(response);
|
62
|
+
el.data('interchange-last-path', path);
|
63
|
+
trigger();
|
64
|
+
});
|
65
|
+
|
66
|
+
}
|
67
|
+
}
|
68
|
+
},
|
69
|
+
|
70
|
+
init : function (scope, method, options) {
|
71
|
+
Foundation.inherit(this, 'throttle');
|
72
|
+
|
73
|
+
this.data_attr = 'data-' + this.settings.load_attr;
|
74
|
+
|
75
|
+
this.bindings(method, options);
|
76
|
+
this.load('images');
|
77
|
+
this.load('nodes');
|
78
|
+
},
|
79
|
+
|
80
|
+
events : function () {
|
81
|
+
var self = this;
|
82
|
+
|
83
|
+
$(window)
|
84
|
+
.off('.interchange')
|
85
|
+
.on('resize.fndtn.interchange', self.throttle(function () {
|
86
|
+
self.resize.call(self);
|
87
|
+
}, 50));
|
88
|
+
|
89
|
+
return this;
|
90
|
+
},
|
91
|
+
|
92
|
+
resize : function () {
|
93
|
+
var cache = this.cache;
|
94
|
+
|
95
|
+
if(!this.images_loaded || !this.nodes_loaded) {
|
96
|
+
setTimeout($.proxy(this.resize, this), 50);
|
97
|
+
return;
|
98
|
+
}
|
99
|
+
|
100
|
+
for (var uuid in cache) {
|
101
|
+
if (cache.hasOwnProperty(uuid)) {
|
102
|
+
var passed = this.results(uuid, cache[uuid]);
|
103
|
+
|
104
|
+
if (passed) {
|
105
|
+
this.settings.directives[passed
|
106
|
+
.scenario[1]](passed.el, passed.scenario[0], function () {
|
107
|
+
if (arguments[0] instanceof Array) {
|
108
|
+
var args = arguments[0];
|
109
|
+
} else {
|
110
|
+
var args = Array.prototype.slice.call(arguments, 0);
|
111
|
+
}
|
112
|
+
|
113
|
+
passed.el.trigger(passed.scenario[1], args);
|
114
|
+
});
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
},
|
120
|
+
|
121
|
+
results : function (uuid, scenarios) {
|
122
|
+
var count = scenarios.length;
|
123
|
+
|
124
|
+
if (count > 0) {
|
125
|
+
var el = this.S('[data-uuid="' + uuid + '"]');
|
126
|
+
|
127
|
+
for (var i = count - 1; i >= 0; i--) {
|
128
|
+
var mq, rule = scenarios[i][2];
|
129
|
+
if (this.settings.named_queries.hasOwnProperty(rule)) {
|
130
|
+
mq = matchMedia(this.settings.named_queries[rule]);
|
131
|
+
} else {
|
132
|
+
mq = matchMedia(rule);
|
133
|
+
}
|
134
|
+
if (mq.matches) {
|
135
|
+
return {el: el, scenario: scenarios[i]};
|
136
|
+
}
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
return false;
|
141
|
+
},
|
142
|
+
|
143
|
+
load : function (type, force_update) {
|
144
|
+
if (typeof this['cached_' + type] === 'undefined' || force_update) {
|
145
|
+
this['update_' + type]();
|
146
|
+
}
|
147
|
+
|
148
|
+
return this['cached_' + type];
|
149
|
+
},
|
150
|
+
|
151
|
+
update_images : function () {
|
152
|
+
var images = this.S('img[' + this.data_attr + ']'),
|
153
|
+
count = images.length,
|
154
|
+
loaded_count = 0,
|
155
|
+
data_attr = this.data_attr;
|
156
|
+
|
157
|
+
this.cache = {};
|
158
|
+
this.cached_images = [];
|
159
|
+
this.images_loaded = (count === 0);
|
160
|
+
|
161
|
+
for (var i = count - 1; i >= 0; i--) {
|
162
|
+
loaded_count++;
|
163
|
+
if (images[i]) {
|
164
|
+
var str = images[i].getAttribute(data_attr) || '';
|
165
|
+
|
166
|
+
if (str.length > 0) {
|
167
|
+
this.cached_images.push(images[i]);
|
168
|
+
}
|
169
|
+
}
|
170
|
+
|
171
|
+
if(loaded_count === count) {
|
172
|
+
this.images_loaded = true;
|
173
|
+
this.enhance('images');
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
return this;
|
178
|
+
},
|
179
|
+
|
180
|
+
update_nodes : function () {
|
181
|
+
var nodes = this.S('[' + this.data_attr + ']:not(img)'),
|
182
|
+
count = nodes.length,
|
183
|
+
loaded_count = 0,
|
184
|
+
data_attr = this.data_attr;
|
185
|
+
|
186
|
+
this.cached_nodes = [];
|
187
|
+
// Set nodes_loaded to true if there are no nodes
|
188
|
+
// this.nodes_loaded = false;
|
189
|
+
this.nodes_loaded = (count === 0);
|
190
|
+
|
191
|
+
|
192
|
+
for (var i = count - 1; i >= 0; i--) {
|
193
|
+
loaded_count++;
|
194
|
+
var str = nodes[i].getAttribute(data_attr) || '';
|
195
|
+
|
196
|
+
if (str.length > 0) {
|
197
|
+
this.cached_nodes.push(nodes[i]);
|
198
|
+
}
|
199
|
+
|
200
|
+
if(loaded_count === count) {
|
201
|
+
this.nodes_loaded = true;
|
202
|
+
this.enhance('nodes');
|
203
|
+
}
|
204
|
+
}
|
205
|
+
|
206
|
+
return this;
|
207
|
+
},
|
208
|
+
|
209
|
+
enhance : function (type) {
|
210
|
+
var count = this['cached_' + type].length;
|
211
|
+
|
212
|
+
for (var i = count - 1; i >= 0; i--) {
|
213
|
+
this.object($(this['cached_' + type][i]));
|
214
|
+
}
|
215
|
+
|
216
|
+
return $(window).trigger('resize');
|
217
|
+
},
|
218
|
+
|
219
|
+
parse_params : function (path, directive, mq) {
|
220
|
+
return [this.trim(path), this.convert_directive(directive), this.trim(mq)];
|
221
|
+
},
|
222
|
+
|
223
|
+
convert_directive : function (directive) {
|
224
|
+
var trimmed = this.trim(directive);
|
225
|
+
|
226
|
+
if (trimmed.length > 0) {
|
227
|
+
return trimmed;
|
228
|
+
}
|
229
|
+
|
230
|
+
return 'replace';
|
231
|
+
},
|
232
|
+
|
233
|
+
object : function(el) {
|
234
|
+
var raw_arr = this.parse_data_attr(el),
|
235
|
+
scenarios = [], count = raw_arr.length;
|
236
|
+
|
237
|
+
if (count > 0) {
|
238
|
+
for (var i = count - 1; i >= 0; i--) {
|
239
|
+
var split = raw_arr[i].split(/\((.*?)(\))$/);
|
240
|
+
|
241
|
+
if (split.length > 1) {
|
242
|
+
var cached_split = split[0].split(','),
|
243
|
+
params = this.parse_params(cached_split[0],
|
244
|
+
cached_split[1], split[1]);
|
245
|
+
|
246
|
+
scenarios.push(params);
|
247
|
+
}
|
248
|
+
}
|
249
|
+
}
|
250
|
+
|
251
|
+
return this.store(el, scenarios);
|
252
|
+
},
|
253
|
+
|
254
|
+
uuid : function (separator) {
|
255
|
+
var delim = separator || "-";
|
256
|
+
|
257
|
+
function S4() {
|
258
|
+
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
|
259
|
+
}
|
260
|
+
|
261
|
+
return (S4() + S4() + delim + S4() + delim + S4()
|
262
|
+
+ delim + S4() + delim + S4() + S4() + S4());
|
263
|
+
},
|
264
|
+
|
265
|
+
store : function (el, scenarios) {
|
266
|
+
var uuid = this.uuid(),
|
267
|
+
current_uuid = el.data('uuid');
|
268
|
+
|
269
|
+
if (current_uuid) return this.cache[current_uuid];
|
270
|
+
|
271
|
+
el.attr('data-uuid', uuid);
|
272
|
+
|
273
|
+
return this.cache[uuid] = scenarios;
|
274
|
+
},
|
275
|
+
|
276
|
+
trim : function(str) {
|
277
|
+
if (typeof str === 'string') {
|
278
|
+
return $.trim(str);
|
279
|
+
}
|
280
|
+
|
281
|
+
return str;
|
282
|
+
},
|
283
|
+
|
284
|
+
parse_data_attr : function (el) {
|
285
|
+
var raw = el.data(this.settings.load_attr).split(/\[(.*?)\]/),
|
286
|
+
count = raw.length, output = [];
|
287
|
+
|
288
|
+
for (var i = count - 1; i >= 0; i--) {
|
289
|
+
if (raw[i].replace(/[\W\d]+/, '').length > 4) {
|
290
|
+
output.push(raw[i]);
|
291
|
+
}
|
292
|
+
}
|
293
|
+
|
294
|
+
return output;
|
295
|
+
},
|
296
|
+
|
297
|
+
reflow : function () {
|
298
|
+
this.load('images', true);
|
299
|
+
this.load('nodes', true);
|
300
|
+
}
|
301
|
+
|
302
|
+
};
|
303
|
+
|
304
|
+
}(jQuery, this, this.document));
|