pbw 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +8 -8
  2. data/MIT-LICENSE +1 -1
  3. data/Rakefile +7 -0
  4. data/app/controllers/pbw/application_controller.rb +9 -3
  5. data/app/controllers/pbw/areas_controller.rb +7 -0
  6. data/app/controllers/pbw/base_models_controller.rb +106 -0
  7. data/app/controllers/pbw/capabilities_controller.rb +7 -0
  8. data/app/controllers/pbw/constraints_controller.rb +7 -0
  9. data/app/controllers/pbw/item_containers_controller.rb +7 -0
  10. data/app/controllers/pbw/item_conversions_controller.rb +7 -0
  11. data/app/controllers/pbw/item_transfers_controller.rb +7 -0
  12. data/app/controllers/pbw/items_controller.rb +7 -0
  13. data/app/controllers/pbw/processes_controller.rb +7 -0
  14. data/app/controllers/pbw/roles_controller.rb +5 -2
  15. data/app/controllers/pbw/tokens_controller.rb +7 -0
  16. data/app/controllers/pbw/triggers_controller.rb +7 -0
  17. data/app/controllers/pbw/user_tokens_controller.rb +7 -0
  18. data/app/models/pbw/area.rb +17 -0
  19. data/app/models/pbw/capability.rb +5 -0
  20. data/app/models/pbw/constraint.rb +6 -0
  21. data/app/models/pbw/item.rb +15 -0
  22. data/app/models/pbw/item_container.rb +12 -0
  23. data/app/models/pbw/item_conversion.rb +9 -0
  24. data/app/models/pbw/item_transfer.rb +9 -0
  25. data/app/models/pbw/permission.rb +1 -0
  26. data/app/models/pbw/process.rb +10 -0
  27. data/app/models/pbw/role.rb +1 -0
  28. data/app/models/pbw/rule.rb +11 -0
  29. data/app/models/pbw/token.rb +16 -0
  30. data/app/models/pbw/trigger.rb +7 -0
  31. data/app/models/pbw/user.rb +7 -5
  32. data/app/models/pbw/user_token.rb +16 -0
  33. data/app/views/layouts/pbw/application.html.erb +41 -8
  34. data/config/initializers/devise.rb +80 -4
  35. data/config/locales/devise.en.yml +59 -0
  36. data/config/routes.rb +11 -0
  37. data/lib/generators/pbw/install/install_generator.rb +9 -1
  38. data/lib/generators/pbw/install/templates/application.html.erb +47 -0
  39. data/lib/pbw/engine.rb +33 -13
  40. data/lib/pbw/version.rb +1 -1
  41. data/public/Foundation-MIT-LICENSE.txt +20 -0
  42. data/public/config.rb +26 -0
  43. data/public/humans.txt +8 -0
  44. data/public/javascripts/foundation/foundation.alerts.js +52 -0
  45. data/public/javascripts/foundation/foundation.clearing.js +516 -0
  46. data/public/javascripts/foundation/foundation.cookie.js +74 -0
  47. data/public/javascripts/foundation/foundation.dropdown.js +178 -0
  48. data/public/javascripts/foundation/foundation.forms.js +525 -0
  49. data/public/javascripts/foundation/foundation.interchange.js +271 -0
  50. data/public/javascripts/foundation/foundation.joyride.js +844 -0
  51. data/public/javascripts/foundation/foundation.js +447 -0
  52. data/public/javascripts/foundation/foundation.magellan.js +134 -0
  53. data/public/javascripts/foundation/foundation.orbit.js +390 -0
  54. data/public/javascripts/foundation/foundation.placeholder.js +179 -0
  55. data/public/javascripts/foundation/foundation.reveal.js +330 -0
  56. data/public/javascripts/foundation/foundation.section.js +422 -0
  57. data/public/javascripts/foundation/foundation.tooltips.js +208 -0
  58. data/public/javascripts/foundation/foundation.topbar.js +303 -0
  59. data/public/javascripts/vendor/custom.modernizr.js +4 -0
  60. data/public/javascripts/vendor/jquery.js +9807 -0
  61. data/public/javascripts/vendor/zepto.js +2000 -0
  62. data/public/robots.txt +4 -0
  63. data/public/sass/_normalize.scss +402 -0
  64. data/public/sass/_settings.scss +1271 -0
  65. data/public/sass/app.scss +48 -0
  66. data/public/stylesheets/app.css +6686 -0
  67. metadata +82 -4
  68. data/app/assets/javascripts/pbw/application.js +0 -13
  69. data/app/assets/stylesheets/pbw/application.css +0 -13
