pbw 0.0.9 → 0.0.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (80) hide show
  1. checksums.yaml +8 -8
  2. data/app/controllers/pbw/application_controller.rb +3 -16
  3. data/app/controllers/pbw/base_models_controller.rb +10 -32
  4. data/app/controllers/pbw/passwords_controller.rb +14 -0
  5. data/app/controllers/pbw/registrations_controller.rb +9 -6
  6. data/app/controllers/pbw/sessions_controller.rb +9 -4
  7. data/app/mailers/pbw/user_mailer.rb +16 -0
  8. data/app/models/pbw/area.rb +5 -5
  9. data/app/models/pbw/attached_process.rb +3 -3
  10. data/app/models/pbw/capability.rb +1 -1
  11. data/app/models/pbw/command.rb +2 -2
  12. data/app/models/pbw/constraint.rb +2 -2
  13. data/app/models/pbw/item.rb +2 -2
  14. data/app/models/pbw/item_container.rb +4 -4
  15. data/app/models/pbw/item_conversion.rb +1 -1
  16. data/app/models/pbw/process.rb +2 -2
  17. data/app/models/pbw/token.rb +7 -7
  18. data/app/models/pbw/trigger.rb +3 -3
  19. data/app/models/pbw/user.rb +30 -8
  20. data/config/initializers/devise.rb +1 -66
  21. data/config/locales/pbw.en.yml +7 -0
  22. data/config/routes.rb +2 -4
  23. data/lib/generators/pbw/install/install_generator.rb +22 -3
  24. data/lib/generators/pbw/model_generator.rb +6 -0
  25. data/lib/generators/pbw/resource_helpers.rb +16 -0
  26. data/lib/generators/pbw/rules/capability/capability_generator.rb +4 -2
  27. data/lib/generators/pbw/rules/constraint/constraint_generator.rb +4 -2
  28. data/lib/generators/pbw/rules/process/process_generator.rb +4 -2
  29. data/lib/generators/pbw/rules/trigger/trigger_generator.rb +4 -2
  30. data/lib/generators/pbw/scaffold_generator.rb +0 -12
  31. data/lib/generators/pbw/templates/app.coffee +5 -3
  32. data/lib/generators/pbw/templates/application.erb +24 -0
  33. data/lib/generators/pbw/templates/lifecycle.rb +1 -0
  34. data/lib/generators/pbw/templates/pbw.coffee +21 -0
  35. data/lib/generators/pbw/templates/router.coffee +15 -0
  36. data/lib/generators/pbw/templates/templates/home.jst +10 -1
  37. data/lib/generators/pbw/templates/templates/login.jst +25 -0
  38. data/lib/generators/pbw/templates/templates/recover_password.jst +17 -0
  39. data/lib/generators/pbw/templates/templates/signup.jst +29 -0
  40. data/lib/generators/pbw/templates/user_recovery.coffee +6 -0
  41. data/lib/generators/pbw/templates/user_registration.coffee +9 -0
  42. data/lib/generators/pbw/templates/user_session.coffee +8 -0
  43. data/lib/generators/pbw/templates/views/edit_view.coffee +15 -8
  44. data/lib/generators/pbw/templates/views/login_view.coffee +39 -0
  45. data/lib/generators/pbw/templates/views/new_view.coffee +5 -9
  46. data/lib/generators/pbw/templates/views/recovery_view.coffee +38 -0
  47. data/lib/generators/pbw/templates/views/signup_view.coffee +39 -0
  48. data/lib/pbw/engine.rb +5 -9
  49. data/lib/pbw/version.rb +1 -1
  50. data/lib/pbw.rb +15 -2
  51. data/vendor/assets/javascripts/backbone_datalink.js +21 -0
  52. metadata +16 -44
  53. data/app/controllers/pbw/capabilities_controller.rb +0 -7
  54. data/app/controllers/pbw/constraints_controller.rb +0 -7
  55. data/app/controllers/pbw/processes_controller.rb +0 -7
  56. data/app/controllers/pbw/triggers_controller.rb +0 -7
  57. data/public/Foundation-MIT-LICENSE.txt +0 -20
  58. data/public/config.rb +0 -26
  59. data/public/javascripts/foundation/foundation.alerts.js +0 -52
  60. data/public/javascripts/foundation/foundation.clearing.js +0 -516
  61. data/public/javascripts/foundation/foundation.cookie.js +0 -74
  62. data/public/javascripts/foundation/foundation.dropdown.js +0 -178
  63. data/public/javascripts/foundation/foundation.forms.js +0 -525
  64. data/public/javascripts/foundation/foundation.interchange.js +0 -271
  65. data/public/javascripts/foundation/foundation.joyride.js +0 -844
  66. data/public/javascripts/foundation/foundation.js +0 -447
  67. data/public/javascripts/foundation/foundation.magellan.js +0 -134
  68. data/public/javascripts/foundation/foundation.orbit.js +0 -390
  69. data/public/javascripts/foundation/foundation.placeholder.js +0 -179
  70. data/public/javascripts/foundation/foundation.reveal.js +0 -330
  71. data/public/javascripts/foundation/foundation.section.js +0 -422
  72. data/public/javascripts/foundation/foundation.tooltips.js +0 -208
  73. data/public/javascripts/foundation/foundation.topbar.js +0 -303
  74. data/public/javascripts/vendor/custom.modernizr.js +0 -4
  75. data/public/javascripts/vendor/jquery.js +0 -9807
  76. data/public/javascripts/vendor/zepto.js +0 -2000
  77. data/public/sass/_normalize.scss +0 -402
  78. data/public/sass/_settings.scss +0 -1271
  79. data/public/sass/app.scss +0 -48
  80. data/public/stylesheets/app.css +0 -6686
