~johnsca/charms/trusty/cloudfoundry/better-basic-reconciler-status

« back to all changes in this revision

Viewing changes to reconciler/ui/static/semantic/less/modules/popup.js

  • Committer: Whit Morriss
  • Date: 2014-10-13 06:50:17 UTC
  • mto: (132.2.1 reconciler) (145.1.1 trunk)
  • mto: This revision was merged to the branch mainline in revision 156.
  • Revision ID: whit.morriss@canonical.com-20141013065017-0feo2ku3yllymkol
reorg reconciler

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * # Semantic - Popup
 
3
 * http://github.com/jlukic/semantic-ui/
 
4
 *
 
5
 *
 
6
 * Copyright 2014 Contributors
 
7
 * Released under the MIT license
 
8
 * http://opensource.org/licenses/MIT
 
9
 *
 
10
 */
 
11
 
 
12
;(function ($, window, document, undefined) {
 
13
 
 
14
$.fn.popup = function(parameters) {
 
15
  var
 
16
    $allModules     = $(this),
 
17
    $document       = $(document),
 
18
 
 
19
    moduleSelector  = $allModules.selector || '',
 
20
 
 
21
    time            = new Date().getTime(),
 
22
    performance     = [],
 
23
 
 
24
    query           = arguments[0],
 
25
    methodInvoked   = (typeof query == 'string'),
 
26
    queryArguments  = [].slice.call(arguments, 1),
 
27
 
 
28
    returnedValue
 
29
  ;
 
30
  $allModules
 
31
    .each(function() {
 
32
      var
 
33
        settings        = ( $.isPlainObject(parameters) )
 
34
          ? $.extend(true, {}, $.fn.popup.settings, parameters)
 
35
          : $.extend({}, $.fn.popup.settings),
 
36
 
 
37
        selector        = settings.selector,
 
38
        className       = settings.className,
 
39
        error           = settings.error,
 
40
        metadata        = settings.metadata,
 
41
        namespace       = settings.namespace,
 
42
 
 
43
        eventNamespace  = '.' + settings.namespace,
 
44
        moduleNamespace = 'module-' + namespace,
 
45
 
 
46
        $module         = $(this),
 
47
        $context        = $(settings.context),
 
48
        $target         = (settings.target)
 
49
          ? $(settings.target)
 
50
          : $module,
 
51
 
 
52
        $window         = $(window),
 
53
 
 
54
        $offsetParent   = (settings.inline)
 
55
          ? $target.offsetParent()
 
56
          : $window,
 
57
        $popup          = (settings.inline)
 
58
          ? $target.next(settings.selector.popup)
 
59
          : $window.children(settings.selector.popup).last(),
 
60
 
 
61
        searchDepth     = 0,
 
62
 
 
63
        element         = this,
 
64
        instance        = $module.data(moduleNamespace),
 
65
        module
 
66
      ;
 
67
 
 
68
      module = {
 
69
 
 
70
        // binds events
 
71
        initialize: function() {
 
72
          module.debug('Initializing module', $module);
 
73
          if(settings.on == 'click') {
 
74
            $module
 
75
              .on('click', module.toggle)
 
76
            ;
 
77
          }
 
78
          else {
 
79
            $module
 
80
              .on(module.get.startEvent() + eventNamespace, module.event.start)
 
81
              .on(module.get.endEvent() + eventNamespace, module.event.end)
 
82
            ;
 
83
          }
 
84
          if(settings.target) {
 
85
            module.debug('Target set to element', $target);
 
86
          }
 
87
          $window
 
88
            .on('resize' + eventNamespace, module.event.resize)
 
89
          ;
 
90
          module.instantiate();
 
91
        },
 
92
 
 
93
        instantiate: function() {
 
94
          module.verbose('Storing instance of module', module);
 
95
          instance = module;
 
96
          $module
 
97
            .data(moduleNamespace, instance)
 
98
          ;
 
99
        },
 
100
 
 
101
        refresh: function() {
 
102
          if(settings.inline) {
 
103
            $popup = $target.next(selector.popup);
 
104
            $offsetParent = $target.offsetParent();
 
105
          }
 
106
          else {
 
107
            $popup = $window.children(selector.popup).last();
 
108
          }
 
109
        },
 
110
 
 
111
        destroy: function() {
 
112
          module.debug('Destroying previous module');
 
113
          $window
 
114
            .off(eventNamespace)
 
115
          ;
 
116
          $popup
 
117
            .remove()
 
118
          ;
 
119
          $module
 
120
            .off(eventNamespace)
 
121
            .removeData(moduleNamespace)
 
122
          ;
 
123
        },
 
124
 
 
125
        event: {
 
126
          start:  function(event) {
 
127
            module.timer = setTimeout(function() {
 
128
              if( module.is.hidden() ) {
 
129
                module.show();
 
130
              }
 
131
            }, settings.delay);
 
132
          },
 
133
          end:  function() {
 
134
            clearTimeout(module.timer);
 
135
            if( module.is.visible() ) {
 
136
              module.hide();
 
137
            }
 
138
          },
 
139
          resize: function() {
 
140
            if( module.is.visible() ) {
 
141
              module.set.position();
 
142
            }
 
143
          }
 
144
        },
 
145
 
 
146
        // generates popup html from metadata
 
147
        create: function() {
 
148
          module.debug('Creating pop-up html');
 
149
          var
 
150
            html      = $module.data(metadata.html)      || settings.html,
 
151
            variation = $module.data(metadata.variation) || settings.variation,
 
152
            title     = $module.data(metadata.title)     || settings.title,
 
153
            content   = $module.data(metadata.content)   || $module.attr('title') || settings.content
 
154
          ;
 
155
          if(html || content || title) {
 
156
            if(!html) {
 
157
              html = settings.template({
 
158
                title   : title,
 
159
                content : content
 
160
              });
 
161
            }
 
162
            $popup = $('<div/>')
 
163
              .addClass(className.popup)
 
164
              .addClass(variation)
 
165
              .html(html)
 
166
            ;
 
167
            if(settings.inline) {
 
168
              module.verbose('Inserting popup element inline', $popup);
 
169
              $popup
 
170
                .data(moduleNamespace, instance)
 
171
                .insertAfter($module)
 
172
              ;
 
173
            }
 
174
            else {
 
175
              module.verbose('Appending popup element to body', $popup);
 
176
              $popup
 
177
                .data(moduleNamespace, instance)
 
178
                .appendTo( $context )
 
179
              ;
 
180
            }
 
181
            $.proxy(settings.onCreate, $popup)();
 
182
          }
 
183
          else {
 
184
            module.error(error.content);
 
185
          }
 
186
        },
 
187
 
 
188
        // determines popup state
 
189
        toggle: function() {
 
190
          module.debug('Toggling pop-up');
 
191
          if( module.is.hidden() ) {
 
192
            module.debug('Popup is hidden, showing pop-up');
 
193
            module.unbind.close();
 
194
            module.hideAll();
 
195
            module.show();
 
196
          }
 
197
          else {
 
198
            module.debug('Popup is visible, hiding pop-up');
 
199
            module.hide();
 
200
          }
 
201
        },
 
202
 
 
203
        show: function(callback) {
 
204
          callback = callback || function(){};
 
205
          module.debug('Showing pop-up', settings.transition);
 
206
          if(!settings.preserve) {
 
207
            module.refresh();
 
208
          }
 
209
          if( !module.exists() ) {
 
210
            module.create();
 
211
          }
 
212
          module.save.conditions();
 
213
          module.set.position();
 
214
          module.animate.show(callback);
 
215
        },
 
216
 
 
217
 
 
218
        hide: function(callback) {
 
219
          callback = callback || function(){};
 
220
          $module
 
221
            .removeClass(className.visible)
 
222
          ;
 
223
          module.restore.conditions();
 
224
          module.unbind.close();
 
225
          if( module.is.visible() ) {
 
226
            module.animate.hide(callback);
 
227
          }
 
228
        },
 
229
 
 
230
        hideAll: function() {
 
231
          $(selector.popup)
 
232
            .filter(':visible')
 
233
              .popup('hide')
 
234
          ;
 
235
        },
 
236
 
 
237
        hideGracefully: function(event) {
 
238
          // don't close on clicks inside popup
 
239
          if(event && $(event.target).closest(selector.popup).size() === 0) {
 
240
            module.debug('Click occurred outside popup hiding popup');
 
241
            module.hide();
 
242
          }
 
243
          else {
 
244
            module.debug('Click was inside popup, keeping popup open');
 
245
          }
 
246
        },
 
247
 
 
248
        exists: function() {
 
249
          if(settings.inline) {
 
250
            return ( $popup.size() !== 0 );
 
251
          }
 
252
          else {
 
253
            return ( $popup.parent($context).size() );
 
254
          }
 
255
        },
 
256
 
 
257
        remove: function() {
 
258
          module.debug('Removing popup');
 
259
          $popup
 
260
            .remove()
 
261
          ;
 
262
          $.proxy(settings.onRemove, $popup)();
 
263
        },
 
264
 
 
265
        save: {
 
266
          conditions: function() {
 
267
            module.cache = {
 
268
              title: $module.attr('title')
 
269
            };
 
270
            if (module.cache.title) {
 
271
              $module.removeAttr('title');
 
272
            }
 
273
            module.verbose('Saving original attributes', module.cache.title);
 
274
          }
 
275
        },
 
276
        restore: {
 
277
          conditions: function() {
 
278
            if(module.cache && module.cache.title) {
 
279
              $module.attr('title', module.cache.title);
 
280
              module.verbose('Restoring original attributes', module.cache.title);
 
281
            }
 
282
            return true;
 
283
          }
 
284
        },
 
285
        animate: {
 
286
          show: function(callback) {
 
287
            callback = callback || function(){};
 
288
            $module
 
289
              .addClass(className.visible)
 
290
            ;
 
291
            if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
 
292
              $popup
 
293
                .transition(settings.transition + ' in', settings.duration, function() {
 
294
                  module.bind.close();
 
295
                  $.proxy(callback, element)();
 
296
                })
 
297
              ;
 
298
            }
 
299
            else {
 
300
              $popup
 
301
                .stop()
 
302
                .fadeIn(settings.duration, settings.easing, function() {
 
303
                  module.bind.close();
 
304
                  $.proxy(callback, element)();
 
305
                })
 
306
              ;
 
307
            }
 
308
            $.proxy(settings.onShow, element)();
 
309
          },
 
310
          hide: function(callback) {
 
311
            callback = callback || function(){};
 
312
            module.debug('Hiding pop-up');
 
313
            if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
 
314
              $popup
 
315
                .transition(settings.transition + ' out', settings.duration, function() {
 
316
                  module.reset();
 
317
                  callback();
 
318
                })
 
319
              ;
 
320
            }
 
321
            else {
 
322
              $popup
 
323
                .stop()
 
324
                .fadeOut(settings.duration, settings.easing, function() {
 
325
                  module.reset();
 
326
                  callback();
 
327
                })
 
328
              ;
 
329
            }
 
330
            $.proxy(settings.onHide, element)();
 
331
          }
 
332
        },
 
333
 
 
334
        get: {
 
335
          startEvent: function() {
 
336
            if(settings.on == 'hover') {
 
337
              return 'mouseenter';
 
338
            }
 
339
            else if(settings.on == 'focus') {
 
340
              return 'focus';
 
341
            }
 
342
          },
 
343
          endEvent: function() {
 
344
            if(settings.on == 'hover') {
 
345
              return 'mouseleave';
 
346
            }
 
347
            else if(settings.on == 'focus') {
 
348
              return 'blur';
 
349
            }
 
350
          },
 
351
          offstagePosition: function() {
 
352
            var
 
353
              boundary  = {
 
354
                top    : $(window).scrollTop(),
 
355
                bottom : $(window).scrollTop() + $(window).height(),
 
356
                left   : 0,
 
357
                right  : $(window).width()
 
358
              },
 
359
              popup     = {
 
360
                width    : $popup.width(),
 
361
                height   : $popup.outerHeight(),
 
362
                position : $popup.offset()
 
363
              },
 
364
              offstage  = {},
 
365
              offstagePositions = []
 
366
            ;
 
367
            if(popup.position) {
 
368
              offstage = {
 
369
                top    : (popup.position.top < boundary.top),
 
370
                bottom : (popup.position.top + popup.height > boundary.bottom),
 
371
                right  : (popup.position.left + popup.width > boundary.right),
 
372
                left   : (popup.position.left < boundary.left)
 
373
              };
 
374
            }
 
375
            module.verbose('Checking if outside viewable area', popup.position);
 
376
            // return only boundaries that have been surpassed
 
377
            $.each(offstage, function(direction, isOffstage) {
 
378
              if(isOffstage) {
 
379
                offstagePositions.push(direction);
 
380
              }
 
381
            });
 
382
            return (offstagePositions.length > 0)
 
383
              ? offstagePositions.join(' ')
 
384
              : false
 
385
            ;
 
386
          },
 
387
          nextPosition: function(position) {
 
388
            switch(position) {
 
389
              case 'top left':
 
390
                position = 'bottom left';
 
391
              break;
 
392
              case 'bottom left':
 
393
                position = 'top right';
 
394
              break;
 
395
              case 'top right':
 
396
                position = 'bottom right';
 
397
              break;
 
398
              case 'bottom right':
 
399
                position = 'top center';
 
400
              break;
 
401
              case 'top center':
 
402
                position = 'bottom center';
 
403
              break;
 
404
              case 'bottom center':
 
405
                position = 'right center';
 
406
              break;
 
407
              case 'right center':
 
408
                position = 'left center';
 
409
              break;
 
410
              case 'left center':
 
411
                position = 'top center';
 
412
              break;
 
413
            }
 
414
            return position;
 
415
          }
 
416
        },
 
417
 
 
418
        set: {
 
419
          position: function(position, arrowOffset) {
 
420
            var
 
421
              windowWidth  = $(window).width(),
 
422
              windowHeight = $(window).height(),
 
423
 
 
424
              width        = $target.outerWidth(),
 
425
              height       = $target.outerHeight(),
 
426
 
 
427
              popupWidth   = $popup.width(),
 
428
              popupHeight  = $popup.outerHeight(),
 
429
 
 
430
              parentWidth  = $offsetParent.outerWidth(),
 
431
              parentHeight = $offsetParent.outerHeight(),
 
432
 
 
433
              distanceAway = settings.distanceAway,
 
434
 
 
435
              offset       = (settings.inline)
 
436
                ? $target.position()
 
437
                : $target.offset(),
 
438
 
 
439
              positioning,
 
440
              offstagePosition
 
441
            ;
 
442
            position    = position    || $module.data(metadata.position)    || settings.position;
 
443
            arrowOffset = arrowOffset || $module.data(metadata.offset)      || settings.offset;
 
444
            // adjust for margin when inline
 
445
            if(settings.inline) {
 
446
              if(position == 'left center' || position == 'right center') {
 
447
                arrowOffset  += parseInt( window.getComputedStyle(element).getPropertyValue('margin-top'), 10);
 
448
                distanceAway += -parseInt( window.getComputedStyle(element).getPropertyValue('margin-left'), 10);
 
449
              }
 
450
              else {
 
451
                arrowOffset  += parseInt( window.getComputedStyle(element).getPropertyValue('margin-left'), 10);
 
452
                distanceAway += parseInt( window.getComputedStyle(element).getPropertyValue('margin-top'), 10);
 
453
              }
 
454
            }
 
455
            module.debug('Calculating offset for position', position);
 
456
            switch(position) {
 
457
              case 'top left':
 
458
                positioning = {
 
459
                  bottom :  parentHeight - offset.top + distanceAway,
 
460
                  right  :  parentWidth - offset.left - arrowOffset,
 
461
                  top    : 'auto',
 
462
                  left   : 'auto'
 
463
                };
 
464
              break;
 
465
              case 'top center':
 
466
                positioning = {
 
467
                  bottom :  parentHeight - offset.top + distanceAway,
 
468
                  left   : offset.left + (width / 2) - (popupWidth / 2) + arrowOffset,
 
469
                  top    : 'auto',
 
470
                  right  : 'auto'
 
471
                };
 
472
              break;
 
473
              case 'top right':
 
474
                positioning = {
 
475
                  top    : 'auto',
 
476
                  bottom :  parentHeight - offset.top + distanceAway,
 
477
                  left   : offset.left + width + arrowOffset,
 
478
                  right  : 'auto'
 
479
                };
 
480
              break;
 
481
              case 'left center':
 
482
                positioning = {
 
483
                  top    :  offset.top + (height / 2) - (popupHeight / 2) + arrowOffset,
 
484
                  right  : parentWidth - offset.left + distanceAway,
 
485
                  left   : 'auto',
 
486
                  bottom : 'auto'
 
487
                };
 
488
              break;
 
489
              case 'right center':
 
490
                positioning = {
 
491
                  top    :  offset.top + (height / 2) - (popupHeight / 2) + arrowOffset,
 
492
                  left   : offset.left + width + distanceAway,
 
493
                  bottom : 'auto',
 
494
                  right  : 'auto'
 
495
                };
 
496
              break;
 
497
              case 'bottom left':
 
498
                positioning = {
 
499
                  top    :  offset.top + height + distanceAway,
 
500
                  right  : parentWidth - offset.left - arrowOffset,
 
501
                  left   : 'auto',
 
502
                  bottom : 'auto'
 
503
                };
 
504
              break;
 
505
              case 'bottom center':
 
506
                positioning = {
 
507
                  top    :  offset.top + height + distanceAway,
 
508
                  left   : offset.left + (width / 2) - (popupWidth / 2) + arrowOffset,
 
509
                  bottom : 'auto',
 
510
                  right  : 'auto'
 
511
                };
 
512
              break;
 
513
              case 'bottom right':
 
514
                positioning = {
 
515
                  top    :  offset.top + height + distanceAway,
 
516
                  left   : offset.left + width + arrowOffset,
 
517
                  bottom : 'auto',
 
518
                  right  : 'auto'
 
519
                };
 
520
              break;
 
521
            }
 
522
            // tentatively place on stage
 
523
            $popup
 
524
              .css(positioning)
 
525
              .removeClass(className.position)
 
526
              .addClass(position)
 
527
              .addClass(className.loading)
 
528
            ;
 
529
            // check if is offstage
 
530
            offstagePosition = module.get.offstagePosition();
 
531
 
 
532
            // recursively find new positioning
 
533
            if(offstagePosition) {
 
534
              module.debug('Element is outside boundaries', offstagePosition);
 
535
              if(searchDepth < settings.maxSearchDepth) {
 
536
                position = module.get.nextPosition(position);
 
537
                searchDepth++;
 
538
                module.debug('Trying new position', position);
 
539
                return module.set.position(position);
 
540
              }
 
541
              else {
 
542
                module.error(error.recursion);
 
543
                searchDepth = 0;
 
544
                module.reset();
 
545
                $popup.removeClass(className.loading);
 
546
                return false;
 
547
              }
 
548
            }
 
549
            else {
 
550
              module.debug('Position is on stage', position);
 
551
              searchDepth = 0;
 
552
              $popup.removeClass(className.loading);
 
553
              return true;
 
554
            }
 
555
          }
 
556
 
 
557
        },
 
558
 
 
559
        bind: {
 
560
          close:function() {
 
561
            if(settings.on == 'click' && settings.closable) {
 
562
              module.verbose('Binding popup close event to document');
 
563
              $document
 
564
                .on('click' + eventNamespace, function(event) {
 
565
                  module.verbose('Pop-up clickaway intent detected');
 
566
                  $.proxy(module.hideGracefully, this)(event);
 
567
                })
 
568
              ;
 
569
            }
 
570
          }
 
571
        },
 
572
 
 
573
        unbind: {
 
574
          close: function() {
 
575
            if(settings.on == 'click' && settings.closable) {
 
576
              module.verbose('Removing close event from document');
 
577
              $document
 
578
                .off('click' + eventNamespace)
 
579
              ;
 
580
            }
 
581
          }
 
582
        },
 
583
 
 
584
        is: {
 
585
          animating: function() {
 
586
            return ( $popup.is(':animated') || $popup.hasClass(className.animating) );
 
587
          },
 
588
          visible: function() {
 
589
            return $popup.is(':visible');
 
590
          },
 
591
          hidden: function() {
 
592
            return !module.is.visible();
 
593
          }
 
594
        },
 
595
 
 
596
        reset: function() {
 
597
          $popup
 
598
            .attr('style', '')
 
599
            .removeAttr('style')
 
600
          ;
 
601
          if(!settings.preserve) {
 
602
            module.remove();
 
603
          }
 
604
        },
 
605
 
 
606
        setting: function(name, value) {
 
607
          if( $.isPlainObject(name) ) {
 
608
            $.extend(true, settings, name);
 
609
          }
 
610
          else if(value !== undefined) {
 
611
            settings[name] = value;
 
612
          }
 
613
          else {
 
614
            return settings[name];
 
615
          }
 
616
        },
 
617
        internal: function(name, value) {
 
618
          if( $.isPlainObject(name) ) {
 
619
            $.extend(true, module, name);
 
620
          }
 
621
          else if(value !== undefined) {
 
622
            module[name] = value;
 
623
          }
 
624
          else {
 
625
            return module[name];
 
626
          }
 
627
        },
 
628
        debug: function() {
 
629
          if(settings.debug) {
 
630
            if(settings.performance) {
 
631
              module.performance.log(arguments);
 
632
            }
 
633
            else {
 
634
              module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
 
635
              module.debug.apply(console, arguments);
 
636
            }
 
637
          }
 
638
        },
 
639
        verbose: function() {
 
640
          if(settings.verbose && settings.debug) {
 
641
            if(settings.performance) {
 
642
              module.performance.log(arguments);
 
643
            }
 
644
            else {
 
645
              module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
 
646
              module.verbose.apply(console, arguments);
 
647
            }
 
648
          }
 
649
        },
 
650
        error: function() {
 
651
          module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
 
652
          module.error.apply(console, arguments);
 
653
        },
 
654
        performance: {
 
655
          log: function(message) {
 
656
            var
 
657
              currentTime,
 
658
              executionTime,
 
659
              previousTime
 
660
            ;
 
661
            if(settings.performance) {
 
662
              currentTime   = new Date().getTime();
 
663
              previousTime  = time || currentTime;
 
664
              executionTime = currentTime - previousTime;
 
665
              time          = currentTime;
 
666
              performance.push({
 
667
                'Element'        : element,
 
668
                'Name'           : message[0],
 
669
                'Arguments'      : [].slice.call(message, 1) || '',
 
670
                'Execution Time' : executionTime
 
671
              });
 
672
            }
 
673
            clearTimeout(module.performance.timer);
 
674
            module.performance.timer = setTimeout(module.performance.display, 100);
 
675
          },
 
676
          display: function() {
 
677
            var
 
678
              title = settings.name + ':',
 
679
              totalTime = 0
 
680
            ;
 
681
            time = false;
 
682
            clearTimeout(module.performance.timer);
 
683
            $.each(performance, function(index, data) {
 
684
              totalTime += data['Execution Time'];
 
685
            });
 
686
            title += ' ' + totalTime + 'ms';
 
687
            if(moduleSelector) {
 
688
              title += ' \'' + moduleSelector + '\'';
 
689
            }
 
690
            if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
 
691
              console.groupCollapsed(title);
 
692
              if(console.table) {
 
693
                console.table(performance);
 
694
              }
 
695
              else {
 
696
                $.each(performance, function(index, data) {
 
697
                  console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
 
698
                });
 
699
              }
 
700
              console.groupEnd();
 
701
            }
 
702
            performance = [];
 
703
          }
 
704
        },
 
705
        invoke: function(query, passedArguments, context) {
 
706
          var
 
707
            object = instance,
 
708
            maxDepth,
 
709
            found,
 
710
            response
 
711
          ;
 
712
          passedArguments = passedArguments || queryArguments;
 
713
          context         = element         || context;
 
714
          if(typeof query == 'string' && object !== undefined) {
 
715
            query    = query.split(/[\. ]/);
 
716
            maxDepth = query.length - 1;
 
717
            $.each(query, function(depth, value) {
 
718
              var camelCaseValue = (depth != maxDepth)
 
719
                ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
 
720
                : query
 
721
              ;
 
722
              if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
 
723
                object = object[camelCaseValue];
 
724
              }
 
725
              else if( object[camelCaseValue] !== undefined ) {
 
726
                found = object[camelCaseValue];
 
727
                return false;
 
728
              }
 
729
              else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
 
730
                object = object[value];
 
731
              }
 
732
              else if( object[value] !== undefined ) {
 
733
                found = object[value];
 
734
                return false;
 
735
              }
 
736
              else {
 
737
                return false;
 
738
              }
 
739
            });
 
740
          }
 
741
          if ( $.isFunction( found ) ) {
 
742
            response = found.apply(context, passedArguments);
 
743
          }
 
744
          else if(found !== undefined) {
 
745
            response = found;
 
746
          }
 
747
          if($.isArray(returnedValue)) {
 
748
            returnedValue.push(response);
 
749
          }
 
750
          else if(returnedValue !== undefined) {
 
751
            returnedValue = [returnedValue, response];
 
752
          }
 
753
          else if(response !== undefined) {
 
754
            returnedValue = response;
 
755
          }
 
756
          return found;
 
757
        }
 
758
      };
 
