Code Duplication    Length = 477-477 lines in 2 locations

public/lib/semantic/semantic.js 1 location

@@ 21-497 (lines=477) @@
18
 *
19
 */
20
21
;(function ($, window, document, undefined) {
22
23
$.site = $.fn.site = function(parameters) {
24
  var
25
    time           = new Date().getTime(),
26
    performance    = [],
27
28
    query          = arguments[0],
29
    methodInvoked  = (typeof query == 'string'),
30
    queryArguments = [].slice.call(arguments, 1),
31
32
    settings        = ( $.isPlainObject(parameters) )
33
      ? $.extend(true, {}, $.site.settings, parameters)
34
      : $.extend({}, $.site.settings),
35
36
    namespace       = settings.namespace,
37
    error           = settings.error,
38
39
    eventNamespace  = '.' + namespace,
40
    moduleNamespace = 'module-' + namespace,
41
42
    $document       = $(document),
43
    $module         = $document,
44
    element         = this,
45
    instance        = $module.data(moduleNamespace),
46
47
    module,
48
    returnedValue
49
  ;
50
  module = {
51
52
    initialize: function() {
53
      module.instantiate();
54
    },
55
56
    instantiate: function() {
57
      module.verbose('Storing instance of site', module);
58
      instance = module;
59
      $module
60
        .data(moduleNamespace, module)
61
      ;
62
    },
63
64
    normalize: function() {
65
      module.fix.console();
66
      module.fix.requestAnimationFrame();
67
    },
68
69
    fix: {
70
      console: function() {
71
        module.debug('Normalizing window.console');
72
        if (console === undefined || console.log === undefined) {
73
          module.verbose('Console not available, normalizing events');
74
          module.disable.console();
75
        }
76
        if (typeof console.group == 'undefined' || typeof console.groupEnd == 'undefined' || typeof console.groupCollapsed == 'undefined') {
77
          module.verbose('Console group not available, normalizing events');
78
          window.console.group = function() {};
79
          window.console.groupEnd = function() {};
80
          window.console.groupCollapsed = function() {};
81
        }
82
        if (typeof console.markTimeline == 'undefined') {
83
          module.verbose('Mark timeline not available, normalizing events');
84
          window.console.markTimeline = function() {};
85
        }
86
      },
87
      consoleClear: function() {
88
        module.debug('Disabling programmatic console clearing');
89
        window.console.clear = function() {};
90
      },
91
      requestAnimationFrame: function() {
92
        module.debug('Normalizing requestAnimationFrame');
93
        if(window.requestAnimationFrame === undefined) {
94
          module.debug('RequestAnimationFrame not available, normalizing event');
95
          window.requestAnimationFrame = window.requestAnimationFrame
96
            || window.mozRequestAnimationFrame
97
            || window.webkitRequestAnimationFrame
98
            || window.msRequestAnimationFrame
99
            || function(callback) { setTimeout(callback, 0); }
100
          ;
101
        }
102
      }
103
    },
104
105
    moduleExists: function(name) {
106
      return ($.fn[name] !== undefined && $.fn[name].settings !== undefined);
107
    },
108
109
    enabled: {
110
      modules: function(modules) {
111
        var
112
          enabledModules = []
113
        ;
114
        modules = modules || settings.modules;
115
        $.each(modules, function(index, name) {
116
          if(module.moduleExists(name)) {
117
            enabledModules.push(name);
118
          }
119
        });
120
        return enabledModules;
121
      }
122
    },
123
124
    disabled: {
125
      modules: function(modules) {
126
        var
127
          disabledModules = []
128
        ;
129
        modules = modules || settings.modules;
130
        $.each(modules, function(index, name) {
131
          if(!module.moduleExists(name)) {
132
            disabledModules.push(name);
133
          }
134
        });
135
        return disabledModules;
136
      }
137
    },
138
139
    change: {
140
      setting: function(setting, value, modules, modifyExisting) {
141
        modules = (typeof modules === 'string')
142
          ? (modules === 'all')
143
            ? settings.modules
144
            : [modules]
145
          : modules || settings.modules
146
        ;
147
        modifyExisting = (modifyExisting !== undefined)
148
          ? modifyExisting
149
          : true
150
        ;
151
        $.each(modules, function(index, name) {
152
          var
153
            namespace = (module.moduleExists(name))
154
              ? $.fn[name].settings.namespace || false
155
              : true,
156
            $existingModules
157
          ;
158
          if(module.moduleExists(name)) {
159
            module.verbose('Changing default setting', setting, value, name);
160
            $.fn[name].settings[setting] = value;
161
            if(modifyExisting && namespace) {
162
              $existingModules = $(':data(module-' + namespace + ')');
163
              if($existingModules.length > 0) {
164
                module.verbose('Modifying existing settings', $existingModules);
165
                $existingModules[name]('setting', setting, value);
166
              }
167
            }
168
          }
169
        });
170
      },
171
      settings: function(newSettings, modules, modifyExisting) {
172
        modules = (typeof modules === 'string')
173
          ? [modules]
174
          : modules || settings.modules
175
        ;
176
        modifyExisting = (modifyExisting !== undefined)
177
          ? modifyExisting
178
          : true
179
        ;
180
        $.each(modules, function(index, name) {
181
          var
182
            $existingModules
183
          ;
184
          if(module.moduleExists(name)) {
185
            module.verbose('Changing default setting', newSettings, name);
186
            $.extend(true, $.fn[name].settings, newSettings);
187
            if(modifyExisting && namespace) {
188
              $existingModules = $(':data(module-' + namespace + ')');
189
              if($existingModules.length > 0) {
190
                module.verbose('Modifying existing settings', $existingModules);
191
                $existingModules[name]('setting', newSettings);
192
              }
193
            }
194
          }
195
        });
196
      }
197
    },
198
199
    enable: {
200
      console: function() {
201
        module.console(true);
202
      },
203
      debug: function(modules, modifyExisting) {
204
        modules = modules || settings.modules;
205
        module.debug('Enabling debug for modules', modules);
206
        module.change.setting('debug', true, modules, modifyExisting);
207
      },
208
      verbose: function(modules, modifyExisting) {
209
        modules = modules || settings.modules;
210
        module.debug('Enabling verbose debug for modules', modules);
211
        module.change.setting('verbose', true, modules, modifyExisting);
212
      }
213
    },
214
    disable: {
215
      console: function() {
216
        module.console(false);
217
      },
218
      debug: function(modules, modifyExisting) {
219
        modules = modules || settings.modules;
220
        module.debug('Disabling debug for modules', modules);
221
        module.change.setting('debug', false, modules, modifyExisting);
222
      },
223
      verbose: function(modules, modifyExisting) {
224
        modules = modules || settings.modules;
225
        module.debug('Disabling verbose debug for modules', modules);
226
        module.change.setting('verbose', false, modules, modifyExisting);
227
      }
228
    },
229
230
    console: function(enable) {
231
      if(enable) {
232
        if(instance.cache.console === undefined) {
233
          module.error(error.console);
234
          return;
235
        }
236
        module.debug('Restoring console function');
237
        window.console = instance.cache.console;
238
      }
239
      else {
240
        module.debug('Disabling console function');
241
        instance.cache.console = window.console;
242
        window.console = {
243
          clear          : function(){},
244
          error          : function(){},
245
          group          : function(){},
246
          groupCollapsed : function(){},
247
          groupEnd       : function(){},
248
          info           : function(){},
249
          log            : function(){},
250
          markTimeline   : function(){},
251
          warn           : function(){}
252
        };
253
      }
254
    },
255
256
    destroy: function() {
257
      module.verbose('Destroying previous site for', $module);
258
      $module
259
        .removeData(moduleNamespace)
260
      ;
261
    },
262
263
    cache: {},
264
265
    setting: function(name, value) {
266
      if( $.isPlainObject(name) ) {
267
        $.extend(true, settings, name);
268
      }
269
      else if(value !== undefined) {
270
        settings[name] = value;
271
      }
272
      else {
273
        return settings[name];
274
      }
275
    },
276
    internal: function(name, value) {
277
      if( $.isPlainObject(name) ) {
278
        $.extend(true, module, name);
279
      }
280
      else if(value !== undefined) {
281
        module[name] = value;
282
      }
283
      else {
284
        return module[name];
285
      }
286
    },
287
    debug: function() {
288
      if(settings.debug) {
289
        if(settings.performance) {
290
          module.performance.log(arguments);
291
        }
292
        else {
293
          module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
294
          module.debug.apply(console, arguments);
295
        }
296
      }
297
    },
298
    verbose: function() {
299
      if(settings.verbose && settings.debug) {
300
        if(settings.performance) {
301
          module.performance.log(arguments);
302
        }
303
        else {
304
          module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
305
          module.verbose.apply(console, arguments);
306
        }
307
      }
308
    },
309
    error: function() {
310
      module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
311
      module.error.apply(console, arguments);
312
    },
313
    performance: {
314
      log: function(message) {
315
        var
316
          currentTime,
317
          executionTime,
318
          previousTime
319
        ;
320
        if(settings.performance) {
321
          currentTime   = new Date().getTime();
322
          previousTime  = time || currentTime;
323
          executionTime = currentTime - previousTime;
324
          time          = currentTime;
325
          performance.push({
326
            'Element'        : element,
327
            'Name'           : message[0],
328
            'Arguments'      : [].slice.call(message, 1) || '',
329
            'Execution Time' : executionTime
330
          });
331
        }
332
        clearTimeout(module.performance.timer);
333
        module.performance.timer = setTimeout(module.performance.display, 500);
334
      },
335
      display: function() {
336
        var
337
          title = settings.name + ':',
338
          totalTime = 0
339
        ;
340
        time = false;
341
        clearTimeout(module.performance.timer);
342
        $.each(performance, function(index, data) {
343
          totalTime += data['Execution Time'];
344
        });
345
        title += ' ' + totalTime + 'ms';
346
        if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
347
          console.groupCollapsed(title);
348
          if(console.table) {
349
            console.table(performance);
350
          }
351
          else {
352
            $.each(performance, function(index, data) {
353
              console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
354
            });
355
          }
356
          console.groupEnd();
357
        }
358
        performance = [];
359
      }
360
    },
361
    invoke: function(query, passedArguments, context) {
362
      var
363
        object = instance,
364
        maxDepth,
365
        found,
366
        response
367
      ;
368
      passedArguments = passedArguments || queryArguments;
369
      context         = element         || context;
370
      if(typeof query == 'string' && object !== undefined) {
371
        query    = query.split(/[\. ]/);
372
        maxDepth = query.length - 1;
373
        $.each(query, function(depth, value) {
374
          var camelCaseValue = (depth != maxDepth)
375
            ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
376
            : query
377
          ;
378
          if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
379
            object = object[camelCaseValue];
380
          }
381
          else if( object[camelCaseValue] !== undefined ) {
382
            found = object[camelCaseValue];
383
            return false;
384
          }
385
          else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
386
            object = object[value];
387
          }
388
          else if( object[value] !== undefined ) {
389
            found = object[value];
390
            return false;
391
          }
392
          else {
393
            module.error(error.method, query);
394
            return false;
395
          }
396
        });
397
      }
398
      if ( $.isFunction( found ) ) {
399
        response = found.apply(context, passedArguments);
400
      }
401
      else if(found !== undefined) {
402
        response = found;
403
      }
404
      if($.isArray(returnedValue)) {
405
        returnedValue.push(response);
406
      }
407
      else if(returnedValue !== undefined) {
408
        returnedValue = [returnedValue, response];
409
      }
410
      else if(response !== undefined) {
411
        returnedValue = response;
412
      }
413
      return found;
414
    }
415
  };
