chemistrykit 3.8.1 → 3.9.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG.md +15 -5
- data/Gemfile +4 -0
- data/README.md +13 -1
- data/Rakefile +3 -3
- data/chemistrykit.gemspec +7 -3
- data/features/brew.feature +1 -1
- data/features/chemists.feature +56 -1
- data/features/concurrency.feature +2 -2
- data/features/exit_status.feature +1 -0
- data/features/logging.feature +88 -85
- data/features/reporting.feature +105 -0
- data/features/step_definitions/steps.rb +4 -4
- data/features/support/env.rb +1 -1
- data/features/tags.feature +1 -0
- data/lib/chemistrykit/chemist.rb +6 -1
- data/lib/chemistrykit/chemist/repository/csv_chemist_repository.rb +1 -1
- data/lib/chemistrykit/cli/cli.rb +33 -12
- data/lib/chemistrykit/configuration.rb +2 -2
- data/lib/chemistrykit/formula/formula_lab.rb +13 -0
- data/lib/chemistrykit/{parallel_tests_mods.rb → parallel_tests/rspec/runner.rb} +5 -5
- data/lib/chemistrykit/reporting/html_report_assembler.rb +170 -0
- data/lib/chemistrykit/rspec/html_formatter.rb +241 -0
- data/lib/chemistrykit/rspec/j_unit_formatter.rb +124 -0
- data/report/config.rb +28 -0
- data/report/index.html +213 -0
- data/report/javascripts/foundation/foundation.abide.js +194 -0
- data/report/javascripts/foundation/foundation.alerts.js +52 -0
- data/report/javascripts/foundation/foundation.clearing.js +516 -0
- data/report/javascripts/foundation/foundation.cookie.js +74 -0
- data/report/javascripts/foundation/foundation.dropdown.js +177 -0
- data/report/javascripts/foundation/foundation.forms.js +533 -0
- data/report/javascripts/foundation/foundation.interchange.js +280 -0
- data/report/javascripts/foundation/foundation.joyride.js +850 -0
- data/report/javascripts/foundation/foundation.js +440 -0
- data/report/javascripts/foundation/foundation.magellan.js +135 -0
- data/report/javascripts/foundation/foundation.orbit.js +412 -0
- data/report/javascripts/foundation/foundation.placeholder.js +179 -0
- data/report/javascripts/foundation/foundation.reveal.js +330 -0
- data/report/javascripts/foundation/foundation.section.js +400 -0
- data/report/javascripts/foundation/foundation.tooltips.js +208 -0
- data/report/javascripts/foundation/foundation.topbar.js +300 -0
- data/report/javascripts/vendor/custom.modernizr.js +4 -0
- data/report/javascripts/vendor/jquery.js +9789 -0
- data/report/sass/_normalize.scss +402 -0
- data/report/sass/_settings.scss +1301 -0
- data/report/sass/app.scss +571 -0
- data/report/stylesheets/app.css +3636 -0
- data/spec/integration/lib/chemistrykit/formula/formula_lab_spec.rb +26 -2
- data/spec/integration/lib/chemistrykit/reporting/html_reporting_assembler_spec.rb +18 -0
- data/spec/support/evidence/results_0.html +30 -0
- data/spec/support/evidence/results_1.html +27 -0
- data/spec/unit/lib/chemistrykit/chemist/repository/csv_chemist_repository_spec.rb +15 -2
- data/spec/unit/lib/chemistrykit/chemist_spec.rb +17 -1
- data/spec/unit/lib/chemistrykit/configuration_spec.rb +2 -2
- data/spec/unit/lib/chemistrykit/formula/formula_lab_spec.rb +7 -0
- data/spec/unit/lib/chemistrykit/reporting/html_reporting_assembler_spec.rb +22 -0
- metadata +94 -13
- data/lib/chemistrykit/j_unit.rb +0 -121
@@ -0,0 +1,412 @@
|
|
1
|
+
;(function ($, window, document, undefined) {
|
2
|
+
'use strict';
|
3
|
+
|
4
|
+
var noop = function() {};
|
5
|
+
|
6
|
+
var Orbit = function(el, settings) {
|
7
|
+
// Don't reinitialize plugin
|
8
|
+
if (el.hasClass(settings.slides_container_class)) {
|
9
|
+
return this;
|
10
|
+
}
|
11
|
+
|
12
|
+
var self = this,
|
13
|
+
container,
|
14
|
+
slides_container = el,
|
15
|
+
number_container,
|
16
|
+
bullets_container,
|
17
|
+
timer_container,
|
18
|
+
idx = 0,
|
19
|
+
animate,
|
20
|
+
timer,
|
21
|
+
locked = false,
|
22
|
+
adjust_height_after = false;
|
23
|
+
|
24
|
+
slides_container.children().first().addClass(settings.active_slide_class);
|
25
|
+
|
26
|
+
self.update_slide_number = function(index) {
|
27
|
+
if (settings.slide_number) {
|
28
|
+
number_container.find('span:first').text(parseInt(index)+1);
|
29
|
+
number_container.find('span:last').text(slides_container.children().length);
|
30
|
+
}
|
31
|
+
if (settings.bullets) {
|
32
|
+
bullets_container.children().removeClass(settings.bullets_active_class);
|
33
|
+
$(bullets_container.children().get(index)).addClass(settings.bullets_active_class);
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
self.build_markup = function() {
|
38
|
+
slides_container.wrap('<div class="'+settings.container_class+'"></div>');
|
39
|
+
container = slides_container.parent();
|
40
|
+
slides_container.addClass(settings.slides_container_class);
|
41
|
+
|
42
|
+
if (settings.navigation_arrows) {
|
43
|
+
container.append($('<a>').addClass(settings.prev_class).append('<span>'));
|
44
|
+
container.append($('<a>').addClass(settings.next_class).append('<span>'));
|
45
|
+
}
|
46
|
+
|
47
|
+
if (settings.timer) {
|
48
|
+
timer_container = $('<div>').addClass(settings.timer_container_class);
|
49
|
+
timer_container.append('<span>');
|
50
|
+
timer_container.append($('<div>').addClass(settings.timer_progress_class));
|
51
|
+
timer_container.addClass(settings.timer_paused_class);
|
52
|
+
container.append(timer_container);
|
53
|
+
}
|
54
|
+
|
55
|
+
if (settings.slide_number) {
|
56
|
+
number_container = $('<div>').addClass(settings.slide_number_class);
|
57
|
+
number_container.append('<span></span> of <span></span>');
|
58
|
+
container.append(number_container);
|
59
|
+
}
|
60
|
+
|
61
|
+
if (settings.bullets) {
|
62
|
+
bullets_container = $('<ol>').addClass(settings.bullets_container_class);
|
63
|
+
container.append(bullets_container);
|
64
|
+
slides_container.children().each(function(idx, el) {
|
65
|
+
var bullet = $('<li>').attr('data-orbit-slide', idx);
|
66
|
+
bullets_container.append(bullet);
|
67
|
+
});
|
68
|
+
}
|
69
|
+
|
70
|
+
if (settings.stack_on_small) {
|
71
|
+
container.addClass(settings.stack_on_small_class);
|
72
|
+
}
|
73
|
+
|
74
|
+
self.update_slide_number(0);
|
75
|
+
};
|
76
|
+
|
77
|
+
self._goto = function(next_idx, start_timer) {
|
78
|
+
// if (locked) {return false;}
|
79
|
+
if (next_idx === idx) {return false;}
|
80
|
+
if (typeof timer === 'object') {timer.restart();}
|
81
|
+
var slides = slides_container.children();
|
82
|
+
|
83
|
+
var dir = 'next';
|
84
|
+
locked = true;
|
85
|
+
if (next_idx < idx) {dir = 'prev';}
|
86
|
+
if (next_idx >= slides.length) {next_idx = 0;}
|
87
|
+
else if (next_idx < 0) {next_idx = slides.length - 1;}
|
88
|
+
|
89
|
+
var current = $(slides.get(idx));
|
90
|
+
var next = $(slides.get(next_idx));
|
91
|
+
|
92
|
+
current.css('zIndex', 2);
|
93
|
+
next.css('zIndex', 4).addClass('active');
|
94
|
+
|
95
|
+
slides_container.trigger('orbit:before-slide-change');
|
96
|
+
settings.before_slide_change();
|
97
|
+
|
98
|
+
var callback = function() {
|
99
|
+
var unlock = function() {
|
100
|
+
idx = next_idx;
|
101
|
+
locked = false;
|
102
|
+
if (start_timer === true) {timer = self.create_timer(); timer.start();}
|
103
|
+
self.update_slide_number(idx);
|
104
|
+
slides_container.trigger('orbit:after-slide-change',[{slide_number: idx, total_slides: slides.length}]);
|
105
|
+
settings.after_slide_change(idx, slides.length);
|
106
|
+
};
|
107
|
+
if (slides_container.height() != next.height()) {
|
108
|
+
slides_container.animate({'height': next.height()}, 250, 'linear', unlock);
|
109
|
+
} else {
|
110
|
+
unlock();
|
111
|
+
}
|
112
|
+
};
|
113
|
+
|
114
|
+
if (slides.length === 1) {callback(); return false;}
|
115
|
+
|
116
|
+
var start_animation = function() {
|
117
|
+
if (dir === 'next') {animate.next(current, next, callback);}
|
118
|
+
if (dir === 'prev') {animate.prev(current, next, callback);}
|
119
|
+
};
|
120
|
+
|
121
|
+
if (next.height() > slides_container.height()) {
|
122
|
+
slides_container.animate({'height': next.height()}, 250, 'linear', start_animation);
|
123
|
+
} else {
|
124
|
+
start_animation();
|
125
|
+
}
|
126
|
+
};
|
127
|
+
|
128
|
+
self.next = function(e) {
|
129
|
+
e.stopImmediatePropagation();
|
130
|
+
e.preventDefault();
|
131
|
+
self._goto(idx + 1);
|
132
|
+
};
|
133
|
+
|
134
|
+
self.prev = function(e) {
|
135
|
+
e.stopImmediatePropagation();
|
136
|
+
e.preventDefault();
|
137
|
+
self._goto(idx - 1);
|
138
|
+
};
|
139
|
+
|
140
|
+
self.link_custom = function(e) {
|
141
|
+
e.preventDefault();
|
142
|
+
var link = $(this).attr('data-orbit-link');
|
143
|
+
if ((typeof link === 'string') && (link = $.trim(link)) != "") {
|
144
|
+
var slide = container.find('[data-orbit-slide='+link+']');
|
145
|
+
if (slide.index() != -1) {self._goto(slide.index());}
|
146
|
+
}
|
147
|
+
};
|
148
|
+
|
149
|
+
self.link_bullet = function(e) {
|
150
|
+
var index = $(this).attr('data-orbit-slide');
|
151
|
+
if ((typeof index === 'string') && (index = $.trim(index)) != "") {
|
152
|
+
self._goto(index);
|
153
|
+
}
|
154
|
+
}
|
155
|
+
|
156
|
+
self.timer_callback = function() {
|
157
|
+
self._goto(idx + 1, true);
|
158
|
+
}
|
159
|
+
|
160
|
+
self.compute_dimensions = function() {
|
161
|
+
var current = $(slides_container.children().get(idx));
|
162
|
+
var h = current.height();
|
163
|
+
if (!settings.variable_height) {
|
164
|
+
slides_container.children().each(function(){
|
165
|
+
if ($(this).height() > h) { h = $(this).height(); }
|
166
|
+
});
|
167
|
+
}
|
168
|
+
slides_container.height(h);
|
169
|
+
};
|
170
|
+
|
171
|
+
self.create_timer = function() {
|
172
|
+
var t = new Timer(
|
173
|
+
container.find('.'+settings.timer_container_class),
|
174
|
+
settings,
|
175
|
+
self.timer_callback
|
176
|
+
);
|
177
|
+
return t;
|
178
|
+
};
|
179
|
+
|
180
|
+
self.stop_timer = function() {
|
181
|
+
if (typeof timer === 'object') timer.stop();
|
182
|
+
};
|
183
|
+
|
184
|
+
self.toggle_timer = function() {
|
185
|
+
var t = container.find('.'+settings.timer_container_class);
|
186
|
+
if (t.hasClass(settings.timer_paused_class)) {
|
187
|
+
if (typeof timer === 'undefined') {timer = self.create_timer();}
|
188
|
+
timer.start();
|
189
|
+
}
|
190
|
+
else {
|
191
|
+
if (typeof timer === 'object') {timer.stop();}
|
192
|
+
}
|
193
|
+
};
|
194
|
+
|
195
|
+
self.init = function() {
|
196
|
+
self.build_markup();
|
197
|
+
if (settings.timer) {timer = self.create_timer(); timer.start();}
|
198
|
+
animate = new FadeAnimation(slides_container);
|
199
|
+
if (settings.animation === 'slide')
|
200
|
+
animate = new SlideAnimation(slides_container);
|
201
|
+
container.on('click', '.'+settings.next_class, self.next);
|
202
|
+
container.on('click', '.'+settings.prev_class, self.prev);
|
203
|
+
container.on('click', '[data-orbit-slide]', self.link_bullet);
|
204
|
+
container.on('click', self.toggle_timer);
|
205
|
+
container.on('touchstart.fndtn.orbit', function(e) {
|
206
|
+
if (!e.touches) {e = e.originalEvent;}
|
207
|
+
var data = {
|
208
|
+
start_page_x: e.touches[0].pageX,
|
209
|
+
start_page_y: e.touches[0].pageY,
|
210
|
+
start_time: (new Date()).getTime(),
|
211
|
+
delta_x: 0,
|
212
|
+
is_scrolling: undefined
|
213
|
+
};
|
214
|
+
container.data('swipe-transition', data);
|
215
|
+
e.stopPropagation();
|
216
|
+
})
|
217
|
+
.on('touchmove.fndtn.orbit', function(e) {
|
218
|
+
if (!e.touches) { e = e.originalEvent; }
|
219
|
+
// Ignore pinch/zoom events
|
220
|
+
if(e.touches.length > 1 || e.scale && e.scale !== 1) return;
|
221
|
+
|
222
|
+
var data = container.data('swipe-transition');
|
223
|
+
if (typeof data === 'undefined') {data = {};}
|
224
|
+
|
225
|
+
data.delta_x = e.touches[0].pageX - data.start_page_x;
|
226
|
+
|
227
|
+
if ( typeof data.is_scrolling === 'undefined') {
|
228
|
+
data.is_scrolling = !!( data.is_scrolling || Math.abs(data.delta_x) < Math.abs(e.touches[0].pageY - data.start_page_y) );
|
229
|
+
}
|
230
|
+
|
231
|
+
if (!data.is_scrolling && !data.active) {
|
232
|
+
e.preventDefault();
|
233
|
+
var direction = (data.delta_x < 0) ? (idx+1) : (idx-1);
|
234
|
+
data.active = true;
|
235
|
+
self._goto(direction);
|
236
|
+
}
|
237
|
+
})
|
238
|
+
.on('touchend.fndtn.orbit', function(e) {
|
239
|
+
container.data('swipe-transition', {});
|
240
|
+
e.stopPropagation();
|
241
|
+
})
|
242
|
+
.on('mouseenter.fndtn.orbit', function(e) {
|
243
|
+
if (settings.timer && settings.pause_on_hover) {
|
244
|
+
self.stop_timer();
|
245
|
+
}
|
246
|
+
})
|
247
|
+
.on('mouseleave.fndtn.orbit', function(e) {
|
248
|
+
if (settings.timer && settings.resume_on_mouseout) {
|
249
|
+
timer.start();
|
250
|
+
}
|
251
|
+
});
|
252
|
+
|
253
|
+
$(document).on('click', '[data-orbit-link]', self.link_custom);
|
254
|
+
$(window).on('resize', self.compute_dimensions);
|
255
|
+
$(window).on('load', self.compute_dimensions);
|
256
|
+
slides_container.trigger('orbit:ready');
|
257
|
+
};
|
258
|
+
|
259
|
+
self.init();
|
260
|
+
};
|
261
|
+
|
262
|
+
var Timer = function(el, settings, callback) {
|
263
|
+
var self = this,
|
264
|
+
duration = settings.timer_speed,
|
265
|
+
progress = el.find('.'+settings.timer_progress_class),
|
266
|
+
start,
|
267
|
+
timeout,
|
268
|
+
left = -1;
|
269
|
+
|
270
|
+
this.update_progress = function(w) {
|
271
|
+
var new_progress = progress.clone();
|
272
|
+
new_progress.attr('style', '');
|
273
|
+
new_progress.css('width', w+'%');
|
274
|
+
progress.replaceWith(new_progress);
|
275
|
+
progress = new_progress;
|
276
|
+
};
|
277
|
+
|
278
|
+
this.restart = function() {
|
279
|
+
clearTimeout(timeout);
|
280
|
+
el.addClass(settings.timer_paused_class);
|
281
|
+
left = -1;
|
282
|
+
self.update_progress(0);
|
283
|
+
};
|
284
|
+
|
285
|
+
this.start = function() {
|
286
|
+
if (!el.hasClass(settings.timer_paused_class)) {return true;}
|
287
|
+
left = (left === -1) ? duration : left;
|
288
|
+
el.removeClass(settings.timer_paused_class);
|
289
|
+
start = new Date().getTime();
|
290
|
+
progress.animate({'width': '100%'}, left, 'linear');
|
291
|
+
timeout = setTimeout(function() {
|
292
|
+
self.restart();
|
293
|
+
callback();
|
294
|
+
}, left);
|
295
|
+
el.trigger('orbit:timer-started')
|
296
|
+
};
|
297
|
+
|
298
|
+
this.stop = function() {
|
299
|
+
if (el.hasClass(settings.timer_paused_class)) {return true;}
|
300
|
+
clearTimeout(timeout);
|
301
|
+
el.addClass(settings.timer_paused_class);
|
302
|
+
var end = new Date().getTime();
|
303
|
+
left = left - (end - start);
|
304
|
+
var w = 100 - ((left / duration) * 100);
|
305
|
+
self.update_progress(w);
|
306
|
+
el.trigger('orbit:timer-stopped');
|
307
|
+
};
|
308
|
+
};
|
309
|
+
|
310
|
+
var SlideAnimation = function(container) {
|
311
|
+
var duration = 400;
|
312
|
+
var is_rtl = ($('html[dir=rtl]').length === 1);
|
313
|
+
var margin = is_rtl ? 'marginRight' : 'marginLeft';
|
314
|
+
|
315
|
+
this.next = function(current, next, callback) {
|
316
|
+
next.animate({margin: '0%'}, duration, 'linear', function() {
|
317
|
+
current.css(margin, '100%');
|
318
|
+
callback();
|
319
|
+
});
|
320
|
+
};
|
321
|
+
|
322
|
+
this.prev = function(current, prev, callback) {
|
323
|
+
prev.css(margin, '-100%');
|
324
|
+
prev.animate({margin:'0%'}, duration, 'linear', function() {
|
325
|
+
current.css(margin, '100%');
|
326
|
+
callback();
|
327
|
+
});
|
328
|
+
};
|
329
|
+
};
|
330
|
+
|
331
|
+
var FadeAnimation = function(container) {
|
332
|
+
var duration = 250;
|
333
|
+
|
334
|
+
this.next = function(current, next, callback) {
|
335
|
+
next.css({'marginLeft':'0%', 'opacity':'0.01'});
|
336
|
+
next.animate({'opacity':'1'}, duration, 'linear', function() {
|
337
|
+
current.css('marginLeft', '100%');
|
338
|
+
callback();
|
339
|
+
});
|
340
|
+
};
|
341
|
+
|
342
|
+
this.prev = function(current, prev, callback) {
|
343
|
+
prev.css({'marginLeft':'0%', 'opacity':'0.01'});
|
344
|
+
prev.animate({'opacity':'1'}, duration, 'linear', function() {
|
345
|
+
current.css('marginLeft', '100%');
|
346
|
+
callback();
|
347
|
+
});
|
348
|
+
};
|
349
|
+
};
|
350
|
+
|
351
|
+
|
352
|
+
Foundation.libs = Foundation.libs || {};
|
353
|
+
|
354
|
+
Foundation.libs.orbit = {
|
355
|
+
name: 'orbit',
|
356
|
+
|
357
|
+
version: '4.3.1',
|
358
|
+
|
359
|
+
settings: {
|
360
|
+
animation: 'slide',
|
361
|
+
timer_speed: 10000,
|
362
|
+
pause_on_hover: true,
|
363
|
+
resume_on_mouseout: false,
|
364
|
+
animation_speed: 500,
|
365
|
+
stack_on_small: false,
|
366
|
+
navigation_arrows: true,
|
367
|
+
slide_number: true,
|
368
|
+
container_class: 'orbit-container',
|
369
|
+
stack_on_small_class: 'orbit-stack-on-small',
|
370
|
+
next_class: 'orbit-next',
|
371
|
+
prev_class: 'orbit-prev',
|
372
|
+
timer_container_class: 'orbit-timer',
|
373
|
+
timer_paused_class: 'paused',
|
374
|
+
timer_progress_class: 'orbit-progress',
|
375
|
+
slides_container_class: 'orbit-slides-container',
|
376
|
+
bullets_container_class: 'orbit-bullets',
|
377
|
+
bullets_active_class: 'active',
|
378
|
+
slide_number_class: 'orbit-slide-number',
|
379
|
+
caption_class: 'orbit-caption',
|
380
|
+
active_slide_class: 'active',
|
381
|
+
orbit_transition_class: 'orbit-transitioning',
|
382
|
+
bullets: true,
|
383
|
+
timer: true,
|
384
|
+
variable_height: false,
|
385
|
+
before_slide_change: noop,
|
386
|
+
after_slide_change: noop
|
387
|
+
},
|
388
|
+
|
389
|
+
init: function (scope, method, options) {
|
390
|
+
var self = this;
|
391
|
+
Foundation.inherit(self, 'data_options');
|
392
|
+
|
393
|
+
if (typeof method === 'object') {
|
394
|
+
$.extend(true, self.settings, method);
|
395
|
+
}
|
396
|
+
|
397
|
+
if ($(scope).is('[data-orbit]')) {
|
398
|
+
var $el = $(scope);
|
399
|
+
var opts = self.data_options($el);
|
400
|
+
new Orbit($el, $.extend({},self.settings, opts));
|
401
|
+
}
|
402
|
+
|
403
|
+
$('[data-orbit]', scope).each(function(idx, el) {
|
404
|
+
var $el = $(el);
|
405
|
+
var opts = self.data_options($el);
|
406
|
+
new Orbit($el, $.extend({},self.settings, opts));
|
407
|
+
});
|
408
|
+
}
|
409
|
+
};
|
410
|
+
|
411
|
+
|
412
|
+
}(Foundation.zj, this, this.document));
|
@@ -0,0 +1,179 @@
|
|
1
|
+
/*! http://mths.be/placeholder v2.0.7 by @mathias
|
2
|
+
Modified to work with Zepto.js by ZURB
|
3
|
+
*/
|
4
|
+
;(function(window, document, $) {
|
5
|
+
|
6
|
+
var isInputSupported = 'placeholder' in document.createElement('input'),
|
7
|
+
isTextareaSupported = 'placeholder' in document.createElement('textarea'),
|
8
|
+
prototype = $.fn,
|
9
|
+
valHooks = $.valHooks,
|
10
|
+
hooks,
|
11
|
+
placeholder;
|
12
|
+
|
13
|
+
if (isInputSupported && isTextareaSupported) {
|
14
|
+
|
15
|
+
placeholder = prototype.placeholder = function() {
|
16
|
+
return this;
|
17
|
+
};
|
18
|
+
|
19
|
+
placeholder.input = placeholder.textarea = true;
|
20
|
+
|
21
|
+
} else {
|
22
|
+
|
23
|
+
placeholder = prototype.placeholder = function() {
|
24
|
+
var $this = this;
|
25
|
+
$this
|
26
|
+
.filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
|
27
|
+
.not('.placeholder')
|
28
|
+
.bind({
|
29
|
+
'focus.placeholder': clearPlaceholder,
|
30
|
+
'blur.placeholder': setPlaceholder
|
31
|
+
})
|
32
|
+
.data('placeholder-enabled', true)
|
33
|
+
.trigger('blur.placeholder');
|
34
|
+
return $this;
|
35
|
+
};
|
36
|
+
|
37
|
+
placeholder.input = isInputSupported;
|
38
|
+
placeholder.textarea = isTextareaSupported;
|
39
|
+
|
40
|
+
hooks = {
|
41
|
+
'get': function(element) {
|
42
|
+
var $element = $(element);
|
43
|
+
return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value;
|
44
|
+
},
|
45
|
+
'set': function(element, value) {
|
46
|
+
var $element = $(element);
|
47
|
+
if (!$element.data('placeholder-enabled')) {
|
48
|
+
return element.value = value;
|
49
|
+
}
|
50
|
+
if (value == '') {
|
51
|
+
element.value = value;
|
52
|
+
// Issue #56: Setting the placeholder causes problems if the element continues to have focus.
|
53
|
+
if (element != document.activeElement) {
|
54
|
+
// We can't use `triggerHandler` here because of dummy text/password inputs :(
|
55
|
+
setPlaceholder.call(element);
|
56
|
+
}
|
57
|
+
} else if ($element.hasClass('placeholder')) {
|
58
|
+
clearPlaceholder.call(element, true, value) || (element.value = value);
|
59
|
+
} else {
|
60
|
+
element.value = value;
|
61
|
+
}
|
62
|
+
// `set` can not return `undefined`; see http://jsapi.info/jquery/1.7.1/val#L2363
|
63
|
+
return $element;
|
64
|
+
}
|
65
|
+
};
|
66
|
+
|
67
|
+
isInputSupported || (valHooks.input = hooks);
|
68
|
+
isTextareaSupported || (valHooks.textarea = hooks);
|
69
|
+
|
70
|
+
$(function() {
|
71
|
+
// Look for forms
|
72
|
+
$(document).delegate('form', 'submit.placeholder', function() {
|
73
|
+
// Clear the placeholder values so they don't get submitted
|
74
|
+
var $inputs = $('.placeholder', this).each(clearPlaceholder);
|
75
|
+
setTimeout(function() {
|
76
|
+
$inputs.each(setPlaceholder);
|
77
|
+
}, 10);
|
78
|
+
});
|
79
|
+
});
|
80
|
+
|
81
|
+
// Clear placeholder values upon page reload
|
82
|
+
$(window).bind('beforeunload.placeholder', function() {
|
83
|
+
$('.placeholder').each(function() {
|
84
|
+
this.value = '';
|
85
|
+
});
|
86
|
+
});
|
87
|
+
|
88
|
+
}
|
89
|
+
|
90
|
+
function args(elem) {
|
91
|
+
// Return an object of element attributes
|
92
|
+
var newAttrs = {},
|
93
|
+
rinlinejQuery = /^jQuery\d+$/;
|
94
|
+
$.each(elem.attributes, function(i, attr) {
|
95
|
+
if (attr.specified && !rinlinejQuery.test(attr.name)) {
|
96
|
+
newAttrs[attr.name] = attr.value;
|
97
|
+
}
|
98
|
+
});
|
99
|
+
return newAttrs;
|
100
|
+
}
|
101
|
+
|
102
|
+
function clearPlaceholder(event, value) {
|
103
|
+
var input = this,
|
104
|
+
$input = $(input);
|
105
|
+
if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
|
106
|
+
if ($input.data('placeholder-password')) {
|
107
|
+
$input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
|
108
|
+
// If `clearPlaceholder` was called from `$.valHooks.input.set`
|
109
|
+
if (event === true) {
|
110
|
+
return $input[0].value = value;
|
111
|
+
}
|
112
|
+
$input.focus();
|
113
|
+
} else {
|
114
|
+
input.value = '';
|
115
|
+
$input.removeClass('placeholder');
|
116
|
+
input == document.activeElement && input.select();
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
function setPlaceholder() {
|
122
|
+
var $replacement,
|
123
|
+
input = this,
|
124
|
+
$input = $(input),
|
125
|
+
$origInput = $input,
|
126
|
+
id = this.id;
|
127
|
+
if (input.value == '') {
|
128
|
+
if (input.type == 'password') {
|
129
|
+
if (!$input.data('placeholder-textinput')) {
|
130
|
+
try {
|
131
|
+
$replacement = $input.clone().attr({ 'type': 'text' });
|
132
|
+
} catch(e) {
|
133
|
+
$replacement = $('<input>').attr($.extend(args(this), { 'type': 'text' }));
|
134
|
+
}
|
135
|
+
$replacement
|
136
|
+
.removeAttr('name')
|
137
|
+
.data({
|
138
|
+
'placeholder-password': true,
|
139
|
+
'placeholder-id': id
|
140
|
+
})
|
141
|
+
.bind('focus.placeholder', clearPlaceholder);
|
142
|
+
$input
|
143
|
+
.data({
|
144
|
+
'placeholder-textinput': $replacement,
|
145
|
+
'placeholder-id': id
|
146
|
+
})
|
147
|
+
.before($replacement);
|
148
|
+
}
|
149
|
+
$input = $input.removeAttr('id').hide().prev().attr('id', id).show();
|
150
|
+
// Note: `$input[0] != input` now!
|
151
|
+
}
|
152
|
+
$input.addClass('placeholder');
|
153
|
+
$input[0].value = $input.attr('placeholder');
|
154
|
+
} else {
|
155
|
+
$input.removeClass('placeholder');
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
}(this, document, Foundation.zj));
|
160
|
+
|
161
|
+
;(function ($, window, document, undefined) {
|
162
|
+
'use strict';
|
163
|
+
|
164
|
+
Foundation.libs.placeholder = {
|
165
|
+
name : 'placeholder',
|
166
|
+
|
167
|
+
version : '4.2.2',
|
168
|
+
|
169
|
+
init : function (scope, method, options) {
|
170
|
+
this.scope = scope || this.scope;
|
171
|
+
|
172
|
+
if (typeof method !== 'string') {
|
173
|
+
window.onload = function () {
|
174
|
+
$('input, textarea').placeholder();
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
178
|
+
};
|
179
|
+
}(Foundation.zj, this, this.document));
|