759
 
 
760
      if(methodInvoked) {
 
761
        if(instance === undefined) {
 
762
          module.initialize();
 
763
        }
 
764
        module.invoke(query);
 
765
      }
 
766
      else {
 
767
        if(instance !== undefined) {
 
768
          module.destroy();
 
769
        }
 
770
        module.initialize();
 
771
      }
 
772
    })
 
773
  ;
 
774
 
 
775
  return (returnedValue !== undefined)
 
776
    ? returnedValue
 
777
    : this
 
778
  ;
 
779
};
 
780
 
 
781
$.fn.popup.settings = {
 
782
 
 
783
  name           : 'Popup',
 
784
  debug          : false,
 
785
  verbose        : true,
 
786
  performance    : true,
 
787
  namespace      : 'popup',
 
788
 
 
789
  onCreate       : function(){},
 
790
  onRemove       : function(){},
 
791
  onShow         : function(){},
 
792
  onHide         : function(){},
 
793
 
 
794
  variation      : '',
 
795
  content        : false,
 
796
  html           : false,
 
797
  title          : false,
 
798
 
 
799
  on             : 'hover',
 
800
  target         : false,
 
801
  closable       : true,
 
802
 
 
803
  context        : 'body',
 
804
  position       : 'top center',
 
805
  delay          : 150,
 
806
  inline         : false,
 
807
  preserve       : false,
 
808
 
 
809
  duration       : 250,
 
810
  easing         : 'easeOutQuad',
 
811
  transition     : 'scale',
 
812
 
 
813
  distanceAway   : 0,
 
814
  offset         : 0,
 
815
  maxSearchDepth : 10,
 
816
 
 
817
  error: {
 
818
    content   : 'Your popup has no content specified',
 
819
    method    : 'The method you called is not defined.',
 
820
    recursion : 'Popup attempted to reposition element to fit, but could not find an adequate position.'
 
821
  },
 
822
 
 
823
  metadata: {
 
824
    content   : 'content',
 
825
    html      : 'html',
 
826
    offset    : 'offset',
 
827
    position  : 'position',
 
828
    title     : 'title',
 
829
    variation : 'variation'
 
830
  },
 
831
 
 
832
  className   : {
 
833
    animating   : 'animating',
 
834
    loading     : 'loading',
 
835
    popup       : 'ui popup',
 
836
    position    : 'top left center bottom right',
 
837
    visible     : 'visible'
 
838
  },
 
839
 
 
840
  selector    : {
 
841
    popup    : '.ui.popup'
 
842
  },
 
843
 
 
844
  template: function(text) {
 
845
    var html = '';
 
846
    if(typeof text !== undefined) {
 
847
      if(typeof text.title !== undefined && text.title) {
 
848
        html += '<div class="header">' + text.title + '</div>';
 
849
      }
 
850
      if(typeof text.content !== undefined && text.content) {
 
851
        html += '<div class="content">' + text.content + '</div>';
 
852
      }
 
853
    }
 
854
    return html;
 
855
  }
 
856
 
 
857
};
 
858
 
 
859
// Adds easing
 
860
$.extend( $.easing, {
 
861
  easeOutQuad: function (x, t, b, c, d) {
 
862
    return -c *(t/=d)*(t-2) + b;
 
863
  }
 
864
});
 
865
 
 
866
 
 
867
})( jQuery, window , document );