416
417
  if(methodInvoked) {
418
    if(instance === undefined) {
419
      module.initialize();
420
    }
421
    module.invoke(query);
422
  }
423
  else {
424
    if(instance !== undefined) {
425
      module.destroy();
426
    }
427
    module.initialize();
428
  }
429
  return (returnedValue !== undefined)
430
    ? returnedValue
431
    : this
432
  ;
433
};
434
435
$.site.settings = {
436
437
  name        : 'Site',
438
  namespace   : 'site',
439
440
  error : {
441
    console : 'Console cannot be restored, most likely it was overwritten outside of module',
442
    method : 'The method you called is not defined.'
443
  },
444
445
  debug       : false,
446
  verbose     : false,
447
  performance : true,
448
449
  modules: [
450
    'accordion',
451
    'api',
452
    'checkbox',
453
    'dimmer',
454
    'dropdown',
455
    'embed',
456
    'form',
457
    'modal',
458
    'nag',
459
    'popup',
460
    'rating',
461
    'shape',
462
    'sidebar',
463
    'state',
464
    'sticky',
465
    'tab',
466
    'transition',
467
    'visit',
468
    'visibility'
469
  ],
470
471
  siteNamespace   : 'site',
472
  namespaceStub   : {
473
    cache     : {},
474
    config    : {},
475
    sections  : {},
476
    section   : {},
477
    utilities : {}
478
  }
479
480
};
481
482
// allows for selection of elements with data attributes
483
$.extend($.expr[ ":" ], {
484
  data: ($.expr.createPseudo)
485
    ? $.expr.createPseudo(function(dataName) {
486
        return function(elem) {
487
          return !!$.data(elem, dataName);
488
        };
489
      })
490
    : function(elem, i, match) {
491
      // support: jQuery < 1.8
492
      return !!$.data(elem, match[ 3 ]);
493
    }
494
});
495
496
497
})( jQuery, window, document );
498
499
/*!
500
 * # Semantic UI 2.2.11 - Form Validation

public/lib/semantic/components/site.js 1 location

@@ 11-487 (lines=477) @@
8
 *
9
 */