@@ -1,390 +0,0 @@
1
- ;(function ($, window, document, undefined) {
2
- 'use strict';
3
-
4
- Foundation.libs = Foundation.libs || {};
5
-
6
- Foundation.libs.orbit = {
7
- name: 'orbit',
8
-
9
- version: '4.2.0',
10
-
11
- settings: {
12
- timer_speed: 10000,
13
- pause_on_hover: true,
14
- resume_on_mouseout: false,
15
- animation_speed: 500,
16
- bullets: true,
17
- stack_on_small: true,
18
- navigation_arrows: true,
19
- slide_number: true,
20
- container_class: 'orbit-container',
21
- stack_on_small_class: 'orbit-stack-on-small',
22
- next_class: 'orbit-next',
23
- prev_class: 'orbit-prev',
24
- timer_container_class: 'orbit-timer',
25
- timer_paused_class: 'paused',
26
- timer_progress_class: 'orbit-progress',
27
- slides_container_class: 'orbit-slides-container',
28
- bullets_container_class: 'orbit-bullets',
29
- bullets_active_class: 'active',
30
- slide_number_class: 'orbit-slide-number',
31
- caption_class: 'orbit-caption',
32
- active_slide_class: 'active',
33
- orbit_transition_class: 'orbit-transitioning'
34
- },
35
-
36
- init: function (scope, method, options) {
37
- var self = this;
38
- Foundation.inherit(self, 'data_options');
39
-
40
- if (typeof method === 'object') {
41
- $.extend(true, self.settings, method);
42
- }
43
-
44
- if ($(scope).is('[data-orbit]')) {
45
- var scoped_self = $.extend(true, {}, self);
46
- scoped_self._init(idx, el);
47
- }
48
-
49
- $('[data-orbit]', scope).each(function(idx, el) {
50
- var scoped_self = $.extend(true, {}, self);
51
- scoped_self._init(idx, el);
52
- });
53
- },
54
-
55
- _container_html: function() {
56
- var self = this;
57
- return '<div class="' + self.settings.container_class + '"></div>';
58
- },
59
-
60
- _bullets_container_html: function($slides) {
61
- var self = this,
62
- $list = $('<ol class="' + self.settings.bullets_container_class + '"></ol>');
63
- $slides.each(function(idx, slide) {
64
- var $item = $('<li data-orbit-slide-number="' + (idx+1) + '" class=""></li>');
65
- if (idx === 0) {
66
- $item.addClass(self.settings.bullets_active_class);
67
- }
68
- $list.append($item);
69
- });
70
- return $list;
71
- },
72
-
73
- _slide_number_html: function(slide_number, total_slides) {
74
- var self = this,
75
- $container = $('<div class="' + self.settings.slide_number_class + '"></div>');
76
- $container.append('<span>' + slide_number + '</span> of <span>' + total_slides + '</span>');
77
- return $container;
78
- },
79
-
80
- _timer_html: function() {
81
- var self = this;
82
- if (typeof self.settings.timer_speed === 'number' && self.settings.timer_speed > 0) {
83
- return '<div class="' + self.settings.timer_container_class
84
- + '"><span></span><div class="' + self.settings.timer_progress_class
85
- + '"></div></div>';
86
- } else {
87
- return '';
88
- }
89
- },
90
-
91
- _next_html: function() {
92
- var self = this;
93
- return '<a href="#" class="' + self.settings.next_class + '">Next <span></span></a>';
94
- },
95
-
96
- _prev_html: function() {
97
- var self = this;
98
- return '<a href="#" class="' + self.settings.prev_class + '">Prev <span></span></a>';
99
- },
100
-
101
- _init: function (idx, slider) {
102
- var self = this,
103
- $slides_container = $(slider),
104
- $container = $slides_container.wrap(self._container_html()).parent(),
105
- $slides = $slides_container.children();
106
-
107
- $.extend(true, self.settings, self.data_options($slides_container));
108
-
109
- if (self.settings.navigation_arrows) {
110
- $container.append(self._prev_html());
111
- $container.append(self._next_html());
112
- }
113
- $slides_container.addClass(self.settings.slides_container_class);
114
- if (self.settings.stack_on_small) {
115
- $container.addClass(self.settings.stack_on_small_class);
116
- }
117
- if (self.settings.slide_number) {
118
- $container.append(self._slide_number_html(1, $slides.length));
119
- }
120
- $container.append(self._timer_html());
121
- if (self.settings.bullets) {
122
- $container.after(self._bullets_container_html($slides));
123
- }
124
- // To better support the "sliding" effect it's easier
125
- // if we just clone the first and last slides
126
- $slides_container.append($slides.first().clone().attr('data-orbit-slide',''));
127
- $slides_container.prepend($slides.last().clone().attr('data-orbit-slide',''));
128
- // Make the first "real" slide active
129
- $slides_container.css(Foundation.rtl ? 'marginRight' : 'marginLeft', '-100%');
130
- $slides.first().addClass(self.settings.active_slide_class);
131
-
132
- self._init_events($slides_container);
133
- self._init_dimensions($slides_container);
134
- self._start_timer($slides_container);
135
- },
136
-
137
- _init_events: function ($slides_container) {
138
- var self = this,
139
- $container = $slides_container.parent();
140
-
141
- $(window)
142
- .on('load.fndtn.orbit', function() {
143
- $slides_container.height('');
144
- $slides_container.height($slides_container.height($container.height()));
145
- $slides_container.trigger('orbit:ready');
146
- })
147
- .on('resize.fndtn.orbit', function() {
148
- $slides_container.height('');
149
- $slides_container.height($slides_container.height($container.height()));
150
- });
151
-
152
- $(document).on('click.fndtn.orbit', '[data-orbit-link]', function(e) {
153
- e.preventDefault();
154
- var id = $(e.currentTarget).attr('data-orbit-link'),
155
- $slide = $slides_container.find('[data-orbit-slide=' + id + ']').first();
156
-
157
- if ($slide.length === 1) {
158
- self._reset_timer($slides_container, true);
159
- self._goto($slides_container, $slide.index(), function() {});
160
- }
161
- });
162
-
163
- $container.siblings('.' + self.settings.bullets_container_class)
164
- .on('click.fndtn.orbit', '[data-orbit-slide-number]', function(e) {
165
- e.preventDefault();
166
- self._reset_timer($slides_container, true);
167
- self._goto($slides_container, $(e.currentTarget).data('orbit-slide-number'),function() {});
168
- });
169
-
170
- $container
171
- .on('mouseenter.fndtn.orbit', function(e) {
172
- if (self.settings.pause_on_hover) {
173
- self._stop_timer($slides_container);
174
- }
175
- })
176
- .on('mouseleave.fndtn.orbit', function(e) {
177
- if (self.settings.resume_on_mouseout) {
178
- self._start_timer($slides_container);
179
- }
180
- })
181
- .on('orbit:after-slide-change.fndtn.orbit', function(e, orbit) {
182
- var $slide_number = $container.find('.' + self.settings.slide_number_class);
183
-
184
- if ($slide_number.length === 1) {
185
- $slide_number.replaceWith(self._slide_number_html(orbit.slide_number, orbit.total_slides));
186
- }
187
- })
188
- .on('orbit:next-slide.fndtn.orbit click.fndtn.orbit', '.' + self.settings.next_class.split(" ").join("."), function(e) {
189
- e.preventDefault();
190
- self._reset_timer($slides_container, true);
191
- self._goto($slides_container, 'next', function() {});
192
- })
193
- .on('orbit:prev-slide.fndtn.orbit click.fndtn.orbit', '.' + self.settings.prev_class.split(" ").join("."), function(e) {
194
- e.preventDefault();
195
- self._reset_timer($slides_container, true);
196
- self._goto($slides_container, 'prev', function() {});
197
- })
198
- .on('orbit:toggle-play-pause.fndtn.orbit click.fndtn.orbit touchstart.fndtn.orbit', '.' + self.settings.timer_container_class, function(e) {
199
- e.preventDefault();
200
- var $timer = $(e.currentTarget).toggleClass(self.settings.timer_paused_class),
201
- $slides_container = $timer.closest('.' + self.settings.container_class)
202
- .find('.' + self.settings.slides_container_class);
203
-
204
- if ($timer.hasClass(self.settings.timer_paused_class)) {
205
- self._stop_timer($slides_container);
206
- } else {
207
- self._start_timer($slides_container);
208
- }
209
- })
210
- .on('touchstart.fndtn.orbit', function(e) {
211
- if (!e.touches) { e = e.originalEvent; }
212
- var data = {
213
- start_page_x: e.touches[0].pageX,
214
- start_page_y: e.touches[0].pageY,
215
- start_time: (new Date()).getTime(),
216
- delta_x: 0,
217
- is_scrolling: undefined
218
- };
219
- $container.data('swipe-transition', data);
220
- e.stopPropagation();
221
- })
222
- .on('touchmove.fndtn.orbit', function(e) {
223
- if (!e.touches) { e = e.originalEvent; }
224
- // Ignore pinch/zoom events
225
- if(e.touches.length > 1 || e.scale && e.scale !== 1) return;
226
-
227
- var data = $container.data('swipe-transition');
228
- if (typeof data === 'undefined') {
229
- data = {};
230
- }
231
-
232
- data.delta_x = e.touches[0].pageX - data.start_page_x;
233
-
234
- if ( typeof data.is_scrolling === 'undefined') {
235
- data.is_scrolling = !!( data.is_scrolling || Math.abs(data.delta_x) < Math.abs(e.touches[0].pageY - data.start_page_y) );
236
- }
237
-
238
- if (!data.is_scrolling && !data.active) {
239
- e.preventDefault();
240
- self._stop_timer($slides_container);
241
- var direction = (data.delta_x < 0) ? 'next' : 'prev';
242
- data.active = true;
243
- self._goto($slides_container, direction, function() {});
244
- }
245
- })
246
- .on('touchend.fndtn.orbit', function(e) {
247
- $container.data('swipe-transition', {});
248
- e.stopPropagation();
249
- });
250
- },
251
-
252
- _init_dimensions: function ($slides_container) {
253
- var $container = $slides_container.parent(),
254
- $slides = $slides_container.children();
255
-
256
- $slides_container.css('width', $slides.length * 100 + '%');
257
- $slides.css('width', 100 / $slides.length + '%');
258
- $slides_container.height($container.height());
259
- $slides_container.css('width', $slides.length * 100 + '%');
260
- },
261
-
262
- _start_timer: function ($slides_container) {
263
- var self = this,
264
- $container = $slides_container.parent();
265
-
266
- var callback = function() {
267
- self._reset_timer($slides_container, false);
268
- self._goto($slides_container, 'next', function() {
269
- self._start_timer($slides_container);
270
- });
271
- };
272
-
273
- var $timer = $container.find('.' + self.settings.timer_container_class),
274
- $progress = $timer.find('.' + self.settings.timer_progress_class),
275
- progress_pct = ($progress.width() / $timer.width()),
276
- delay = self.settings.timer_speed - (progress_pct * self.settings.timer_speed);
277
-
278
- $progress.animate({'width': '100%'}, delay, 'linear', callback);
279
- $slides_container.trigger('orbit:timer-started');
280
- },
281
-
282
- _stop_timer: function ($slides_container) {
283
- var self = this,
284
- $container = $slides_container.parent(),
285
- $timer = $container.find('.' + self.settings.timer_container_class),
286
- $progress = $timer.find('.' + self.settings.timer_progress_class),
287
- progress_pct = $progress.width() / $timer.width();
288
- self._rebuild_timer($container, progress_pct * 100 + '%');
289
- // $progress.stop();
290
- $slides_container.trigger('orbit:timer-stopped');
291
- $timer = $container.find('.' + self.settings.timer_container_class);
292
- $timer.addClass(self.settings.timer_paused_class);
293
- },
294
-
295
- _reset_timer: function($slides_container, is_paused) {
296
- var self = this,
297
- $container = $slides_container.parent();
298
- self._rebuild_timer($container, '0%');
299
- if (typeof is_paused === 'boolean' && is_paused) {
300
- var $timer = $container.find('.' + self.settings.timer_container_class);
301
- $timer.addClass(self.settings.timer_paused_class);
302
- }
303
- },
304
-
305
- _rebuild_timer: function ($container, width_pct) {
306
- // Zepto is unable to stop animations since they
307
- // are css-based. This is a workaround for that
308
- // limitation, which rebuilds the dom element
309
- // thus stopping the animation
310
- var self = this,
311
- $timer = $container.find('.' + self.settings.timer_container_class),
312
- $new_timer = $(self._timer_html()),
313
- $new_timer_progress = $new_timer.find('.' + self.settings.timer_progress_class);
314
-
315
- if (typeof Zepto === 'function') {
316
- $timer.remove();
317
- $container.append($new_timer);
318
- $new_timer_progress.css('width', width_pct);
319
- } else if (typeof jQuery === 'function') {
320
- var $progress = $timer.find('.' + self.settings.timer_progress_class);
321
- $progress.css('width', width_pct);
322
- $progress.stop();
323
- }
324
- },
325
-
326
- _goto: function($slides_container, index_or_direction, callback) {
327
- var self = this,
328
- $container = $slides_container.parent(),
329
- $slides = $slides_container.children(),
330
- $active_slide = $slides_container.find('.' + self.settings.active_slide_class),
331
- active_index = $active_slide.index(),
332
- margin_position = Foundation.rtl ? 'marginRight' : 'marginLeft';
333
-
334
- if ($container.hasClass(self.settings.orbit_transition_class)) {
335
- return false;
336
- }
337
-
338
- if (index_or_direction === 'prev') {
339
- if (active_index === 0) {
340
- active_index = $slides.length - 1;
341
- }
342
- else {
343
- active_index--;
344
- }
345
- }
346
- else if (index_or_direction === 'next') {
347
- active_index = (active_index+1) % $slides.length;
348
- }
349
- else if (typeof index_or_direction === 'number') {
350
- active_index = (index_or_direction % $slides.length);
351
- }
352
- if (active_index === ($slides.length - 1) && index_or_direction === 'next') {
353
- $slides_container.css(margin_position, '0%');
354
- active_index = 1;
355
- }
356
- else if (active_index === 0 && index_or_direction === 'prev') {
357
- $slides_container.css(margin_position, '-' + ($slides.length - 1) * 100 + '%');
358
- active_index = $slides.length - 2;
359
- }
360
- // Start transition, make next slide active
361
- $container.addClass(self.settings.orbit_transition_class);
362
- $active_slide.removeClass(self.settings.active_slide_class);
363
- $($slides[active_index]).addClass(self.settings.active_slide_class);
364
- // Make next bullet active
365
- var $bullets = $container.siblings('.' + self.settings.bullets_container_class);
366
- if ($bullets.length === 1) {
367
- $bullets.children().removeClass(self.settings.bullets_active_class);
368
- $($bullets.children()[active_index-1]).addClass(self.settings.bullets_active_class);
369
- }
370
- var new_margin_left = '-' + (active_index * 100) + '%';
371
- // Check to see if animation will occur, otherwise perform
372
- // callbacks manually
373
- $slides_container.trigger('orbit:before-slide-change');
374
- if ($slides_container.css(margin_position) === new_margin_left) {
375
- $container.removeClass(self.settings.orbit_transition_class);
376
- $slides_container.trigger('orbit:after-slide-change', [{slide_number: active_index, total_slides: $slides_container.children().length - 2}]);
377
- callback();
378
- } else {
379
- var properties = {};
380
- properties[margin_position] = new_margin_left;
381
-
382
- $slides_container.animate(properties, self.settings.animation_speed, 'linear', function() {
383
- $container.removeClass(self.settings.orbit_transition_class);
384
- $slides_container.trigger('orbit:after-slide-change', [{slide_number: active_index, total_slides: $slides_container.children().length - 2}]);
385
- callback();
386
- });
387
- }
388
- }
389
- };
390
- }(Foundation.zj, this, this.document));
@@ -1,179 +0,0 @@
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));