@@ -0,0 +1,844 @@
1
+ /*jslint unparam: true, browser: true, indent: 2 */
2
+
3
+ (function ($, window, document, undefined) {
4
+ 'use strict';
5
+
6
+ Foundation.libs.joyride = {
7
+ name: 'joyride',
8
+
9
+ version : '4.2.2',
10
+
11
+ defaults : {
12
+ expose : false, // turn on or off the expose feature
13
+ modal : false, // Whether to cover page with modal during the tour
14
+ tipLocation : 'bottom', // 'top' or 'bottom' in relation to parent
15
+ nubPosition : 'auto', // override on a per tooltip bases
16
+ scrollSpeed : 300, // Page scrolling speed in milliseconds, 0 = no scroll animation
17
+ timer : 0, // 0 = no timer , all other numbers = timer in milliseconds
18
+ startTimerOnClick : true, // true or false - true requires clicking the first button start the timer
19
+ startOffset : 0, // the index of the tooltip you want to start on (index of the li)
20
+ nextButton : true, // true or false to control whether a next button is used
21
+ tipAnimation : 'fade', // 'pop' or 'fade' in each tip
22
+ pauseAfter : [], // array of indexes where to pause the tour after
23
+ exposed : [], // array of expose elements
24
+ tipAnimationFadeSpeed: 300, // when tipAnimation = 'fade' this is speed in milliseconds for the transition
25
+ cookieMonster : false, // true or false to control whether cookies are used
26
+ cookieName : 'joyride', // Name the cookie you'll use
27
+ cookieDomain : false, // Will this cookie be attached to a domain, ie. '.notableapp.com'
28
+ cookieExpires : 365, // set when you would like the cookie to expire.
29
+ tipContainer : 'body', // Where will the tip be attached
30
+ postRideCallback : function (){}, // A method to call once the tour closes (canceled or complete)
31
+ postStepCallback : function (){}, // A method to call after each step
32
+ preStepCallback : function (){}, // A method to call before each step
33
+ preRideCallback : function (){}, // A method to call before the tour starts (passed index, tip, and cloned exposed element)
34
+ postExposeCallback : function (){}, // A method to call after an element has been exposed
35
+ template : { // HTML segments for tip layout
36
+ link : '<a href="#close" class="joyride-close-tip">&times;</a>',
37
+ timer : '<div class="joyride-timer-indicator-wrap"><span class="joyride-timer-indicator"></span></div>',
38
+ tip : '<div class="joyride-tip-guide"><span class="joyride-nub"></span></div>',
39
+ wrapper : '<div class="joyride-content-wrapper"></div>',
40
+ button : '<a href="#" class="small button joyride-next-tip"></a>',
41
+ modal : '<div class="joyride-modal-bg"></div>',
42
+ expose : '<div class="joyride-expose-wrapper"></div>',
43
+ exposeCover: '<div class="joyride-expose-cover"></div>'
44
+ },
45
+ exposeAddClass : '' // One or more space-separated class names to be added to exposed element
46
+ },
47
+
48
+ settings : {},
49
+
50
+ init : function (scope, method, options) {
51
+ this.scope = scope || this.scope;
52
+ Foundation.inherit(this, 'throttle data_options scrollTo scrollLeft delay');
53
+
54
+ if (typeof method === 'object') {
55
+ $.extend(true, this.settings, this.defaults, method);
56
+ } else {
57
+ $.extend(true, this.settings, this.defaults, options);
58
+ }
59
+
60
+ if (typeof method !== 'string') {
61
+ if (!this.settings.init) this.events();
62
+
63
+ return this.settings.init;
64
+ } else {
65
+ return this[method].call(this, options);
66
+ }
67
+ },
68
+
69
+ events : function () {
70
+ var self = this;
71
+
72
+ $(this.scope)
73
+ .on('click.joyride', '.joyride-next-tip, .joyride-modal-bg', function (e) {
74
+ e.preventDefault();
75
+
76
+ if (this.settings.$li.next().length < 1) {
77
+ this.end();
78
+ } else if (this.settings.timer > 0) {
79
+ clearTimeout(this.settings.automate);
80
+ this.hide();
81
+ this.show();
82
+ this.startTimer();
83
+ } else {
84
+ this.hide();
85
+ this.show();
86
+ }
87
+
88
+ }.bind(this))
89
+
90
+ .on('click.joyride', '.joyride-close-tip', function (e) {
91
+ e.preventDefault();
92
+ this.end();
93
+ }.bind(this));
94
+
95
+ $(window).on('resize.fndtn.joyride', self.throttle(function () {
96
+ if ($('[data-joyride]').length > 0 && self.settings.$next_tip) {
97
+ if (self.settings.exposed.length > 0) {
98
+ var $els = $(self.settings.exposed);
99
+
100
+ $els.each(function () {
101
+ var $this = $(this);
102
+ self.un_expose($this);
103
+ self.expose($this);
104
+ });
105
+ }
106
+
107
+ if (self.is_phone()) {
108
+ self.pos_phone();
109
+ } else {
110
+ self.pos_default(false, true);
111
+ }
112
+ }
113
+ }, 100));
114
+
115
+ this.settings.init = true;
116
+ },
117
+
118
+ start : function () {
119
+ var self = this,
120
+ $this = $(this.scope).find('[data-joyride]'),
121
+ integer_settings = ['timer', 'scrollSpeed', 'startOffset', 'tipAnimationFadeSpeed', 'cookieExpires'],
122
+ int_settings_count = integer_settings.length;
123
+
124
+ if (!this.settings.init) this.init();
125
+
126
+ // non configureable settings
127
+ this.settings.$content_el = $this;
128
+ this.settings.$body = $(this.settings.tipContainer);
129
+ this.settings.body_offset = $(this.settings.tipContainer).position();
130
+ this.settings.$tip_content = this.settings.$content_el.find('> li');
131
+ this.settings.paused = false;
132
+ this.settings.attempts = 0;
133
+
134
+ this.settings.tipLocationPatterns = {
135
+ top: ['bottom'],
136
+ bottom: [], // bottom should not need to be repositioned
137
+ left: ['right', 'top', 'bottom'],
138
+ right: ['left', 'top', 'bottom']
139
+ };
140
+
141
+ // can we create cookies?
142
+ if (typeof $.cookie !== 'function') {
143
+ this.settings.cookieMonster = false;
144
+ }
145
+
146
+ // generate the tips and insert into dom.
147
+ if (!this.settings.cookieMonster || this.settings.cookieMonster && $.cookie(this.settings.cookieName) === null) {
148
+ this.settings.$tip_content.each(function (index) {
149
+ var $this = $(this);
150
+ $.extend(true, self.settings, self.data_options($this));
151
+ // Make sure that settings parsed from data_options are integers where necessary
152
+ for (var i = int_settings_count - 1; i >= 0; i--) {
153
+ self.settings[integer_settings[i]] = parseInt(self.settings[integer_settings[i]], 10);
154
+ }
155
+ self.create({$li : $this, index : index});
156
+ });
157
+
158
+ // show first tip
159
+ if (!this.settings.startTimerOnClick && this.settings.timer > 0) {
160
+ this.show('init');
161
+ this.startTimer();
162
+ } else {
163
+ this.show('init');
164
+ }
165
+
166
+ }
167
+ },
168
+
169
+ resume : function () {
170
+ this.set_li();
171
+ this.show();
172
+ },
173
+
174
+ tip_template : function (opts) {
175
+ var $blank, content;
176
+
177
+ opts.tip_class = opts.tip_class || '';
178
+
179
+ $blank = $(this.settings.template.tip).addClass(opts.tip_class);
180
+ content = $.trim($(opts.li).html()) +
181
+ this.button_text(opts.button_text) +
182
+ this.settings.template.link +
183
+ this.timer_instance(opts.index);
184
+
185
+ $blank.append($(this.settings.template.wrapper));
186
+ $blank.first().attr('data-index', opts.index);
187
+ $('.joyride-content-wrapper', $blank).append(content);
188
+
189
+ return $blank[0];
190
+ },
191
+
192
+ timer_instance : function (index) {
193
+ var txt;
194
+
195
+ if ((index === 0 && this.settings.startTimerOnClick && this.settings.timer > 0) || this.settings.timer === 0) {
196
+ txt = '';
197
+ } else {
198
+ txt = this.outerHTML($(this.settings.template.timer)[0]);
199
+ }
200
+ return txt;
201
+ },
202
+
203
+ button_text : function (txt) {
204
+ if (this.settings.nextButton) {
205
+ txt = $.trim(txt) || 'Next';
206
+ txt = this.outerHTML($(this.settings.template.button).append(txt)[0]);
207
+ } else {
208
+ txt = '';
209
+ }
210
+ return txt;
211
+ },
212
+
213
+ create : function (opts) {
214
+ var buttonText = opts.$li.attr('data-button') || opts.$li.attr('data-text'),
215
+ tipClass = opts.$li.attr('class'),
216
+ $tip_content = $(this.tip_template({
217
+ tip_class : tipClass,
218
+ index : opts.index,
219
+ button_text : buttonText,
220
+ li : opts.$li
221
+ }));
222
+
223
+ $(this.settings.tipContainer).append($tip_content);
224
+ },
225
+
226
+ show : function (init) {
227
+ var $timer = null;
228
+
229
+ // are we paused?
230
+ if (this.settings.$li === undefined
231
+ || ($.inArray(this.settings.$li.index(), this.settings.pauseAfter) === -1)) {
232
+
233
+ // don't go to the next li if the tour was paused
234
+ if (this.settings.paused) {
235
+ this.settings.paused = false;
236
+ } else {
237
+ this.set_li(init);
238
+ }
239
+
240
+ this.settings.attempts = 0;
241
+
242
+ if (this.settings.$li.length && this.settings.$target.length > 0) {
243
+ if (init) { //run when we first start
244
+ this.settings.preRideCallback(this.settings.$li.index(), this.settings.$next_tip);
245
+ if (this.settings.modal) {
246
+ this.show_modal();
247
+ }
248
+ }
249
+
250
+ this.settings.preStepCallback(this.settings.$li.index(), this.settings.$next_tip);
251
+
252
+ if (this.settings.modal && this.settings.expose) {
253
+ this.expose();
254
+ }
255
+
256
+ this.settings.tipSettings = $.extend(this.settings, this.data_options(this.settings.$li));
257
+
258
+ this.settings.timer = parseInt(this.settings.timer, 10);
259
+
260
+ this.settings.tipSettings.tipLocationPattern = this.settings.tipLocationPatterns[this.settings.tipSettings.tipLocation];
261
+
262
+ // scroll if not modal
263
+ if (!/body/i.test(this.settings.$target.selector)) {
264
+ this.scroll_to();
265
+ }
266
+
267
+ if (this.is_phone()) {
268
+ this.pos_phone(true);
269
+ } else {
270
+ this.pos_default(true);
271
+ }
272
+
273
+ $timer = this.settings.$next_tip.find('.joyride-timer-indicator');
274
+
275
+ if (/pop/i.test(this.settings.tipAnimation)) {
276
+
277
+ $timer.width(0);
278
+
279
+ if (this.settings.timer > 0) {
280
+
281
+ this.settings.$next_tip.show();
282
+
283
+ this.delay(function () {
284
+ $timer.animate({
285
+ width: $timer.parent().width()
286
+ }, this.settings.timer, 'linear');
287
+ }.bind(this), this.settings.tipAnimationFadeSpeed);
288
+
289
+ } else {
290
+ this.settings.$next_tip.show();
291
+
292
+ }
293
+
294
+
295
+ } else if (/fade/i.test(this.settings.tipAnimation)) {
296
+
297
+ $timer.width(0);
298
+
299
+ if (this.settings.timer > 0) {
300
+
301
+ this.settings.$next_tip
302
+ .fadeIn(this.settings.tipAnimationFadeSpeed)
303
+ .show();
304
+
305
+ this.delay(function () {
306
+ $timer.animate({
307
+ width: $timer.parent().width()
308
+ }, this.settings.timer, 'linear');
309
+ }.bind(this), this.settings.tipAnimationFadeSpeed);
310
+
311
+ } else {
312
+ this.settings.$next_tip.fadeIn(this.settings.tipAnimationFadeSpeed);
313
+
314
+ }
315
+ }
316
+
317
+ this.settings.$current_tip = this.settings.$next_tip;
318
+
319
+ // skip non-existant targets
320
+ } else if (this.settings.$li && this.settings.$target.length < 1) {
321
+
322
+ this.show();
323
+
324
+ } else {
325
+
326
+ this.end();
327
+
328
+ }
329
+ } else {
330
+
331
+ this.settings.paused = true;
332
+
333
+ }
334
+
335
+ },
336
+
337
+ is_phone : function () {
338
+ if (Modernizr) {
339
+ return Modernizr.mq('only screen and (max-width: 767px)') || $('.lt-ie9').length > 0;
340
+ }
341
+
342
+ return (this.settings.$window.width() < 767);
343
+ },
344
+
345
+ hide : function () {
346
+ if (this.settings.modal && this.settings.expose) {
347
+ this.un_expose();
348
+ }
349
+
350
+ if (!this.settings.modal) {
351
+ $('.joyride-modal-bg').hide();
352
+ }
353
+ this.settings.$current_tip.hide();
354
+ this.settings.postStepCallback(this.settings.$li.index(),
355
+ this.settings.$current_tip);
356
+ },
357
+
358
+ set_li : function (init) {
359
+ if (init) {
360
+ this.settings.$li = this.settings.$tip_content.eq(this.settings.startOffset);
361
+ this.set_next_tip();
362
+ this.settings.$current_tip = this.settings.$next_tip;
363
+ } else {
364
+ this.settings.$li = this.settings.$li.next();
365
+ this.set_next_tip();
366
+ }
367
+
368
+ this.set_target();
369
+ },
370
+
371
+ set_next_tip : function () {
372
+ this.settings.$next_tip = $(".joyride-tip-guide[data-index='" + this.settings.$li.index() + "']");
373
+ this.settings.$next_tip.data('closed', '');
374
+ },
375
+
376
+ set_target : function () {
377
+ var cl = this.settings.$li.attr('data-class'),
378
+ id = this.settings.$li.attr('data-id'),
379
+ $sel = function () {
380
+ if (id) {
381
+ return $(document.getElementById(id));
382
+ } else if (cl) {
383
+ return $('.' + cl).first();
384
+ } else {
385
+ return $('body');
386
+ }
387
+ };
388
+
389
+ this.settings.$target = $sel();
390
+ },
391
+
392
+ scroll_to : function () {
393
+ var window_half, tipOffset;
394
+
395
+ window_half = $(window).height() / 2;
396
+ tipOffset = Math.ceil(this.settings.$target.offset().top - window_half + this.outerHeight(this.settings.$next_tip));
397
+ if (tipOffset > 0) {
398
+ this.scrollTo($('html, body'), tipOffset, this.settings.scrollSpeed);
399
+ }
400
+ },
401
+
402
+ paused : function () {
403
+ return ($.inArray((this.settings.$li.index() + 1), this.settings.pauseAfter) === -1);
404
+ },
405
+
406
+ restart : function () {
407
+ this.hide();
408
+ this.settings.$li = undefined;
409
+ this.show('init');
410
+ },
411
+
412
+ pos_default : function (init, resizing) {
413
+ var half_fold = Math.ceil($(window).height() / 2),
414
+ tip_position = this.settings.$next_tip.offset(),
415
+ $nub = this.settings.$next_tip.find('.joyride-nub'),
416
+ nub_width = Math.ceil(this.outerWidth($nub) / 2),
417
+ nub_height = Math.ceil(this.outerHeight($nub) / 2),
418
+ toggle = init || false;
419
+
420
+ // tip must not be "display: none" to calculate position
421
+ if (toggle) {
422
+ this.settings.$next_tip.css('visibility', 'hidden');
423
+ this.settings.$next_tip.show();
424
+ }
425
+
426
+ if (typeof resizing === 'undefined') {
427
+ resizing = false;
428
+ }
429
+
430
+ if (!/body/i.test(this.settings.$target.selector)) {
431
+
432
+ if (this.bottom()) {
433
+ var leftOffset = this.settings.$target.offset().left;
434
+ if (Foundation.rtl) {
435
+ leftOffset = this.settings.$target.offset().width - this.settings.$next_tip.width() + leftOffset;
436
+ }
437
+ this.settings.$next_tip.css({
438
+ top: (this.settings.$target.offset().top + nub_height + this.outerHeight(this.settings.$target)),
439
+ left: leftOffset});
440
+
441
+ this.nub_position($nub, this.settings.tipSettings.nubPosition, 'top');
442
+
443
+ } else if (this.top()) {
444
+ var leftOffset = this.settings.$target.offset().left;
445
+ if (Foundation.rtl) {
446
+ leftOffset = this.settings.$target.offset().width - this.settings.$next_tip.width() + leftOffset;
447
+ }
448
+ this.settings.$next_tip.css({
449
+ top: (this.settings.$target.offset().top - this.outerHeight(this.settings.$next_tip) - nub_height),
450
+ left: leftOffset});
451
+
452
+ this.nub_position($nub, this.settings.tipSettings.nubPosition, 'bottom');
453
+
454
+ } else if (this.right()) {
455
+
456
+ this.settings.$next_tip.css({
457
+ top: this.settings.$target.offset().top,
458
+ left: (this.outerWidth(this.settings.$target) + this.settings.$target.offset().left + nub_width)});
459
+
460
+ this.nub_position($nub, this.settings.tipSettings.nubPosition, 'left');
461
+
462
+ } else if (this.left()) {
463
+
464
+ this.settings.$next_tip.css({
465
+ top: this.settings.$target.offset().top,
466
+ left: (this.settings.$target.offset().left - this.outerWidth(this.settings.$next_tip) - nub_width)});
467
+
468
+ this.nub_position($nub, this.settings.tipSettings.nubPosition, 'right');
469
+
470
+ }
471
+
472
+ if (!this.visible(this.corners(this.settings.$next_tip)) && this.settings.attempts < this.settings.tipSettings.tipLocationPattern.length) {
473
+
474
+ $nub.removeClass('bottom')
475
+ .removeClass('top')
476
+ .removeClass('right')
477
+ .removeClass('left');
478
+
479
+ this.settings.tipSettings.tipLocation = this.settings.tipSettings.tipLocationPattern[this.settings.attempts];
480
+
481
+ this.settings.attempts++;
482
+
483
+ this.pos_default();
484
+
485
+ }
486
+
487
+ } else if (this.settings.$li.length) {
488
+
489
+ this.pos_modal($nub);
490
+
491
+ }
492
+
493
+ if (toggle) {
494
+ this.settings.$next_tip.hide();
495
+ this.settings.$next_tip.css('visibility', 'visible');
496
+ }
497
+
498
+ },
499
+
500
+ pos_phone : function (init) {
501
+ var tip_height = this.outerHeight(this.settings.$next_tip),
502
+ tip_offset = this.settings.$next_tip.offset(),
503
+ target_height = this.outerHeight(this.settings.$target),
504
+ $nub = $('.joyride-nub', this.settings.$next_tip),
505
+ nub_height = Math.ceil(this.outerHeight($nub) / 2),
506
+ toggle = init || false;
507
+
508
+ $nub.removeClass('bottom')
509
+ .removeClass('top')
510
+ .removeClass('right')
511
+ .removeClass('left');
512
+
513
+ if (toggle) {
514
+ this.settings.$next_tip.css('visibility', 'hidden');
515
+ this.settings.$next_tip.show();
516
+ }
517
+
518
+ if (!/body/i.test(this.settings.$target.selector)) {
519
+
520
+ if (this.top()) {
521
+
522
+ this.settings.$next_tip.offset({top: this.settings.$target.offset().top - tip_height - nub_height});
523
+ $nub.addClass('bottom');
524
+
525
+ } else {
526
+
527
+ this.settings.$next_tip.offset({top: this.settings.$target.offset().top + target_height + nub_height});
528
+ $nub.addClass('top');
529
+
530
+ }
531
+
532
+ } else if (this.settings.$li.length) {
533
+ this.pos_modal($nub);
534
+ }
535
+
536
+ if (toggle) {
537
+ this.settings.$next_tip.hide();
538
+ this.settings.$next_tip.css('visibility', 'visible');
539
+ }
540
+ },
541
+
542
+ pos_modal : function ($nub) {
543
+ this.center();
544
+ $nub.hide();
545
+
546
+ this.show_modal();
547
+ },
548
+
549
+ show_modal : function () {
550
+ if (!this.settings.$next_tip.data('closed')) {
551
+ var joyridemodalbg = $('.joyride-modal-bg');
552
+ if (joyridemodalbg.length < 1) {
553
+ $('body').append(this.settings.template.modal).show();
554
+ }
555
+
556
+ if (/pop/i.test(this.settings.tipAnimation)) {
557
+ joyridemodalbg.show();
558
+ } else {
559
+ joyridemodalbg.fadeIn(this.settings.tipAnimationFadeSpeed);
560
+ }
561
+ }
562
+ },
563
+
564
+ expose : function () {
565
+ var expose,
566
+ exposeCover,
567
+ el,
568
+ origCSS,
569
+ origClasses,
570
+ randId = 'expose-'+Math.floor(Math.random()*10000);
571
+
572
+ if (arguments.length > 0 && arguments[0] instanceof $) {
573
+ el = arguments[0];
574
+ } else if(this.settings.$target && !/body/i.test(this.settings.$target.selector)){
575
+ el = this.settings.$target;
576
+ } else {
577
+ return false;
578
+ }
579
+
580
+ if(el.length < 1){
581
+ if(window.console){
582
+ console.error('element not valid', el);
583
+ }
584
+ return false;
585
+ }
586
+
587
+ expose = $(this.settings.template.expose);
588
+ this.settings.$body.append(expose);
589
+ expose.css({
590
+ top: el.offset().top,
591
+ left: el.offset().left,
592
+ width: this.outerWidth(el, true),
593
+ height: this.outerHeight(el, true)
594
+ });
595
+
596
+ exposeCover = $(this.settings.template.exposeCover);
597
+
598
+ origCSS = {
599
+ zIndex: el.css('z-index'),
600
+ position: el.css('position')
601
+ };
602
+
603
+ origClasses = el.attr('class') == null ? '' : el.attr('class');
604
+
605
+ el.css('z-index',parseInt(expose.css('z-index'))+1);
606
+
607
+ if (origCSS.position == 'static') {
608
+ el.css('position','relative');
609
+ }
610
+
611
+ el.data('expose-css',origCSS);
612
+ el.data('orig-class', origClasses);
613
+ el.attr('class', origClasses + ' ' + this.settings.exposeAddClass);
614
+
615
+ exposeCover.css({
616
+ top: el.offset().top,
617
+ left: el.offset().left,
618
+ width: this.outerWidth(el, true),
619
+ height: this.outerHeight(el, true)
620
+ });
621
+
622
+ this.settings.$body.append(exposeCover);
623
+ expose.addClass(randId);
624
+ exposeCover.addClass(randId);
625
+ el.data('expose', randId);
626
+ this.settings.postExposeCallback(this.settings.$li.index(), this.settings.$next_tip, el);
627
+ this.add_exposed(el);
628
+ },
629
+
630
+ un_expose : function () {
631
+ var exposeId,
632
+ el,
633
+ expose ,
634
+ origCSS,
635
+ origClasses,
636
+ clearAll = false;
637
+
638
+ if (arguments.length > 0 && arguments[0] instanceof $) {
639
+ el = arguments[0];
640
+ } else if(this.settings.$target && !/body/i.test(this.settings.$target.selector)){
641
+ el = this.settings.$target;
642
+ } else {
643
+ return false;
644
+ }
645
+
646
+ if(el.length < 1){
647
+ if (window.console) {
648
+ console.error('element not valid', el);
649
+ }
650
+ return false;
651
+ }
652
+
653
+ exposeId = el.data('expose');
654
+ expose = $('.' + exposeId);
655
+
656
+ if (arguments.length > 1) {
657
+ clearAll = arguments[1];
658
+ }
659
+
660
+ if (clearAll === true) {
661
+ $('.joyride-expose-wrapper,.joyride-expose-cover').remove();
662
+ } else {
663
+ expose.remove();
664
+ }
665
+
666
+ origCSS = el.data('expose-css');
667
+
668
+ if (origCSS.zIndex == 'auto') {
669
+ el.css('z-index', '');
670
+ } else {
671
+ el.css('z-index', origCSS.zIndex);
672
+ }
673
+
674
+ if (origCSS.position != el.css('position')) {
675
+ if(origCSS.position == 'static') {// this is default, no need to set it.
676
+ el.css('position', '');
677
+ } else {
678
+ el.css('position', origCSS.position);
679
+ }
680
+ }
681
+
682
+ origClasses = el.data('orig-class');
683
+ el.attr('class', origClasses);
684
+ el.removeData('orig-classes');
685
+
686
+ el.removeData('expose');
687
+ el.removeData('expose-z-index');
688
+ this.remove_exposed(el);
689
+ },
690
+
691
+ add_exposed: function(el){
692
+ this.settings.exposed = this.settings.exposed || [];
693
+ if (el instanceof $ || typeof el === 'object') {
694
+ this.settings.exposed.push(el[0]);
695
+ } else if (typeof el == 'string') {
696
+ this.settings.exposed.push(el);
697
+ }
698
+ },
699
+
700
+ remove_exposed: function(el){
701
+ var search, count;
702
+ if (el instanceof $) {
703
+ search = el[0]
704
+ } else if (typeof el == 'string'){
705
+ search = el;
706
+ }
707
+
708
+ this.settings.exposed = this.settings.exposed || [];
709
+ count = this.settings.exposed.length;
710
+
711
+ for (var i=0; i < count; i++) {
712
+ if (this.settings.exposed[i] == search) {
713
+ this.settings.exposed.splice(i, 1);
714
+ return;
715
+ }
716
+ }
717
+ },
718
+
719
+ center : function () {
720
+ var $w = $(window);
721
+
722
+ this.settings.$next_tip.css({
723
+ top : ((($w.height() - this.outerHeight(this.settings.$next_tip)) / 2) + $w.scrollTop()),
724
+ left : ((($w.width() - this.outerWidth(this.settings.$next_tip)) / 2) + this.scrollLeft($w))
725
+ });
726
+
727
+ return true;
728
+ },
729
+
730
+ bottom : function () {
731
+ return /bottom/i.test(this.settings.tipSettings.tipLocation);
732
+ },
733
+
734
+ top : function () {
735
+ return /top/i.test(this.settings.tipSettings.tipLocation);
736
+ },
737
+
738
+ right : function () {
739
+ return /right/i.test(this.settings.tipSettings.tipLocation);
740
+ },
741
+
742
+ left : function () {
743
+ return /left/i.test(this.settings.tipSettings.tipLocation);
744
+ },
745
+
746
+ corners : function (el) {
747
+ var w = $(window),
748
+ window_half = w.height() / 2,
749
+ //using this to calculate since scroll may not have finished yet.
750
+ tipOffset = Math.ceil(this.settings.$target.offset().top - window_half + this.settings.$next_tip.outerHeight()),
751
+ right = w.width() + this.scrollLeft(w),
752
+ offsetBottom = w.height() + tipOffset,
753
+ bottom = w.height() + w.scrollTop(),
754
+ top = w.scrollTop();
755
+
756
+ if (tipOffset < top) {
757
+ if (tipOffset < 0) {
758
+ top = 0;
759
+ } else {
760
+ top = tipOffset;
761
+ }
762
+ }
763
+
764
+ if (offsetBottom > bottom) {
765
+ bottom = offsetBottom;
766
+ }
767
+
768
+ return [
769
+ el.offset().top < top,
770
+ right < el.offset().left + el.outerWidth(),
771
+ bottom < el.offset().top + el.outerHeight(),
772
+ this.scrollLeft(w) > el.offset().left
773
+ ];
774
+ },
775
+
776
+ visible : function (hidden_corners) {
777
+ var i = hidden_corners.length;
778
+
779
+ while (i--) {
780
+ if (hidden_corners[i]) return false;
781
+ }
782
+
783
+ return true;
784
+ },
785
+
786
+ nub_position : function (nub, pos, def) {
787
+ if (pos === 'auto') {
788
+ nub.addClass(def);
789
+ } else {
790
+ nub.addClass(pos);
791
+ }
792
+ },
793
+
794
+ startTimer : function () {
795
+ if (this.settings.$li.length) {
796
+ this.settings.automate = setTimeout(function () {
797
+ this.hide();
798
+ this.show();
799
+ this.startTimer();
800
+ }.bind(this), this.settings.timer);
801
+ } else {
802
+ clearTimeout(this.settings.automate);
803
+ }
804
+ },
805
+
806
+ end : function () {
807
+ if (this.settings.cookieMonster) {
808
+ $.cookie(this.settings.cookieName, 'ridden', { expires: this.settings.cookieExpires, domain: this.settings.cookieDomain });
809
+ }
810
+
811
+ if (this.settings.timer > 0) {
812
+ clearTimeout(this.settings.automate);
813
+ }
814
+
815
+ if (this.settings.modal && this.settings.expose) {
816
+ this.un_expose();
817
+ }
818
+
819
+ this.settings.$next_tip.data('closed', true);
820
+
821
+ $('.joyride-modal-bg').hide();
822
+ this.settings.$current_tip.hide();
823
+ this.settings.postStepCallback(this.settings.$li.index(), this.settings.$current_tip);
824
+ this.settings.postRideCallback(this.settings.$li.index(), this.settings.$current_tip);
825
+ $('.joyride-tip-guide').remove();
826
+ },
827
+
828
+ outerHTML : function (el) {
829
+ // support FireFox < 11
830
+ return el.outerHTML || new XMLSerializer().serializeToString(el);
831
+ },
832
+
833
+ off : function () {
834
+ $(this.scope).off('.joyride');
835
+ $(window).off('.joyride');
836
+ $('.joyride-close-tip, .joyride-next-tip, .joyride-modal-bg').off('.joyride');
837
+ $('.joyride-tip-guide, .joyride-modal-bg').remove();
838
+ clearTimeout(this.settings.automate);
839
+ this.settings = {};
840
+ },
841
+
842
+ reflow : function () {}
843
+ };
844
+ }(Foundation.zj, this, this.document));