10
11
;(function ($, window, document, undefined) {
12
13
$.site = $.fn.site = function(parameters) {
14
  var
15
    time           = new Date().getTime(),
16
    performance    = [],
17
18
    query          = arguments[0],
19
    methodInvoked  = (typeof query == 'string'),
20
    queryArguments = [].slice.call(arguments, 1),
21
22
    settings        = ( $.isPlainObject(parameters) )
23
      ? $.extend(true, {}, $.site.settings, parameters)
24
      : $.extend({}, $.site.settings),
25
26
    namespace       = settings.namespace,
27
    error           = settings.error,
28
29
    eventNamespace  = '.' + namespace,
30
    moduleNamespace = 'module-' + namespace,
31
32
    $document       = $(document),
33
    $module         = $document,
34
    element         = this,
35
    instance        = $module.data(moduleNamespace),
36
37
    module,
38
    returnedValue
39
  ;
40
  module = {
41
42
    initialize: function() {
43
      module.instantiate();
44
    },
45
46
    instantiate: function() {
47
      module.verbose('Storing instance of site', module);
48
      instance = module;
49
      $module
50
        .data(moduleNamespace, module)
51
      ;
52
    },
53
54
    normalize: function() {
55
      module.fix.console();
56
      module.fix.requestAnimationFrame();
57
    },
58
59
    fix: {
60
      console: function() {
61
        module.debug('Normalizing window.console');
62
        if (console === undefined || console.log === undefined) {
63
          module.verbose('Console not available, normalizing events');
64
          module.disable.console();
65
        }
66
        if (typeof console.group == 'undefined' || typeof console.groupEnd == 'undefined' || typeof console.groupCollapsed == 'undefined') {
67
          module.verbose('Console group not available, normalizing events');
68
          window.console.group = function() {};
69
          window.console.groupEnd = function() {};
70
          window.console.groupCollapsed = function() {};
71
        }
72
        if (typeof console.markTimeline == 'undefined') {
73
          module.verbose('Mark timeline not available, normalizing events');
74
          window.console.markTimeline = function() {};
75
        }
76
      },
77
      consoleClear: function() {
78
        module.debug('Disabling programmatic console clearing');
79
        window.console.clear = function() {};
80
      },
81
      requestAnimationFrame: function() {
82
        module.debug('Normalizing requestAnimationFrame');
83
        if(window.requestAnimationFrame === undefined) {
84
          module.debug('RequestAnimationFrame not available, normalizing event');
85
          window.requestAnimationFrame = window.requestAnimationFrame
86
            || window.mozRequestAnimationFrame
87
            || window.webkitRequestAnimationFrame
88
            || window.msRequestAnimationFrame
89
            || function(callback) { setTimeout(callback, 0); }
90
          ;
91
        }
92
      }
93
    },
94
95
    moduleExists: function(name) {
96
      return ($.fn[name] !== undefined && $.fn[name].settings !== undefined);
97
    },
98
99
    enabled: {
100
      modules: function(modules) {
101
        var
102
          enabledModules = []
103
        ;
104
        modules = modules || settings.modules;
105
        $.each(modules, function(index, name) {
106
          if(module.moduleExists(name)) {
107
            enabledModules.push(name);
108
          }
109
        });
110
        return enabledModules;
111
      }
112
    },
113
114
    disabled: {
115
      modules: function(modules) {
116
        var
117
          disabledModules = []
118
        ;
119
        modules = modules || settings.modules;
120
        $.each(modules, function(index, name) {
121
          if(!module.moduleExists(name)) {
122
            disabledModules.push(name);
123
          }
124
        });
125
        return disabledModules;
126
      }
127
    },
128
129
    change: {
130
      setting: function(setting, value, modules, modifyExisting) {
131
        modules = (typeof modules === 'string')
132
          ? (modules === 'all')
133
            ? settings.modules
134
            : [modules]
135
          : modules || settings.modules
136
        ;
137
        modifyExisting = (modifyExisting !== undefined)
138
          ? modifyExisting
139
          : true
140
        ;
141
        $.each(modules, function(index, name) {
142
          var
143
            namespace = (module.moduleExists(name))
144
              ? $.fn[name].settings.namespace || false
145
              : true,
146
            $existingModules
147
          ;
148
          if(module.moduleExists(name)) {
149
            module.verbose('Changing default setting', setting, value, name);
150
            $.fn[name].settings[setting] = value;
151
            if(modifyExisting && namespace) {
152
              $existingModules = $(':data(module-' + namespace + ')');
153
              if($existingModules.length > 0) {
154
                module.verbose('Modifying existing settings', $existingModules);
155
                $existingModules[name]('setting', setting, value);
156
              }
157
            }
158
          }
159
        });
160
      },
161
      settings: function(newSettings, modules, modifyExisting) {
162
        modules = (typeof modules === 'string')
163
          ? [modules]
164
          : modules || settings.modules
165
        ;
166
        modifyExisting = (modifyExisting !== undefined)
167
          ? modifyExisting
168
          : true
169
        ;
170
        $.each(modules, function(index, name) {
171
          var
172
            $existingModules
173
          ;
174
          if(module.moduleExists(name)) {
175
            module.verbose('Changing default setting', newSettings, name);
176
            $.extend(true, $.fn[name].settings, newSettings);
177
            if(modifyExisting && namespace) {
178
              $existingModules = $(':data(module-' + namespace + ')');
179
              if($existingModules.length > 0) {
180
                module.verbose('Modifying existing settings', $existingModules);
181
                $existingModules[name]('setting', newSettings);
182
              }
183
            }
184
          }
185
        });
186
      }
187
    },
188
189
    enable: {
190
      console: function() {
191
        module.console(true);
192
      },
193
      debug: function(modules, modifyExisting) {
194
        modules = modules || settings.modules;
195
        module.debug('Enabling debug for modules', modules);
196
        module.change.setting('debug', true, modules, modifyExisting);
197
      },
198
      verbose: function(modules, modifyExisting) {
199
        modules = modules || settings.modules;
200
        module.debug('Enabling verbose debug for modules', modules);
201
        module.change.setting('verbose', true, modules, modifyExisting);
202
      }
203
    },
204
    disable: {
205
      console: function() {
206
        module.console(false);
207
      },
208
      debug: function(modules, modifyExisting) {
209
        modules = modules || settings.modules;
210
        module.debug('Disabling debug for modules', modules);
211
        module.change.setting('debug', false, modules, modifyExisting);
212
      },
213
      verbose: function(modules, modifyExisting) {
214
        modules = modules || settings.modules;
215
        module.debug('Disabling verbose debug for modules', modules);
216
        module.change.setting('verbose', false, modules, modifyExisting);
217
      }
218
    },
219
220
    console: function(enable) {
221
      if(enable) {
222
        if(instance.cache.console === undefined) {
223
          module.error(error.console);
224
          return;
225
        }
226
        module.debug('Restoring console function');
227
        window.console = instance.cache.console;
228
      }
229
      else {
230
        module.debug('Disabling console function');
231
        instance.cache.console = window.console;
232
        window.console = {
233
          clear          : function(){},
234
          error          : function(){},
235
          group          : function(){},
236
          groupCollapsed : function(){},
237
          groupEnd       : function(){},
238
          info           : function(){},
239
          log            : function(){},
240
          markTimeline   : function(){},
241
          warn           : function(){}
242
        };
243
      }
244
    },
245
246
    destroy: function() {
247
      module.verbose('Destroying previous site for', $module);
248
      $module
249
        .removeData(moduleNamespace)
250
      ;
251
    },
252
253
    cache: {},
254
255
    setting: function(name, value) {
256
      if( $.isPlainObject(name) ) {
257
        $.extend(true, settings, name);
258
      }
259
      else if(value !== undefined) {
260
        settings[name] = value;
261
      }
262
      else {
263
        return settings[name];
264
      }
265
    },
266
    internal: function(name, value) {
267
      if( $.isPlainObject(name) ) {
268
        $.extend(true, module, name);
269
      }
270
      else if(value !== undefined) {
271
        module[name] = value;
272
      }
273
      else {
274
        return module[name];
275
      }
276
    },
277
    debug: function() {
278
      if(settings.debug) {
279
        if(settings.performance) {
280
          module.performance.log(arguments);
281
        }
282
        else {
283
          module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
284
          module.debug.apply(console, arguments);
285
        }
286
      }
287
    },
288
    verbose: function() {
289
      if(settings.verbose && settings.debug) {
290
        if(settings.performance) {
291
          module.performance.log(arguments);
292
        }
293
        else {
294
          module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
295
          module.verbose.apply(console, arguments);
296
        }
297
      }
298
    },
299
    error: function() {
300
      module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
301
      module.error.apply(console, arguments);
302
    },
303
    performance: {
304
      log: function(message) {
305
        var
306
          currentTime,
307
          executionTime,
308
          previousTime
309
        ;
310
        if(settings.performance) {
311
          currentTime   = new Date().getTime();
312
          previousTime  = time || currentTime;
313
          executionTime = currentTime - previousTime;
314
          time          = currentTime;
315
          performance.push({
316
            'Element'        : element,
317
            'Name'           : message[0],
318
            'Arguments'      : [].slice.call(message, 1) || '',
319
            'Execution Time' : executionTime
320
          });
321
        }
322
        clearTimeout(module.performance.timer);
323
        module.performance.timer = setTimeout(module.performance.display, 500);
324
      },
325
      display: function() {
326
        var
327
          title = settings.name + ':',
328
          totalTime = 0
329
        ;
330
        time = false;
331
        clearTimeout(module.performance.timer);
332
        $.each(performance, function(index, data) {
333
          totalTime += data['Execution Time'];
334
        });
335
        title += ' ' + totalTime + 'ms';
336
        if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
337
          console.groupCollapsed(title);
338
          if(console.table) {
339
            console.table(performance);
340
          }
341
          else {
342
            $.each(performance, function(index, data) {
343
              console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
344
            });
345
          }
346
          console.groupEnd();
347
        }
348
        performance = [];
349
      }
350
    },
351
    invoke: function(query, passedArguments, context) {
352
      var
353
        object = instance,
354
        maxDepth,
355
        found,
356
        response
357
      ;
358
      passedArguments = passedArguments || queryArguments;
359
      context         = element         || context;
360
      if(typeof query == 'string' && object !== undefined) {
361
        query    = query.split(/[\. ]/);
362
        maxDepth = query.length - 1;
363
        $.each(query, function(depth, value) {
364
          var camelCaseValue = (depth != maxDepth)
365
            ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
366
            : query
367
          ;
368
          if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
369
            object = object[camelCaseValue];
370
          }
371
          else if( object[camelCaseValue] !== undefined ) {
372
            found = object[camelCaseValue];
373
            return false;
374
          }
375
          else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
376
            object = object[value];
377
          }
378
          else if( object[value] !== undefined ) {
379
            found = object[value];
380
            return false;
381
          }
382
          else {
383
            module.error(error.method, query);
384
            return false;
385
          }
386
        });
387
      }
388
      if ( $.isFunction( found ) ) {
389
        response = found.apply(context, passedArguments);
390
      }
391
      else if(found !== undefined) {
392
        response = found;
393
      }
394
      if($.isArray(returnedValue)) {
395
        returnedValue.push(response);
396
      }
397
      else if(returnedValue !== undefined) {
398
        returnedValue = [returnedValue, response];
399
      }
400
      else if(response !== undefined) {
401
        returnedValue = response;
402
      }
403
      return found;
404
    }
405
  };
406
407
  if(methodInvoked) {
408
    if(instance === undefined) {
409
      module.initialize();
410
    }
411
    module.invoke(query);
412
  }
413
  else {
414
    if(instance !== undefined) {
415
      module.destroy();
416
    }
417
    module.initialize();
418
  }
419
  return (returnedValue !== undefined)
420
    ? returnedValue
421
    : this
422
  ;
423
};
424
425
$.site.settings = {
426
427
  name        : 'Site',
428
  namespace   : 'site',
429
430
  error : {
431
    console : 'Console cannot be restored, most likely it was overwritten outside of module',
432
    method : 'The method you called is not defined.'
433
  },
434
435
  debug       : false,
436
  verbose     : false,
437
  performance : true,
438
439
  modules: [
440
    'accordion',
441
    'api',
442
    'checkbox',
443
    'dimmer',
444
    'dropdown',
445
    'embed',
446
    'form',
447
    'modal',
448
    'nag',
449
    'popup',
450
    'rating',
451
    'shape',
452
    'sidebar',
453
    'state',
454
    'sticky',
455
    'tab',
456
    'transition',
457
    'visit',
458
    'visibility'
459
  ],
460
461
  siteNamespace   : 'site',
462
  namespaceStub   : {
463
    cache     : {},
464
    config    : {},
465
    sections  : {},
466
    section   : {},
467
    utilities : {}
468
  }
469
470
};
471
472
// allows for selection of elements with data attributes
473
$.extend($.expr[ ":" ], {
474
  data: ($.expr.createPseudo)
475
    ? $.expr.createPseudo(function(dataName) {
476
        return function(elem) {
477
          return !!$.data(elem, dataName);
478
        };
479
      })
480
    : function(elem, i, match) {
481
      // support: jQuery < 1.8
482
      return !!$.data(elem, match[ 3 ]);
483
    }
484
});
485
486
487
})( jQuery, window, document );
488