aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/hl/index.cljs.hl78
-rw-r--r--src/js/semantic.js14128
-rw-r--r--src/js/semantic.min.js17
3 files changed, 10120 insertions, 4103 deletions
diff --git a/src/hl/index.cljs.hl b/src/hl/index.cljs.hl
index a315c12..3c51e48 100644
--- a/src/hl/index.cljs.hl
+++ b/src/hl/index.cljs.hl
@@ -153,9 +153,9 @@
attr
(div :class "bar"
(div :class "progress")))]
- (with-timeout 0 (+++ (.progress
- (js/$ progress)
- (js-obj "percent" 0))))
+ (with-init! (+++ (.progress
+ (js/$ progress)
+ (js-obj "percent" 0))))
(add-watch state nil
(fn [_ _ _ new-state]
(+++ (.progress
@@ -165,17 +165,18 @@
(defelem ui-search
[attr kids]
- (let [input (input :type "text" :placeholder "Keywords...")]
- (div
- (form :class (cell= {:ui true :icon true :input true
- :error (zero? connection-count)})
- :submit #(start-search (.-value input) @anonymity)
- input
- (i :class (cell= {:icon true :search true
- :loading active-search})))
- (div :class "ui pointing left red label"
- :toggle (cell= (zero? connection-count))
- "Live results are unavailable when not connected"))))
+ (let [input (input
+ :type "text"
+ :placeholder (cell=
+ (if (zero? connection-count)
+ "Keywords... Offline"
+ "Keywords...")))]
+ (form :class (cell= {:ui true :icon true :input true
+ :error (zero? connection-count)
+ :loading active-search})
+ :submit #(start-search (.-value input) @anonymity)
+ (i :class (cell= {:icon true :search true}))
+ input)))
(defelem ui-publish
[attr kids]
@@ -198,13 +199,15 @@
@metadata))
(reset! file-chosen true)))]
(div :class "ui form segment"
- (div :class "ui labeled input"
- (div :class "ui label" "Choose a file to publish")
- file)
- (div :class "ui labeled input"
- :toggle file-chosen
- (div :class "ui label" "Keywords")
- keywords)
+ (div :class "field"
+ (div :class "ui labeled input"
+ (div :class "ui label" "Choose a file to publish")
+ file))
+ (div :class "field"
+ (div :class "ui labeled input field"
+ :toggle file-chosen
+ (div :class "ui label" "Keywords")
+ keywords))
(div :class "ui icon button"
:title "Publish"
:toggle file-chosen
@@ -242,8 +245,9 @@
(defelem ui-dropdown
[{:keys [state class] :as attr} kids]
- (let [attr (assoc (dissoc attr :state) :class (str "ui dropdown "
- class))
+ (let [attr (assoc (dissoc attr :state) :class (assoc class
+ :ui true
+ :dropdown true))
dropdown (div
attr
(input :type "hidden"
@@ -253,13 +257,13 @@
(i :class "dropdown icon")
(div :class "menu"
(map #(div :class "item" %) kids)))]
- (with-timeout 0 (+++ (.dropdown (js/$ dropdown))))
+ (with-init! (+++ (.dropdown (js/$ dropdown))))
dropdown))
(defelem ui-popup
[{:keys [settings] :as attr} kids]
(let [popup (div (dissoc attr :settings) kids)]
- (with-timeout 0 (+++ (.popup (js/$ popup) (clj->js settings))))
+ (with-init! (+++ (.popup (js/$ popup) (clj->js settings))))
popup))
(defelem peer-table
@@ -293,14 +297,12 @@
(body
(div :class "ui fixed main menu grid" ; grid somehow fixes things here too
(div :class "container"
+ (div :class "item"
+ "gnunet-web"
+ (span :class "ui red label" "Pre-Alpha")))
(div :class "right item"
- (a :href "https://github.com/amatus/gnunet-web"
- :title "Fork me on GitHub"
- (i :class "github icon")))
- (div :class "right item"
- "Anonymity"
- (div :class "ui label"
- (ui-dropdown :state anonymity "0" "1" "2" "3")))
+ :title (cell= (data->string my-id))
+ (text "My Peer ID: ~(peer-id-short my-id)\u2026"))
(ui-popup :class "right item"
:settings {:inline true
:position "bottom right"
@@ -313,11 +315,13 @@
(div :class "ui flowing popup"
(peer-table))
(div :class "right item"
- :title (cell= (data->string my-id))
- (text "My Peer ID: ~(peer-id-short my-id)\u2026"))
- (div :class "item"
- "gnunet-web"
- (span :class "ui red label" "Pre-Alpha"))))
+ "Anonymity"
+ (div :class "ui label"
+ (ui-dropdown :state anonymity "0" "1" "2" "3")))
+ (div :class "right item"
+ (a :href "https://github.com/amatus/gnunet-web"
+ :title "Fork me on GitHub"
+ (i :class "github icon"))))
(div :class "ui grid") ; This pushes content down so it's not under the menu
(div :class "ui inverted segment"
:toggle (cell= (not (nil? browser-support)))
diff --git a/src/js/semantic.js b/src/js/semantic.js
index c0ea5b7..378108c 100644
--- a/src/js/semantic.js
+++ b/src/js/semantic.js
@@ -1,5 +1,5 @@
/*
- * # Semantic UI
+ * # Semantic UI - 2.1.6
* https://github.com/Semantic-Org/Semantic-UI
* http://www.semantic-ui.com/
*
@@ -8,12 +8,12 @@
* http://opensource.org/licenses/MIT
*
*/
-/*
- * # Semantic - Site
+/*!
+ * # Semantic UI 2.1.6 - Site
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -91,7 +91,7 @@ $.site = $.fn.site = function(parameters) {
requestAnimationFrame: function() {
module.debug('Normalizing requestAnimationFrame');
if(window.requestAnimationFrame === undefined) {
- module.debug('RequestAnimationFrame not available, normailizing event');
+ module.debug('RequestAnimationFrame not available, normalizing event');
window.requestAnimationFrame = window.requestAnimationFrame
|| window.mozRequestAnimationFrame
|| window.webkitRequestAnimationFrame
@@ -160,7 +160,7 @@ $.site = $.fn.site = function(parameters) {
$.fn[name].settings[setting] = value;
if(modifyExisting && namespace) {
$existingModules = $(':data(module-' + namespace + ')');
- if($existingModules.size() > 0) {
+ if($existingModules.length > 0) {
module.verbose('Modifying existing settings', $existingModules);
$existingModules[name]('setting', setting, value);
}
@@ -186,7 +186,7 @@ $.site = $.fn.site = function(parameters) {
$.extend(true, $.fn[name].settings, newSettings);
if(modifyExisting && namespace) {
$existingModules = $(':data(module-' + namespace + ')');
- if($existingModules.size() > 0) {
+ if($existingModules.length > 0) {
module.verbose('Modifying existing settings', $existingModules);
$existingModules[name]('setting', newSettings);
}
@@ -330,7 +330,7 @@ $.site = $.fn.site = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -443,7 +443,7 @@ $.site.settings = {
},
debug : false,
- verbose : true,
+ verbose : false,
performance : true,
modules: [
@@ -452,6 +452,7 @@ $.site.settings = {
'checkbox',
'dimmer',
'dropdown',
+ 'embed',
'form',
'modal',
'nag',
@@ -463,7 +464,6 @@ $.site.settings = {
'sticky',
'tab',
'transition',
- 'video',
'visit',
'visibility'
],
@@ -494,13 +494,14 @@ $.extend($.expr[ ":" ], {
});
-})( jQuery, window , document );
-/*
- * # Semantic - Form Validation
+})( jQuery, window, document );
+
+/*!
+ * # Semantic UI 2.1.6 - Form Validation
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -508,55 +509,74 @@ $.extend($.expr[ ":" ], {
;(function ( $, window, document, undefined ) {
-$.fn.form = function(fields, parameters) {
- var
- $allModules = $(this),
-
- settings = $.extend(true, {}, $.fn.form.settings, parameters),
- validation = $.extend({}, $.fn.form.settings.defaults, fields),
-
- namespace = settings.namespace,
- metadata = settings.metadata,
- selector = settings.selector,
- className = settings.className,
- error = settings.error,
-
- eventNamespace = '.' + namespace,
- moduleNamespace = 'module-' + namespace,
+"use strict";
- moduleSelector = $allModules.selector || '',
+$.fn.form = function(parameters) {
+ var
+ $allModules = $(this),
+ moduleSelector = $allModules.selector || '',
- time = new Date().getTime(),
- performance = [],
+ time = new Date().getTime(),
+ performance = [],
- query = arguments[0],
- methodInvoked = (typeof query == 'string'),
- queryArguments = [].slice.call(arguments, 1),
+ query = arguments[0],
+ legacyParameters = arguments[1],
+ methodInvoked = (typeof query == 'string'),
+ queryArguments = [].slice.call(arguments, 1),
returnedValue
;
$allModules
.each(function() {
var
- $module = $(this),
- $field = $(this).find(selector.field),
- $group = $(this).find(selector.group),
- $message = $(this).find(selector.message),
- $prompt = $(this).find(selector.prompt),
- $submit = $(this).find(selector.submit),
+ $module = $(this),
+ element = this,
- formErrors = [],
+ formErrors = [],
+ keyHeldDown = false,
- element = this,
- instance = $module.data(moduleNamespace),
+ // set at run-time
+ $field,
+ $group,
+ $message,
+ $prompt,
+ $submit,
+ $clear,
+ $reset,
+
+ settings,
+ validation,
+
+ metadata,
+ selector,
+ className,
+ error,
+
+ namespace,
+ moduleNamespace,
+ eventNamespace,
+
+ instance,
module
;
module = {
initialize: function() {
- module.verbose('Initializing form validation', $module, validation, settings);
- module.bindEvents();
- module.instantiate();
+
+ // settings grabbed at run time
+ module.get.settings();
+ if(methodInvoked) {
+ if(instance === undefined) {
+ module.instantiate();
+ }
+ module.invoke(query);
+ }
+ else {
+ module.verbose('Initializing form validation', $module, settings);
+ module.bindEvents();
+ module.set.defaults();
+ module.instantiate();
+ }
},
instantiate: function() {
@@ -577,7 +597,14 @@ $.fn.form = function(fields, parameters) {
refresh: function() {
module.verbose('Refreshing selector cache');
- $field = $module.find(selector.field);
+ $field = $module.find(selector.field);
+ $group = $module.find(selector.group);
+ $message = $module.find(selector.message);
+ $prompt = $module.find(selector.prompt);
+
+ $submit = $module.find(selector.submit);
+ $clear = $module.find(selector.clear);
+ $reset = $module.find(selector.reset);
},
submit: function() {
@@ -590,7 +617,7 @@ $.fn.form = function(fields, parameters) {
attachEvents: function(selector, action) {
action = action || 'submit';
$(selector)
- .on('click', function(event) {
+ .on('click' + eventNamespace, function(event) {
module[action]();
event.preventDefault();
})
@@ -598,26 +625,25 @@ $.fn.form = function(fields, parameters) {
},
bindEvents: function() {
-
- if(settings.keyboardShortcuts) {
- $field
- .on('keydown' + eventNamespace, module.event.field.keydown)
- ;
- }
+ module.verbose('Attaching form events');
$module
.on('submit' + eventNamespace, module.validate.form)
+ .on('blur' + eventNamespace, selector.field, module.event.field.blur)
+ .on('click' + eventNamespace, selector.submit, module.submit)
+ .on('click' + eventNamespace, selector.reset, module.reset)
+ .on('click' + eventNamespace, selector.clear, module.clear)
;
- $field
- .on('blur' + eventNamespace, module.event.field.blur)
- ;
- // attach submit events
- module.attachEvents($submit, 'submit');
-
+ if(settings.keyboardShortcuts) {
+ $module
+ .on('keydown' + eventNamespace, selector.field, module.event.field.keydown)
+ ;
+ }
$field
.each(function() {
var
- type = $(this).prop('type'),
- inputEvent = module.get.changeEvent(type)
+ $input = $(this),
+ type = $input.prop('type'),
+ inputEvent = module.get.changeEvent(type, $input)
;
$(this)
.on(inputEvent + eventNamespace, module.event.field.change)
@@ -626,6 +652,94 @@ $.fn.form = function(fields, parameters) {
;
},
+ clear: function() {
+ $field
+ .each(function () {
+ var
+ $field = $(this),
+ $element = $field.parent(),
+ $fieldGroup = $field.closest($group),
+ $prompt = $fieldGroup.find(selector.prompt),
+ defaultValue = $field.data(metadata.defaultValue) || '',
+ isCheckbox = $element.is(selector.uiCheckbox),
+ isDropdown = $element.is(selector.uiDropdown),
+ isErrored = $fieldGroup.hasClass(className.error)
+ ;
+ if(isErrored) {
+ module.verbose('Resetting error on field', $fieldGroup);
+ $fieldGroup.removeClass(className.error);
+ $prompt.remove();
+ }
+ if(isDropdown) {
+ module.verbose('Resetting dropdown value', $element, defaultValue);
+ $element.dropdown('clear');
+ }
+ else if(isCheckbox) {
+ $field.prop('checked', false);
+ }
+ else {
+ module.verbose('Resetting field value', $field, defaultValue);
+ $field.val('');
+ }
+ })
+ ;
+ },
+
+ reset: function() {
+ $field
+ .each(function () {
+ var
+ $field = $(this),
+ $element = $field.parent(),
+ $fieldGroup = $field.closest($group),
+ $prompt = $fieldGroup.find(selector.prompt),
+ defaultValue = $field.data(metadata.defaultValue),
+ isCheckbox = $element.is(selector.uiCheckbox),
+ isDropdown = $element.is(selector.uiDropdown),
+ isErrored = $fieldGroup.hasClass(className.error)
+ ;
+ if(defaultValue === undefined) {
+ return;
+ }
+ if(isErrored) {
+ module.verbose('Resetting error on field', $fieldGroup);
+ $fieldGroup.removeClass(className.error);
+ $prompt.remove();
+ }
+ if(isDropdown) {
+ module.verbose('Resetting dropdown value', $element, defaultValue);
+ $element.dropdown('restore defaults');
+ }
+ else if(isCheckbox) {
+ module.verbose('Resetting checkbox value', $element, defaultValue);
+ $field.prop('checked', defaultValue);
+ }
+ else {
+ module.verbose('Resetting field value', $field, defaultValue);
+ $field.val(defaultValue);
+ }
+ })
+ ;
+ },
+
+ is: {
+ bracketedRule: function(rule) {
+ return (rule.type && rule.type.match(settings.regExp.bracket));
+ },
+ valid: function() {
+ var
+ allValid = true
+ ;
+ module.verbose('Checking if form is valid');
+ $.each(validation, function(fieldName, field) {
+ if( !( module.validate.field(field, fieldName) ) ) {
+ allValid = false;
+ }
+ });
+ return allValid;
+ }
+ },
+
removeEvents: function() {
$module
.off(eventNamespace)
@@ -658,35 +772,37 @@ $.fn.form = function(fields, parameters) {
.blur()
;
}
- if(!event.ctrlKey && key == keyCode.enter && $field.is(selector.input) && $field.not(selector.checkbox).size() > 0 ) {
- module.debug('Enter key pressed, submitting form');
- $submit
- .addClass(className.down)
- ;
- $field
- .one('keyup' + eventNamespace, module.event.field.keyup)
- ;
+ if(!event.ctrlKey && key == keyCode.enter && $field.is(selector.input) && $field.not(selector.checkbox).length > 0 ) {
+ if(!keyHeldDown) {
+ $field
+ .one('keyup' + eventNamespace, module.event.field.keyup)
+ ;
+ module.submit();
+ module.debug('Enter pressed on input submitting form');
+ }
+ keyHeldDown = true;
}
},
keyup: function() {
- module.verbose('Doing keyboard shortcut form submit');
- $submit.removeClass(className.down);
- module.submit();
+ keyHeldDown = false;
},
- blur: function() {
+ blur: function(event) {
var
- $field = $(this),
- $fieldGroup = $field.closest($group)
+ $field = $(this),
+ $fieldGroup = $field.closest($group),
+ validationRules = module.get.validation($field)
;
if( $fieldGroup.hasClass(className.error) ) {
- module.debug('Revalidating field', $field, module.get.validation($field));
- module.validate.field( module.get.validation($field) );
+ module.debug('Revalidating field', $field, validationRules);
+ module.validate.form.call(module, event, true);
}
else if(settings.on == 'blur' || settings.on == 'change') {
- module.validate.field( module.get.validation($field) );
+ if(validationRules) {
+ module.validate.field( validationRules );
+ }
}
},
- change: function() {
+ change: function(event) {
var
$field = $(this),
$fieldGroup = $field.closest($group)
@@ -695,7 +811,7 @@ $.fn.form = function(fields, parameters) {
clearTimeout(module.timer);
module.timer = setTimeout(function() {
module.debug('Revalidating field', $field, module.get.validation($field));
- module.validate.field( module.get.validation($field) );
+ module.validate.form.call(module, event, true);
}, settings.delay);
}
}
@@ -704,42 +820,237 @@ $.fn.form = function(fields, parameters) {
},
get: {
- changeEvent: function(type) {
- if(type == 'checkbox' || type == 'radio' || type == 'hidden') {
+ ancillaryValue: function(rule) {
+ if(!rule.type || !module.is.bracketedRule(rule)) {
+ return false;
+ }
+ return rule.type.match(settings.regExp.bracket)[1] + '';
+ },
+ ruleName: function(rule) {
+ if( module.is.bracketedRule(rule) ) {
+ return rule.type.replace(rule.type.match(settings.regExp.bracket)[0], '');
+ }
+ return rule.type;
+ },
+ changeEvent: function(type, $input) {
+ if(type == 'checkbox' || type == 'radio' || type == 'hidden' || $input.is('select')) {
return 'change';
}
else {
- return (document.createElement('input').oninput !== undefined)
- ? 'input'
- : (document.createElement('input').onpropertychange !== undefined)
- ? 'propertychange'
- : 'keyup'
+ return module.get.inputEvent();
+ }
+ },
+ inputEvent: function() {
+ return (document.createElement('input').oninput !== undefined)
+ ? 'input'
+ : (document.createElement('input').onpropertychange !== undefined)
+ ? 'propertychange'
+ : 'keyup'
+ ;
+ },
+ prompt: function(rule, field) {
+ var
+ ruleName = module.get.ruleName(rule),
+ ancillary = module.get.ancillaryValue(rule),
+ prompt = rule.prompt || settings.prompt[ruleName] || settings.text.unspecifiedRule,
+ requiresValue = (prompt.search('{value}') !== -1),
+ requiresName = (prompt.search('{name}') !== -1),
+ $label,
+ $field,
+ name
+ ;
+ if(requiresName || requiresValue) {
+ $field = module.get.field(field.identifier);
+ }
+ if(requiresValue) {
+ prompt = prompt.replace('{value}', $field.val());
+ }
+ if(requiresName) {
+ $label = $field.closest(selector.group).find('label').eq(0);
+ name = ($label.size() == 1)
+ ? $label.text()
+ : $field.prop('placeholder') || settings.text.unspecifiedField
;
+ prompt = prompt.replace('{name}', name);
+ }
+ prompt = prompt.replace('{identifier}', field.identifier);
+ prompt = prompt.replace('{ruleValue}', ancillary);
+ if(!rule.prompt) {
+ module.verbose('Using default validation prompt for type', prompt, ruleName);
+ }
+ return prompt;
+ },
+ settings: function() {
+ if($.isPlainObject(parameters)) {
+ var
+ keys = Object.keys(parameters),
+ isLegacySettings = (keys.length > 0)
+ ? (parameters[keys[0]].identifier !== undefined && parameters[keys[0]].rules !== undefined)
+ : false,
+ ruleKeys
+ ;
+ if(isLegacySettings) {
+ // 1.x (ducktyped)
+ settings = $.extend(true, {}, $.fn.form.settings, legacyParameters);
+ validation = $.extend({}, $.fn.form.settings.defaults, parameters);
+ module.error(settings.error.oldSyntax, element);
+ module.verbose('Extending settings from legacy parameters', validation, settings);
+ }
+ else {
+ // 2.x
+ if(parameters.fields) {
+ ruleKeys = Object.keys(parameters.fields);
+ if( typeof parameters.fields[ruleKeys[0]] == 'string' || $.isArray(parameters.fields[ruleKeys[0]]) ) {
+ $.each(parameters.fields, function(name, rules) {
+ if(typeof rules == 'string') {
+ rules = [rules];
+ }
+ parameters.fields[name] = {
+ rules: []
+ };
+ $.each(rules, function(index, rule) {
+ parameters.fields[name].rules.push({ type: rule });
+ });
+ });
+ }
+ }
+
+ settings = $.extend(true, {}, $.fn.form.settings, parameters);
+ validation = $.extend({}, $.fn.form.settings.defaults, settings.fields);
+ module.verbose('Extending settings', validation, settings);
+ }
}
+ else {
+ settings = $.fn.form.settings;
+ validation = $.fn.form.settings.defaults;
+ module.verbose('Using default form validation', validation, settings);
+ }
+
+ // shorthand
+ namespace = settings.namespace;
+ metadata = settings.metadata;
+ selector = settings.selector;
+ className = settings.className;
+ error = settings.error;
+ moduleNamespace = 'module-' + namespace;
+ eventNamespace = '.' + namespace;
+
+ // grab instance
+ instance = $module.data(moduleNamespace);
+
+ // refresh selector cache
+ module.refresh();
},
field: function(identifier) {
module.verbose('Finding field with identifier', identifier);
- if( $field.filter('#' + identifier).size() > 0 ) {
+ if( $field.filter('#' + identifier).length > 0 ) {
return $field.filter('#' + identifier);
}
- else if( $field.filter('[name="' + identifier +'"]').size() > 0 ) {
+ else if( $field.filter('[name="' + identifier +'"]').length > 0 ) {
return $field.filter('[name="' + identifier +'"]');
}
- else if( $field.filter('[data-' + metadata.validate + '="'+ identifier +'"]').size() > 0 ) {
+ else if( $field.filter('[name="' + identifier +'[]"]').length > 0 ) {
+ return $field.filter('[name="' + identifier +'[]"]');
+ }
+ else if( $field.filter('[data-' + metadata.validate + '="'+ identifier +'"]').length > 0 ) {
return $field.filter('[data-' + metadata.validate + '="'+ identifier +'"]');
}
return $('<input/>');
},
+ fields: function(fields) {
+ var
+ $fields = $()
+ ;
+ $.each(fields, function(index, name) {
+ $fields = $fields.add( module.get.field(name) );
+ });
+ return $fields;
+ },
validation: function($field) {
var
- rules
+ fieldValidation,
+ identifier
;
+ if(!validation) {
+ return false;
+ }
$.each(validation, function(fieldName, field) {
- if( module.get.field(field.identifier).get(0) == $field.get(0) ) {
- rules = field;
+ identifier = field.identifier || fieldName;
+ if( module.get.field(identifier)[0] == $field[0] ) {
+ field.identifier = identifier;
+ fieldValidation = field;
}
});
- return rules || false;
+ return fieldValidation || false;
+ },
+ value: function (field) {
+ var
+ fields = [],
+ results
+ ;
+ fields.push(field);
+ results = module.get.values.call(element, fields);
+ return results[field];
+ },
+ values: function (fields) {
+ var
+ $fields = $.isArray(fields)
+ ? module.get.fields(fields)
+ : $field,
+ values = {}
+ ;
+ $fields.each(function(index, field) {
+ var
+ $field = $(field),
+ type = $field.prop('type'),
+ name = $field.prop('name'),
+ value = $field.val(),
+ isCheckbox = $field.is(selector.checkbox),
+ isRadio = $field.is(selector.radio),
+ isMultiple = (name.indexOf('[]') !== -1),
+ isChecked = (isCheckbox)
+ ? $field.is(':checked')
+ : false
+ ;
+ if(name) {
+ if(isMultiple) {
+ name = name.replace('[]', '');
+ if(!values[name]) {
+ values[name] = [];
+ }
+ if(isCheckbox) {
+ if(isChecked) {
+ values[name].push(value || true);
+ }
+ else {
+ values[name].push(false);
+ }
+ }
+ else {
+ values[name].push(value);
+ }
+ }
+ else {
+ if(isRadio) {
+ if(isChecked) {
+ values[name] = value;
+ }
+ }
+ else if(isCheckbox) {
+ if(isChecked) {
+ values[name] = value || true;
+ }
+ else {
+ values[name] = false;
+ }
+ }
+ else {
+ values[name] = value;
+ }
+ }
+ }
+ });
+ return values;
}
},
@@ -747,13 +1058,16 @@ $.fn.form = function(fields, parameters) {
field: function(identifier) {
module.verbose('Checking for existence of a field with identifier', identifier);
- if( $field.filter('#' + identifier).size() > 0 ) {
+ if(typeof identifier !== 'string') {
+ module.error(error.identifier, identifier);
+ }
+ if( $field.filter('#' + identifier).length > 0 ) {
return true;
}
- else if( $field.filter('[name="' + identifier +'"]').size() > 0 ) {
+ else if( $field.filter('[name="' + identifier +'"]').length > 0 ) {
return true;
}
- else if( $field.filter('[data-' + metadata.validate + '="'+ identifier +'"]').size() > 0 ) {
+ else if( $field.filter('[data-' + metadata.validate + '="'+ identifier +'"]').length > 0 ) {
return true;
}
return false;
@@ -766,8 +1080,8 @@ $.fn.form = function(fields, parameters) {
var
$field = module.get.field(identifier),
$fieldGroup = $field.closest($group),
- $prompt = $fieldGroup.find(selector.prompt),
- promptExists = ($prompt.size() !== 0)
+ $prompt = $fieldGroup.children(selector.prompt),
+ promptExists = ($prompt.length !== 0)
;
errors = (typeof errors == 'string')
? [errors]
@@ -806,6 +1120,7 @@ $.fn.form = function(fields, parameters) {
},
errors: function(errors) {
module.debug('Adding form error messages', errors);
+ module.set.error();
$message
.html( settings.templates.error(errors) )
;
@@ -813,17 +1128,17 @@ $.fn.form = function(fields, parameters) {
},
remove: {
- prompt: function(field) {
+ prompt: function(identifier) {
var
- $field = module.get.field(field.identifier),
+ $field = module.get.field(identifier),
$fieldGroup = $field.closest($group),
- $prompt = $fieldGroup.find(selector.prompt)
+ $prompt = $fieldGroup.children(selector.prompt)
;
$fieldGroup
.removeClass(className.error)
;
if(settings.inline && $prompt.is(':visible')) {
- module.verbose('Removing prompt for field', field);
+ module.verbose('Removing prompt for field', identifier);
if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
$prompt.transition(settings.transition + ' out', settings.duration, function() {
$prompt.remove();
@@ -847,32 +1162,110 @@ $.fn.form = function(fields, parameters) {
.addClass(className.success)
;
},
+ defaults: function () {
+ $field
+ .each(function () {
+ var
+ $field = $(this),
+ isCheckbox = ($field.filter(selector.checkbox).length > 0),
+ value = (isCheckbox)
+ ? $field.is(':checked')
+ : $field.val()
+ ;
+ $field.data(metadata.defaultValue, value);
+ })
+ ;
+ },
error: function() {
$module
.removeClass(className.success)
.addClass(className.error)
;
+ },
+ value: function (field, value) {
+ var
+ fields = {}
+ ;
+ fields[field] = value;
+ return module.set.values.call(element, fields);
+ },
+ values: function (fields) {
+ if($.isEmptyObject(fields)) {
+ return;
+ }
+ $.each(fields, function(key, value) {
+ var
+ $field = module.get.field(key),
+ $element = $field.parent(),
+ isMultiple = $.isArray(value),
+ isCheckbox = $element.is(selector.uiCheckbox),
+ isDropdown = $element.is(selector.uiDropdown),
+ isRadio = ($field.is(selector.radio) && isCheckbox),
+ fieldExists = ($field.length > 0),
+ $multipleField
+ ;
+ if(fieldExists) {
+ if(isMultiple && isCheckbox) {
+ module.verbose('Selecting multiple', value, $field);
+ $element.checkbox('uncheck');
+ $.each(value, function(index, value) {
+ $multipleField = $field.filter('[value="' + value + '"]');
+ $element = $multipleField.parent();
+ if($multipleField.length > 0) {
+ $element.checkbox('check');
+ }
+ });
+ }
+ else if(isRadio) {
+ module.verbose('Selecting radio value', value, $field);
+ $field.filter('[value="' + value + '"]')
+ .parent(selector.uiCheckbox)
+ .checkbox('check')
+ ;
+ }
+ else if(isCheckbox) {
+ module.verbose('Setting checkbox value', value, $element);
+ if(value === true) {
+ $element.checkbox('check');
+ }
+ else {
+ $element.checkbox('uncheck');
+ }
+ }
+ else if(isDropdown) {
+ module.verbose('Setting dropdown value', value, $element);
+ $element.dropdown('set selected', value);
+ }
+ else {
+ module.verbose('Setting field value', value, $field);
+ $field.val(value);
+ }
+ }
+ });
}
},
validate: {
- form: function(event) {
+ form: function(event, ignoreCallbacks) {
var
- allValid = true,
+ values = module.get.values(),
apiRequest
;
+
+ // input keydown event will fire submit repeatedly by browser default
+ if(keyHeldDown) {
+ return false;
+ }
+
// reset errors
formErrors = [];
- $.each(validation, function(fieldName, field) {
- if( !( module.validate.field(field) ) ) {
- allValid = false;
- }
- });
- if(allValid) {
+ if( module.is.valid() ) {
module.debug('Form has no validation errors, submitting');
module.set.success();
- return $.proxy(settings.onSuccess, this)(event);
+ if(ignoreCallbacks !== true) {
+ return settings.onSuccess.call(element, event, values);
+ }
}
else {
module.debug('Form has errors');
@@ -884,67 +1277,75 @@ $.fn.form = function(fields, parameters) {
if($module.data('moduleApi') !== undefined) {
event.stopImmediatePropagation();
}
- return $.proxy(settings.onFailure, this)(formErrors);
+ if(ignoreCallbacks !== true) {
+ return settings.onFailure.call(element, formErrors, values);
+ }
}
},
// takes a validation object and returns whether field passes validation
- field: function(field) {
+ field: function(field, fieldName) {
var
- $field = module.get.field(field.identifier),
+ identifier = field.identifier || fieldName,
+ $field = module.get.field(identifier),
fieldValid = true,
fieldErrors = []
;
- if(field.optional && $.trim($field.val()) === ''){
- module.debug('Field is optional and empty. Skipping', field.identifier);
+ if(!field.identifier) {
+ module.debug('Using field name as identifier', identifier);
+ field.identifier = identifier;
+ }
+ if($field.prop('disabled')) {
+ module.debug('Field is disabled. Skipping', identifier);
+ fieldValid = true;
+ }
+ else if(field.optional && $.trim($field.val()) === ''){
+ module.debug('Field is optional and empty. Skipping', identifier);
fieldValid = true;
}
else if(field.rules !== undefined) {
$.each(field.rules, function(index, rule) {
- if( module.has.field(field.identifier) && !( module.validate.rule(field, rule) ) ) {
- module.debug('Field is invalid', field.identifier, rule.type);
- fieldErrors.push(rule.prompt);
+ if( module.has.field(identifier) && !( module.validate.rule(field, rule) ) ) {
+ module.debug('Field is invalid', identifier, rule.type);
+ fieldErrors.push(module.get.prompt(rule, field));
fieldValid = false;
}
});
}
if(fieldValid) {
- module.remove.prompt(field, fieldErrors);
- $.proxy(settings.onValid, $field)();
+ module.remove.prompt(identifier, fieldErrors);
+ settings.onValid.call($field);
}
else {
formErrors = formErrors.concat(fieldErrors);
- module.add.prompt(field.identifier, fieldErrors);
- $.proxy(settings.onInvalid, $field)(fieldErrors);
+ module.add.prompt(identifier, fieldErrors);
+ settings.onInvalid.call($field, fieldErrors);
return false;
}
return true;
},
// takes validation rule and returns whether field passes rule
- rule: function(field, validation) {
+ rule: function(field, rule) {
var
- $field = module.get.field(field.identifier),
- type = validation.type,
- value = $.trim($field.val() + ''),
-
- bracketRegExp = /\[(.*)\]/i,
- bracket = bracketRegExp.exec(type),
- isValid = true,
- ancillary,
- functionType
- ;
- // if bracket notation is used, pass in extra parameters
- if(bracket !== undefined && bracket !== null) {
- ancillary = '' + bracket[1];
- functionType = type.replace(bracket[0], '');
- isValid = $.proxy(settings.rules[functionType], $module)(value, ancillary);
- }
- // normal notation
- else {
- isValid = $.proxy(settings.rules[type], $field)(value);
+ $field = module.get.field(field.identifier),
+ type = rule.type,
+ value = $field.val(),
+ isValid = true,
+ ancillary = module.get.ancillaryValue(rule),
+ ruleName = module.get.ruleName(rule),
+ ruleFunction = settings.rules[ruleName]
+ ;
+ if( !$.isFunction(ruleFunction) ) {
+ module.error(error.noRule, ruleName);
+ return;
}
- return isValid;
+ // cast to string avoiding encoding special values
+ value = (value === undefined || value === '' || value === null)
+ ? ''
+ : $.trim(value + '')
+ ;
+ return ruleFunction.call($field, value, ancillary);
}
},
@@ -1016,7 +1417,7 @@ $.fn.form = function(fields, parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -1032,8 +1433,8 @@ $.fn.form = function(fields, parameters) {
if(moduleSelector) {
title += ' \'' + moduleSelector + '\'';
}
- if($allModules.size() > 1) {
- title += ' ' + '(' + $allModules.size() + ')';
+ if($allModules.length > 1) {
+ title += ' ' + '(' + $allModules.length + ')';
}
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
console.groupCollapsed(title);
@@ -1086,7 +1487,7 @@ $.fn.form = function(fields, parameters) {
}
});
}
- if ( $.isFunction( found ) ) {
+ if( $.isFunction( found ) ) {
response = found.apply(context, passedArguments);
}
else if(found !== undefined) {
@@ -1104,19 +1505,7 @@ $.fn.form = function(fields, parameters) {
return found;
}
};
- if(methodInvoked) {
- if(instance === undefined) {
- module.initialize();
- }
- module.invoke(query);
- }
- else {
- if(instance !== undefined) {
- module.destroy();
- }
- module.initialize();
- }
-
+ module.initialize();
})
;
@@ -1132,9 +1521,10 @@ $.fn.form.settings = {
namespace : 'form',
debug : false,
- verbose : true,
+ verbose : false,
performance : true,
+ fields : false,
keyboardShortcuts : true,
on : 'submit',
@@ -1146,38 +1536,93 @@ $.fn.form.settings = {
transition : 'scale',
duration : 200,
-
onValid : function() {},
onInvalid : function() {},
onSuccess : function() { return true; },
onFailure : function() { return false; },
metadata : {
- validate: 'validate'
+ defaultValue : 'default',
+ validate : 'validate'
+ },
+
+ regExp: {
+ bracket : /\[(.*)\]/i,
+ decimal : /^\d*(\.)\d+/,
+ email : "[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",
+ escape : /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,
+ flags : /^\/(.*)\/(.*)?/,
+ integer : /^\-?\d+$/,
+ number : /^\-?\d*(\.\d+)?$/,
+ url : /(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/i
+ },
+
+ text: {
+ unspecifiedRule : 'Please enter a valid value',
+ unspecifiedField : 'This field'
+ },
+
+ prompt: {
+ empty : '{name} must have a value',
+ checked : '{name} must be checked',
+ email : '{name} must be a valid e-mail',
+ url : '{name} must be a valid url',
+ regExp : '{name} is not formatted correctly',
+ integer : '{name} must be an integer',
+ decimal : '{name} must be a decimal number',
+ number : '{name} must be set to a number',
+ is : '{name} must be "{ruleValue}"',
+ isExactly : '{name} must be exactly "{ruleValue}"',
+ not : '{name} cannot be set to "{ruleValue}"',
+ notExactly : '{name} cannot be set to exactly "{ruleValue}"',
+ contain : '{name} cannot contain "{ruleValue}"',
+ containExactly : '{name} cannot contain exactly "{ruleValue}"',
+ doesntContain : '{name} must contain "{ruleValue}"',
+ doesntContainExactly : '{name} must contain exactly "{ruleValue}"',
+ minLength : '{name} must be at least {ruleValue} characters',
+ length : '{name} must be at least {ruleValue} characters',
+ exactLength : '{name} must be exactly {ruleValue} characters',
+ maxLength : '{name} cannot be longer than {ruleValue} characters',
+ match : '{name} must match {ruleValue} field',
+ different : '{name} must have a different value than {ruleValue} field',
+ creditCard : '{name} must be a valid credit card number',
+ minCount : '{name} must have at least {ruleValue} choices',
+ exactCount : '{name} must have exactly {ruleValue} choices',
+ maxCount : '{name} must have {ruleValue} or less choices'
},
selector : {
- message : '.error.message',
- field : 'input, textarea, select',
- group : '.field',
- checkbox: 'input[type="checkbox"], input[type="radio"]',
- input : 'input',
- prompt : '.prompt',
- submit : '.submit'
+ checkbox : 'input[type="checkbox"], input[type="radio"]',
+ clear : '.clear',
+ field : 'input, textarea, select',
+ group : '.field',
+ input : 'input',
+ message : '.error.message',
+ prompt : '.prompt.label',
+ radio : 'input[type="radio"]',
+ reset : '.reset:not([type="reset"])',
+ submit : '.submit:not([type="submit"])',
+ uiCheckbox : '.ui.checkbox',
+ uiDropdown : '.ui.dropdown'
},
className : {
error : 'error',
- success : 'success',
- down : 'down',
- label : 'ui prompt label'
+ label : 'ui prompt label',
+ pressed : 'down',
+ success : 'success'
},
error: {
- method : 'The method you called is not defined.'
+ identifier : 'You must specify a string identifier for each field',
+ method : 'The method you called is not defined.',
+ noRule : 'There is no rule matching the one you specified',
+ oldSyntax : 'Starting in 2.0 forms now only take a single settings object. Validation settings converted to new syntax automatically.'
},
templates: {
+
+ // template that produces error message
error: function(errors) {
var
html = '<ul class="list">'
@@ -1188,9 +1633,11 @@ $.fn.form.settings = {
html += '</ul>';
return $(html);
},
+
+ // template that produces label
prompt: function(errors) {
return $('<div/>')
- .addClass('ui red pointing prompt label')
+ .addClass('ui basic red pointing prompt label')
.html(errors[0])
;
}
@@ -1198,52 +1645,71 @@ $.fn.form.settings = {
rules: {
- // checkbox checked
- checked: function() {
- return ($(this).filter(':checked').size() > 0);
+ // is not empty or blank string
+ empty: function(value) {
+ return !(value === undefined || '' === value || $.isArray(value) && value.length === 0);
},
- // value contains (text)
- contains: function(value, text) {
- text = text.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
- return (value.search(text) !== -1);
+ // checkbox checked
+ checked: function() {
+ return ($(this).filter(':checked').length > 0);
},
// is most likely an email
email: function(value){
var
- emailRegExp = new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", "i")
+ emailRegExp = new RegExp($.fn.form.settings.regExp.email, 'i')
;
return emailRegExp.test(value);
},
- // is not empty or blank string
- empty: function(value) {
- return !(value === undefined || '' === value);
+ // value is most likely url
+ url: function(value) {
+ return $.fn.form.settings.regExp.url.test(value);
+ },
+
+ // matches specified regExp
+ regExp: function(value, regExp) {
+ var
+ regExpParts = regExp.match($.fn.form.settings.regExp.flags),
+ flags
+ ;
+ // regular expression specified as /baz/gi (flags)
+ if(regExpParts) {
+ regExp = (regExpParts.length >= 2)
+ ? regExpParts[1]
+ : regExp
+ ;
+ flags = (regExpParts.length >= 3)
+ ? regExpParts[2]
+ : ''
+ ;
+ }
+ return value.match( new RegExp(regExp, flags) );
},
- // is valid integer
+ // is valid integer or matches range
integer: function(value, range) {
var
- intRegExp = /^\-?\d+$/,
+ intRegExp = $.fn.form.settings.regExp.integer,
min,
max,
parts
;
- if (range === undefined || range === '' || range === '..') {
+ if( !range || ['', '..'].indexOf(range) !== -1) {
// do nothing
}
- else if (range.indexOf('..') == -1) {
- if (intRegExp.test(range)) {
+ else if(range.indexOf('..') == -1) {
+ if(intRegExp.test(range)) {
min = max = range - 0;
}
}
else {
parts = range.split('..', 2);
- if (intRegExp.test(parts[0])) {
+ if(intRegExp.test(parts[0])) {
min = parts[0] - 0;
}
- if (intRegExp.test(parts[1])) {
+ if(intRegExp.test(parts[1])) {
max = parts[1] - 0;
}
}
@@ -1254,12 +1720,89 @@ $.fn.form.settings = {
);
},
- // is exactly value
+ // is valid number (with decimal)
+ decimal: function(value) {
+ return $.fn.form.settings.regExp.decimal.test(value);
+ },
+
+ // is valid number
+ number: function(value) {
+ return $.fn.form.settings.regExp.number.test(value);
+ },
+
+ // is value (case insensitive)
is: function(value, text) {
+ text = (typeof text == 'string')
+ ? text.toLowerCase()
+ : text
+ ;
+ value = (typeof value == 'string')
+ ? value.toLowerCase()
+ : value
+ ;
return (value == text);
},
+ // is value
+ isExactly: function(value, text) {
+ return (value == text);
+ },
+
+ // value is not another value (case insensitive)
+ not: function(value, notValue) {
+ value = (typeof value == 'string')
+ ? value.toLowerCase()
+ : value
+ ;
+ notValue = (typeof notValue == 'string')
+ ? notValue.toLowerCase()
+ : notValue
+ ;
+ return (value != notValue);
+ },
+
+ // value is not another value (case sensitive)
+ notExactly: function(value, notValue) {
+ return (value != notValue);
+ },
+
+ // value contains text (insensitive)
+ contains: function(value, text) {
+ // escape regex characters
+ text = text.replace($.fn.form.settings.regExp.escape, "\\$&");
+ return (value.search( new RegExp(text, 'i') ) !== -1);
+ },
+
+ // value contains text (case sensitive)
+ containsExactly: function(value, text) {
+ // escape regex characters
+ text = text.replace($.fn.form.settings.regExp.escape, "\\$&");
+ return (value.search( new RegExp(text) ) !== -1);
+ },
+
+ // value contains text (insensitive)
+ doesntContain: function(value, text) {
+ // escape regex characters
+ text = text.replace($.fn.form.settings.regExp.escape, "\\$&");
+ return (value.search( new RegExp(text, 'i') ) === -1);
+ },
+
+ // value contains text (case sensitive)
+ doesntContainExactly: function(value, text) {
+ // escape regex characters
+ text = text.replace($.fn.form.settings.regExp.escape, "\\$&");
+ return (value.search( new RegExp(text) ) === -1);
+ },
+
// is at least string length
+ minLength: function(value, requiredLength) {
+ return (value !== undefined)
+ ? (value.length >= requiredLength)
+ : false
+ ;
+ },
+
+ // see rls notes for 2.0.6 (this is a duplicate of minLength)
length: function(value, requiredLength) {
return (value !== undefined)
? (value.length >= requiredLength)
@@ -1267,21 +1810,39 @@ $.fn.form.settings = {
;
},
+ // is exactly length
+ exactLength: function(value, requiredLength) {
+ return (value !== undefined)
+ ? (value.length == requiredLength)
+ : false
+ ;
+ },
+
+ // is less than length
+ maxLength: function(value, maxLength) {
+ return (value !== undefined)
+ ? (value.length <= maxLength)
+ : false
+ ;
+ },
+
// matches another field
- match: function(value, fieldIdentifier) {
- // use either id or name of field
+ match: function(value, identifier) {
var
$form = $(this),
matchingValue
;
- if($form.find('#' + fieldIdentifier).size() > 0) {
- matchingValue = $form.find('#' + fieldIdentifier).val();
+ if( $('[data-validate="'+ identifier +'"]').length > 0 ) {
+ matchingValue = $('[data-validate="'+ identifier +'"]').val();
}
- else if($form.find('[name="' + fieldIdentifier +'"]').size() > 0) {
- matchingValue = $form.find('[name="' + fieldIdentifier + '"]').val();
+ else if($('#' + identifier).length > 0) {
+ matchingValue = $('#' + identifier).val();
}
- else if( $form.find('[data-validate="'+ fieldIdentifier +'"]').size() > 0 ) {
- matchingValue = $form.find('[data-validate="'+ fieldIdentifier +'"]').val();
+ else if($('[name="' + identifier +'"]').length > 0) {
+ matchingValue = $('[name="' + identifier + '"]').val();
+ }
+ else if( $('[name="' + identifier +'[]"]').length > 0 ) {
+ matchingValue = $('[name="' + identifier +'[]"]');
}
return (matchingValue !== undefined)
? ( value.toString() == matchingValue.toString() )
@@ -1289,38 +1850,176 @@ $.fn.form.settings = {
;
},
- // string length is less than max length
- maxLength: function(value, maxLength) {
- return (value !== undefined)
- ? (value.length <= maxLength)
+ // different than another field
+ different: function(value, identifier) {
+ // use either id or name of field
+ var
+ $form = $(this),
+ matchingValue
+ ;
+ if( $('[data-validate="'+ identifier +'"]').length > 0 ) {
+ matchingValue = $('[data-validate="'+ identifier +'"]').val();
+ }
+ else if($('#' + identifier).length > 0) {
+ matchingValue = $('#' + identifier).val();
+ }
+ else if($('[name="' + identifier +'"]').length > 0) {
+ matchingValue = $('[name="' + identifier + '"]').val();
+ }
+ else if( $('[name="' + identifier +'[]"]').length > 0 ) {
+ matchingValue = $('[name="' + identifier +'[]"]');
+ }
+ return (matchingValue !== undefined)
+ ? ( value.toString() !== matchingValue.toString() )
: false
;
},
- // value is not exactly notValue
- not: function(value, notValue) {
- return (value != notValue);
- },
+ creditCard: function(cardNumber, cardTypes) {
+ var
+ cards = {
+ visa: {
+ pattern : /^4/,
+ length : [16]
+ },
+ amex: {
+ pattern : /^3[47]/,
+ length : [15]
+ },
+ mastercard: {
+ pattern : /^5[1-5]/,
+ length : [16]
+ },
+ discover: {
+ pattern : /^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/,
+ length : [16]
+ },
+ unionPay: {
+ pattern : /^(62|88)/,
+ length : [16, 17, 18, 19]
+ },
+ jcb: {
+ pattern : /^35(2[89]|[3-8][0-9])/,
+ length : [16]
+ },
+ maestro: {
+ pattern : /^(5018|5020|5038|6304|6759|676[1-3])/,
+ length : [12, 13, 14, 15, 16, 17, 18, 19]
+ },
+ dinersClub: {
+ pattern : /^(30[0-5]|^36)/,
+ length : [14]
+ },
+ laser: {
+ pattern : /^(6304|670[69]|6771)/,
+ length : [16, 17, 18, 19]
+ },
+ visaElectron: {
+ pattern : /^(4026|417500|4508|4844|491(3|7))/,
+ length : [16]
+ }
+ },
+ valid = {},
+ validCard = false,
+ requiredTypes = (typeof cardTypes == 'string')
+ ? cardTypes.split(',')
+ : false,
+ unionPay,
+ validation
+ ;
- // value is most likely url
- url: function(value) {
+ if(typeof cardNumber !== 'string' || cardNumber.length === 0) {
+ return;
+ }
+
+ // verify card types
+ if(requiredTypes) {
+ $.each(requiredTypes, function(index, type){
+ // verify each card type
+ validation = cards[type];
+ if(validation) {
+ valid = {
+ length : ($.inArray(cardNumber.length, validation.length) !== -1),
+ pattern : (cardNumber.search(validation.pattern) !== -1)
+ };
+ if(valid.length && valid.pattern) {
+ validCard = true;
+ }
+ }
+ });
+
+ if(!validCard) {
+ return false;
+ }
+ }
+
+ // skip luhn for UnionPay
+ unionPay = {
+ number : ($.inArray(cardNumber.length, cards.unionPay.length) !== -1),
+ pattern : (cardNumber.search(cards.unionPay.pattern) !== -1)
+ };
+ if(unionPay.number && unionPay.pattern) {
+ return true;
+ }
+
+ // verify luhn, adapted from <https://gist.github.com/2134376>
var
- urlRegExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
+ length = cardNumber.length,
+ multiple = 0,
+ producedValue = [
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
+ [0, 2, 4, 6, 8, 1, 3, 5, 7, 9]
+ ],
+ sum = 0
;
- return urlRegExp.test(value);
+ while (length--) {
+ sum += producedValue[multiple][parseInt(cardNumber.charAt(length), 10)];
+ multiple ^= 1;
+ }
+ return (sum % 10 === 0 && sum > 0);
+ },
+
+ minCount: function(value, minCount) {
+ if(minCount == 0) {
+ return true;
+ }
+ if(minCount == 1) {
+ return (value !== '');
+ }
+ return (value.split(',').length >= minCount);
+ },
+
+ exactCount: function(value, exactCount) {
+ if(exactCount == 0) {
+ return (value === '');
+ }
+ if(exactCount == 1) {
+ return (value !== '' && value.search(',') === -1);
+ }
+ return (value.split(',').length == exactCount);
+ },
+
+ maxCount: function(value, maxCount) {
+ if(maxCount == 0) {
+ return false;
+ }
+ if(maxCount == 1) {
+ return (value.search(',') === -1);
+ }
+ return (value.split(',').length <= maxCount);
}
}
};
-})( jQuery, window , document );
+})( jQuery, window, document );
-/*
- * # Semantic - Accordion
+/*!
+ * # Semantic UI 2.1.6 - Accordion
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -1378,11 +2077,11 @@ $.fn.accordion = function(parameters) {
module = {
initialize: function() {
- module.debug('Initializing accordion with bound events', $module);
- $module
- .on('click' + eventNamespace, selector.title, module.event.click)
- ;
- module.observeChanges();
+ module.debug('Initializing', $module);
+ module.bind.events();
+ if(settings.observeChanges) {
+ module.observeChanges();
+ }
module.instantiate();
},
@@ -1394,12 +2093,10 @@ $.fn.accordion = function(parameters) {
},
destroy: function() {
- module.debug('Destroying previous accordion for', $module);
+ module.debug('Destroying previous instance', $module);
$module
- .removeData(moduleNamespace)
- ;
- $title
.off(eventNamespace)
+ .removeData(moduleNamespace)
;
},
@@ -1422,10 +2119,18 @@ $.fn.accordion = function(parameters) {
}
},
+ bind: {
+ events: function() {
+ module.debug('Binding delegated events');
+ $module
+ .on(settings.on + eventNamespace, selector.trigger, module.event.click)
+ ;
+ }
+ },
event: {
click: function() {
- $.proxy(module.toggle, this)();
+ module.toggle.call(this);
}
},
@@ -1434,22 +2139,25 @@ $.fn.accordion = function(parameters) {
$activeTitle = (query !== undefined)
? (typeof query === 'number')
? $title.eq(query)
- : $(query)
- : $(this),
+ : $(query).closest(selector.title)
+ : $(this).closest(selector.title),
$activeContent = $activeTitle.next($content),
- contentIsOpen = $activeContent.is(':visible')
+ isAnimating = $activeContent.hasClass(className.animating),
+ isActive = $activeContent.hasClass(className.active),
+ isOpen = (isActive && !isAnimating),
+ isOpening = (!isActive && isAnimating)
;
module.debug('Toggling visibility of content', $activeTitle);
- if(contentIsOpen) {
+ if(isOpen || isOpening) {
if(settings.collapsible) {
- $.proxy(module.close, $activeTitle)();
+ module.close.call($activeTitle);
}
else {
module.debug('Cannot close accordion content collapsing is disabled');
}
}
else {
- $.proxy(module.open, $activeTitle)();
+ module.open.call($activeTitle);
}
},
@@ -1458,38 +2166,64 @@ $.fn.accordion = function(parameters) {
$activeTitle = (query !== undefined)
? (typeof query === 'number')
? $title.eq(query)
- : $(query)
- : $(this),
- $activeContent = $activeTitle.next($content),
- currentlyAnimating = $activeContent.is(':animated'),
- currentlyActive = $activeContent.hasClass(className.active)
+ : $(query).closest(selector.title)
+ : $(this).closest(selector.title),
+ $activeContent = $activeTitle.next($content),
+ isAnimating = $activeContent.hasClass(className.animating),
+ isActive = $activeContent.hasClass(className.active),
+ isOpen = (isActive || isAnimating)
;
- if(!currentlyAnimating && !currentlyActive) {
- module.debug('Opening accordion content', $activeTitle);
- if(settings.exclusive) {
- $.proxy(module.closeOthers, $activeTitle)();
+ if(isOpen) {
+ module.debug('Accordion already open, skipping', $activeContent);
+ return;
+ }
+ module.debug('Opening accordion content', $activeTitle);
+ settings.onOpening.call($activeContent);
+ if(settings.exclusive) {
+ module.closeOthers.call($activeTitle);
+ }
+ $activeTitle
+ .addClass(className.active)
+ ;
+ $activeContent
+ .stop(true, true)
+ .addClass(className.animating)
+ ;
+ if(settings.animateChildren) {
+ if($.fn.transition !== undefined && $module.transition('is supported')) {
+ $activeContent
+ .children()
+ .transition({
+ animation : 'fade in',
+ queue : false,
+ useFailSafe : true,
+ debug : settings.debug,
+ verbose : settings.verbose,
+ duration : settings.duration
+ })
+ ;
+ }
+ else {
+ $activeContent
+ .children()
+ .stop(true, true)
+ .animate({
+ opacity: 1
+ }, settings.duration, module.resetOpacity)
+ ;
}
- $activeTitle
- .addClass(className.active)
- ;
- $activeContent
- .stop()
- .children()
- .stop()
- .animate({
- opacity: 1
- }, settings.duration, module.reset.display)
- .end()
- .slideDown(settings.duration, settings.easing, function() {
- $activeContent
- .addClass(className.active)
- ;
- $.proxy(module.reset.display, this)();
- $.proxy(settings.onOpen, this)();
- $.proxy(settings.onChange, this)();
- })
- ;
}
+ $activeContent
+ .slideDown(settings.duration, settings.easing, function() {
+ $activeContent
+ .removeClass(className.animating)
+ .addClass(className.active)
+ ;
+ module.reset.display.call(this);
+ settings.onOpen.call(this);
+ settings.onChange.call(this);
+ })
+ ;
},
close: function(query) {
@@ -1497,30 +2231,57 @@ $.fn.accordion = function(parameters) {
$activeTitle = (query !== undefined)
? (typeof query === 'number')
? $title.eq(query)
- : $(query)
- : $(this),
+ : $(query).closest(selector.title)
+ : $(this).closest(selector.title),
$activeContent = $activeTitle.next($content),
- isActive = $activeContent.hasClass(className.active)
+ isAnimating = $activeContent.hasClass(className.animating),
+ isActive = $activeContent.hasClass(className.active),
+ isOpening = (!isActive && isAnimating),
+ isClosing = (isActive && isAnimating)
;
- if(isActive) {
+ if((isActive || isOpening) && !isClosing) {
module.debug('Closing accordion content', $activeContent);
+ settings.onClosing.call($activeContent);
$activeTitle
.removeClass(className.active)
;
$activeContent
- .removeClass(className.active)
- .show()
- .stop()
- .children()
- .stop()
- .animate({
- opacity: 0
- }, settings.duration, module.reset.opacity)
- .end()
+ .stop(true, true)
+ .addClass(className.animating)
+ ;
+ if(settings.animateChildren) {
+ if($.fn.transition !== undefined && $module.transition('is supported')) {
+ $activeContent
+ .children()
+ .transition({
+ animation : 'fade out',
+ queue : false,
+ useFailSafe : true,
+ debug : settings.debug,
+ verbose : settings.verbose,
+ duration : settings.duration
+ })
+ ;
+ }
+ else {
+ $activeContent
+ .children()
+ .stop(true, true)
+ .animate({
+ opacity: 0
+ }, settings.duration, module.resetOpacity)
+ ;
+ }
+ }
+ $activeContent
.slideUp(settings.duration, settings.easing, function() {
- $.proxy(module.reset.display, this)();
- $.proxy(settings.onClose, this)();
- $.proxy(settings.onChange, this)();
+ $activeContent
+ .removeClass(className.animating)
+ .removeClass(className.active)
+ ;
+ module.reset.display.call(this);
+ settings.onClose.call(this);
+ settings.onChange.call(this);
})
;
}
@@ -1530,7 +2291,7 @@ $.fn.accordion = function(parameters) {
var
$activeTitle = (index !== undefined)
? $title.eq(index)
- : $(this),
+ : $(this).closest(selector.title),
$parentTitles = $activeTitle.parents(selector.content).prev(selector.title),
$activeAccordion = $activeTitle.closest(selector.accordion),
activeSelector = selector.title + '.' + className.active + ':visible',
@@ -1546,25 +2307,45 @@ $.fn.accordion = function(parameters) {
else {
$openTitles = $activeAccordion.find(activeSelector).not($parentTitles);
$nestedTitles = $activeAccordion.find(activeContent).find(activeSelector).not($parentTitles);
- $openTitles = $openTitles.not($nestedTitles);
+ $openTitles = $openTitles.not($nestedTitles);
$openContents = $openTitles.next($content);
}
- if( ($openTitles.size() > 0) ) {
+ if( ($openTitles.length > 0) ) {
module.debug('Exclusive enabled, closing other content', $openTitles);
$openTitles
.removeClass(className.active)
;
$openContents
- .stop()
- .children()
- .stop()
- .animate({
- opacity: 0
- }, settings.duration, module.resetOpacity)
- .end()
+ .removeClass(className.animating)
+ .stop(true, true)
+ ;
+ if(settings.animateChildren) {
+ if($.fn.transition !== undefined && $module.transition('is supported')) {
+ $openContents
+ .children()
+ .transition({
+ animation : 'fade out',
+ useFailSafe : true,
+ debug : settings.debug,
+ verbose : settings.verbose,
+ duration : settings.duration
+ })
+ ;
+ }
+ else {
+ $openContents
+ .children()
+ .stop(true, true)
+ .animate({
+ opacity: 0
+ }, settings.duration, module.resetOpacity)
+ ;
+ }
+ }
+ $openContents
.slideUp(settings.duration , settings.easing, function() {
$(this).removeClass(className.active);
- $.proxy(module.reset.display, this)();
+ module.reset.display.call(this);
})
;
}
@@ -1668,7 +2449,7 @@ $.fn.accordion = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -1731,6 +2512,7 @@ $.fn.accordion = function(parameters) {
return false;
}
else {
+ module.error(error.method, query);
return false;
}
});
@@ -1761,7 +2543,7 @@ $.fn.accordion = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
@@ -1775,35 +2557,45 @@ $.fn.accordion = function(parameters) {
$.fn.accordion.settings = {
- name : 'Accordion',
- namespace : 'accordion',
+ name : 'Accordion',
+ namespace : 'accordion',
- debug : false,
- verbose : true,
- performance : true,
+ debug : false,
+ verbose : false,
+ performance : true,
- exclusive : true,
- collapsible : true,
- closeNested : false,
+ on : 'click', // event on title that opens accordion
- duration : 500,
- easing : 'easeInOutQuint',
+ observeChanges : true, // whether accordion should automatically refresh on DOM insertion
- onOpen : function(){},
- onClose : function(){},
- onChange : function(){},
+ exclusive : true, // whether a single accordion content panel should be open at once
+ collapsible : true, // whether accordion content can be closed
+ closeNested : false, // whether nested content should be closed when a panel is closed
+ animateChildren : true, // whether children opacity should be animated
+
+ duration : 350, // duration of animation
+ easing : 'easeOutQuad', // easing equation for animation
+
+
+ onOpening : function(){}, // callback before open animation
+ onOpen : function(){}, // callback after open animation
+ onClosing : function(){}, // callback before closing animation
+ onClose : function(){}, // callback after closing animation
+ onChange : function(){}, // callback after closing or opening animation
error: {
- method : 'The method you called is not defined'
+ method : 'The method you called is not defined'
},
className : {
- active : 'active'
+ active : 'active',
+ animating : 'animating'
},
selector : {
accordion : '.accordion',
title : '.title',
+ trigger : '.title',
content : '.content'
}
@@ -1811,21 +2603,20 @@ $.fn.accordion.settings = {
// Adds easing
$.extend( $.easing, {
- easeInOutQuint: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
- return c/2*((t-=2)*t*t*t*t + 2) + b;
+ easeOutQuad: function (x, t, b, c, d) {
+ return -c *(t/=d)*(t-2) + b;
}
});
-})( jQuery, window , document );
+})( jQuery, window, document );
-/*
- * # Semantic - Checkbox
+/*!
+ * # Semantic UI 2.1.6 - Checkbox
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -1863,9 +2654,12 @@ $.fn.checkbox = function(parameters) {
moduleNamespace = 'module-' + namespace,
$module = $(this),
- $label = $(this).find(selector.label).first(),
- $input = $(this).find(selector.input),
+ $label = $(this).children(selector.label),
+ $input = $(this).children(selector.input),
+ input = $input[0],
+ initialLoad = false,
+ shortcutPressed = false,
instance = $module.data(moduleNamespace),
observer,
@@ -1879,23 +2673,14 @@ $.fn.checkbox = function(parameters) {
module.verbose('Initializing checkbox', settings);
module.create.label();
- module.add.events();
+ module.bind.events();
- if( module.is.checked() ) {
- module.set.checked();
- if(settings.fireOnInit) {
- $.proxy(settings.onChecked, $input.get())();
- }
- }
- else {
- module.remove.checked();
- if(settings.fireOnInit) {
- $.proxy(settings.onUnchecked, $input.get())();
- }
- }
- module.observeChanges();
+ module.set.tabbable();
+ module.hide.input();
+ module.observeChanges();
module.instantiate();
+ module.setup();
},
instantiate: function() {
@@ -1908,16 +2693,55 @@ $.fn.checkbox = function(parameters) {
destroy: function() {
module.verbose('Destroying module');
- module.remove.events();
- $module
- .removeData(moduleNamespace)
- ;
+ module.unbind.events();
+ module.show.input();
+ $module.removeData(moduleNamespace);
+ },
+
+ fix: {
+ reference: function() {
+ if( $module.is(selector.input) ) {
+ module.debug('Behavior called on <input> adjusting invoked element');
+ $module = $module.closest(selector.checkbox);
+ module.refresh();
+ }
+ }
+ },
+
+ setup: function() {
+ module.set.initialLoad();
+ if( module.is.indeterminate() ) {
+ module.debug('Initial value is indeterminate');
+ module.indeterminate();
+ }
+ else if( module.is.checked() ) {
+ module.debug('Initial value is checked');
+ module.check();
+ }
+ else {
+ module.debug('Initial value is unchecked');
+ module.uncheck();
+ }
+ module.remove.initialLoad();
},
refresh: function() {
- $module = $(this);
- $label = $(this).find(selector.label).first();
- $input = $(this).find(selector.input);
+ $label = $module.children(selector.label);
+ $input = $module.children(selector.input);
+ input = $input[0];
+ },
+
+ hide: {
+ input: function() {
+ module.verbose('Modfying <input> z-index to be unselectable');
+ $input.addClass(className.hidden);
+ }
+ },
+ show: {
+ input: function() {
+ module.verbose('Modfying <input> z-index to be selectable');
+ $input.removeClass(className.hidden);
+ }
},
observeChanges: function() {
@@ -1942,7 +2766,7 @@ $.fn.checkbox = function(parameters) {
? module[event]
: module.toggle
;
- if($element.size() > 0) {
+ if($element.length > 0) {
module.debug('Attaching checkbox events to element', selector, event);
$element
.on('click' + eventNamespace, event)
@@ -1954,43 +2778,220 @@ $.fn.checkbox = function(parameters) {
},
event: {
+ click: function(event) {
+ var
+ $target = $(event.target)
+ ;
+ if( $target.is(selector.input) ) {
+ module.verbose('Using default check action on initialized checkbox');
+ return;
+ }
+ if( $target.is(selector.link) ) {
+ module.debug('Clicking link inside checkbox, skipping toggle');
+ return;
+ }
+ module.toggle();
+ $input.focus();
+ event.preventDefault();
+ },
keydown: function(event) {
var
key = event.which,
keyCode = {
enter : 13,
+ space : 32,
escape : 27
}
;
- if( key == keyCode.escape) {
+ if(key == keyCode.escape) {
module.verbose('Escape key pressed blurring field');
- $module
- .blur()
- ;
+ $input.blur();
+ shortcutPressed = true;
}
- if(!event.ctrlKey && key == keyCode.enter) {
- module.verbose('Enter key pressed, toggling checkbox');
- $.proxy(module.toggle, this)();
+ else if(!event.ctrlKey && ( key == keyCode.space || key == keyCode.enter) ) {
+ module.verbose('Enter/space key pressed, toggling checkbox');
+ module.toggle();
+ shortcutPressed = true;
+ }
+ else {
+ shortcutPressed = false;
+ }
+ },
+ keyup: function(event) {
+ if(shortcutPressed) {
event.preventDefault();
}
}
},
+ check: function() {
+ if( !module.should.allowCheck() ) {
+ return;
+ }
+ module.debug('Checking checkbox', $input);
+ module.set.checked();
+ if( !module.should.ignoreCallbacks() ) {
+ settings.onChecked.call(input);
+ settings.onChange.call(input);
+ }
+ },
+
+ uncheck: function() {
+ if( !module.should.allowUncheck() ) {
+ return;
+ }
+ module.debug('Unchecking checkbox');
+ module.set.unchecked();
+ if( !module.should.ignoreCallbacks() ) {
+ settings.onUnchecked.call(input);
+ settings.onChange.call(input);
+ }
+ },
+
+ indeterminate: function() {
+ if( module.should.allowIndeterminate() ) {
+ module.debug('Checkbox is already indeterminate');
+ return;
+ }
+ module.debug('Making checkbox indeterminate');
+ module.set.indeterminate();
+ if( !module.should.ignoreCallbacks() ) {
+ settings.onIndeterminate.call(input);
+ settings.onChange.call(input);
+ }
+ },
+
+ determinate: function() {
+ if( module.should.allowDeterminate() ) {
+ module.debug('Checkbox is already determinate');
+ return;
+ }
+ module.debug('Making checkbox determinate');
+ module.set.determinate();
+ if( !module.should.ignoreCallbacks() ) {
+ settings.onDeterminate.call(input);
+ settings.onChange.call(input);
+ }
+ },
+
+ enable: function() {
+ if( module.is.enabled() ) {
+ module.debug('Checkbox is already enabled');
+ return;
+ }
+ module.debug('Enabling checkbox');
+ module.set.enabled();
+ settings.onEnable.call(input);
+ },
+
+ disable: function() {
+ if( module.is.disabled() ) {
+ module.debug('Checkbox is already disabled');
+ return;
+ }
+ module.debug('Disabling checkbox');
+ module.set.disabled();
+ settings.onDisable.call(input);
+ },
+
+ get: {
+ radios: function() {
+ var
+ name = module.get.name()
+ ;
+ return $('input[name="' + name + '"]').closest(selector.checkbox);
+ },
+ otherRadios: function() {
+ return module.get.radios().not($module);
+ },
+ name: function() {
+ return $input.attr('name');
+ }
+ },
+
is: {
+ initialLoad: function() {
+ return initialLoad;
+ },
radio: function() {
- return $module.hasClass(className.radio);
+ return ($input.hasClass(className.radio) || $input.attr('type') == 'radio');
+ },
+ indeterminate: function() {
+ return $input.prop('indeterminate') !== undefined && $input.prop('indeterminate');
},
checked: function() {
return $input.prop('checked') !== undefined && $input.prop('checked');
},
+ disabled: function() {
+ return $input.prop('disabled') !== undefined && $input.prop('disabled');
+ },
+ enabled: function() {
+ return !module.is.disabled();
+ },
+ determinate: function() {
+ return !module.is.indeterminate();
+ },
unchecked: function() {
return !module.is.checked();
}
},
+ should: {
+ allowCheck: function() {
+ if(module.is.determinate() && module.is.checked() && !module.should.forceCallbacks() ) {
+ module.debug('Should not allow check, checkbox is already checked');
+ return false;
+ }
+ if(settings.beforeChecked.apply(input) === false) {
+ module.debug('Should not allow check, beforeChecked cancelled');
+ return false;
+ }
+ return true;
+ },
+ allowUncheck: function() {
+ if(module.is.determinate() && module.is.unchecked() && !module.should.forceCallbacks() ) {
+ module.debug('Should not allow uncheck, checkbox is already unchecked');
+ return false;
+ }
+ if(settings.beforeUnchecked.apply(input) === false) {
+ module.debug('Should not allow uncheck, beforeUnchecked cancelled');
+ return false;
+ }
+ return true;
+ },
+ allowIndeterminate: function() {
+ if(module.is.indeterminate() && !module.should.forceCallbacks() ) {
+ module.debug('Should not allow indeterminate, checkbox is already indeterminate');
+ return false;
+ }
+ if(settings.beforeIndeterminate.apply(input) === false) {
+ module.debug('Should not allow indeterminate, beforeIndeterminate cancelled');
+ return false;
+ }
+ return true;
+ },
+ allowDeterminate: function() {
+ if(module.is.determinate() && !module.should.forceCallbacks() ) {
+ module.debug('Should not allow determinate, checkbox is already determinate');
+ return false;
+ }
+ if(settings.beforeDeterminate.apply(input) === false) {
+ module.debug('Should not allow determinate, beforeDeterminate cancelled');
+ return false;
+ }
+ return true;
+ },
+ forceCallbacks: function() {
+ return (module.is.initialLoad() && settings.fireOnInit);
+ },
+ ignoreCallbacks: function() {
+ return (initialLoad && !settings.fireOnInit);
+ }
+ },
+
can: {
change: function() {
- return !( $module.hasClass(className.disabled) || $module.hasClass(className.readOnly) || $input.prop('disabled') );
+ return !( $module.hasClass(className.disabled) || $module.hasClass(className.readOnly) || $input.prop('disabled') || $input.prop('readonly') );
},
uncheck: function() {
return (typeof settings.uncheckable === 'boolean')
@@ -2001,21 +3002,135 @@ $.fn.checkbox = function(parameters) {
},
set: {
+ initialLoad: function() {
+ initialLoad = true;
+ },
checked: function() {
- $module.addClass(className.checked);
+ module.verbose('Setting class to checked');
+ $module
+ .removeClass(className.indeterminate)
+ .addClass(className.checked)
+ ;
+ if( module.is.radio() ) {
+ module.uncheckOthers();
+ }
+ if(!module.is.indeterminate() && module.is.checked()) {
+ module.debug('Input is already checked, skipping input property change');
+ return;
+ }
+ module.verbose('Setting state to checked', input);
+ $input
+ .prop('indeterminate', false)
+ .prop('checked', true)
+ ;
+ module.trigger.change();
},
- tab: function() {
+ unchecked: function() {
+ module.verbose('Removing checked class');
+ $module
+ .removeClass(className.indeterminate)
+ .removeClass(className.checked)
+ ;
+ if(!module.is.indeterminate() && module.is.unchecked() ) {
+ module.debug('Input is already unchecked');
+ return;
+ }
+ module.debug('Setting state to unchecked');
+ $input
+ .prop('indeterminate', false)
+ .prop('checked', false)
+ ;
+ module.trigger.change();
+ },
+ indeterminate: function() {
+ module.verbose('Setting class to indeterminate');
+ $module
+ .addClass(className.indeterminate)
+ ;
+ if( module.is.indeterminate() ) {
+ module.debug('Input is already indeterminate, skipping input property change');
+ return;
+ }
+ module.debug('Setting state to indeterminate');
+ $input
+ .prop('indeterminate', true)
+ ;
+ module.trigger.change();
+ },
+ determinate: function() {
+ module.verbose('Removing indeterminate class');
+ $module
+ .removeClass(className.indeterminate)
+ ;
+ if( module.is.determinate() ) {
+ module.debug('Input is already determinate, skipping input property change');
+ return;
+ }
+ module.debug('Setting state to determinate');
+ $input
+ .prop('indeterminate', false)
+ ;
+ },
+ disabled: function() {
+ module.verbose('Setting class to disabled');
+ $module
+ .addClass(className.disabled)
+ ;
+ if( module.is.disabled() ) {
+ module.debug('Input is already disabled, skipping input property change');
+ return;
+ }
+ module.debug('Setting state to disabled');
+ $input
+ .prop('disabled', 'disabled')
+ ;
+ module.trigger.change();
+ },
+ enabled: function() {
+ module.verbose('Removing disabled class');
+ $module.removeClass(className.disabled);
+ if( module.is.enabled() ) {
+ module.debug('Input is already enabled, skipping input property change');
+ return;
+ }
+ module.debug('Setting state to enabled');
+ $input
+ .prop('disabled', false)
+ ;
+ module.trigger.change();
+ },
+ tabbable: function() {
+ module.verbose('Adding tabindex to checkbox');
if( $input.attr('tabindex') === undefined) {
- $input
- .attr('tabindex', 0)
- ;
+ $input.attr('tabindex', 0);
+ }
+ }
+ },
+
+ remove: {
+ initialLoad: function() {
+ initialLoad = false;
+ }
+ },
+
+ trigger: {
+ change: function() {
+ var
+ events = document.createEvent('HTMLEvents'),
+ inputElement = $input[0]
+ ;
+ if(inputElement) {
+ module.verbose('Triggering native change event');
+ events.initEvent('change', true, false);
+ inputElement.dispatchEvent(events);
}
}
},
+
create: {
label: function() {
- if($input.prevAll(selector.label).size() > 0) {
+ if($input.prevAll(selector.label).length > 0) {
$input.prev(selector.label).detach().insertAfter($input);
module.debug('Moving existing label', $label);
}
@@ -2028,86 +3143,51 @@ $.fn.checkbox = function(parameters) {
has: {
label: function() {
- return ($label.size() > 0);
+ return ($label.length > 0);
}
},
- add: {
+ bind: {
events: function() {
module.verbose('Attaching checkbox events');
$module
- .on('click' + eventNamespace, module.toggle)
+ .on('click' + eventNamespace, module.event.click)
.on('keydown' + eventNamespace, selector.input, module.event.keydown)
+ .on('keyup' + eventNamespace, selector.input, module.event.keyup)
;
}
},
- remove: {
- checked: function() {
- $module.removeClass(className.checked);
- },
+ unbind: {
events: function() {
module.debug('Removing events');
$module
.off(eventNamespace)
- .removeData(moduleNamespace)
- ;
- $input
- .off(eventNamespace, module.event.keydown)
- ;
- $label
- .off(eventNamespace)
;
}
},
- enable: function() {
- module.debug('Enabling checkbox functionality');
- $module.removeClass(className.disabled);
- $input.prop('disabled', false);
- $.proxy(settings.onEnabled, $input.get())();
- },
-
- disable: function() {
- module.debug('Disabling checkbox functionality');
- $module.addClass(className.disabled);
- $input.prop('disabled', 'disabled');
- $.proxy(settings.onDisabled, $input.get())();
- },
-
- check: function() {
- module.debug('Enabling checkbox', $input);
- $input
- .prop('checked', true)
- .trigger('change')
- ;
- module.set.checked();
- $.proxy(settings.onChange, $input.get())();
- $.proxy(settings.onChecked, $input.get())();
- },
-
- uncheck: function() {
- module.debug('Disabling checkbox');
- $input
- .prop('checked', false)
- .trigger('change')
+ uncheckOthers: function() {
+ var
+ $radios = module.get.otherRadios()
;
- module.remove.checked();
- $.proxy(settings.onChange, $input.get())();
- $.proxy(settings.onUnchecked, $input.get())();
+ module.debug('Unchecking other radios', $radios);
+ $radios.removeClass(className.checked);
},
- toggle: function(event) {
+ toggle: function() {
if( !module.can.change() ) {
- console.log(module.can.change());
- module.debug('Checkbox is read-only or disabled, ignoring toggle');
+ if(!module.is.radio()) {
+ module.debug('Checkbox is read-only or disabled, ignoring toggle');
+ }
return;
}
- module.verbose('Determining new checkbox state');
- if( module.is.unchecked() ) {
+ if( module.is.indeterminate() || module.is.unchecked() ) {
+ module.debug('Currently unchecked');
module.check();
}
else if( module.is.checked() && module.can.uncheck() ) {
+ module.debug('Currently checked');
module.uncheck();
}
},
@@ -2180,7 +3260,7 @@ $.fn.checkbox = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -2243,6 +3323,7 @@ $.fn.checkbox = function(parameters) {
return false;
}
else {
+ module.error(error.method, query);
return false;
}
});
@@ -2274,7 +3355,7 @@ $.fn.checkbox = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
@@ -2289,49 +3370,63 @@ $.fn.checkbox = function(parameters) {
$.fn.checkbox.settings = {
- name : 'Checkbox',
- namespace : 'checkbox',
+ name : 'Checkbox',
+ namespace : 'checkbox',
- debug : false,
- verbose : true,
- performance : true,
+ debug : false,
+ verbose : true,
+ performance : true,
// delegated event context
- uncheckable : 'auto',
- fireOnInit : true,
+ uncheckable : 'auto',
+ fireOnInit : false,
- onChange : function(){},
- onChecked : function(){},
- onUnchecked : function(){},
- onEnabled : function(){},
- onDisabled : function(){},
+ onChange : function(){},
- className : {
- checked : 'checked',
- disabled : 'disabled',
- radio : 'radio',
- readOnly : 'read-only'
+ beforeChecked : function(){},
+ beforeUnchecked : function(){},
+ beforeDeterminate : function(){},
+ beforeIndeterminate : function(){},
+
+ onChecked : function(){},
+ onUnchecked : function(){},
+
+ onDeterminate : function() {},
+ onIndeterminate : function() {},
+
+ onEnabled : function(){},
+ onDisabled : function(){},
+
+ className : {
+ checked : 'checked',
+ indeterminate : 'indeterminate',
+ disabled : 'disabled',
+ hidden : 'hidden',
+ radio : 'radio',
+ readOnly : 'read-only'
},
error : {
- method : 'The method you called is not defined.'
+ method : 'The method you called is not defined'
},
selector : {
- input : 'input[type=checkbox], input[type=radio]',
- label : 'label'
+ checkbox : '.ui.checkbox',
+ label : 'label, .box',
+ input : 'input[type="checkbox"], input[type="radio"]',
+ link : 'a[href]'
}
};
-})( jQuery, window , document );
+})( jQuery, window, document );
-/*
- * # Semantic - Dimmer
+/*!
+ * # Semantic UI 2.1.6 - Dimmer
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -2339,6 +3434,8 @@ $.fn.checkbox.settings = {
;(function ( $, window, document, undefined ) {
+"use strict";
+
$.fn.dimmer = function(parameters) {
var
$allModules = $(this),
@@ -2386,6 +3483,7 @@ $.fn.dimmer = function(parameters) {
preinitialize: function() {
if( module.is.dimmer() ) {
+
$dimmable = $module.parent();
$dimmer = $module;
}
@@ -2393,10 +3491,10 @@ $.fn.dimmer = function(parameters) {
$dimmable = $module;
if( module.has.dimmer() ) {
if(settings.dimmerName) {
- $dimmer = $dimmable.children(selector.dimmer).filter('.' + settings.dimmerName);
+ $dimmer = $dimmable.find(selector.dimmer).filter('.' + settings.dimmerName);
}
else {
- $dimmer = $dimmable.children(selector.dimmer);
+ $dimmer = $dimmable.find(selector.dimmer);
}
}
else {
@@ -2407,28 +3505,8 @@ $.fn.dimmer = function(parameters) {
initialize: function() {
module.debug('Initializing dimmer', settings);
- if(settings.on == 'hover') {
- $dimmable
- .on('mouseenter' + eventNamespace, module.show)
- .on('mouseleave' + eventNamespace, module.hide)
- ;
- }
- else if(settings.on == 'click') {
- $dimmable
- .on(clickEvent + eventNamespace, module.toggle)
- ;
- }
- if( module.is.page() ) {
- module.debug('Setting as a page dimmer', $dimmable);
- module.set.pageDimmer();
- }
- if( module.is.closable() ) {
- module.verbose('Adding dimmer close event', $dimmer);
- $dimmer
- .on(clickEvent + eventNamespace, module.event.click)
- ;
- }
+ module.bind.events();
module.set.dimmable();
module.instantiate();
},
@@ -2443,21 +3521,52 @@ $.fn.dimmer = function(parameters) {
destroy: function() {
module.verbose('Destroying previous module', $dimmer);
- $module
- .removeData(moduleNamespace)
- ;
+ module.unbind.events();
+ module.remove.variation();
$dimmable
.off(eventNamespace)
;
- $dimmer
- .off(eventNamespace)
- ;
+ },
+
+ bind: {
+ events: function() {
+ if(settings.on == 'hover') {
+ $dimmable
+ .on('mouseenter' + eventNamespace, module.show)
+ .on('mouseleave' + eventNamespace, module.hide)
+ ;
+ }
+ else if(settings.on == 'click') {
+ $dimmable
+ .on(clickEvent + eventNamespace, module.toggle)
+ ;
+ }
+ if( module.is.page() ) {
+ module.debug('Setting as a page dimmer', $dimmable);
+ module.set.pageDimmer();
+ }
+
+ if( module.is.closable() ) {
+ module.verbose('Adding dimmer close event', $dimmer);
+ $dimmable
+ .on(clickEvent + eventNamespace, selector.dimmer, module.event.click)
+ ;
+ }
+ }
+ },
+
+ unbind: {
+ events: function() {
+ $module
+ .removeData(moduleNamespace)
+ ;
+ }
},
event: {
click: function(event) {
module.verbose('Determining if event occured on dimmer', event);
- if( $dimmer.find(event.target).size() === 0 || $(event.target).is(selector.content) ) {
+ if( $dimmer.find(event.target).length === 0 || $(event.target).is(selector.content) ) {
module.hide();
event.stopImmediatePropagation();
}
@@ -2480,7 +3589,7 @@ $.fn.dimmer = function(parameters) {
;
if(settings.variation) {
module.debug('Creating dimmer with variation', settings.variation);
- $element.addClass(className.variation);
+ $element.addClass(settings.variation);
}
if(settings.dimmerName) {
module.debug('Creating named dimmer', settings.dimmerName);
@@ -2500,8 +3609,8 @@ $.fn.dimmer = function(parameters) {
module.debug('Showing dimmer', $dimmer, settings);
if( (!module.is.dimmed() || module.is.animating()) && module.is.enabled() ) {
module.animate.show(callback);
- $.proxy(settings.onShow, element)();
- $.proxy(settings.onChange, element)();
+ settings.onShow.call(element);
+ settings.onChange.call(element);
}
else {
module.debug('Dimmer is already shown or disabled');
@@ -2516,8 +3625,8 @@ $.fn.dimmer = function(parameters) {
if( module.is.dimmed() || module.is.animating() ) {
module.debug('Hiding dimmer', $dimmer);
module.animate.hide(callback);
- $.proxy(settings.onHide, element)();
- $.proxy(settings.onChange, element)();
+ settings.onHide.call(element);
+ settings.onChange.call(element);
}
else {
module.debug('Dimmer is not visible');
@@ -2541,15 +3650,19 @@ $.fn.dimmer = function(parameters) {
: function(){}
;
if(settings.useCSS && $.fn.transition !== undefined && $dimmer.transition('is supported')) {
+ if(settings.opacity !== 'auto') {
+ module.set.opacity();
+ }
$dimmer
.transition({
- animation : settings.transition + ' in',
+ animation : settings.transition + ' in',
queue : false,
- duration : module.get.duration(),
- onStart : function() {
+ duration : module.get.duration(),
+ useFailSafe : true,
+ onStart : function() {
module.set.dimmed();
},
- onComplete : function() {
+ onComplete : function() {
module.set.active();
callback();
}
@@ -2559,6 +3672,9 @@ $.fn.dimmer = function(parameters) {
else {
module.verbose('Showing dimmer animation with javascript');
module.set.dimmed();
+ if(settings.opacity == 'auto') {
+ settings.opacity = 0.8;
+ }
$dimmer
.stop()
.css({
@@ -2566,7 +3682,7 @@ $.fn.dimmer = function(parameters) {
width : '100%',
height : '100%'
})
- .fadeTo(module.get.duration(), 1, function() {
+ .fadeTo(module.get.duration(), settings.opacity, function() {
$dimmer.removeAttr('style');
module.set.active();
callback();
@@ -2583,13 +3699,14 @@ $.fn.dimmer = function(parameters) {
module.verbose('Hiding dimmer with css');
$dimmer
.transition({
- animation : settings.transition + ' out',
- queue : false,
- duration : module.get.duration(),
- onStart : function() {
+ animation : settings.transition + ' out',
+ queue : false,
+ duration : module.get.duration(),
+ useFailSafe : true,
+ onStart : function() {
module.remove.dimmed();
},
- onComplete : function() {
+ onComplete : function() {
module.remove.active();
callback();
}
@@ -2631,10 +3748,10 @@ $.fn.dimmer = function(parameters) {
has: {
dimmer: function() {
if(settings.dimmerName) {
- return ($module.children(selector.dimmer).filter('.' + settings.dimmerName).size() > 0);
+ return ($module.find(selector.dimmer).filter('.' + settings.dimmerName).length > 0);
}
else {
- return ( $module.children(selector.dimmer).size() > 0 );
+ return ( $module.find(selector.dimmer).length > 0 );
}
}
},
@@ -2656,10 +3773,10 @@ $.fn.dimmer = function(parameters) {
return settings.closable;
},
dimmer: function() {
- return $module.is(selector.dimmer);
+ return $module.hasClass(className.dimmer);
},
dimmable: function() {
- return $module.is(selector.dimmable);
+ return $module.hasClass(className.dimmable);
},
dimmed: function() {
return $dimmable.hasClass(className.dimmed);
@@ -2685,6 +3802,23 @@ $.fn.dimmer = function(parameters) {
},
set: {
+ opacity: function(opacity) {
+ var
+ color = $dimmer.css('background-color'),
+ colorArray = color.split(','),
+ isRGBA = (colorArray && colorArray.length == 4)
+ ;
+ opacity = settings.opacity === 0 ? 0 : settings.opacity || opacity;
+ if(isRGBA) {
+ colorArray[3] = opacity + ')';
+ color = colorArray.join(',');
+ }
+ else {
+ color = 'rgba(0, 0, 0, ' + opacity + ')';
+ }
+ module.debug('Setting opacity to', opacity);
+ $dimmer.css('background-color', color);
+ },
active: function() {
$dimmer.addClass(className.active);
},
@@ -2699,6 +3833,12 @@ $.fn.dimmer = function(parameters) {
},
disabled: function() {
$dimmer.addClass(className.disabled);
+ },
+ variation: function(variation) {
+ variation = variation || settings.variation;
+ if(variation) {
+ $dimmer.addClass(variation);
+ }
}
},
@@ -2713,6 +3853,12 @@ $.fn.dimmer = function(parameters) {
},
disabled: function() {
$dimmer.removeClass(className.disabled);
+ },
+ variation: function(variation) {
+ variation = variation || settings.variation;
+ if(variation) {
+ $dimmer.removeClass(variation);
+ }
}
},
@@ -2785,7 +3931,7 @@ $.fn.dimmer = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -2801,8 +3947,8 @@ $.fn.dimmer = function(parameters) {
if(moduleSelector) {
title += ' \'' + moduleSelector + '\'';
}
- if($allModules.size() > 1) {
- title += ' ' + '(' + $allModules.size() + ')';
+ if($allModules.length > 1) {
+ title += ' ' + '(' + $allModules.length + ')';
}
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
console.groupCollapsed(title);
@@ -2851,6 +3997,7 @@ $.fn.dimmer = function(parameters) {
return false;
}
else {
+ module.error(error.method, query);
return false;
}
});
@@ -2884,7 +4031,7 @@ $.fn.dimmer = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
@@ -2903,16 +4050,31 @@ $.fn.dimmer.settings = {
namespace : 'dimmer',
debug : false,
- verbose : true,
+ verbose : false,
performance : true,
+ // name to distinguish between multiple dimmers in context
dimmerName : false,
+
+ // whether to add a variation type
variation : false,
+
+ // whether to bind close events
closable : 'auto',
- transition : 'fade',
+
+ // whether to use css animations
useCSS : true,
+
+ // css animation to use
+ transition : 'fade',
+
+ // event to bind to
on : false,
+ // overriding opacity value
+ opacity : 'auto',
+
+ // transition durations
duration : {
show : 500,
hide : 500
@@ -2926,38 +4088,38 @@ $.fn.dimmer.settings = {
method : 'The method you called is not defined.'
},
- selector: {
- dimmable : '.dimmable',
- dimmer : '.ui.dimmer',
- content : '.ui.dimmer > .content, .ui.dimmer > .content > .center'
- },
-
- template: {
- dimmer: function() {
- return $('<div />').attr('class', 'ui dimmer');
- }
- },
-
className : {
active : 'active',
animating : 'animating',
dimmable : 'dimmable',
dimmed : 'dimmed',
+ dimmer : 'dimmer',
disabled : 'disabled',
hide : 'hide',
pageDimmer : 'page',
show : 'show'
+ },
+
+ selector: {
+ dimmer : '> .ui.dimmer',
+ content : '.ui.dimmer > .content, .ui.dimmer > .content > .center'
+ },
+
+ template: {
+ dimmer: function() {
+ return $('<div />').attr('class', 'ui dimmer');
+ }
}
};
-})( jQuery, window , document );
-/*
- * # Semantic - Dropdown
+})( jQuery, window, document );
+/*!
+ * # Semantic UI 2.1.6 - Dropdown
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -2985,27 +4147,34 @@ $.fn.dropdown = function(parameters) {
;
$allModules
- .each(function() {
+ .each(function(elementIndex) {
var
settings = ( $.isPlainObject(parameters) )
? $.extend(true, {}, $.fn.dropdown.settings, parameters)
: $.extend({}, $.fn.dropdown.settings),
className = settings.className,
+ message = settings.message,
+ fields = settings.fields,
+ keys = settings.keys,
metadata = settings.metadata,
namespace = settings.namespace,
+ regExp = settings.regExp,
selector = settings.selector,
error = settings.error,
+ templates = settings.templates,
eventNamespace = '.' + namespace,
moduleNamespace = 'module-' + namespace,
$module = $(this),
+ $context = $(settings.context),
$text = $module.find(selector.text),
$search = $module.find(selector.search),
$input = $module.find(selector.input),
+ $icon = $module.find(selector.icon),
- $combo = ($module.prev().find(selector.text).size() > 0)
+ $combo = ($module.prev().find(selector.text).length > 0)
? $module.prev().find(selector.text)
: $module.prev(),
@@ -3014,10 +4183,16 @@ $.fn.dropdown = function(parameters) {
activated = false,
itemActivated = false,
-
+ internalChange = false,
element = this,
instance = $module.data(moduleNamespace),
- observer,
+
+ initialLoad,
+ pageLostFocus,
+ elementNamespace,
+ id,
+ selectObserver,
+ menuObserver,
module
;
@@ -3025,18 +4200,24 @@ $.fn.dropdown = function(parameters) {
initialize: function() {
module.debug('Initializing dropdown', settings);
- module.setup.layout();
- module.save.defaults();
- module.set.selected();
- if(hasTouch) {
- module.bind.touchEvents();
+ if( module.is.alreadySetup() ) {
+ module.setup.reference();
+ }
+ else {
+ module.setup.layout();
+ module.refreshData();
+
+ module.save.defaults();
+ module.restore.selected();
+
+ module.create.id();
+ module.bind.events();
+
+ module.observeChanges();
+ module.instantiate();
}
- module.bind.mouseEvents();
- module.bind.keyboardEvents();
- module.observeChanges();
- module.instantiate();
},
instantiate: function() {
@@ -3048,37 +4229,175 @@ $.fn.dropdown = function(parameters) {
},
destroy: function() {
- module.verbose('Destroying previous dropdown for', $module);
+ module.verbose('Destroying previous dropdown', $module);
module.remove.tabbable();
$module
.off(eventNamespace)
.removeData(moduleNamespace)
;
+ $menu
+ .off(eventNamespace)
+ ;
+ $document
+ .off(elementNamespace)
+ ;
+ if(selectObserver) {
+ selectObserver.disconnect();
+ }
+ if(menuObserver) {
+ menuObserver.disconnect();
+ }
},
observeChanges: function() {
if('MutationObserver' in window) {
- observer = new MutationObserver(function(mutations) {
- module.debug('DOM tree modified, updating selector cache');
+ selectObserver = new MutationObserver(function(mutations) {
+ module.debug('<select> modified, recreating menu');
+ module.setup.select();
+ });
+ menuObserver = new MutationObserver(function(mutations) {
+ module.debug('Menu modified, updating selector cache');
module.refresh();
});
- observer.observe(element, {
- childList : true,
- subtree : true
+ if(module.has.input()) {
+ selectObserver.observe($input[0], {
+ childList : true,
+ subtree : true
+ });
+ }
+ if(module.has.menu()) {
+ menuObserver.observe($menu[0], {
+ childList : true,
+ subtree : true
+ });
+ }
+ module.debug('Setting up mutation observer', selectObserver, menuObserver);
+ }
+ },
+
+ create: {
+ id: function() {
+ id = (Math.random().toString(16) + '000000000').substr(2, 8);
+ elementNamespace = '.' + id;
+ module.verbose('Creating unique id for element', id);
+ },
+ userChoice: function(values) {
+ var
+ $userChoices,
+ $userChoice,
+ isUserValue,
+ html
+ ;
+ values = values || module.get.userValues();
+ if(!values) {
+ return false;
+ }
+ values = $.isArray(values)
+ ? values
+ : [values]
+ ;
+ $.each(values, function(index, value) {
+ if(module.get.item(value) === false) {
+ html = settings.templates.addition( module.add.variables(message.addResult, value) );
+ $userChoice = $('<div />')
+ .html(html)
+ .attr('data-' + metadata.value, value)
+ .attr('data-' + metadata.text, value)
+ .addClass(className.addition)
+ .addClass(className.item)
+ ;
+ $userChoices = ($userChoices === undefined)
+ ? $userChoice
+ : $userChoices.add($userChoice)
+ ;
+ module.verbose('Creating user choices for value', value, $userChoice);
+ }
});
- module.debug('Setting up mutation observer', observer);
+ return $userChoices;
+ },
+ userLabels: function(value) {
+ var
+ userValues = module.get.userValues()
+ ;
+ if(userValues) {
+ module.debug('Adding user labels', userValues);
+ $.each(userValues, function(index, value) {
+ module.verbose('Adding custom user value');
+ module.add.label(value, value);
+ });
+ }
+ },
+ menu: function() {
+ $menu = $('<div />')
+ .addClass(className.menu)
+ .appendTo($module)
+ ;
}
},
- setup: {
+ search: function(query) {
+ query = (query !== undefined)
+ ? query
+ : module.get.query()
+ ;
+ module.verbose('Searching for query', query);
+ module.filter(query);
+ },
+ select: {
+ firstUnfiltered: function() {
+ module.verbose('Selecting first non-filtered element');
+ module.remove.selectedItem();
+ $item
+ .not(selector.unselectable)
+ .eq(0)
+ .addClass(className.selected)
+ ;
+ },
+ nextAvailable: function($selected) {
+ $selected = $selected.eq(0);
+ var
+ $nextAvailable = $selected.nextAll(selector.item).not(selector.unselectable).eq(0),
+ $prevAvailable = $selected.prevAll(selector.item).not(selector.unselectable).eq(0),
+ hasNext = ($nextAvailable.length > 0)
+ ;
+ if(hasNext) {
+ module.verbose('Moving selection to', $nextAvailable);
+ $nextAvailable.addClass(className.selected);
+ }
+ else {
+ module.verbose('Moving selection to', $prevAvailable);
+ $prevAvailable.addClass(className.selected);
+ }
+ }
+ },
+
+ setup: {
+ api: function() {
+ var
+ apiSettings = {
+ debug : settings.debug,
+ on : false
+ }
+ ;
+ module.verbose('First request, initializing API');
+ $module
+ .api(apiSettings)
+ ;
+ },
layout: function() {
if( $module.is('select') ) {
module.setup.select();
+ module.setup.returnedObject();
}
- if( module.is.search() && !module.is.searchable() ) {
+ if( !module.has.menu() ) {
+ module.create.menu();
+ }
+ if( module.is.search() && !module.has.search() ) {
+ module.verbose('Adding search input');
$search = $('<input />')
.addClass(className.search)
+ .prop('autocomplete', 'off')
.insertBefore($text)
;
}
@@ -3088,46 +4407,106 @@ $.fn.dropdown = function(parameters) {
},
select: function() {
var
- selectValues = module.get.selectValues()
+ selectValues = module.get.selectValues()
;
module.debug('Dropdown initialized on a select', selectValues);
- // see if select exists inside a dropdown
- $input = $module;
- if($input.parents(selector.dropdown).size() > 0) {
- module.debug('Creating dropdown menu only from template');
+ if( $module.is('select') ) {
+ $input = $module;
+ }
+ // see if select is placed correctly already
+ if($input.parent(selector.dropdown).length > 0) {
+ module.debug('UI dropdown already exists. Creating dropdown menu only');
$module = $input.closest(selector.dropdown);
- if($module.find('.' + className.dropdown).size() === 0) {
- $('<div />')
- .addClass(className.menu)
- .html( settings.templates.menu( selectValues ))
- .appendTo($module)
- ;
+ if( !module.has.menu() ) {
+ module.create.menu();
}
+ $menu = $module.children(selector.menu);
+ module.setup.menu(selectValues);
}
else {
- module.debug('Creating entire dropdown from template');
+ module.debug('Creating entire dropdown from select');
$module = $('<div />')
.attr('class', $input.attr('class') )
.addClass(className.selection)
.addClass(className.dropdown)
- .html( settings.templates.dropdown(selectValues) )
+ .html( templates.dropdown(selectValues) )
.insertBefore($input)
;
+ if($input.hasClass(className.multiple) && $input.prop('multiple') === false) {
+ module.error(error.missingMultiple);
+ $input.prop('multiple', true);
+ }
+ if($input.is('[multiple]')) {
+ module.set.multiple();
+ }
+ if ($input.prop('disabled')) {
+ module.debug('Disabling dropdown')
+ $module.addClass(className.disabled)
+ }
$input
.removeAttr('class')
+ .detach()
.prependTo($module)
;
}
module.refresh();
+ },
+ menu: function(values) {
+ $menu.html( templates.menu(values, fields));
+ $item = $menu.find(selector.item);
+ },
+ reference: function() {
+ module.debug('Dropdown behavior was called on select, replacing with closest dropdown');
+ // replace module reference
+ $module = $module.parent(selector.dropdown);
+ module.refresh();
+ module.setup.returnedObject();
+ // invoke method in context of current instance
+ if(methodInvoked) {
+ instance = module;
+ module.invoke(query);
+ }
+ },
+ returnedObject: function() {
+ var
+ $firstModules = $allModules.slice(0, elementIndex),
+ $lastModules = $allModules.slice(elementIndex + 1)
+ ;
+ // adjust all modules to use correct reference
+ $allModules = $firstModules.add($module).add($lastModules);
}
},
refresh: function() {
+ module.refreshSelectors();
+ module.refreshData();
+ },
+
+ refreshSelectors: function() {
+ module.verbose('Refreshing selector cache');
$text = $module.find(selector.text);
$search = $module.find(selector.search);
$input = $module.find(selector.input);
- $menu = $module.children(selector.menu);
- $item = $menu.find(selector.item);
+ $icon = $module.find(selector.icon);
+ $combo = ($module.prev().find(selector.text).length > 0)
+ ? $module.prev().find(selector.text)
+ : $module.prev()
+ ;
+ $menu = $module.children(selector.menu);
+ $item = $menu.find(selector.item);
+ },
+
+ refreshData: function() {
+ module.verbose('Refreshing cached metadata');
+ $item
+ .removeData(metadata.text)
+ .removeData(metadata.value)
+ ;
+ $module
+ .removeData(metadata.defaultText)
+ .removeData(metadata.defaultValue)
+ .removeData(metadata.placeholderText)
+ ;
},
toggle: function() {
@@ -3140,26 +4519,44 @@ $.fn.dropdown = function(parameters) {
}
},
- show: function() {
- module.debug('Checking if dropdown can show');
- if( !module.is.active() ) {
- module.animate.show(function() {
- if( module.can.click() ) {
- module.bind.intent();
- }
- module.set.visible();
- });
- $.proxy(settings.onShow, element)();
+ show: function(callback) {
+ callback = $.isFunction(callback)
+ ? callback
+ : function(){}
+ ;
+ if( module.can.show() && !module.is.active() ) {
+ module.debug('Showing dropdown');
+ if(module.is.multiple() && !module.has.search() && module.is.allFiltered()) {
+ return true;
+ }
+ if(module.has.message() && !(module.has.maxSelections() || module.has.allResultsFiltered()) ) {
+ module.remove.message();
+ }
+ if(settings.onShow.call(element) !== false) {
+ module.animate.show(function() {
+ if( module.can.click() ) {
+ module.bind.intent();
+ }
+ module.set.visible();
+ callback.call(element);
+ });
+ }
}
},
- hide: function() {
+ hide: function(callback) {
+ callback = $.isFunction(callback)
+ ? callback
+ : function(){}
+ ;
if( module.is.active() ) {
module.debug('Hiding dropdown');
- module.animate.hide(function() {
- module.remove.visible();
- });
- $.proxy(settings.onHide, element)();
+ if(settings.onHide.call(element) !== false) {
+ module.animate.hide(function() {
+ module.remove.visible();
+ callback.call(element);
+ });
+ }
}
},
@@ -3167,36 +4564,41 @@ $.fn.dropdown = function(parameters) {
module.verbose('Finding other dropdowns to hide');
$allModules
.not($module)
- .has(selector.menu + ':visible:not(.' + className.animating + ')')
+ .has(selector.menu + '.' + className.visible)
.dropdown('hide')
;
},
+ hideMenu: function() {
+ module.verbose('Hiding menu instantaneously');
+ module.remove.active();
+ module.remove.visible();
+ $menu.transition('hide');
+ },
+
hideSubMenus: function() {
var
- $subMenus = $menu.find(selector.menu)
+ $subMenus = $menu.children(selector.item).find(selector.menu)
;
+ module.verbose('Hiding sub menus', $subMenus);
$subMenus.transition('hide');
},
bind: {
- keyboardEvents: function() {
- module.debug('Binding keyboard events');
- $module
- .on('keydown' + eventNamespace, module.event.keydown)
- ;
- if( module.is.searchable() ) {
- $module
- .on(module.get.inputEvent(), selector.search, module.event.input)
- ;
+ events: function() {
+ if(hasTouch) {
+ module.bind.touchEvents();
}
+ module.bind.keyboardEvents();
+ module.bind.inputEvents();
+ module.bind.mouseEvents();
},
touchEvents: function() {
module.debug('Touch device detected binding additional touch events');
if( module.is.searchSelection() ) {
// do nothing special yet
}
- else {
+ else if( module.is.single() ) {
$module
.on('touchstart' + eventNamespace, module.event.test.toggle)
;
@@ -3205,20 +4607,56 @@ $.fn.dropdown = function(parameters) {
.on('touchstart' + eventNamespace, selector.item, module.event.item.mouseenter)
;
},
+ keyboardEvents: function() {
+ module.verbose('Binding keyboard events');
+ $module
+ .on('keydown' + eventNamespace, module.event.keydown)
+ ;
+ if( module.has.search() ) {
+ $module
+ .on(module.get.inputEvent() + eventNamespace, selector.search, module.event.input)
+ ;
+ }
+ if( module.is.multiple() ) {
+ $document
+ .on('keydown' + elementNamespace, module.event.document.keydown)
+ ;
+ }
+ },
+ inputEvents: function() {
+ module.verbose('Binding input change events');
+ $module
+ .on('change' + eventNamespace, selector.input, module.event.change)
+ ;
+ },
mouseEvents: function() {
- module.verbose('Mouse detected binding mouse events');
+ module.verbose('Binding mouse events');
+ if(module.is.multiple()) {
+ $module
+ .on('click' + eventNamespace, selector.label, module.event.label.click)
+ .on('click' + eventNamespace, selector.remove, module.event.remove.click)
+ ;
+ }
if( module.is.searchSelection() ) {
$module
- .on('mousedown' + eventNamespace, selector.menu, module.event.menu.activate)
- .on('mouseup' + eventNamespace, selector.menu, module.event.menu.deactivate)
- .on('focus' + eventNamespace, selector.search, module.event.searchFocus)
+ .on('mousedown' + eventNamespace, selector.menu, module.event.menu.mousedown)
+ .on('mouseup' + eventNamespace, selector.menu, module.event.menu.mouseup)
+ .on('click' + eventNamespace, selector.icon, module.event.icon.click)
.on('click' + eventNamespace, selector.search, module.show)
- .on('blur' + eventNamespace, selector.search, module.event.searchBlur)
+ .on('focus' + eventNamespace, selector.search, module.event.search.focus)
+ .on('blur' + eventNamespace, selector.search, module.event.search.blur)
+ .on('click' + eventNamespace, selector.text, module.event.text.focus)
;
+ if(module.is.multiple()) {
+ $module
+ .on('click' + eventNamespace, module.event.click)
+ ;
+ }
}
else {
if(settings.on == 'click') {
$module
+ .on('click' + eventNamespace, selector.icon, module.event.icon.click)
.on('click' + eventNamespace, module.event.test.toggle)
;
}
@@ -3250,12 +4688,12 @@ $.fn.dropdown = function(parameters) {
module.verbose('Binding hide intent event to document');
if(hasTouch) {
$document
- .on('touchstart' + eventNamespace, module.event.test.touch)
- .on('touchmove' + eventNamespace, module.event.test.touch)
+ .on('touchstart' + elementNamespace, module.event.test.touch)
+ .on('touchmove' + elementNamespace, module.event.test.touch)
;
}
$document
- .on('click' + eventNamespace, module.event.test.hide)
+ .on('click' + elementNamespace, module.event.test.hide)
;
}
},
@@ -3265,204 +4703,367 @@ $.fn.dropdown = function(parameters) {
module.verbose('Removing hide intent event from document');
if(hasTouch) {
$document
- .off('touchstart' + eventNamespace)
- .off('touchmove' + eventNamespace)
+ .off('touchstart' + elementNamespace)
+ .off('touchmove' + elementNamespace)
;
}
$document
- .off('click' + eventNamespace)
+ .off('click' + elementNamespace)
;
}
},
- filter: function(searchTerm) {
+ filter: function(query) {
var
- $results = $(),
- exactRegExp = new RegExp('(?:\s|^)' + searchTerm, 'i'),
- fullTextRegExp = new RegExp(searchTerm, 'i'),
- allItemsFiltered,
- $filteredItems
- ;
- $item
- .each(function(){
- var
- $choice = $(this),
- text = ( $choice.data(metadata.text) !== undefined )
- ? $choice.data(metadata.text)
- : (settings.preserveHTML)
- ? $choice.html()
- : $choice.text(),
- value = ( $choice.data(metadata.value) !== undefined)
- ? $choice.data(metadata.value)
- : (typeof text === 'string')
- ? text.toLowerCase()
- : text
- ;
- if( exactRegExp.test( text ) || exactRegExp.test( value ) ) {
- $results = $results.add($choice);
- }
- else if(settings.fullTextSearch) {
- if( fullTextRegExp.test( text ) || fullTextRegExp.test( value ) ) {
- $results = $results.add($choice);
+ searchTerm = (query !== undefined)
+ ? query
+ : module.get.query(),
+ afterFiltered = function() {
+ if(module.is.multiple()) {
+ module.filterActive();
+ }
+ module.select.firstUnfiltered();
+ if( module.has.allResultsFiltered() ) {
+ if( settings.onNoResults.call(element, searchTerm) ) {
+ if(!settings.allowAdditions) {
+ module.verbose('All items filtered, showing message', searchTerm);
+ module.add.message(message.noResults);
+ }
+ }
+ else {
+ module.verbose('All items filtered, hiding dropdown', searchTerm);
+ module.hideMenu();
}
}
- })
+ else {
+ module.remove.message();
+ }
+ if(settings.allowAdditions) {
+ module.add.userSuggestion(query);
+ }
+ if(module.is.searchSelection() && module.can.show() && module.is.focusedOnSearch() ) {
+ module.show();
+ }
+ }
;
- $filteredItems = $item.not($results);
- allItemsFiltered = ($filteredItems.size() == $item.size());
+ if(settings.useLabels && module.has.maxSelections()) {
+ return;
+ }
+ if(settings.apiSettings) {
+ if( module.can.useAPI() ) {
+ module.queryRemote(searchTerm, function() {
+ afterFiltered();
+ });
+ }
+ else {
+ module.error(error.noAPI);
+ }
+ }
+ else {
+ module.filterItems(searchTerm);
+ afterFiltered();
+ }
+ },
- module.remove.filteredItem();
- module.remove.selectedItem();
- $filteredItems
- .addClass(className.filtered)
+ queryRemote: function(query, callback) {
+ var
+ apiSettings = {
+ errorDuration : false,
+ throttle : settings.throttle,
+ urlData : {
+ query: query
+ },
+ onError: function() {
+ module.add.message(message.serverError);
+ callback();
+ },
+ onFailure: function() {
+ module.add.message(message.serverError);
+ callback();
+ },
+ onSuccess : function(response) {
+ module.remove.message();
+ module.setup.menu({
+ values: response[fields.remoteValues]
+ });
+ callback();
+ }
+ }
;
- $item
- .not('.' + className.filtered)
- .eq(0)
- .addClass(className.selected)
+ if( !$module.api('get request') ) {
+ module.setup.api();
+ }
+ apiSettings = $.extend(true, {}, apiSettings, settings.apiSettings);
+ $module
+ .api('setting', apiSettings)
+ .api('query')
;
- if(allItemsFiltered) {
- module.hide();
+ },
+
+ filterItems: function(query) {
+ var
+ searchTerm = (query !== undefined)
+ ? query
+ : module.get.query(),
+ results = null,
+ escapedTerm = module.escape.regExp(searchTerm),
+ beginsWithRegExp = new RegExp('^' + escapedTerm, 'igm')
+ ;
+ // avoid loop if we're matching nothing
+ if( module.has.query() ) {
+ results = [];
+
+ module.verbose('Searching for matching values', searchTerm);
+ $item
+ .each(function(){
+ var
+ $choice = $(this),
+ text,
+ value
+ ;
+ if(settings.match == 'both' || settings.match == 'text') {
+ text = String(module.get.choiceText($choice, false));
+ if(text.search(beginsWithRegExp) !== -1) {
+ results.push(this);
+ return true;
+ }
+ else if(settings.fullTextSearch && module.fuzzySearch(searchTerm, text)) {
+ results.push(this);
+ return true;
+ }
+ }
+ if(settings.match == 'both' || settings.match == 'value') {
+ value = String(module.get.choiceValue($choice, text));
+
+ if(value.search(beginsWithRegExp) !== -1) {
+ results.push(this);
+ return true;
+ }
+ else if(settings.fullTextSearch && module.fuzzySearch(searchTerm, value)) {
+ results.push(this);
+ return true;
+ }
+ }
+ })
+ ;
+ }
+ module.debug('Showing only matched items', searchTerm);
+ module.remove.filteredItem();
+ if(results) {
+ $item
+ .not(results)
+ .addClass(className.filtered)
+ ;
}
},
- focusSearch: function() {
- if( module.is.search() ) {
- $search
- .focus()
+ fuzzySearch: function(query, term) {
+ var
+ termLength = term.length,
+ queryLength = query.length
+ ;
+ query = query.toLowerCase();
+ term = term.toLowerCase();
+ if(queryLength > termLength) {
+ return false;
+ }
+ if(queryLength === termLength) {
+ return (query === term);
+ }
+ search: for (var characterIndex = 0, nextCharacterIndex = 0; characterIndex < queryLength; characterIndex++) {
+ var
+ queryCharacter = query.charCodeAt(characterIndex)
;
+ while(nextCharacterIndex < termLength) {
+ if(term.charCodeAt(nextCharacterIndex++) === queryCharacter) {
+ continue search;
+ }
+ }
+ return false;
+ }
+ return true;
+ },
+
+ filterActive: function() {
+ if(settings.useLabels) {
+ $item.filter('.' + className.active)
+ .addClass(className.filtered)
+ ;
+ }
+ },
+
+ focusSearch: function() {
+ if( module.is.search() && !module.is.focusedOnSearch() ) {
+ $search[0].focus();
+ }
+ },
+
+ forceSelection: function() {
+ var
+ $currentlySelected = $item.not(className.filtered).filter('.' + className.selected).eq(0),
+ $activeItem = $item.not(className.filtered).filter('.' + className.active).eq(0),
+ $selectedItem = ($currentlySelected.length > 0)
+ ? $currentlySelected
+ : $activeItem,
+ hasSelected = ($selectedItem.size() > 0)
+ ;
+ if( module.has.query() ) {
+ if(hasSelected) {
+ module.debug('Forcing partial selection to selected item', $selectedItem);
+ module.event.item.click.call($selectedItem);
+ return;
+ }
+ else {
+ module.remove.searchTerm();
+ }
}
+ module.hide();
},
event: {
- // prevents focus callback from occuring on mousedown
- mousedown: function() {
- activated = true;
- },
- mouseup: function() {
- activated = false;
+ change: function() {
+ if(!internalChange) {
+ module.debug('Input changed, updating selection');
+ module.set.selected();
+ }
},
focus: function() {
- if(!activated && module.is.hidden()) {
+ if(settings.showOnFocus && !activated && module.is.hidden() && !pageLostFocus) {
module.show();
}
},
+ click: function(event) {
+ var
+ $target = $(event.target)
+ ;
+ // focus search
+ if($target.is($module) && !module.is.focusedOnSearch()) {
+ module.focusSearch();
+ }
+ },
blur: function(event) {
- if(!activated) {
+ pageLostFocus = (document.activeElement === this);
+ if(!activated && !pageLostFocus) {
+ module.remove.activeLabel();
module.hide();
}
},
- searchFocus: function() {
+ // prevents focus callback from occurring on mousedown
+ mousedown: function() {
activated = true;
- module.show();
},
- searchBlur: function(event) {
- if(!itemActivated) {
- module.hide();
- }
+ mouseup: function() {
+ activated = false;
},
- input: function(event) {
- var
- query = $search.val()
- ;
- if(module.is.searchSelection()) {
- if( module.can.show() ) {
- module.show();
+ search: {
+ focus: function() {
+ activated = true;
+ if(module.is.multiple()) {
+ module.remove.activeLabel();
}
- module.set.filtered();
- }
- module.filter(query);
- },
- keydown: function(event) {
- var
- $selectedItem = $item.not(className.filtered).filter('.' + className.selected).eq(0),
- $visibleItems = $item.not('.' + className.filtered),
- pressedKey = event.which,
- keys = {
- enter : 13,
- escape : 27,
- upArrow : 38,
- downArrow : 40
- },
- selectedClass = className.selected,
- currentIndex = $visibleItems.index( $selectedItem ),
- hasSelectedItem = ($selectedItem.size() > 0),
- $nextItem,
- newIndex
- ;
- // default to activated choice if no selection present
- if(!hasSelectedItem) {
- $selectedItem = $item.filter('.' + className.active).eq(0);
- hasSelectedItem = ($selectedItem.size() > 0);
- }
- // close shortcuts
- if(pressedKey == keys.escape) {
- module.verbose('Escape key pressed, closing dropdown');
- module.hide();
- }
- // result shortcuts
- if(module.is.visible()) {
- if(pressedKey == keys.enter && hasSelectedItem) {
- module.verbose('Enter key pressed, choosing selected item');
- $.proxy(module.event.item.click, $selectedItem)(event);
- event.preventDefault();
- return false;
+ if(settings.showOnFocus) {
+ module.search();
+ module.show();
}
- else if(pressedKey == keys.upArrow) {
- if(!hasSelectedItem) {
- $nextItem = $visibleItems.eq(0);
- }
- else {
- $nextItem = $selectedItem.prevAll(selector.item + ':not(.' + className.filtered + ')').eq(0);
- }
- if(currentIndex !== 0) {
- module.verbose('Up key pressed, changing active item');
- $item
- .removeClass(selectedClass)
- ;
- $nextItem
- .addClass(selectedClass)
- ;
- module.set.scrollPosition($nextItem);
+ },
+ blur: function(event) {
+ pageLostFocus = (document.activeElement === this);
+ if(!itemActivated && !pageLostFocus) {
+ if(module.is.multiple()) {
+ module.remove.activeLabel();
+ module.hide();
}
- event.preventDefault();
- }
- else if(pressedKey == keys.downArrow) {
- if(!hasSelectedItem) {
- $nextItem = $visibleItems.eq(0);
+ else if(settings.forceSelection) {
+ module.forceSelection();
}
else {
- $nextItem = $selectedItem.nextAll(selector.item + ':not(.' + className.filtered + ')').eq(0);
+ module.hide();
}
- if(currentIndex + 1 < $visibleItems.size() ) {
- module.verbose('Down key pressed, changing active item');
- $item
- .removeClass(selectedClass)
- ;
- $nextItem
- .addClass(selectedClass)
- ;
- module.set.scrollPosition($nextItem);
+ }
+ else if(pageLostFocus) {
+ if(settings.forceSelection) {
+ module.forceSelection();
}
- event.preventDefault();
}
}
- else {
- if(pressedKey == keys.enter) {
- module.show();
+ },
+ icon: {
+ click: function(event) {
+ module.toggle();
+ event.stopPropagation();
+ }
+ },
+ text: {
+ focus: function(event) {
+ activated = true;
+ module.focusSearch();
+ }
+ },
+ input: function(event) {
+ if(module.is.multiple() || module.is.searchSelection()) {
+ module.set.filtered();
+ }
+ clearTimeout(module.timer);
+ module.timer = setTimeout(module.search, settings.delay.search);
+ },
+ label: {
+ click: function(event) {
+ var
+ $label = $(this),
+ $labels = $module.find(selector.label),
+ $activeLabels = $labels.filter('.' + className.active),
+ $nextActive = $label.nextAll('.' + className.active),
+ $prevActive = $label.prevAll('.' + className.active),
+ $range = ($nextActive.length > 0)
+ ? $label.nextUntil($nextActive).add($activeLabels).add($label)
+ : $label.prevUntil($prevActive).add($activeLabels).add($label)
+ ;
+ if(event.shiftKey) {
+ $activeLabels.removeClass(className.active);
+ $range.addClass(className.active);
+ }
+ else if(event.ctrlKey) {
+ $label.toggleClass(className.active);
+ }
+ else {
+ $activeLabels.removeClass(className.active);
+ $label.addClass(className.active);
+ }
+ settings.onLabelSelect.apply(this, $labels.filter('.' + className.active));
+ }
+ },
+ remove: {
+ click: function() {
+ var
+ $label = $(this).parent()
+ ;
+ if( $label.hasClass(className.active) ) {
+ // remove all selected labels
+ module.remove.activeLabels();
+ }
+ else {
+ // remove this label only
+ module.remove.activeLabels( $label );
}
}
},
test: {
toggle: function(event) {
- if( module.determine.eventInMenu(event, module.toggle) ) {
+ var
+ toggleBehavior = (module.is.multiple())
+ ? module.show
+ : module.toggle
+ ;
+ if( module.determine.eventOnElement(event, toggleBehavior) ) {
event.preventDefault();
}
},
touch: function(event) {
- module.determine.eventInMenu(event, function() {
+ module.determine.eventOnElement(event, function() {
if(event.type == 'touchstart') {
- module.timer = setTimeout(module.hide, settings.delay.touch);
+ module.timer = setTimeout(function() {
+ module.hide();
+ }, settings.delay.touch);
}
else if(event.type == 'touchmove') {
clearTimeout(module.timer);
@@ -3474,78 +5075,362 @@ $.fn.dropdown = function(parameters) {
module.determine.eventInModule(event, module.hide);
}
},
-
menu: {
- activate: function() {
+ mousedown: function() {
itemActivated = true;
},
- deactivate: function() {
+ mouseup: function() {
itemActivated = false;
}
},
item: {
mouseenter: function(event) {
var
- $currentMenu = $(this).children(selector.menu),
- $otherMenus = $(this).siblings(selector.item).children(selector.menu)
+ $subMenu = $(this).children(selector.menu),
+ $otherMenus = $(this).siblings(selector.item).children(selector.menu)
;
- if( $currentMenu.size() > 0 ) {
+ if( $subMenu.length > 0 ) {
clearTimeout(module.itemTimer);
module.itemTimer = setTimeout(function() {
+ module.verbose('Showing sub-menu', $subMenu);
$.each($otherMenus, function() {
module.animate.hide(false, $(this));
});
- module.verbose('Showing sub-menu', $currentMenu);
- module.animate.show(false, $currentMenu);
+ module.animate.show(false, $subMenu);
}, settings.delay.show);
event.preventDefault();
}
},
-
mouseleave: function(event) {
var
- $currentMenu = $(this).children(selector.menu)
+ $subMenu = $(this).children(selector.menu)
;
- if($currentMenu.size() > 0) {
+ if($subMenu.length > 0) {
clearTimeout(module.itemTimer);
module.itemTimer = setTimeout(function() {
- module.verbose('Hiding sub-menu', $currentMenu);
- module.animate.hide(false, $currentMenu);
+ module.verbose('Hiding sub-menu', $subMenu);
+ module.animate.hide(false, $subMenu);
}, settings.delay.hide);
}
},
-
+ touchend: function() {
+ },
click: function (event) {
var
- $choice = $(this),
- text = ( $choice.data(metadata.text) !== undefined )
- ? $choice.data(metadata.text)
- : (settings.preserveHTML)
- ? $choice.html()
- : $choice.text(),
- value = ( $choice.data(metadata.value) !== undefined)
- ? $choice.data(metadata.value)
- : (typeof text === 'string')
- ? text.toLowerCase()
- : text,
- callback = function() {
- module.remove.searchTerm();
- module.remove.filteredItem();
- module.determine.selectAction(text, value);
- },
- openingSubMenu = ($choice.find(selector.menu).size() > 0)
+ $choice = $(this),
+ $target = (event)
+ ? $(event.target)
+ : $(''),
+ $subMenu = $choice.find(selector.menu),
+ text = module.get.choiceText($choice),
+ value = module.get.choiceValue($choice, text),
+ hasSubMenu = ($subMenu.length > 0),
+ isBubbledEvent = ($subMenu.find($target).length > 0)
;
- if( !openingSubMenu ) {
- callback();
+ if(!isBubbledEvent && (!hasSubMenu || settings.allowCategorySelection)) {
+ if(!settings.useLabels) {
+ module.remove.filteredItem();
+ module.remove.searchTerm();
+ module.set.scrollPosition($choice);
+ }
+ module.determine.selectAction.call(this, text, value);
}
}
+ },
+ document: {
+ // label selection should occur even when element has no focus
+ keydown: function(event) {
+ var
+ pressedKey = event.which,
+ isShortcutKey = module.is.inObject(pressedKey, keys)
+ ;
+ if(isShortcutKey) {
+ var
+ $label = $module.find(selector.label),
+ $activeLabel = $label.filter('.' + className.active),
+ activeValue = $activeLabel.data(metadata.value),
+ labelIndex = $label.index($activeLabel),
+ labelCount = $label.length,
+ hasActiveLabel = ($activeLabel.length > 0),
+ hasMultipleActive = ($activeLabel.length > 1),
+ isFirstLabel = (labelIndex === 0),
+ isLastLabel = (labelIndex + 1 == labelCount),
+ isSearch = module.is.searchSelection(),
+ isFocusedOnSearch = module.is.focusedOnSearch(),
+ isFocused = module.is.focused(),
+ caretAtStart = (isFocusedOnSearch && module.get.caretPosition() === 0),
+ $nextLabel
+ ;
+ if(isSearch && !hasActiveLabel && !isFocusedOnSearch) {
+ return;
+ }
+
+ if(pressedKey == keys.leftArrow) {
+ // activate previous label
+ if((isFocused || caretAtStart) && !hasActiveLabel) {
+ module.verbose('Selecting previous label');
+ $label.last().addClass(className.active);
+ }
+ else if(hasActiveLabel) {
+ if(!event.shiftKey) {
+ module.verbose('Selecting previous label');
+ $label.removeClass(className.active);
+ }
+ else {
+ module.verbose('Adding previous label to selection');
+ }
+ if(isFirstLabel && !hasMultipleActive) {
+ $activeLabel.addClass(className.active);
+ }
+ else {
+ $activeLabel.prev(selector.siblingLabel)
+ .addClass(className.active)
+ .end()
+ ;
+ }
+ event.preventDefault();
+ }
+ }
+ else if(pressedKey == keys.rightArrow) {
+ // activate first label
+ if(isFocused && !hasActiveLabel) {
+ $label.first().addClass(className.active);
+ }
+ // activate next label
+ if(hasActiveLabel) {
+ if(!event.shiftKey) {
+ module.verbose('Selecting next label');
+ $label.removeClass(className.active);
+ }
+ else {
+ module.verbose('Adding next label to selection');
+ }
+ if(isLastLabel) {
+ if(isSearch) {
+ if(!isFocusedOnSearch) {
+ module.focusSearch();
+ }
+ else {
+ $label.removeClass(className.active);
+ }
+ }
+ else if(hasMultipleActive) {
+ $activeLabel.next(selector.siblingLabel).addClass(className.active);
+ }
+ else {
+ $activeLabel.addClass(className.active);
+ }
+ }
+ else {
+ $activeLabel.next(selector.siblingLabel).addClass(className.active);
+ }
+ event.preventDefault();
+ }
+ }
+ else if(pressedKey == keys.deleteKey || pressedKey == keys.backspace) {
+ if(hasActiveLabel) {
+ module.verbose('Removing active labels');
+ if(isLastLabel) {
+ if(isSearch && !isFocusedOnSearch) {
+ module.focusSearch();
+ }
+ }
+ $activeLabel.last().next(selector.siblingLabel).addClass(className.active);
+ module.remove.activeLabels($activeLabel);
+ event.preventDefault();
+ }
+ else if(caretAtStart && !hasActiveLabel && pressedKey == keys.backspace) {
+ module.verbose('Removing last label on input backspace');
+ $activeLabel = $label.last().addClass(className.active);
+ module.remove.activeLabels($activeLabel);
+ }
+ }
+ else {
+ $activeLabel.removeClass(className.active);
+ }
+ }
+ }
},
- resetStyle: function() {
- $(this).removeAttr('style');
+ keydown: function(event) {
+ var
+ pressedKey = event.which,
+ isShortcutKey = module.is.inObject(pressedKey, keys)
+ ;
+ if(isShortcutKey) {
+ var
+ $currentlySelected = $item.not(selector.unselectable).filter('.' + className.selected).eq(0),
+ $activeItem = $menu.children('.' + className.active).eq(0),
+ $selectedItem = ($currentlySelected.length > 0)
+ ? $currentlySelected
+ : $activeItem,
+ $visibleItems = ($selectedItem.length > 0)
+ ? $selectedItem.siblings(':not(.' + className.filtered +')').andSelf()
+ : $menu.children(':not(.' + className.filtered +')'),
+ $subMenu = $selectedItem.children(selector.menu),
+ $parentMenu = $selectedItem.closest(selector.menu),
+ inVisibleMenu = ($parentMenu.hasClass(className.visible) || $parentMenu.hasClass(className.animating) || $parentMenu.parent(selector.menu).length > 0),
+ hasSubMenu = ($subMenu.length> 0),
+ hasSelectedItem = ($selectedItem.length > 0),
+ selectedIsSelectable = ($selectedItem.not(selector.unselectable).length > 0),
+ delimiterPressed = (pressedKey == keys.delimiter && settings.allowAdditions && module.is.multiple()),
+ $nextItem,
+ isSubMenuItem,
+ newIndex
+ ;
+ // visible menu keyboard shortcuts
+ if( module.is.visible() ) {
+
+ // enter (select or open sub-menu)
+ if(pressedKey == keys.enter || delimiterPressed) {
+ if(pressedKey == keys.enter && hasSelectedItem && hasSubMenu && !settings.allowCategorySelection) {
+ module.verbose('Pressed enter on unselectable category, opening sub menu');
+ pressedKey = keys.rightArrow;
+ }
+ else if(selectedIsSelectable) {
+ module.verbose('Selecting item from keyboard shortcut', $selectedItem);
+ module.event.item.click.call($selectedItem, event);
+ if(module.is.searchSelection()) {
+ module.remove.searchTerm();
+ }
+ }
+ event.preventDefault();
+ }
+
+ // left arrow (hide sub-menu)
+ if(pressedKey == keys.leftArrow) {
+
+ isSubMenuItem = ($parentMenu[0] !== $menu[0]);
+
+ if(isSubMenuItem) {
+ module.verbose('Left key pressed, closing sub-menu');
+ module.animate.hide(false, $parentMenu);
+ $selectedItem
+ .removeClass(className.selected)
+ ;
+ $parentMenu
+ .closest(selector.item)
+ .addClass(className.selected)
+ ;
+ event.preventDefault();
+ }
+ }
+
+ // right arrow (show sub-menu)
+ if(pressedKey == keys.rightArrow) {
+ if(hasSubMenu) {
+ module.verbose('Right key pressed, opening sub-menu');
+ module.animate.show(false, $subMenu);
+ $selectedItem
+ .removeClass(className.selected)
+ ;
+ $subMenu
+ .find(selector.item).eq(0)
+ .addClass(className.selected)
+ ;
+ event.preventDefault();
+ }
+ }
+
+ // up arrow (traverse menu up)
+ if(pressedKey == keys.upArrow) {
+ $nextItem = (hasSelectedItem && inVisibleMenu)
+ ? $selectedItem.prevAll(selector.item + ':not(' + selector.unselectable + ')').eq(0)
+ : $item.eq(0)
+ ;
+ if($visibleItems.index( $nextItem ) < 0) {
+ module.verbose('Up key pressed but reached top of current menu');
+ event.preventDefault();
+ return;
+ }
+ else {
+ module.verbose('Up key pressed, changing active item');
+ $selectedItem
+ .removeClass(className.selected)
+ ;
+ $nextItem
+ .addClass(className.selected)
+ ;
+ module.set.scrollPosition($nextItem);
+ }
+ event.preventDefault();
+ }
+
+ // down arrow (traverse menu down)
+ if(pressedKey == keys.downArrow) {
+ $nextItem = (hasSelectedItem && inVisibleMenu)
+ ? $nextItem = $selectedItem.nextAll(selector.item + ':not(' + selector.unselectable + ')').eq(0)
+ : $item.eq(0)
+ ;
+ if($nextItem.length === 0) {
+ module.verbose('Down key pressed but reached bottom of current menu');
+ event.preventDefault();
+ return;
+ }
+ else {
+ module.verbose('Down key pressed, changing active item');
+ $item
+ .removeClass(className.selected)
+ ;
+ $nextItem
+ .addClass(className.selected)
+ ;
+ module.set.scrollPosition($nextItem);
+ }
+ event.preventDefault();
+ }
+
+ // page down (show next page)
+ if(pressedKey == keys.pageUp) {
+ module.scrollPage('up');
+ event.preventDefault();
+ }
+ if(pressedKey == keys.pageDown) {
+ module.scrollPage('down');
+ event.preventDefault();
+ }
+
+ // escape (close menu)
+ if(pressedKey == keys.escape) {
+ module.verbose('Escape key pressed, closing dropdown');
+ module.hide();
+ }
+
+ }
+ else {
+ // delimiter key
+ if(delimiterPressed) {
+ event.preventDefault();
+ }
+ // down arrow (open menu)
+ if(pressedKey == keys.downArrow) {
+ module.verbose('Down key pressed, showing dropdown');
+ module.show();
+ event.preventDefault();
+ }
+ }
+ }
+ else {
+ if( module.is.selection() && !module.is.search() ) {
+ module.set.selectedLetter( String.fromCharCode(pressedKey) );
+ }
+ }
}
+ },
+ trigger: {
+ change: function() {
+ var
+ events = document.createEvent('HTMLEvents'),
+ inputElement = $input[0]
+ ;
+ if(inputElement) {
+ module.verbose('Triggering native change event');
+ events.initEvent('change', true, false);
+ inputElement.dispatchEvent(events);
+ }
+ }
},
determine: {
@@ -3553,19 +5438,27 @@ $.fn.dropdown = function(parameters) {
module.verbose('Determining action', settings.action);
if( $.isFunction( module.action[settings.action] ) ) {
module.verbose('Triggering preset action', settings.action, text, value);
- module.action[ settings.action ](text, value);
+ module.action[ settings.action ].call(this, text, value);
}
else if( $.isFunction(settings.action) ) {
module.verbose('Triggering user action', settings.action, text, value);
- settings.action(text, value);
+ settings.action.call(this, text, value);
}
else {
module.error(error.action, settings.action);
}
},
eventInModule: function(event, callback) {
- callback = callback || function(){};
- if( $(event.target).closest($module).size() === 0 ) {
+ var
+ $target = $(event.target),
+ inDocument = ($target.closest(document.documentElement).length > 0),
+ inModule = ($target.closest($module).length > 0)
+ ;
+ callback = $.isFunction(callback)
+ ? callback
+ : function(){}
+ ;
+ if(inDocument && !inModule) {
module.verbose('Triggering event', callback);
callback();
return true;
@@ -3575,9 +5468,18 @@ $.fn.dropdown = function(parameters) {
return false;
}
},
- eventInMenu: function(event, callback) {
- callback = callback || function(){};
- if( $(event.target).closest($menu).size() === 0 ) {
+ eventOnElement: function(event, callback) {
+ var
+ $target = $(event.target),
+ $label = $target.closest(selector.siblingLabel),
+ notOnLabel = ($module.find($label).length === 0),
+ notInMenu = ($target.closest($menu).length === 0)
+ ;
+ callback = $.isFunction(callback)
+ ? callback
+ : function(){}
+ ;
+ if(notOnLabel && notInMenu) {
module.verbose('Triggering event', callback);
callback();
return true;
@@ -3593,28 +5495,25 @@ $.fn.dropdown = function(parameters) {
nothing: function() {},
- hide: function() {
- module.hide();
- },
-
- select: function(text, value) {
+ activate: function(text, value) {
value = (value !== undefined)
? value
: text
;
- module.set.selected(value);
- module.set.value(value);
- module.hide();
+ if( module.can.activate( $(this) ) ) {
+ module.set.selected(value, $(this));
+ if(module.is.multiple() && !module.is.allFiltered()) {
+ return;
+ }
+ else {
+ module.hideAndClear();
+ }
+ }
},
- activate: function(text, value) {
- value = (value !== undefined)
- ? value
- : text
- ;
- module.set.selected(value);
- module.set.value(value);
- module.hide();
+ select: function(text, value) {
+ // mimics action.activate but does not select text
+ module.action.activate.call(this);
},
combo: function(text, value) {
@@ -3622,21 +5521,178 @@ $.fn.dropdown = function(parameters) {
? value
: text
;
- module.set.selected(value);
+ module.set.selected(value, $(this));
+ module.hideAndClear();
+ },
+
+ hide: function(text, value) {
module.set.value(value);
- module.hide();
+ module.hideAndClear();
}
},
get: {
+ id: function() {
+ return id;
+ },
+ defaultText: function() {
+ return $module.data(metadata.defaultText);
+ },
+ defaultValue: function() {
+ return $module.data(metadata.defaultValue);
+ },
+ placeholderText: function() {
+ return $module.data(metadata.placeholderText) || '';
+ },
text: function() {
return $text.text();
},
+ query: function() {
+ return $.trim($search.val());
+ },
+ searchWidth: function(characterCount) {
+ return (characterCount * settings.glyphWidth) + 'em';
+ },
+ selectionCount: function() {
+ var
+ values = module.get.values(),
+ count
+ ;
+ count = ( module.is.multiple() )
+ ? $.isArray(values)
+ ? values.length
+ : 0
+ : (module.get.value() !== '')
+ ? 1
+ : 0
+ ;
+ return count;
+ },
+ transition: function($subMenu) {
+ return (settings.transition == 'auto')
+ ? module.is.upward($subMenu)
+ ? 'slide up'
+ : 'slide down'
+ : settings.transition
+ ;
+ },
+ userValues: function() {
+ var
+ values = module.get.values()
+ ;
+ if(!values) {
+ return false;
+ }
+ values = $.isArray(values)
+ ? values
+ : [values]
+ ;
+ return $.grep(values, function(value) {
+ return (module.get.item(value) === false);
+ });
+ },
+ uniqueArray: function(array) {
+ return $.grep(array, function (value, index) {
+ return $.inArray(value, array) === index;
+ });
+ },
+ caretPosition: function() {
+ var
+ input = $search.get(0),
+ range,
+ rangeLength
+ ;
+ if('selectionStart' in input) {
+ return input.selectionStart;
+ }
+ else if (document.selection) {
+ input.focus();
+ range = document.selection.createRange();
+ rangeLength = range.text.length;
+ range.moveStart('character', -input.value.length);
+ return range.text.length - rangeLength;
+ }
+ },
value: function() {
- return ($input.size() > 0)
- ? $input.val()
- : $module.data(metadata.value)
+ var
+ value = ($input.length > 0)
+ ? $input.val()
+ : $module.data(metadata.value)
+ ;
+ // prevents placeholder element from being selected when multiple
+ if($.isArray(value) && value.length === 1 && value[0] === '') {
+ return '';
+ }
+ return value;
+ },
+ values: function() {
+ var
+ value = module.get.value()
+ ;
+ if(value === '') {
+ return '';
+ }
+ return ( !module.has.selectInput() && module.is.multiple() )
+ ? (typeof value == 'string') // delimited string
+ ? value.split(settings.delimiter)
+ : ''
+ : value
+ ;
+ },
+ remoteValues: function() {
+ var
+ values = module.get.values(),
+ remoteValues = false
+ ;
+ if(values) {
+ if(typeof values == 'string') {
+ values = [values];
+ }
+ remoteValues = {};
+ $.each(values, function(index, value) {
+ var
+ name = module.read.remoteData(value)
+ ;
+ module.verbose('Restoring value from session data', name, value);
+ remoteValues[value] = (name)
+ ? name
+ : value
+ ;
+ });
+ }
+ return remoteValues;
+ },
+ choiceText: function($choice, preserveHTML) {
+ preserveHTML = (preserveHTML !== undefined)
+ ? preserveHTML
+ : settings.preserveHTML
+ ;
+ if($choice) {
+ if($choice.find(selector.menu).length > 0) {
+ module.verbose('Retreiving text of element with sub-menu');
+ $choice = $choice.clone();
+ $choice.find(selector.menu).remove();
+ $choice.find(selector.menuIcon).remove();
+ }
+ return ($choice.data(metadata.text) !== undefined)
+ ? $choice.data(metadata.text)
+ : (preserveHTML)
+ ? $.trim($choice.html())
+ : $.trim($choice.text())
+ ;
+ }
+ },
+ choiceValue: function($choice, choiceText) {
+ choiceText = choiceText || module.get.choiceText($choice);
+ if(!$choice) {
+ return false;
+ }
+ return ($choice.data(metadata.value) !== undefined)
+ ? String( $choice.data(metadata.value) )
+ : (typeof choiceText === 'string')
+ ? $.trim(choiceText.toLowerCase())
+ : String(choiceText)
;
},
inputEvent: function() {
@@ -3655,158 +5711,453 @@ $.fn.dropdown = function(parameters) {
},
selectValues: function() {
var
- select = {
- values : {}
- }
+ select = {}
;
+ select.values = [];
$module
.find('option')
.each(function() {
var
- name = $(this).html(),
- value = ( $(this).attr('value') !== undefined )
- ? $(this).attr('value')
+ $option = $(this),
+ name = $option.html(),
+ disabled = $option.attr('disabled'),
+ value = ( $option.attr('value') !== undefined )
+ ? $option.attr('value')
: name
;
- if(value === '') {
+ if(settings.placeholder === 'auto' && value === '') {
select.placeholder = name;
}
else {
- select.values[value] = name;
+ select.values.push({
+ name : name,
+ value : value,
+ disabled : disabled
+ });
}
})
;
- module.debug('Retrieved values from select', select);
+ if(settings.placeholder && settings.placeholder !== 'auto') {
+ module.debug('Setting placeholder value to', settings.placeholder);
+ select.placeholder = settings.placeholder;
+ }
+ if(settings.sortSelect) {
+ select.values.sort(function(a, b) {
+ return (a.name > b.name)
+ ? 1
+ : -1
+ ;
+ });
+ module.debug('Retrieved and sorted values from select', select);
+ }
+ else {
+ module.debug('Retreived values from select', select);
+ }
return select;
},
+ activeItem: function() {
+ return $item.filter('.' + className.active);
+ },
+ selectedItem: function() {
+ var
+ $selectedItem = $item.not(selector.unselectable).filter('.' + className.selected)
+ ;
+ return ($selectedItem.length > 0)
+ ? $selectedItem
+ : $item.eq(0)
+ ;
+ },
+ itemWithAdditions: function(value) {
+ var
+ $items = module.get.item(value),
+ $userItems = module.create.userChoice(value),
+ hasUserItems = ($userItems && $userItems.length > 0)
+ ;
+ if(hasUserItems) {
+ $items = ($items.length > 0)
+ ? $items.add($userItems)
+ : $userItems
+ ;
+ }
+ return $items;
+ },
item: function(value, strict) {
var
- $selectedItem = false
+ $selectedItem = false,
+ shouldSearch,
+ isMultiple
;
value = (value !== undefined)
? value
- : ( module.get.value() !== undefined)
- ? module.get.value()
+ : ( module.get.values() !== undefined)
+ ? module.get.values()
: module.get.text()
;
- strict = (value === '' || value === 0)
+ shouldSearch = (isMultiple)
+ ? (value.length > 0)
+ : (value !== undefined && value !== null)
+ ;
+ isMultiple = (module.is.multiple() && $.isArray(value));
+ strict = (value === '' || value === 0)
? true
: strict || false
;
- if(value !== undefined) {
+ if(shouldSearch) {
$item
.each(function() {
var
$choice = $(this),
- optionText = ( $choice.data(metadata.text) !== undefined )
- ? $choice.data(metadata.text)
- : (settings.preserveHTML)
- ? $choice.html()
- : $choice.text(),
- optionValue = ( $choice.data(metadata.value) !== undefined )
- ? $choice.data(metadata.value)
- : (typeof optionText === 'string')
- ? optionText.toLowerCase()
- : optionText
+ optionText = module.get.choiceText($choice),
+ optionValue = module.get.choiceValue($choice, optionText)
;
- if(strict) {
- module.verbose('Ambiguous dropdown value using strict type check', $choice, value);
- if( optionValue === value ) {
- $selectedItem = $(this);
+ // safe early exit
+ if(optionValue === null || optionValue === undefined) {
+ return;
+ }
+ if(isMultiple) {
+ if($.inArray( String(optionValue), value) !== -1 || $.inArray(optionText, value) !== -1) {
+ $selectedItem = ($selectedItem)
+ ? $selectedItem.add($choice)
+ : $choice
+ ;
}
- else if( !$selectedItem && optionText === value ) {
- $selectedItem = $(this);
+ }
+ else if(strict) {
+ module.verbose('Ambiguous dropdown value using strict type check', $choice, value);
+ if( optionValue === value || optionText === value) {
+ $selectedItem = $choice;
+ return true;
}
}
else {
- if( optionValue == value ) {
+ if( String(optionValue) == String(value) || optionText == value) {
module.verbose('Found select item by value', optionValue, value);
- $selectedItem = $(this);
- }
- else if( !$selectedItem && optionText == value ) {
- module.verbose('Found select item by text', optionText, value);
- $selectedItem = $(this);
+ $selectedItem = $choice;
+ return true;
}
}
})
;
}
- else {
- value = module.get.text();
+ return $selectedItem;
+ }
+ },
+
+ check: {
+ maxSelections: function(selectionCount) {
+ if(settings.maxSelections) {
+ selectionCount = (selectionCount !== undefined)
+ ? selectionCount
+ : module.get.selectionCount()
+ ;
+ if(selectionCount >= settings.maxSelections) {
+ module.debug('Maximum selection count reached');
+ if(settings.useLabels) {
+ $item.addClass(className.filtered);
+ module.add.message(message.maxSelections);
+ }
+ return true;
+ }
+ else {
+ module.verbose('No longer at maximum selection count');
+ module.remove.message();
+ module.remove.filteredItem();
+ if(module.is.searchSelection()) {
+ module.filterItems();
+ }
+ return false;
+ }
}
- return $selectedItem || false;
+ return true;
}
},
restore: {
defaults: function() {
+ module.clear();
module.restore.defaultText();
module.restore.defaultValue();
},
defaultText: function() {
var
- defaultText = $module.data(metadata.defaultText)
+ defaultText = module.get.defaultText(),
+ placeholderText = module.get.placeholderText
;
- module.debug('Restoring default text', defaultText);
- module.set.text(defaultText);
+ if(defaultText === placeholderText) {
+ module.debug('Restoring default placeholder text', defaultText);
+ module.set.placeholderText(defaultText);
+ }
+ else {
+ module.debug('Restoring default text', defaultText);
+ module.set.text(defaultText);
+ }
},
defaultValue: function() {
var
- defaultValue = $module.data(metadata.defaultValue)
+ defaultValue = module.get.defaultValue()
;
if(defaultValue !== undefined) {
module.debug('Restoring default value', defaultValue);
- module.set.selected(defaultValue);
- module.set.value(defaultValue);
+ if(defaultValue !== '') {
+ module.set.value(defaultValue);
+ module.set.selected();
+ }
+ else {
+ module.remove.activeItem();
+ module.remove.selectedItem();
+ }
+ }
+ },
+ labels: function() {
+ if(settings.allowAdditions) {
+ if(!settings.useLabels) {
+ module.error(error.labels);
+ settings.useLabels = true;
+ }
+ module.debug('Restoring selected values');
+ module.create.userLabels();
+ }
+ module.check.maxSelections();
+ },
+ selected: function() {
+ module.restore.values();
+ if(module.is.multiple()) {
+ module.debug('Restoring previously selected values and labels');
+ module.restore.labels();
}
+ else {
+ module.debug('Restoring previously selected values');
+ }
+ },
+ values: function() {
+ // prevents callbacks from occuring on initial load
+ module.set.initialLoad();
+ if(settings.apiSettings) {
+ if(settings.saveRemoteData) {
+ module.restore.remoteValues();
+ }
+ else {
+ module.clearValue();
+ }
+ }
+ else {
+ module.set.selected();
+ }
+ module.remove.initialLoad();
+ },
+ remoteValues: function() {
+ var
+ values = module.get.remoteValues()
+ ;
+ module.debug('Recreating selected from session data', values);
+ if(values) {
+ if( module.is.single() ) {
+ $.each(values, function(value, name) {
+ module.set.text(name);
+ });
+ }
+ else {
+ $.each(values, function(value, name) {
+ module.add.label(value, name);
+ });
+ }
+ }
+ }
+ },
+
+ read: {
+ remoteData: function(value) {
+ var
+ name
+ ;
+ if(window.Storage === undefined) {
+ module.error(error.noStorage);
+ return;
+ }
+ name = sessionStorage.getItem(value);
+ return (name !== undefined)
+ ? name
+ : false
+ ;
}
},
save: {
defaults: function() {
module.save.defaultText();
+ module.save.placeholderText();
module.save.defaultValue();
},
defaultValue: function() {
- $module.data(metadata.defaultValue, module.get.value() );
+ var
+ value = module.get.value()
+ ;
+ module.verbose('Saving default value as', value);
+ $module.data(metadata.defaultValue, value);
},
defaultText: function() {
- $module.data(metadata.defaultText, $text.text() );
+ var
+ text = module.get.text()
+ ;
+ module.verbose('Saving default text as', text);
+ $module.data(metadata.defaultText, text);
+ },
+ placeholderText: function() {
+ var
+ text
+ ;
+ if(settings.placeholder !== false && $text.hasClass(className.placeholder)) {
+ text = module.get.text();
+ module.verbose('Saving placeholder text as', text);
+ $module.data(metadata.placeholderText, text);
+ }
+ },
+ remoteData: function(name, value) {
+ if(window.Storage === undefined) {
+ module.error(error.noStorage);
+ return;
+ }
+ module.verbose('Saving remote data to session storage', value, name);
+ sessionStorage.setItem(value, name);
+ }
+ },
+
+ clear: function() {
+ if(module.is.multiple()) {
+ module.remove.labels();
+ }
+ else {
+ module.remove.activeItem();
+ module.remove.selectedItem();
+ }
+ module.set.placeholderText();
+ module.clearValue();
+ },
+
+ clearValue: function() {
+ module.set.value('');
+ },
+
+ scrollPage: function(direction, $selectedItem) {
+ var
+ $currentItem = $selectedItem || module.get.selectedItem(),
+ $menu = $currentItem.closest(selector.menu),
+ menuHeight = $menu.outerHeight(),
+ currentScroll = $menu.scrollTop(),
+ itemHeight = $item.eq(0).outerHeight(),
+ itemsPerPage = Math.floor(menuHeight / itemHeight),
+ maxScroll = $menu.prop('scrollHeight'),
+ newScroll = (direction == 'up')
+ ? currentScroll - (itemHeight * itemsPerPage)
+ : currentScroll + (itemHeight * itemsPerPage),
+ $selectableItem = $item.not(selector.unselectable),
+ isWithinRange,
+ $nextSelectedItem,
+ elementIndex
+ ;
+ elementIndex = (direction == 'up')
+ ? $selectableItem.index($currentItem) - itemsPerPage
+ : $selectableItem.index($currentItem) + itemsPerPage
+ ;
+ isWithinRange = (direction == 'up')
+ ? (elementIndex >= 0)
+ : (elementIndex < $selectableItem.length)
+ ;
+ $nextSelectedItem = (isWithinRange)
+ ? $selectableItem.eq(elementIndex)
+ : (direction == 'up')
+ ? $selectableItem.first()
+ : $selectableItem.last()
+ ;
+ if($nextSelectedItem.length > 0) {
+ module.debug('Scrolling page', direction, $nextSelectedItem);
+ $currentItem
+ .removeClass(className.selected)
+ ;
+ $nextSelectedItem
+ .addClass(className.selected)
+ ;
+ $menu
+ .scrollTop(newScroll)
+ ;
}
},
set: {
filtered: function() {
- $text.addClass(className.filtered);
+ var
+ isMultiple = module.is.multiple(),
+ isSearch = module.is.searchSelection(),
+ isSearchMultiple = (isMultiple && isSearch),
+ searchValue = (isSearch)
+ ? module.get.query()
+ : '',
+ hasSearchValue = (typeof searchValue === 'string' && searchValue.length > 0),
+ searchWidth = module.get.searchWidth(searchValue.length),
+ valueIsSet = searchValue !== ''
+ ;
+ if(isMultiple && hasSearchValue) {
+ module.verbose('Adjusting input width', searchWidth, settings.glyphWidth);
+ $search.css('width', searchWidth);
+ }
+ if(hasSearchValue || (isSearchMultiple && valueIsSet)) {
+ module.verbose('Hiding placeholder text');
+ $text.addClass(className.filtered);
+ }
+ else if(!isMultiple || (isSearchMultiple && !valueIsSet)) {
+ module.verbose('Showing placeholder text');
+ $text.removeClass(className.filtered);
+ }
+ },
+ loading: function() {
+ $module.addClass(className.loading);
+ },
+ placeholderText: function(text) {
+ text = text || module.get.placeholderText();
+ module.debug('Setting placeholder text', text);
+ module.set.text(text);
+ $text.addClass(className.placeholder);
},
tabbable: function() {
- if( module.is.searchable() ) {
- module.debug('Searchable dropdown initialized');
+ if( module.has.search() ) {
+ module.debug('Added tabindex to searchable dropdown');
$search
.val('')
.attr('tabindex', 0)
;
$menu
- .attr('tabindex', '-1')
+ .attr('tabindex', -1)
;
}
else {
- module.debug('Simple selection dropdown initialized');
- if(!$module.attr('tabindex') ) {
+ module.debug('Added tabindex to dropdown');
+ if( $module.attr('tabindex') === undefined) {
$module
.attr('tabindex', 0)
;
$menu
- .attr('tabindex', '-1')
+ .attr('tabindex', -1)
;
}
}
},
- scrollPosition: function($item) {
+ initialLoad: function() {
+ module.verbose('Setting initial load');
+ initialLoad = true;
+ },
+ activeItem: function($item) {
+ if( settings.allowAdditions && $item.filter(selector.addition).length > 0 ) {
+ $item.addClass(className.filtered);
+ }
+ else {
+ $item.addClass(className.active);
+ }
+ },
+ scrollPosition: function($item, forceScroll) {
var
- $item = $item || module.get.item(),
- hasActive = ($item && $item.size() > 0),
edgeTolerance = 5,
+ $menu,
+ hasActive,
offset,
itemHeight,
itemOffset,
@@ -3816,57 +6167,158 @@ $.fn.dropdown = function(parameters) {
abovePage,
belowPage
;
- if($item && hasActive) {
- menuHeight = $menu.height();
- itemHeight = $item.height();
+
+ $item = $item || module.get.selectedItem();
+ $menu = $item.closest(selector.menu);
+ hasActive = ($item && $item.length > 0);
+ forceScroll = (forceScroll !== undefined)
+ ? forceScroll
+ : false
+ ;
+ if($item && $menu.length > 0 && hasActive) {
+ itemOffset = $item.position().top;
+
+ $menu.addClass(className.loading);
menuScroll = $menu.scrollTop();
menuOffset = $menu.offset().top;
itemOffset = $item.offset().top;
offset = menuScroll - menuOffset + itemOffset;
- belowPage = menuScroll + menuHeight < (offset + edgeTolerance);
- abovePage = ((offset - edgeTolerance) < menuScroll);
- if(abovePage || belowPage) {
- module.debug('Scrolling to active item');
- $menu
- .scrollTop(offset)
- ;
+ if(!forceScroll) {
+ menuHeight = $menu.height();
+ belowPage = menuScroll + menuHeight < (offset + edgeTolerance);
+ abovePage = ((offset - edgeTolerance) < menuScroll);
}
+ module.debug('Scrolling to active item', offset);
+ if(forceScroll || abovePage || belowPage) {
+ $menu.scrollTop(offset);
+ }
+ $menu.removeClass(className.loading);
}
},
text: function(text) {
- if(settings.action == 'combo') {
- module.debug('Changing combo button text', text, $combo);
- if(settings.preserveHTML) {
- $combo.html(text);
+ if(settings.action !== 'select') {
+ if(settings.action == 'combo') {
+ module.debug('Changing combo button text', text, $combo);
+ if(settings.preserveHTML) {
+ $combo.html(text);
+ }
+ else {
+ $combo.text(text);
+ }
}
else {
- $combo.text(text);
+ if(text !== module.get.placeholderText()) {
+ $text.removeClass(className.placeholder);
+ }
+ module.debug('Changing text', text, $text);
+ $text
+ .removeClass(className.filtered)
+ ;
+ if(settings.preserveHTML) {
+ $text.html(text);
+ }
+ else {
+ $text.text(text);
+ }
}
}
- else if(settings.action !== 'select') {
- module.debug('Changing text', text, $text);
- $text
- .removeClass(className.filtered)
- .removeClass(className.placeholder)
+ },
+ selectedLetter: function(letter) {
+ var
+ $selectedItem = $item.filter('.' + className.selected),
+ alreadySelectedLetter = $selectedItem.length > 0 && module.has.firstLetter($selectedItem, letter),
+ $nextValue = false,
+ $nextItem
+ ;
+ // check next of same letter
+ if(alreadySelectedLetter) {
+ $nextItem = $selectedItem.nextAll($item).eq(0);
+ if( module.has.firstLetter($nextItem, letter) ) {
+ $nextValue = $nextItem;
+ }
+ }
+ // check all values
+ if(!$nextValue) {
+ $item
+ .each(function(){
+ if(module.has.firstLetter($(this), letter)) {
+ $nextValue = $(this);
+ return false;
+ }
+ })
;
- if(settings.preserveHTML) {
- $text.html(text);
+ }
+ // set next value
+ if($nextValue) {
+ module.verbose('Scrolling to next value with letter', letter);
+ module.set.scrollPosition($nextValue);
+ $selectedItem.removeClass(className.selected);
+ $nextValue.addClass(className.selected);
+ }
+ },
+ direction: function($menu) {
+ if(settings.direction == 'auto') {
+ if(module.is.onScreen($menu)) {
+ module.remove.upward($menu);
}
else {
- $text.text(text);
+ module.set.upward($menu);
}
}
+ else if(settings.direction == 'upward') {
+ module.set.upward($menu);
+ }
},
- value: function(value) {
- module.debug('Adding selected value to hidden input', value, $input);
- if($input.size() > 0) {
+ upward: function($menu) {
+ var $element = $menu || $module;
+ $element.addClass(className.upward);
+ },
+ value: function(value, text, $selected) {
+ var
+ hasInput = ($input.length > 0),
+ isAddition = !module.has.value(value),
+ currentValue = module.get.values(),
+ stringValue = (value !== undefined)
+ ? String(value)
+ : value,
+ newValue
+ ;
+ if(hasInput) {
+ if(stringValue == currentValue) {
+ module.verbose('Skipping value update already same value', value, currentValue);
+ if(!module.is.initialLoad()) {
+ return;
+ }
+ }
+
+ if( module.is.single() && module.has.selectInput() && module.can.extendSelect() ) {
+ module.debug('Adding user option', value);
+ module.add.optionValue(value);
+ }
+ module.debug('Updating input value', value, currentValue);
+ internalChange = true;
$input
.val(value)
- .trigger('change')
;
+ if(settings.fireOnInit === false && module.is.initialLoad()) {
+ module.debug('Input native change event ignored on initial load');
+ }
+ else {
+ module.trigger.change();
+ }
+ internalChange = false;
}
else {
- $module.data(metadata.value, value);
+ module.verbose('Storing value in metadata', value, $input);
+ if(value !== currentValue) {
+ $module.data(metadata.value, stringValue);
+ }
+ }
+ if(settings.fireOnInit === false && module.is.initialLoad()) {
+ module.verbose('No callback on initial load', settings.onChange);
+ }
+ else {
+ settings.onChange.call(element, value, text, $selected);
}
},
active: function() {
@@ -3874,31 +6326,274 @@ $.fn.dropdown = function(parameters) {
.addClass(className.active)
;
},
+ multiple: function() {
+ $module.addClass(className.multiple);
+ },
visible: function() {
$module.addClass(className.visible);
},
- selected: function(value) {
+ exactly: function(value, $selectedItem) {
+ module.debug('Setting selected to exact values');
+ module.clear();
+ module.set.selected(value, $selectedItem);
+ },
+ selected: function(value, $selectedItem) {
var
- $selectedItem = module.get.item(value),
- selectedText
+ isMultiple = module.is.multiple(),
+ $userSelectedItem
;
- if($selectedItem) {
- module.debug('Setting selected menu item to', $selectedItem);
- selectedText = ($selectedItem.data(metadata.text) !== undefined)
- ? $selectedItem.data(metadata.text)
- : (settings.preserveHTML)
- ? $selectedItem.html()
- : $selectedItem.text()
- ;
+ $selectedItem = (settings.allowAdditions)
+ ? $selectedItem || module.get.itemWithAdditions(value)
+ : $selectedItem || module.get.item(value)
+ ;
+ if(!$selectedItem) {
+ return;
+ }
+ module.debug('Setting selected menu item to', $selectedItem);
+ if(module.is.single()) {
module.remove.activeItem();
module.remove.selectedItem();
- $selectedItem
- .addClass(className.active)
+ }
+ else if(settings.useLabels) {
+ module.remove.selectedItem();
+ }
+ // select each item
+ $selectedItem
+ .each(function() {
+ var
+ $selected = $(this),
+ selectedText = module.get.choiceText($selected),
+ selectedValue = module.get.choiceValue($selected, selectedText),
+
+ isFiltered = $selected.hasClass(className.filtered),
+ isActive = $selected.hasClass(className.active),
+ isUserValue = $selected.hasClass(className.addition),
+ shouldAnimate = (isMultiple && $selectedItem.length == 1)
+ ;
+ if(isMultiple) {
+ if(!isActive || isUserValue) {
+ if(settings.apiSettings && settings.saveRemoteData) {
+ module.save.remoteData(selectedText, selectedValue);
+ }
+ if(settings.useLabels) {
+ module.add.value(selectedValue, selectedText, $selected);
+ module.add.label(selectedValue, selectedText, shouldAnimate);
+ module.set.activeItem($selected);
+ module.filterActive();
+ module.select.nextAvailable($selectedItem);
+ }
+ else {
+ module.add.value(selectedValue, selectedText, $selected);
+ module.set.text(module.add.variables(message.count));
+ module.set.activeItem($selected);
+ }
+ }
+ else if(!isFiltered) {
+ module.debug('Selected active value, removing label');
+ module.remove.selected(selectedValue);
+ }
+ }
+ else {
+ if(settings.apiSettings && settings.saveRemoteData) {
+ module.save.remoteData(selectedText, selectedValue);
+ }
+ module.set.text(selectedText);
+ module.set.value(selectedValue, selectedText, $selected);
+ $selected
+ .addClass(className.active)
+ .addClass(className.selected)
+ ;
+ }
+ })
+ ;
+ }
+ },
+
+ add: {
+ label: function(value, text, shouldAnimate) {
+ var
+ $next = module.is.searchSelection()
+ ? $search
+ : $text,
+ $label
+ ;
+ $label = $('<a />')
+ .addClass(className.label)
+ .attr('data-value', value)
+ .html(templates.label(value, text))
+ ;
+ $label = settings.onLabelCreate.call($label, value, text);
+
+ if(module.has.label(value)) {
+ module.debug('Label already exists, skipping', value);
+ return;
+ }
+ if(settings.label.variation) {
+ $label.addClass(settings.label.variation);
+ }
+ if(shouldAnimate === true) {
+ module.debug('Animating in label', $label);
+ $label
+ .addClass(className.hidden)
+ .insertBefore($next)
+ .transition(settings.label.transition, settings.label.duration)
+ ;
+ }
+ else {
+ module.debug('Adding selection label', $label);
+ $label
+ .insertBefore($next)
+ ;
+ }
+ },
+ message: function(message) {
+ var
+ $message = $menu.children(selector.message),
+ html = settings.templates.message(module.add.variables(message))
+ ;
+ if($message.length > 0) {
+ $message
+ .html(html)
+ ;
+ }
+ else {
+ $message = $('<div/>')
+ .html(html)
+ .addClass(className.message)
+ .appendTo($menu)
+ ;
+ }
+ },
+ optionValue: function(value) {
+ var
+ $option = $input.find('option[value="' + value + '"]'),
+ hasOption = ($option.length > 0)
+ ;
+ if(hasOption) {
+ return;
+ }
+ // temporarily disconnect observer
+ if(selectObserver) {
+ selectObserver.disconnect();
+ module.verbose('Temporarily disconnecting mutation observer', value);
+ }
+ if( module.is.single() ) {
+ module.verbose('Removing previous user addition');
+ $input.find('option.' + className.addition).remove();
+ }
+ $('<option/>')
+ .prop('value', value)
+ .addClass(className.addition)
+ .html(value)
+ .appendTo($input)
+ ;
+ module.verbose('Adding user addition as an <option>', value);
+ if(selectObserver) {
+ selectObserver.observe($input[0], {
+ childList : true,
+ subtree : true
+ });
+ }
+ },
+ userSuggestion: function(value) {
+ var
+ $addition = $menu.children(selector.addition),
+ $existingItem = module.get.item(value),
+ alreadyHasValue = $existingItem && $existingItem.not(selector.addition).length,
+ hasUserSuggestion = $addition.length > 0,
+ html
+ ;
+ if(settings.useLabels && module.has.maxSelections()) {
+ return;
+ }
+ if(value === '' || alreadyHasValue) {
+ $addition.remove();
+ return;
+ }
+ $item
+ .removeClass(className.selected)
+ ;
+ if(hasUserSuggestion) {
+ html = settings.templates.addition( module.add.variables(message.addResult, value) );
+ $addition
+ .html(html)
+ .attr('data-' + metadata.value, value)
+ .attr('data-' + metadata.text, value)
+ .removeClass(className.filtered)
.addClass(className.selected)
;
- module.set.text(selectedText);
- $.proxy(settings.onChange, element)(value, selectedText, $selectedItem);
+ module.verbose('Replacing user suggestion with new value', $addition);
+ }
+ else {
+ $addition = module.create.userChoice(value);
+ $addition
+ .prependTo($menu)
+ .addClass(className.selected)
+ ;
+ module.verbose('Adding item choice to menu corresponding with user choice addition', $addition);
+ }
+ },
+ variables: function(message, term) {
+ var
+ hasCount = (message.search('{count}') !== -1),
+ hasMaxCount = (message.search('{maxCount}') !== -1),
+ hasTerm = (message.search('{term}') !== -1),
+ values,
+ count,
+ query
+ ;
+ module.verbose('Adding templated variables to message', message);
+ if(hasCount) {
+ count = module.get.selectionCount();
+ message = message.replace('{count}', count);
+ }
+ if(hasMaxCount) {
+ count = module.get.selectionCount();
+ message = message.replace('{maxCount}', settings.maxSelections);
+ }
+ if(hasTerm) {
+ query = term || module.get.query();
+ message = message.replace('{term}', query);
+ }
+ return message;
+ },
+ value: function(addedValue, addedText, $selectedItem) {
+ var
+ currentValue = module.get.values(),
+ newValue
+ ;
+ if(addedValue === '') {
+ module.debug('Cannot select blank values from multiselect');
+ return;
+ }
+ // extend current array
+ if($.isArray(currentValue)) {
+ newValue = currentValue.concat([addedValue]);
+ newValue = module.get.uniqueArray(newValue);
+ }
+ else {
+ newValue = [addedValue];
}
+ // add values
+ if( module.has.selectInput() ) {
+ if(module.can.extendSelect()) {
+ module.debug('Adding value to select', addedValue, newValue, $input);
+ module.add.optionValue(addedValue);
+ }
+ }
+ else {
+ newValue = newValue.join(settings.delimiter);
+ module.debug('Setting hidden input to delimited value', newValue, $input);
+ }
+
+ if(settings.fireOnInit === false && module.is.initialLoad()) {
+ module.verbose('Skipping onadd callback on initial load', settings.onAdd);
+ }
+ else {
+ settings.onAdd.call(element, addedValue, addedText, $selectedItem);
+ }
+ module.set.value(newValue, addedValue, addedText, $selectedItem);
+ module.check.maxSelections();
}
},
@@ -3906,6 +6601,19 @@ $.fn.dropdown = function(parameters) {
active: function() {
$module.removeClass(className.active);
},
+ activeLabel: function() {
+ $module.find(selector.label).removeClass(className.active);
+ },
+ loading: function() {
+ $module.removeClass(className.loading);
+ },
+ initialLoad: function() {
+ initialLoad = false;
+ },
+ upward: function($menu) {
+ var $element = $menu || $module;
+ $element.removeClass(className.upward);
+ },
visible: function() {
$module.removeClass(className.visible);
},
@@ -3913,78 +6621,398 @@ $.fn.dropdown = function(parameters) {
$item.removeClass(className.active);
},
filteredItem: function() {
- $item.removeClass(className.filtered);
+ if(settings.useLabels && module.has.maxSelections() ) {
+ return;
+ }
+ if(settings.useLabels && module.is.multiple()) {
+ $item.not('.' + className.active).removeClass(className.filtered);
+ }
+ else {
+ $item.removeClass(className.filtered);
+ }
+ },
+ optionValue: function(value) {
+ var
+ $option = $input.find('option[value="' + value + '"]'),
+ hasOption = ($option.length > 0)
+ ;
+ if(!hasOption || !$option.hasClass(className.addition)) {
+ return;
+ }
+ // temporarily disconnect observer
+ if(selectObserver) {
+ selectObserver.disconnect();
+ module.verbose('Temporarily disconnecting mutation observer', value);
+ }
+ $option.remove();
+ module.verbose('Removing user addition as an <option>', value);
+ if(selectObserver) {
+ selectObserver.observe($input[0], {
+ childList : true,
+ subtree : true
+ });
+ }
+ },
+ message: function() {
+ $menu.children(selector.message).remove();
},
searchTerm: function() {
+ module.verbose('Cleared search term');
$search.val('');
+ module.set.filtered();
+ },
+ selected: function(value, $selectedItem) {
+ $selectedItem = (settings.allowAdditions)
+ ? $selectedItem || module.get.itemWithAdditions(value)
+ : $selectedItem || module.get.item(value)
+ ;
+
+ if(!$selectedItem) {
+ return false;
+ }
+
+ $selectedItem
+ .each(function() {
+ var
+ $selected = $(this),
+ selectedText = module.get.choiceText($selected),
+ selectedValue = module.get.choiceValue($selected, selectedText)
+ ;
+ if(module.is.multiple()) {
+ if(settings.useLabels) {
+ module.remove.value(selectedValue, selectedText, $selected);
+ module.remove.label(selectedValue);
+ }
+ else {
+ module.remove.value(selectedValue, selectedText, $selected);
+ if(module.get.selectionCount() === 0) {
+ module.set.placeholderText();
+ }
+ else {
+ module.set.text(module.add.variables(message.count));
+ }
+ }
+ }
+ else {
+ module.remove.value(selectedValue, selectedText, $selected);
+ }
+ $selected
+ .removeClass(className.filtered)
+ .removeClass(className.active)
+ ;
+ if(settings.useLabels) {
+ $selected.removeClass(className.selected);
+ }
+ })
+ ;
},
selectedItem: function() {
$item.removeClass(className.selected);
},
+ value: function(removedValue, removedText, $removedItem) {
+ var
+ values = module.get.values(),
+ newValue
+ ;
+ if( module.has.selectInput() ) {
+ module.verbose('Input is <select> removing selected option', removedValue);
+ newValue = module.remove.arrayValue(removedValue, values);
+ module.remove.optionValue(removedValue);
+ }
+ else {
+ module.verbose('Removing from delimited values', removedValue);
+ newValue = module.remove.arrayValue(removedValue, values);
+ newValue = newValue.join(settings.delimiter);
+ }
+ if(settings.fireOnInit === false && module.is.initialLoad()) {
+ module.verbose('No callback on initial load', settings.onRemove);
+ }
+ else {
+ settings.onRemove.call(element, removedValue, removedText, $removedItem);
+ }
+ module.set.value(newValue, removedText, $removedItem);
+ module.check.maxSelections();
+ },
+ arrayValue: function(removedValue, values) {
+ if( !$.isArray(values) ) {
+ values = [values];
+ }
+ values = $.grep(values, function(value){
+ return (removedValue != value);
+ });
+ module.verbose('Removed value from delimited string', removedValue, values);
+ return values;
+ },
+ label: function(value, shouldAnimate) {
+ var
+ $labels = $module.find(selector.label),
+ $removedLabel = $labels.filter('[data-value="' + value +'"]')
+ ;
+ module.verbose('Removing label', $removedLabel);
+ $removedLabel.remove();
+ },
+ activeLabels: function($activeLabels) {
+ $activeLabels = $activeLabels || $module.find(selector.label).filter('.' + className.active);
+ module.verbose('Removing active label selections', $activeLabels);
+ module.remove.labels($activeLabels);
+ },
+ labels: function($labels) {
+ $labels = $labels || $module.find(selector.label);
+ module.verbose('Removing labels', $labels);
+ $labels
+ .each(function(){
+ var
+ $label = $(this),
+ value = $label.data(metadata.value),
+ stringValue = (value !== undefined)
+ ? String(value)
+ : value,
+ isUserValue = module.is.userValue(stringValue)
+ ;
+ if(settings.onLabelRemove.call($label, value) === false) {
+ module.debug('Label remove callback cancelled removal');
+ return;
+ }
+ if(isUserValue) {
+ module.remove.value(stringValue);
+ module.remove.label(stringValue);
+ }
+ else {
+ // selected will also remove label
+ module.remove.selected(stringValue);
+ }
+ })
+ ;
+ },
tabbable: function() {
- if( module.is.searchable() ) {
+ if( module.has.search() ) {
module.debug('Searchable dropdown initialized');
$search
- .attr('tabindex', '-1')
+ .removeAttr('tabindex')
;
$menu
- .attr('tabindex', '-1')
+ .removeAttr('tabindex')
;
}
else {
module.debug('Simple selection dropdown initialized');
$module
- .attr('tabindex', '-1')
+ .removeAttr('tabindex')
;
$menu
- .attr('tabindex', '-1')
+ .removeAttr('tabindex')
;
}
}
},
- is: {
+ has: {
search: function() {
- return $module.hasClass(className.search);
+ return ($search.length > 0);
},
- searchable: function() {
- return ($search.size() > 0);
+ selectInput: function() {
+ return ( $input.is('select') );
},
- searchSelection: function() {
- return ( module.is.searchable() && $search.parent().is($module) );
+ firstLetter: function($item, letter) {
+ var
+ text,
+ firstLetter
+ ;
+ if(!$item || $item.length === 0 || typeof letter !== 'string') {
+ return false;
+ }
+ text = module.get.choiceText($item, false);
+ letter = letter.toLowerCase();
+ firstLetter = String(text).charAt(0).toLowerCase();
+ return (letter == firstLetter);
},
- selection: function() {
- return $module.hasClass(className.selection);
+ input: function() {
+ return ($input.length > 0);
},
- animating: function($subMenu) {
- return ($subMenu)
- ? $subMenu.is(':animated') || $subMenu.transition && $subMenu.transition('is animating')
- : $menu.is(':animated') || $menu.transition && $menu.transition('is animating')
+ items: function() {
+ return ($item.length > 0);
+ },
+ menu: function() {
+ return ($menu.length > 0);
+ },
+ message: function() {
+ return ($menu.children(selector.message).length !== 0);
+ },
+ label: function(value) {
+ var
+ $labels = $module.find(selector.label)
;
+ return ($labels.filter('[data-value="' + value +'"]').length > 0);
},
+ maxSelections: function() {
+ return (settings.maxSelections && module.get.selectionCount() >= settings.maxSelections);
+ },
+ allResultsFiltered: function() {
+ return ($item.filter(selector.unselectable).length === $item.length);
+ },
+ query: function() {
+ return (module.get.query() !== '');
+ },
+ value: function(value) {
+ var
+ values = module.get.values(),
+ hasValue = $.isArray(values)
+ ? values && ($.inArray(value, values) !== -1)
+ : (values == value)
+ ;
+ return (hasValue)
+ ? true
+ : false
+ ;
+ }
+ },
+
+ is: {
active: function() {
return $module.hasClass(className.active);
},
- visible: function($subMenu) {
+ alreadySetup: function() {
+ return ($module.is('select') && $module.parent(selector.dropdown).length > 0 && $module.prev().length === 0);
+ },
+ animating: function($subMenu) {
return ($subMenu)
- ? $subMenu.is(':visible')
- : $menu.is(':visible')
+ ? $subMenu.transition && $subMenu.transition('is animating')
+ : $menu.transition && $menu.transition('is animating')
;
},
+ disabled: function() {
+ return $module.hasClass(className.disabled);
+ },
+ focused: function() {
+ return (document.activeElement === $module[0]);
+ },
+ focusedOnSearch: function() {
+ return (document.activeElement === $search[0]);
+ },
+ allFiltered: function() {
+ return( (module.is.multiple() || module.has.search()) && !module.has.message() && module.has.allResultsFiltered() );
+ },
hidden: function($subMenu) {
+ return !module.is.visible($subMenu);
+ },
+ initialLoad: function() {
+ return initialLoad;
+ },
+ onScreen: function($subMenu) {
+ var
+ $currentMenu = $subMenu || $menu,
+ canOpenDownward = true,
+ onScreen = {},
+ calculations
+ ;
+ $currentMenu.addClass(className.loading);
+ calculations = {
+ context: {
+ scrollTop : $context.scrollTop(),
+ height : $context.outerHeight()
+ },
+ menu : {
+ offset: $currentMenu.offset(),
+ height: $currentMenu.outerHeight()
+ }
+ };
+ onScreen = {
+ above : (calculations.context.scrollTop) <= calculations.menu.offset.top - calculations.menu.height,
+ below : (calculations.context.scrollTop + calculations.context.height) >= calculations.menu.offset.top + calculations.menu.height
+ };
+ if(onScreen.below) {
+ module.verbose('Dropdown can fit in context downward', onScreen);
+ canOpenDownward = true;
+ }
+ else if(!onScreen.below && !onScreen.above) {
+ module.verbose('Dropdown cannot fit in either direction, favoring downward', onScreen);
+ canOpenDownward = true;
+ }
+ else {
+ module.verbose('Dropdown cannot fit below, opening upward', onScreen);
+ canOpenDownward = false;
+ }
+ $currentMenu.removeClass(className.loading);
+ return canOpenDownward;
+ },
+ inObject: function(needle, object) {
+ var
+ found = false
+ ;
+ $.each(object, function(index, property) {
+ if(property == needle) {
+ found = true;
+ return true;
+ }
+ });
+ return found;
+ },
+ multiple: function() {
+ return $module.hasClass(className.multiple);
+ },
+ single: function() {
+ return !module.is.multiple();
+ },
+ selectMutation: function(mutations) {
+ var
+ selectChanged = false
+ ;
+ $.each(mutations, function(index, mutation) {
+ if(mutation.target && $(mutation.target).is('select')) {
+ selectChanged = true;
+ return true;
+ }
+ });
+ return selectChanged;
+ },
+ search: function() {
+ return $module.hasClass(className.search);
+ },
+ searchSelection: function() {
+ return ( module.has.search() && $search.parent(selector.dropdown).length === 1 );
+ },
+ selection: function() {
+ return $module.hasClass(className.selection);
+ },
+ userValue: function(value) {
+ return ($.inArray(value, module.get.userValues()) !== -1);
+ },
+ upward: function($menu) {
+ var $element = $menu || $module;
+ return $element.hasClass(className.upward);
+ },
+ visible: function($subMenu) {
return ($subMenu)
- ? $subMenu.is(':hidden')
- : $menu.is(':hidden')
+ ? $subMenu.hasClass(className.visible)
+ : $menu.hasClass(className.visible)
;
}
},
can: {
+ activate: function($item) {
+ if(settings.useLabels) {
+ return true;
+ }
+ if(!module.has.maxSelections()) {
+ return true;
+ }
+ if(module.has.maxSelections() && $item.hasClass(className.active)) {
+ return true;
+ }
+ return false;
+ },
click: function() {
return (hasTouch || settings.on == 'click');
},
+ extendSelect: function() {
+ return settings.allowAdditions || settings.apiSettings;
+ },
show: function() {
- return !$module.hasClass(className.disabled);
+ return !module.is.disabled() && (module.has.items() || module.has.message());
+ },
+ useAPI: function() {
+ return $.fn.api !== undefined;
}
},
@@ -3998,62 +7026,42 @@ $.fn.dropdown = function(parameters) {
module.hideSubMenus();
module.hideOthers();
module.set.active();
- module.set.scrollPosition();
- }
+ },
+ transition
+ ;
+ callback = $.isFunction(callback)
+ ? callback
+ : function(){}
;
- callback = callback || function(){};
module.verbose('Doing menu show animation', $currentMenu);
+ module.set.direction($subMenu);
+ transition = module.get.transition($subMenu);
+ if( module.is.selection() ) {
+ module.set.scrollPosition(module.get.selectedItem(), true);
+ }
if( module.is.hidden($currentMenu) || module.is.animating($currentMenu) ) {
- if(settings.transition == 'none') {
- $.proxy(callback, element)();
+ if(transition == 'none') {
+ start();
+ $currentMenu.transition('show');
+ callback.call(element);
}
else if($.fn.transition !== undefined && $module.transition('is supported')) {
$currentMenu
.transition({
- animation : settings.transition + ' in',
+ animation : transition + ' in',
debug : settings.debug,
verbose : settings.verbose,
duration : settings.duration,
queue : true,
onStart : start,
onComplete : function() {
- $.proxy(callback, element)();
+ callback.call(element);
}
})
;
}
- else if(settings.transition == 'slide down') {
- start();
- $currentMenu
- .hide()
- .clearQueue()
- .children()
- .clearQueue()
- .css('opacity', 0)
- .delay(50)
- .animate({
- opacity : 1
- }, settings.duration, 'easeOutQuad', module.event.resetStyle)
- .end()
- .slideDown(100, 'easeOutQuad', function() {
- $.proxy(module.event.resetStyle, this)();
- $.proxy(callback, element)();
- })
- ;
- }
- else if(settings.transition == 'fade') {
- start();
- $currentMenu
- .hide()
- .clearQueue()
- .fadeIn(settings.duration, function() {
- $.proxy(module.event.resetStyle, this)();
- $.proxy(callback, element)();
- })
- ;
- }
else {
- module.error(error.transition, settings.transition);
+ module.error(error.noTransition, transition);
}
}
},
@@ -4069,62 +7077,40 @@ $.fn.dropdown = function(parameters) {
if( module.can.click() ) {
module.unbind.intent();
}
- module.focusSearch();
module.remove.active();
- }
+ },
+ transition = module.get.transition($subMenu)
+ ;
+ callback = $.isFunction(callback)
+ ? callback
+ : function(){}
;
- callback = callback || function(){};
if( module.is.visible($currentMenu) || module.is.animating($currentMenu) ) {
module.verbose('Doing menu hide animation', $currentMenu);
- if(settings.transition == 'none') {
- $.proxy(callback, element)();
+ if(transition == 'none') {
+ start();
+ $currentMenu.transition('hide');
+ callback.call(element);
}
else if($.fn.transition !== undefined && $module.transition('is supported')) {
$currentMenu
.transition({
- animation : settings.transition + ' out',
+ animation : transition + ' out',
duration : settings.duration,
debug : settings.debug,
verbose : settings.verbose,
queue : true,
onStart : start,
onComplete : function() {
- $.proxy(callback, element)();
+ if(settings.direction == 'auto') {
+ module.remove.upward($subMenu);
+ }
+ callback.call(element);
}
})
;
}
- else if(settings.transition == 'slide down') {
- start();
- $currentMenu
- .show()
- .clearQueue()
- .children()
- .clearQueue()
- .css('opacity', 1)
- .animate({
- opacity : 0
- }, 100, 'easeOutQuad', module.event.resetStyle)
- .end()
- .delay(50)
- .slideUp(100, 'easeOutQuad', function() {
- $.proxy(module.event.resetStyle, this)();
- $.proxy(callback, element)();
- })
- ;
- }
- else if(settings.transition == 'fade') {
- start();
- $currentMenu
- .show()
- .clearQueue()
- .fadeOut(150, function() {
- $.proxy(module.event.resetStyle, this)();
- $.proxy(callback, element)();
- })
- ;
- }
else {
module.error(error.transition);
}
@@ -4132,6 +7118,21 @@ $.fn.dropdown = function(parameters) {
}
},
+ hideAndClear: function() {
+ module.remove.searchTerm();
+ if( module.has.maxSelections() ) {
+ return;
+ }
+ if(module.has.search()) {
+ module.hide(function() {
+ module.remove.filteredItem();
+ });
+ }
+ else {
+ module.hide();
+ }
+ },
+
delay: {
show: function() {
module.verbose('Delaying show event to ensure user intent');
@@ -4145,6 +7146,13 @@ $.fn.dropdown = function(parameters) {
}
},
+ escape: {
+ regExp: function(text) {
+ text = String(text);
+ return text.replace(regExp.escape, '\\$&');
+ }
+ },
+
setting: function(name, value) {
module.debug('Changing setting', name, value);
if( $.isPlainObject(name) ) {
@@ -4214,7 +7222,7 @@ $.fn.dropdown = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -4309,85 +7317,181 @@ $.fn.dropdown = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
})
;
-
return (returnedValue !== undefined)
? returnedValue
- : this
+ : $allModules
;
};
$.fn.dropdown.settings = {
- debug : false,
- verbose : true,
- performance : true,
+ debug : false,
+ verbose : false,
+ performance : true,
+
+ on : 'click', // what event should show menu action on item selection
+ action : 'activate', // action on item selection (nothing, activate, select, combo, hide, function(){})
+
- on : 'click',
- action : 'activate',
+ apiSettings : false,
+ saveRemoteData : true, // Whether remote name/value pairs should be stored in sessionStorage to allow remote data to be restored on page refresh
+ throttle : 200, // How long to wait after last user input to search remotely
- allowTab : true,
- fullTextSearch : true,
- preserveHTML : true,
+ context : window, // Context to use when determining if on screen
+ direction : 'auto', // Whether dropdown should always open in one direction
+ keepOnScreen : true, // Whether dropdown should check whether it is on screen before showing
- delay : {
- show : 200,
- hide : 300,
- touch : 50
+ match : 'both', // what to match against with search selection (both, text, or label)
+ fullTextSearch : false, // search anywhere in value
+
+ placeholder : 'auto', // whether to convert blank <select> values to placeholder text
+ preserveHTML : true, // preserve html when selecting value
+ sortSelect : false, // sort selection on init
+
+ forceSelection : true, // force a choice on blur with search selection
+ allowAdditions : false, // whether multiple select should allow user added values
+
+ maxSelections : false, // When set to a number limits the number of selections to this count
+ useLabels : true, // whether multiple select should filter currently active selections from choices
+ delimiter : ',', // when multiselect uses normal <input> the values will be delimited with this character
+
+ showOnFocus : true, // show menu on focus
+ allowTab : true, // add tabindex to element
+ allowCategorySelection : false, // allow elements with sub-menus to be selected
+
+ fireOnInit : false, // Whether callbacks should fire when initializing dropdown values
+
+ transition : 'auto', // auto transition will slide down or up based on direction
+ duration : 200, // duration of transition
+
+ glyphWidth : 1.0714, // widest glyph width in em (W is 1.0714 em) used to calculate multiselect input width
+
+ // label settings on multi-select
+ label: {
+ transition : 'scale',
+ duration : 200,
+ variation : false
},
- transition : 'slide down',
- duration : 250,
+ // delay before event
+ delay : {
+ hide : 300,
+ show : 200,
+ search : 20,
+ touch : 50
+ },
/* Callbacks */
-
- onChange : function(value, text){},
- onShow : function(){},
- onHide : function(){},
+ onChange : function(value, text, $selected){},
+ onAdd : function(value, text, $selected){},
+ onRemove : function(value, text, $selected){},
+
+ onLabelSelect : function($selectedLabels){},
+ onLabelCreate : function(value, text) { return $(this); },
+ onLabelRemove : function(value) { return true; },
+ onNoResults : function(searchTerm) { return true; },
+ onShow : function(){},
+ onHide : function(){},
/* Component */
-
name : 'Dropdown',
namespace : 'dropdown',
- error : {
- action : 'You called a dropdown action that was not defined',
- method : 'The method you called is not defined.',
- transition : 'The requested transition was not found'
+ message: {
+ addResult : 'Add <b>{term}</b>',
+ count : '{count} selected',
+ maxSelections : 'Max {maxCount} selections',
+ noResults : 'No results found.',
+ serverError : 'There was an error contacting the server'
},
- metadata: {
- defaultText : 'defaultText',
- defaultValue : 'defaultValue',
- text : 'text',
- value : 'value'
+ error : {
+ action : 'You called a dropdown action that was not defined',
+ alreadySetup : 'Once a select has been initialized behaviors must be called on the created ui dropdown',
+ labels : 'Allowing user additions currently requires the use of labels.',
+ missingMultiple : '<select> requires multiple property to be set to correctly preserve multiple values',
+ method : 'The method you called is not defined.',
+ noAPI : 'The API module is required to load resources remotely',
+ noStorage : 'Saving remote data requires session storage',
+ noTransition : 'This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>'
+ },
+
+ regExp : {
+ escape : /[-[\]{}()*+?.,\\^$|#\s]/g,
+ },
+
+ metadata : {
+ defaultText : 'defaultText',
+ defaultValue : 'defaultValue',
+ placeholderText : 'placeholder',
+ text : 'text',
+ value : 'value'
+ },
+
+ // property names for remote query
+ fields: {
+ remoteValues : 'results', // grouping for api results
+ values : 'values', // grouping for all dropdown values
+ name : 'name', // displayed dropdown text
+ value : 'value' // actual dropdown value
+ },
+
+ keys : {
+ backspace : 8,
+ delimiter : 188, // comma
+ deleteKey : 46,
+ enter : 13,
+ escape : 27,
+ pageUp : 33,
+ pageDown : 34,
+ leftArrow : 37,
+ upArrow : 38,
+ rightArrow : 39,
+ downArrow : 40
},
selector : {
- dropdown : '.ui.dropdown',
- text : '> .text:not(.icon)',
- input : '> input[type="hidden"], > select',
- search : '> input.search, .menu > .search > input, .menu > input.search',
- menu : '.menu',
- item : '.item'
+ addition : '.addition',
+ dropdown : '.ui.dropdown',
+ icon : '> .dropdown.icon',
+ input : '> input[type="hidden"], > select',
+ item : '.item',
+ label : '> .label',
+ remove : '> .label > .delete.icon',
+ siblingLabel : '.label',
+ menu : '.menu',
+ message : '.message',
+ menuIcon : '.dropdown.icon',
+ search : 'input.search, .menu > .search > input',
+ text : '> .text:not(.icon)',
+ unselectable : '.disabled, .filtered'
},
className : {
active : 'active',
+ addition : 'addition',
animating : 'animating',
disabled : 'disabled',
dropdown : 'ui dropdown',
filtered : 'filtered',
+ hidden : 'hidden transition',
+ item : 'item',
+ label : 'ui label',
+ loading : 'loading',
menu : 'menu',
+ message : 'message',
+ multiple : 'multiple',
placeholder : 'default',
search : 'search',
selected : 'selected',
selection : 'selection',
+ upward : 'upward',
visible : 'visible'
}
@@ -4395,17 +7499,8 @@ $.fn.dropdown.settings = {
/* Templates */
$.fn.dropdown.settings.templates = {
- menu: function(select) {
- var
- placeholder = select.placeholder || false,
- values = select.values || {},
- html = ''
- ;
- $.each(select.values, function(value, name) {
- html += '<div class="item" data-value="' + value + '">' + name + '</div>';
- });
- return html;
- },
+
+ // generates dropdown from select values
dropdown: function(select) {
var
placeholder = select.placeholder || false,
@@ -4420,30 +7515,714 @@ $.fn.dropdown.settings.templates = {
html += '<div class="text"></div>';
}
html += '<div class="menu">';
- $.each(select.values, function(value, name) {
- html += '<div class="item" data-value="' + value + '">' + name + '</div>';
+ $.each(select.values, function(index, option) {
+ html += (option.disabled)
+ ? '<div class="disabled item" data-value="' + option.value + '">' + option.name + '</div>'
+ : '<div class="item" data-value="' + option.value + '">' + option.name + '</div>'
+ ;
});
html += '</div>';
return html;
+ },
+
+ // generates just menu from select
+ menu: function(response, fields) {
+ var
+ values = response[fields.values] || {},
+ html = ''
+ ;
+ $.each(values, function(index, option) {
+ html += '<div class="item" data-value="' + option[fields.value] + '">' + option[fields.name] + '</div>';
+ });
+ return html;
+ },
+
+ // generates label for multiselect
+ label: function(value, text) {
+ return text + '<i class="delete icon"></i>';
+ },
+
+
+ // generates messages like "No results"
+ message: function(message) {
+ return message;
+ },
+
+ // generates user addition to selection menu
+ addition: function(choice) {
+ return choice;
}
+
};
+})( jQuery, window, document );
-/* Dependencies */
-$.extend( $.easing, {
- easeOutQuad: function (x, t, b, c, d) {
- return -c *(t/=d)*(t-2) + b;
+/*!
+ * # Semantic UI 2.1.6 - Video
+ * http://github.com/semantic-org/semantic-ui/
+ *
+ *
+ * Copyright 2015 Contributors
+ * Released under the MIT license
+ * http://opensource.org/licenses/MIT
+ *
+ */
+
+;(function ($, window, document, undefined) {
+
+"use strict";
+
+$.fn.embed = function(parameters) {
+
+ var
+ $allModules = $(this),
+
+ moduleSelector = $allModules.selector || '',
+
+ time = new Date().getTime(),
+ performance = [],
+
+ query = arguments[0],
+ methodInvoked = (typeof query == 'string'),
+ queryArguments = [].slice.call(arguments, 1),
+
+ returnedValue
+ ;
+
+ $allModules
+ .each(function() {
+ var
+ settings = ( $.isPlainObject(parameters) )
+ ? $.extend(true, {}, $.fn.embed.settings, parameters)
+ : $.extend({}, $.fn.embed.settings),
+
+ selector = settings.selector,
+ className = settings.className,
+ sources = settings.sources,
+ error = settings.error,
+ metadata = settings.metadata,
+ namespace = settings.namespace,
+ templates = settings.templates,
+
+ eventNamespace = '.' + namespace,
+ moduleNamespace = 'module-' + namespace,
+
+ $window = $(window),
+ $module = $(this),
+ $placeholder = $module.find(selector.placeholder),
+ $icon = $module.find(selector.icon),
+ $embed = $module.find(selector.embed),
+
+ element = this,
+ instance = $module.data(moduleNamespace),
+ module
+ ;
+
+ module = {
+
+ initialize: function() {
+ module.debug('Initializing embed');
+ module.determine.autoplay();
+ module.create();
+ module.bind.events();
+ module.instantiate();
+ },
+
+ instantiate: function() {
+ module.verbose('Storing instance of module', module);
+ instance = module;
+ $module
+ .data(moduleNamespace, module)
+ ;
+ },
+
+ destroy: function() {
+ module.verbose('Destroying previous instance of embed');
+ module.reset();
+ $module
+ .removeData(moduleNamespace)
+ .off(eventNamespace)
+ ;
+ },
+
+ refresh: function() {
+ module.verbose('Refreshing selector cache');
+ $placeholder = $module.find(selector.placeholder);
+ $icon = $module.find(selector.icon);
+ $embed = $module.find(selector.embed);
+ },
+
+ bind: {
+ events: function() {
+ if( module.has.placeholder() ) {
+ module.debug('Adding placeholder events');
+ $module
+ .on('click' + eventNamespace, selector.placeholder, module.createAndShow)
+ .on('click' + eventNamespace, selector.icon, module.createAndShow)
+ ;
+ }
+ }
+ },
+
+ create: function() {
+ var
+ placeholder = module.get.placeholder()
+ ;
+ if(placeholder) {
+ module.createPlaceholder();
+ }
+ else {
+ module.createAndShow();
+ }
+ },
+
+ createPlaceholder: function(placeholder) {
+ var
+ icon = module.get.icon(),
+ url = module.get.url(),
+ embed = module.generate.embed(url)
+ ;
+ placeholder = placeholder || module.get.placeholder();
+ $module.html( templates.placeholder(placeholder, icon) );
+ module.debug('Creating placeholder for embed', placeholder, icon);
+ },
+
+ createEmbed: function(url) {
+ module.refresh();
+ url = url || module.get.url();
+ $embed = $('<div/>')
+ .addClass(className.embed)
+ .html( module.generate.embed(url) )
+ .appendTo($module)
+ ;
+ settings.onCreate.call(element, url);
+ module.debug('Creating embed object', $embed);
+ },
+
+ createAndShow: function() {
+ module.createEmbed();
+ module.show();
+ },
+
+ // sets new embed
+ change: function(source, id, url) {
+ module.debug('Changing video to ', source, id, url);
+ $module
+ .data(metadata.source, source)
+ .data(metadata.id, id)
+ .data(metadata.url, url)
+ ;
+ module.create();
+ },
+
+ // clears embed
+ reset: function() {
+ module.debug('Clearing embed and showing placeholder');
+ module.remove.active();
+ module.remove.embed();
+ module.showPlaceholder();
+ settings.onReset.call(element);
+ },
+
+ // shows current embed
+ show: function() {
+ module.debug('Showing embed');
+ module.set.active();
+ settings.onDisplay.call(element);
+ },
+
+ hide: function() {
+ module.debug('Hiding embed');
+ module.showPlaceholder();
+ },
+
+ showPlaceholder: function() {
+ module.debug('Showing placeholder image');
+ module.remove.active();
+ settings.onPlaceholderDisplay.call(element);
+ },
+
+ get: {
+ id: function() {
+ return settings.id || $module.data(metadata.id);
+ },
+ placeholder: function() {
+ return settings.placeholder || $module.data(metadata.placeholder);
+ },
+ icon: function() {
+ return (settings.icon)
+ ? settings.icon
+ : ($module.data(metadata.icon) !== undefined)
+ ? $module.data(metadata.icon)
+ : module.determine.icon()
+ ;
+ },
+ source: function(url) {
+ return (settings.source)
+ ? settings.source
+ : ($module.data(metadata.source) !== undefined)
+ ? $module.data(metadata.source)
+ : module.determine.source()
+ ;
+ },
+ type: function() {
+ var source = module.get.source();
+ return (sources[source] !== undefined)
+ ? sources[source].type
+ : false
+ ;
+ },
+ url: function() {
+ return (settings.url)
+ ? settings.url
+ : ($module.data(metadata.url) !== undefined)
+ ? $module.data(metadata.url)
+ : module.determine.url()
+ ;
+ }
+ },
+
+ determine: {
+ autoplay: function() {
+ if(module.should.autoplay()) {
+ settings.autoplay = true;
+ }
+ },
+ source: function(url) {
+ var
+ matchedSource = false
+ ;
+ url = url || module.get.url();
+ if(url) {
+ $.each(sources, function(name, source) {
+ if(url.search(source.domain) !== -1) {
+ matchedSource = name;
+ return false;
+ }
+ });
+ }
+ return matchedSource;
+ },
+ icon: function() {
+ var
+ source = module.get.source()
+ ;
+ return (sources[source] !== undefined)
+ ? sources[source].icon
+ : false
+ ;
+ },
+ url: function() {
+ var
+ id = settings.id || $module.data(metadata.id),
+ source = settings.source || $module.data(metadata.source),
+ url
+ ;
+ url = (sources[source] !== undefined)
+ ? sources[source].url.replace('{id}', id)
+ : false
+ ;
+ if(url) {
+ $module.data(metadata.url, url);
+ }
+ return url;
+ }
+ },
+
+
+ set: {
+ active: function() {
+ $module.addClass(className.active);
+ }
+ },
+
+ remove: {
+ active: function() {
+ $module.removeClass(className.active);
+ },
+ embed: function() {
+ $embed.empty();
+ }
+ },
+
+ encode: {
+ parameters: function(parameters) {
+ var
+ urlString = [],
+ index
+ ;
+ for (index in parameters) {
+ urlString.push( encodeURIComponent(index) + '=' + encodeURIComponent( parameters[index] ) );
+ }
+ return urlString.join('&amp;');
+ }
+ },
+
+ generate: {
+ embed: function(url) {
+ module.debug('Generating embed html');
+ var
+ source = module.get.source(),
+ html,
+ parameters
+ ;
+ url = module.get.url(url);
+ if(url) {
+ parameters = module.generate.parameters(source);
+ html = templates.iframe(url, parameters);
+ }
+ else {
+ module.error(error.noURL, $module);
+ }
+ return html;
+ },
+ parameters: function(source, extraParameters) {
+ var
+ parameters = (sources[source] && sources[source].parameters !== undefined)
+ ? sources[source].parameters(settings)
+ : {}
+ ;
+ extraParameters = extraParameters || settings.parameters;
+ if(extraParameters) {
+ parameters = $.extend({}, parameters, extraParameters);
+ }
+ parameters = settings.onEmbed(parameters);
+ return module.encode.parameters(parameters);
+ }
+ },
+
+ has: {
+ placeholder: function() {
+ return settings.placeholder || $module.data(metadata.placeholder);
+ }
+ },
+
+ should: {
+ autoplay: function() {
+ return (settings.autoplay === 'auto')
+ ? (settings.placeholder || $module.data(metadata.placeholder) !== undefined)
+ : settings.autoplay
+ ;
+ }
+ },
+
+ is: {
+ video: function() {
+ return module.get.type() == 'video';
+ }
+ },
+
+ setting: function(name, value) {
+ module.debug('Changing setting', name, value);
+ if( $.isPlainObject(name) ) {
+ $.extend(true, settings, name);
+ }
+ else if(value !== undefined) {
+ settings[name] = value;
+ }
+ else {
+ return settings[name];
+ }
+ },
+ internal: function(name, value) {
+ if( $.isPlainObject(name) ) {
+ $.extend(true, module, name);
+ }
+ else if(value !== undefined) {
+ module[name] = value;
+ }
+ else {
+ return module[name];
+ }
+ },
+ debug: function() {
+ if(settings.debug) {
+ if(settings.performance) {
+ module.performance.log(arguments);
+ }
+ else {
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
+ module.debug.apply(console, arguments);
+ }
+ }
+ },
+ verbose: function() {
+ if(settings.verbose && settings.debug) {
+ if(settings.performance) {
+ module.performance.log(arguments);
+ }
+ else {
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
+ module.verbose.apply(console, arguments);
+ }
+ }
+ },
+ error: function() {
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
+ module.error.apply(console, arguments);
+ },
+ performance: {
+ log: function(message) {
+ var
+ currentTime,
+ executionTime,
+ previousTime
+ ;
+ if(settings.performance) {
+ currentTime = new Date().getTime();
+ previousTime = time || currentTime;
+ executionTime = currentTime - previousTime;
+ time = currentTime;
+ performance.push({
+ 'Name' : message[0],
+ 'Arguments' : [].slice.call(message, 1) || '',
+ 'Element' : element,
+ 'Execution Time' : executionTime
+ });
+ }
+ clearTimeout(module.performance.timer);
+ module.performance.timer = setTimeout(module.performance.display, 500);
+ },
+ display: function() {
+ var
+ title = settings.name + ':',
+ totalTime = 0
+ ;
+ time = false;
+ clearTimeout(module.performance.timer);
+ $.each(performance, function(index, data) {
+ totalTime += data['Execution Time'];
+ });
+ title += ' ' + totalTime + 'ms';
+ if(moduleSelector) {
+ title += ' \'' + moduleSelector + '\'';
+ }
+ if($allModules.length > 1) {
+ title += ' ' + '(' + $allModules.length + ')';
+ }
+ if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
+ console.groupCollapsed(title);
+ if(console.table) {
+ console.table(performance);
+ }
+ else {
+ $.each(performance, function(index, data) {
+ console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
+ });
+ }
+ console.groupEnd();
+ }
+ performance = [];
+ }
+ },
+ invoke: function(query, passedArguments, context) {
+ var
+ object = instance,
+ maxDepth,
+ found,
+ response
+ ;
+ passedArguments = passedArguments || queryArguments;
+ context = element || context;
+ if(typeof query == 'string' && object !== undefined) {
+ query = query.split(/[\. ]/);
+ maxDepth = query.length - 1;
+ $.each(query, function(depth, value) {
+ var camelCaseValue = (depth != maxDepth)
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
+ : query
+ ;
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
+ object = object[camelCaseValue];
+ }
+ else if( object[camelCaseValue] !== undefined ) {
+ found = object[camelCaseValue];
+ return false;
+ }
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
+ object = object[value];
+ }
+ else if( object[value] !== undefined ) {
+ found = object[value];
+ return false;
+ }
+ else {
+ module.error(error.method, query);
+ return false;
+ }
+ });
+ }
+ if ( $.isFunction( found ) ) {
+ response = found.apply(context, passedArguments);
+ }
+ else if(found !== undefined) {
+ response = found;
+ }
+ if($.isArray(returnedValue)) {
+ returnedValue.push(response);
+ }
+ else if(returnedValue !== undefined) {
+ returnedValue = [returnedValue, response];
+ }
+ else if(response !== undefined) {
+ returnedValue = response;
+ }
+ return found;
+ }
+ };
+
+ if(methodInvoked) {
+ if(instance === undefined) {
+ module.initialize();
+ }
+ module.invoke(query);
+ }
+ else {
+ if(instance !== undefined) {
+ instance.invoke('destroy');
+ }
+ module.initialize();
+ }
+ })
+ ;
+ return (returnedValue !== undefined)
+ ? returnedValue
+ : this
+ ;
+};
+
+$.fn.embed.settings = {
+
+ name : 'Embed',
+ namespace : 'embed',
+
+ debug : false,
+ verbose : false,
+ performance : true,
+
+ icon : false,
+ source : false,
+ url : false,
+ id : false,
+
+ // standard video settings
+ autoplay : 'auto',
+ color : '#444444',
+ hd : true,
+ brandedUI : false,
+
+ // additional parameters to include with the embed
+ parameters: false,
+
+ onDisplay : function() {},
+ onPlaceholderDisplay : function() {},
+ onReset : function() {},
+ onCreate : function(url) {},
+ onEmbed : function(parameters) {
+ return parameters;
+ },
+
+ metadata : {
+ id : 'id',
+ icon : 'icon',
+ placeholder : 'placeholder',
+ source : 'source',
+ url : 'url'
+ },
+
+ error : {
+ noURL : 'No URL specified',
+ method : 'The method you called is not defined'
},
-});
+ className : {
+ active : 'active',
+ embed : 'embed'
+ },
-})( jQuery, window , document );
-/*
- * # Semantic - Modal
+ selector : {
+ embed : '.embed',
+ placeholder : '.placeholder',
+ icon : '.icon'
+ },
+
+ sources: {
+ youtube: {
+ name : 'youtube',
+ type : 'video',
+ icon : 'video play',
+ domain : 'youtube.com',
+ url : '//www.youtube.com/embed/{id}',
+ parameters: function(settings) {
+ return {
+ autohide : !settings.brandedUI,
+ autoplay : settings.autoplay,
+ color : settings.colors || undefined,
+ hq : settings.hd,
+ jsapi : settings.api,
+ modestbranding : !settings.brandedUI
+ };
+ }
+ },
+ vimeo: {
+ name : 'vimeo',
+ type : 'video',
+ icon : 'video play',
+ domain : 'vimeo.com',
+ url : '//player.vimeo.com/video/{id}',
+ parameters: function(settings) {
+ return {
+ api : settings.api,
+ autoplay : settings.autoplay,
+ byline : settings.brandedUI,
+ color : settings.colors || undefined,
+ portrait : settings.brandedUI,
+ title : settings.brandedUI
+ };
+ }
+ }
+ },
+
+ templates: {
+ iframe : function(url, parameters) {
+ return ''
+ + '<iframe src="' + url + '?' + parameters + '"'
+ + ' width="100%" height="100%"'
+ + ' frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'
+ ;
+ },
+ placeholder : function(image, icon) {
+ var
+ html = ''
+ ;
+ if(icon) {
+ html += '<i class="' + icon + ' icon"></i>';
+ }
+ if(image) {
+ html += '<img class="placeholder" src="' + image + '">';
+ }
+ return html;
+ }
+ },
+
+ // NOT YET IMPLEMENTED
+ api : true,
+ onPause : function() {},
+ onPlay : function() {},
+ onStop : function() {}
+
+};
+
+
+
+})( jQuery, window, document );
+
+/*!
+ * # Semantic UI 2.1.6 - Modal
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -4516,37 +8295,14 @@ $.fn.modal = function(parameters) {
initialize: function() {
module.verbose('Initializing dimmer', $context);
- if($.fn.dimmer === undefined) {
- module.error(error.dimmer);
- return;
- }
-
- id = module.get.uniqueID();
- elementNamespace = '.' + id;
-
- $dimmable = $context
- .dimmer({
- debug : settings.debug,
- dimmerName : 'modals',
- closable : false,
- useCSS : true,
- duration : {
- show : settings.duration * 0.9,
- hide : settings.duration * 1.1
- }
- })
- ;
- if(settings.detachable) {
- $dimmable.dimmer('add content', $module);
- }
-
- $dimmer = $dimmable.dimmer('get dimmer');
+ module.create.id();
+ module.create.dimmer();
module.refreshModals();
- module.verbose('Attaching close events', $close);
module.bind.events();
- module.observeChanges();
-
+ if(settings.observeChanges) {
+ module.observeChanges();
+ }
module.instantiate();
},
@@ -4558,6 +8314,50 @@ $.fn.modal = function(parameters) {
;
},
+ create: {
+ dimmer: function() {
+ var
+ defaultSettings = {
+ debug : settings.debug,
+ dimmerName : 'modals',
+ duration : {
+ show : settings.duration,
+ hide : settings.duration
+ }
+ },
+ dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings)
+ ;
+ if(settings.inverted) {
+ dimmerSettings.variation = (dimmerSettings.variation !== undefined)
+ ? dimmerSettings.variation + ' inverted'
+ : 'inverted'
+ ;
+ }
+ if($.fn.dimmer === undefined) {
+ module.error(error.dimmer);
+ return;
+ }
+ module.debug('Creating dimmer with settings', dimmerSettings);
+ $dimmable = $context.dimmer(dimmerSettings);
+ if(settings.detachable) {
+ module.verbose('Modal is detachable, moving content into dimmer');
+ $dimmable.dimmer('add content', $module);
+ }
+ else {
+ module.set.undetached();
+ }
+ if(settings.blurring) {
+ $dimmable.addClass(className.blurring);
+ }
+ $dimmer = $dimmable.dimmer('get dimmer');
+ },
+ id: function() {
+ id = (Math.random().toString(16) + '000000000').substr(2,8);
+ elementNamespace = '.' + id;
+ module.verbose('Creating unique id for element', id);
+ }
+ },
+
destroy: function() {
module.verbose('Destroying previous modal');
$module
@@ -4604,7 +8404,7 @@ $.fn.modal = function(parameters) {
? module[event]
: module.toggle
;
- if($toggle.size() > 0) {
+ if($toggle.length > 0) {
module.debug('Attaching modal events to element', selector, event);
$toggle
.off(eventNamespace)
@@ -4618,8 +8418,11 @@ $.fn.modal = function(parameters) {
bind: {
events: function() {
- $close
- .on('click' + eventNamespace, module.event.close)
+ module.verbose('Attaching events');
+ $module
+ .on('click' + eventNamespace, selector.close, module.event.close)
+ .on('click' + eventNamespace, selector.approve, module.event.approve)
+ .on('click' + eventNamespace, selector.deny, module.event.deny)
;
$window
.on('resize' + elementNamespace, module.event.resize)
@@ -4628,36 +8431,36 @@ $.fn.modal = function(parameters) {
},
get: {
- uniqueID: function() {
+ id: function() {
return (Math.random().toString(16) + '000000000').substr(2,8);
}
},
event: {
- close: function() {
- module.verbose('Closing element pressed');
- if( $(this).is(selector.approve) ) {
- if($.proxy(settings.onApprove, element)() !== false) {
- module.hide();
- }
- else {
- module.verbose('Approve callback returned false cancelling hide');
- }
- }
- else if( $(this).is(selector.deny) ) {
- if($.proxy(settings.onDeny, element)() !== false) {
- module.hide();
- }
- else {
- module.verbose('Deny callback returned false cancelling hide');
- }
+ approve: function() {
+ if(settings.onApprove.call(element, $(this)) === false) {
+ module.verbose('Approve callback returned false cancelling hide');
+ return;
}
- else {
- module.hide();
+ module.hide();
+ },
+ deny: function() {
+ if(settings.onDeny.call(element, $(this)) === false) {
+ module.verbose('Deny callback returned false cancelling hide');
+ return;
}
+ module.hide();
+ },
+ close: function() {
+ module.hide();
},
click: function(event) {
- if( $(event.target).closest($module).size() === 0 ) {
+ var
+ $target = $(event.target),
+ isInModal = ($target.closest(selector.modal).length > 0),
+ isInDOM = $.contains(document.documentElement, event.target)
+ ;
+ if(!isInModal && isInDOM) {
module.debug('Dimmer clicked, hiding all modals');
if( module.is.active() ) {
module.remove.clickaway();
@@ -4712,7 +8515,6 @@ $.fn.modal = function(parameters) {
: function(){}
;
module.refreshModals();
- module.showDimmer();
module.showModal(callback);
},
@@ -4722,9 +8524,6 @@ $.fn.modal = function(parameters) {
: function(){}
;
module.refreshModals();
- if( !module.othersActive() ) {
- module.hideDimmer();
- }
module.hideModal(callback);
},
@@ -4733,49 +8532,44 @@ $.fn.modal = function(parameters) {
? callback
: function(){}
;
- if( !module.is.active() ) {
+ if( module.is.animating() || !module.is.active() ) {
+
+ module.showDimmer();
+ module.cacheSizes();
+ module.set.position();
+ module.set.screenHeight();
+ module.set.type();
+ module.set.clickaway();
- if( !settings.allowMultiple && $otherModals.filter(':visible').size() > 0) {
- module.debug('Other modals visible, queueing show animation');
+ if( !settings.allowMultiple && module.others.active() ) {
module.hideOthers(module.showModal);
}
else {
- $.proxy(settings.onShow, element)();
+ settings.onShow.call(element);
if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
module.debug('Showing modal with css animations');
- module.cacheSizes();
- module.set.position();
- module.set.screenHeight();
- module.set.type();
- module.set.clickaway();
$module
.transition({
- debug : settings.debug,
- animation : settings.transition + ' in',
- queue : false,
- duration : settings.duration,
+ debug : settings.debug,
+ animation : settings.transition + ' in',
+ queue : settings.queue,
+ duration : settings.duration,
+ useFailSafe : true,
onComplete : function() {
- $.proxy(settings.onVisible, element)();
+ settings.onVisible.apply(element);
module.add.keyboardShortcuts();
module.save.focus();
module.set.active();
- module.set.autofocus();
+ if(settings.autofocus) {
+ module.set.autofocus();
+ }
callback();
}
})
;
}
else {
- module.debug('Showing modal with javascript');
- $module
- .fadeIn(settings.duration, settings.easing, function() {
- $.proxy(settings.onVisible, element)();
- module.add.keyboardShortcuts();
- module.save.focus();
- module.set.active();
- callback();
- })
- ;
+ module.error(error.noTransition);
}
}
}
@@ -4784,8 +8578,49 @@ $.fn.modal = function(parameters) {
}
},
+ hideModal: function(callback, keepDimmed) {
+ callback = $.isFunction(callback)
+ ? callback
+ : function(){}
+ ;
+ module.debug('Hiding modal');
+ if(settings.onHide.call(element, $(this)) === false) {
+ module.verbose('Hide callback returned false cancelling hide');
+ return;
+ }
+
+ if( module.is.animating() || module.is.active() ) {
+ if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
+ module.remove.active();
+ $module
+ .transition({
+ debug : settings.debug,
+ animation : settings.transition + ' out',
+ queue : settings.queue,
+ duration : settings.duration,
+ useFailSafe : true,
+ onStart : function() {
+ if(!module.others.active() && !keepDimmed) {
+ module.hideDimmer();
+ }
+ module.remove.keyboardShortcuts();
+ },
+ onComplete : function() {
+ settings.onHidden.call(element);
+ module.restore.focus();
+ callback();
+ }
+ })
+ ;
+ }
+ else {
+ module.error(error.noTransition);
+ }
+ }
+ },
+
showDimmer: function() {
- if( !$dimmable.dimmer('is active') ) {
+ if($dimmable.dimmer('is animating') || !$dimmable.dimmer('is active') ) {
module.debug('Showing dimmer');
$dimmable.dimmer('show');
}
@@ -4795,91 +8630,61 @@ $.fn.modal = function(parameters) {
},
hideDimmer: function() {
- if( !($dimmable.dimmer('is active') || $dimmable.dimmer('is animating')) ) {
- module.debug('Dimmer is not visible cannot hide');
- return;
- }
- module.debug('Hiding dimmer');
- $dimmable.dimmer('hide', function() {
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
+ if( $dimmable.dimmer('is animating') || ($dimmable.dimmer('is active')) ) {
+ $dimmable.dimmer('hide', function() {
module.remove.clickaway();
module.remove.screenHeight();
- }
- });
- },
-
- hideModal: function(callback) {
- callback = $.isFunction(callback)
- ? callback
- : function(){}
- ;
- module.debug('Hiding modal');
- $.proxy(settings.onHide, element)();
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
- module.remove.active();
- $module
- .transition({
- debug : settings.debug,
- animation : settings.transition + ' out',
- queue : false,
- duration : settings.duration,
- onStart : function() {
- module.remove.keyboardShortcuts();
- },
- onComplete : function() {
- $.proxy(settings.onHidden, element)();
- module.restore.focus();
- callback();
- }
- })
- ;
+ });
}
else {
- module.remove.active();
- module.remove.keyboardShortcuts();
- $module
- .fadeOut(settings.duration, settings.easing, function() {
- $.proxy(settings.onHidden, element)();
- module.restore.focus();
- callback();
- })
- ;
+ module.debug('Dimmer is not visible cannot hide');
+ return;
}
},
hideAll: function(callback) {
+ var
+ $visibleModals = $allModals.filter('.' + className.active + ', .' + className.animating)
+ ;
callback = $.isFunction(callback)
? callback
: function(){}
;
- if( $allModals.is(':visible') ) {
+ if( $visibleModals.length > 0 ) {
module.debug('Hiding all visible modals');
module.hideDimmer();
- $allModals
- .filter(':visible')
- .modal('hide modal', callback)
+ $visibleModals
+ .modal('hide modal', callback)
;
}
},
hideOthers: function(callback) {
+ var
+ $visibleModals = $otherModals.filter('.' + className.active + ', .' + className.animating)
+ ;
callback = $.isFunction(callback)
? callback
: function(){}
;
- if( $otherModals.is(':visible') ) {
+ if( $visibleModals.length > 0 ) {
module.debug('Hiding other modals', $otherModals);
- $otherModals
- .filter(':visible')
- .modal('hide modal', callback)
+ $visibleModals
+ .modal('hide modal', callback, true)
;
}
},
- othersActive: function() {
- return ($otherModals.filter('.' + className.active).size() > 0);
+ others: {
+ active: function() {
+ return ($otherModals.filter('.' + className.active).length > 0);
+ },
+ animating: function() {
+ return ($otherModals.filter('.' + className.animating).length > 0);
+ }
},
+
add: {
keyboardShortcuts: function() {
module.verbose('Adding keyboard shortcuts');
@@ -4897,7 +8702,7 @@ $.fn.modal = function(parameters) {
restore: {
focus: function() {
- if($focusedElement && $focusedElement.size() > 0) {
+ if($focusedElement && $focusedElement.length > 0) {
$focusedElement.focus();
}
}
@@ -4914,14 +8719,18 @@ $.fn.modal = function(parameters) {
;
}
},
- screenHeight: function() {
- if(module.cache.height > module.cache.pageHeight) {
- module.debug('Removing page height');
- $body
- .css('height', '')
- ;
+ bodyStyle: function() {
+ if($body.attr('style') === '') {
+ module.verbose('Removing style attribute');
+ $body.removeAttr('style');
}
},
+ screenHeight: function() {
+ module.debug('Removing page height');
+ $body
+ .css('height', '')
+ ;
+ },
keyboardShortcuts: function() {
module.verbose('Removing keyboard shortcuts');
$document
@@ -4952,7 +8761,7 @@ $.fn.modal = function(parameters) {
can: {
fit: function() {
- return (module.cache.height < module.cache.contextHeight);
+ return ( ( module.cache.height + (settings.padding * 2) ) < module.cache.contextHeight);
}
},
@@ -4977,15 +8786,15 @@ $.fn.modal = function(parameters) {
set: {
autofocus: function() {
- if(settings.autofocus) {
- var
- $inputs = $module.find(':input:visible'),
- $autofocus = $inputs.filter('[autofocus]'),
- $input = ($autofocus.size() > 0)
- ? $autofocus
- : $inputs
- ;
- $input.first().focus();
+ var
+ $inputs = $module.find(':input').filter(':visible'),
+ $autofocus = $inputs.filter('[autofocus]'),
+ $input = ($autofocus.length > 0)
+ ? $autofocus.first()
+ : $inputs.first()
+ ;
+ if($input.length > 0) {
+ $input.focus();
}
},
clickaway: function() {
@@ -4996,15 +8805,15 @@ $.fn.modal = function(parameters) {
}
},
screenHeight: function() {
- if(module.cache.height > module.cache.pageHeight) {
+ if( module.can.fit() ) {
+ $body.css('height', '');
+ }
+ else {
module.debug('Modal is taller than page content, resizing page height');
$body
- .css('height', module.cache.height + settings.padding)
+ .css('height', module.cache.height + (settings.padding * 2) )
;
}
- else {
- $body.css('height', '');
- }
},
active: function() {
$module.addClass(className.active);
@@ -5016,7 +8825,7 @@ $.fn.modal = function(parameters) {
type: function() {
if(module.can.fit()) {
module.verbose('Modal fits on screen');
- if(!module.othersActive) {
+ if(!module.others.active() && !module.others.animating()) {
module.remove.scrolling();
}
}
@@ -5043,6 +8852,9 @@ $.fn.modal = function(parameters) {
})
;
}
+ },
+ undetached: function() {
+ $dimmable.addClass(className.undetached);
}
},
@@ -5115,7 +8927,7 @@ $.fn.modal = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -5209,7 +9021,7 @@ $.fn.modal = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
@@ -5224,38 +9036,59 @@ $.fn.modal = function(parameters) {
$.fn.modal.settings = {
- name : 'Modal',
- namespace : 'modal',
+ name : 'Modal',
+ namespace : 'modal',
- debug : false,
- verbose : true,
- performance : true,
+ debug : false,
+ verbose : false,
+ performance : true,
+
+ observeChanges : false,
- allowMultiple : false,
- detachable : true,
- closable : true,
- autofocus : true,
+ allowMultiple : false,
+ detachable : true,
+ closable : true,
+ autofocus : true,
- context : 'body',
+ inverted : false,
+ blurring : false,
- duration : 500,
- easing : 'easeOutExpo',
- offset : 0,
- transition : 'scale',
+ dimmerSettings : {
+ closable : false,
+ useCSS : true
+ },
- padding : 30,
- onShow : function(){},
- onHide : function(){},
+ context : 'body',
- onVisible : function(){},
- onHidden : function(){},
+ queue : false,
+ duration : 500,
+ offset : 0,
+ transition : 'scale',
- onApprove : function(){ return true; },
- onDeny : function(){ return true; },
+ // padding with edge of page
+ padding : 50,
+
+ // called before show animation
+ onShow : function(){},
+
+ // called after show animation
+ onVisible : function(){},
+
+ // called before hide animation
+ onHide : function(){ return true; },
+
+ // called after hide animation
+ onHidden : function(){},
+
+ // called after approve selector match
+ onApprove : function(){ return true; },
+
+ // called after deny selector match
+ onDeny : function(){ return true; },
selector : {
- close : '.close, .actions .button',
+ close : '> .close',
approve : '.actions .positive, .actions .approve, .actions .ok',
deny : '.actions .negative, .actions .deny, .actions .cancel',
modal : '.ui.modal'
@@ -5266,20 +9099,23 @@ $.fn.modal.settings = {
notFound : 'The element you specified could not be found'
},
className : {
- active : 'active',
- scrolling : 'scrolling'
+ active : 'active',
+ animating : 'animating',
+ blurring : 'blurring',
+ scrolling : 'scrolling',
+ undetached : 'undetached'
}
};
-})( jQuery, window , document );
+})( jQuery, window, document );
-/*
- * # Semantic - Nag
+/*!
+ * # Semantic UI 2.1.6 - Nag
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -5352,11 +9188,9 @@ $.fn.nag = function(parameters) {
module.verbose('Initializing element');
$module
+ .on('click' + eventNamespace, selector.close, module.dismiss)
.data(moduleNamespace, module)
;
- $close
- .on('click' + eventNamespace, module.dismiss)
- ;
if(settings.detachable && $module.parent()[0] !== $context[0]) {
$module
@@ -5472,6 +9306,10 @@ $.fn.nag = function(parameters) {
window.localStorage.setItem(key, value);
module.debug('Value stored using local storage', key, value);
}
+ else if(settings.storageMethod == 'sessionstorage' && window.sessionStorage !== undefined) {
+ window.sessionStorage.setItem(key, value);
+ module.debug('Value stored using session storage', key, value);
+ }
else if($.cookie !== undefined) {
$.cookie(key, value, options);
module.debug('Value stored using cookie', key, value, options);
@@ -5488,6 +9326,9 @@ $.fn.nag = function(parameters) {
if(settings.storageMethod == 'localstorage' && window.localStorage !== undefined) {
storedValue = window.localStorage.getItem(key);
}
+ else if(settings.storageMethod == 'sessionstorage' && window.sessionStorage !== undefined) {
+ storedValue = window.sessionStorage.getItem(key);
+ }
// get by cookie
else if($.cookie !== undefined) {
storedValue = $.cookie(key);
@@ -5504,9 +9345,12 @@ $.fn.nag = function(parameters) {
var
options = module.get.storageOptions()
;
- if(settings.storageMethod == 'local' && window.store !== undefined) {
+ if(settings.storageMethod == 'localstorage' && window.localStorage !== undefined) {
window.localStorage.removeItem(key);
}
+ else if(settings.storageMethod == 'sessionstorage' && window.sessionStorage !== undefined) {
+ window.sessionStorage.removeItem(key);
+ }
// store by cookie
else if($.cookie !== undefined) {
$.removeCookie(key, options);
@@ -5586,7 +9430,7 @@ $.fn.nag = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -5681,7 +9525,7 @@ $.fn.nag = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
@@ -5699,7 +9543,7 @@ $.fn.nag.settings = {
name : 'Nag',
debug : false,
- verbose : true,
+ verbose : false,
performance : true,
namespace : 'Nag',
@@ -5730,8 +9574,9 @@ $.fn.nag.settings = {
value : 'dismiss',
error: {
- noStorage : 'Neither $.cookie or store is defined. A storage solution is required for storing state',
- method : 'The method you called is not defined.'
+ noCookieStorage : '$.cookie is not included. A storage solution is required.',
+ noStorage : 'Neither $.cookie or store is defined. A storage solution is required for storing state',
+ method : 'The method you called is not defined.'
},
className : {
@@ -5750,14 +9595,14 @@ $.fn.nag.settings = {
};
-})( jQuery, window , document );
+})( jQuery, window, document );
-/*
- * # Semantic - Popup
- * http://github.com/jlukic/semantic-ui/
+/*!
+ * # Semantic UI 2.1.6 - Popup
+ * http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -5771,10 +9616,12 @@ $.fn.popup = function(parameters) {
var
$allModules = $(this),
$document = $(document),
+ $window = $(window),
+ $body = $('body'),
moduleSelector = $allModules.selector || '',
- hasTouch = ('ontouchstart' in document.documentElement),
+ hasTouch = (true),
time = new Date().getTime(),
performance = [],
@@ -5806,16 +9653,18 @@ $.fn.popup = function(parameters) {
? $(settings.target)
: $module,
- $window = $(window),
- $body = $('body'),
$popup,
$offsetParent,
searchDepth = 0,
triedPositions = false,
+ openedWithTouch = false,
element = this,
instance = $module.data(moduleNamespace),
+
+ elementNamespace,
+ id,
module
;
@@ -5823,36 +9672,17 @@ $.fn.popup = function(parameters) {
// binds events
initialize: function() {
- module.debug('Initializing module', $module);
- module.refresh();
- if(settings.on == 'click') {
- $module
- .on('click' + eventNamespace, module.toggle)
- ;
- }
- else if( module.get.startEvent() ) {
- $module
- .on(module.get.startEvent() + eventNamespace, module.event.start)
- .on(module.get.endEvent() + eventNamespace, module.event.end)
- ;
- }
- if(settings.target) {
- module.debug('Target set to element', $target);
- }
- $window
- .on('resize' + eventNamespace, module.event.resize)
- ;
- if( !module.exists() ) {
+ module.debug('Initializing', $module);
+ module.createID();
+ module.bind.events();
+ if( !module.exists() && settings.preserve) {
module.create();
}
- else if(settings.hoverable) {
- module.bind.popup();
- }
module.instantiate();
},
instantiate: function() {
- module.verbose('Storing instance of module', module);
+ module.verbose('Storing instance', module);
instance = module;
$module
.data(moduleNamespace, instance)
@@ -5861,28 +9691,41 @@ $.fn.popup = function(parameters) {
refresh: function() {
if(settings.popup) {
- $popup = $(settings.popup);
+ $popup = $(settings.popup).eq(0);
}
else {
if(settings.inline) {
- $popup = $target.next(settings.selector.popup);
+ $popup = $target.nextAll(selector.popup).eq(0);
+ settings.popup = $popup;
}
}
if(settings.popup) {
$popup.addClass(className.loading);
- $offsetParent = $popup.offsetParent();
+ $offsetParent = module.get.offsetParent();
$popup.removeClass(className.loading);
+ if(settings.movePopup && module.has.popup() && module.get.offsetParent($popup)[0] !== $offsetParent[0]) {
+ module.debug('Moving popup to the same offset parent as activating element');
+ $popup
+ .detach()
+ .appendTo($offsetParent)
+ ;
+ }
}
else {
$offsetParent = (settings.inline)
- ? $target.offsetParent()
+ ? module.get.offsetParent($target)
+ : module.has.popup()
+ ? module.get.offsetParent($popup)
: $body
;
}
- if( $offsetParent.is('html') ) {
- module.debug('Page is popups offset parent');
+ if( $offsetParent.is('html') && $offsetParent[0] !== $body[0] ) {
+ module.debug('Setting page as offset parent');
$offsetParent = $body;
}
+ if( module.get.variation() ) {
+ module.set.variation();
+ }
},
reposition: function() {
@@ -5892,9 +9735,15 @@ $.fn.popup = function(parameters) {
destroy: function() {
module.debug('Destroying previous module');
+ // remove element only if was created dynamically
if($popup && !settings.preserve) {
module.removePopup();
}
+ // clear all timeouts
+ clearTimeout(module.hideTimer);
+ clearTimeout(module.showTimer);
+ // remove events
+ $window.off(elementNamespace);
$module
.off(eventNamespace)
.removeData(moduleNamespace)
@@ -5909,11 +9758,9 @@ $.fn.popup = function(parameters) {
: settings.delay
;
clearTimeout(module.hideTimer);
- module.showTimer = setTimeout(function() {
- if( module.is.hidden() && !( module.is.active() && module.is.dropdown()) ) {
- module.show();
- }
- }, delay);
+ if(!openedWithTouch) {
+ module.showTimer = setTimeout(module.show, delay);
+ }
},
end: function() {
var
@@ -5922,27 +9769,37 @@ $.fn.popup = function(parameters) {
: settings.delay
;
clearTimeout(module.showTimer);
- module.hideTimer = setTimeout(function() {
- if( module.is.visible() ) {
- module.hide();
- }
- }, delay);
+ module.hideTimer = setTimeout(module.hide, delay);
+ },
+ touchstart: function(event) {
+ openedWithTouch = true;
+ module.show();
},
resize: function() {
if( module.is.visible() ) {
module.set.position();
}
+ },
+ hideGracefully: function(event) {
+ // don't close on clicks inside popup
+ if(event && $(event.target).closest(selector.popup).length === 0) {
+ module.debug('Click occurred outside popup hiding popup');
+ module.hide();
+ }
+ else {
+ module.debug('Click was inside popup, keeping popup open');
+ }
}
},
// generates popup html from metadata
create: function() {
var
- html = $module.data(metadata.html) || settings.html,
- variation = $module.data(metadata.variation) || settings.variation,
- title = $module.data(metadata.title) || settings.title,
- content = $module.data(metadata.content) || $module.attr('title') || settings.content
+ html = module.get.html(),
+ title = module.get.title(),
+ content = module.get.content()
;
+
if(html || content || title) {
module.debug('Creating pop-up html');
if(!html) {
@@ -5953,14 +9810,9 @@ $.fn.popup = function(parameters) {
}
$popup = $('<div/>')
.addClass(className.popup)
- .addClass(variation)
+ .data(metadata.activator, $module)
.html(html)
;
- if(variation) {
- $popup
- .addClass(variation)
- ;
- }
if(settings.inline) {
module.verbose('Inserting popup element inline', $popup);
$popup
@@ -5973,14 +9825,26 @@ $.fn.popup = function(parameters) {
.appendTo( $context )
;
}
+ module.refresh();
+ module.set.variation();
+
if(settings.hoverable) {
module.bind.popup();
}
- $.proxy(settings.onCreate, $popup)(element);
+ settings.onCreate.call($popup, element);
}
- else if($target.next(settings.selector.popup).size() !== 0) {
- module.verbose('Pre-existing popup found, reverting to inline');
+ else if($target.next(selector.popup).length !== 0) {
+ module.verbose('Pre-existing popup found');
settings.inline = true;
+ settings.popups = $target.next(selector.popup).data(metadata.activator, $module);
+ module.refresh();
+ if(settings.hoverable) {
+ module.bind.popup();
+ }
+ }
+ else if(settings.popup) {
+ $(settings.popup).data(metadata.activator, $module);
+ module.verbose('Used popup specified in settings');
module.refresh();
if(settings.hoverable) {
module.bind.popup();
@@ -5991,13 +9855,18 @@ $.fn.popup = function(parameters) {
}
},
+ createID: function() {
+ id = (Math.random().toString(16) + '000000000').substr(2,8);
+ elementNamespace = '.' + id;
+ module.verbose('Creating unique id for element', id);
+ },
+
// determines popup state
toggle: function() {
module.debug('Toggling pop-up');
if( module.is.hidden() ) {
module.debug('Popup is hidden, showing pop-up');
module.unbind.close();
- module.hideAll();
module.show();
}
else {
@@ -6007,26 +9876,39 @@ $.fn.popup = function(parameters) {
},
show: function(callback) {
- callback = $.isFunction(callback) ? callback : function(){};
+ callback = callback || function(){};
module.debug('Showing pop-up', settings.transition);
- if(!settings.preserve && !settings.popup) {
- module.refresh();
- }
- if( !module.exists() ) {
- module.create();
- }
- if( $popup && module.set.position() ) {
- module.save.conditions();
- module.animate.show(callback);
+ if(module.is.hidden() && !( module.is.active() && module.is.dropdown()) ) {
+ if( !module.exists() ) {
+ module.create();
+ }
+ if(settings.onShow.call($popup, element) === false) {
+ module.debug('onShow callback returned false, cancelling popup animation');
+ return;
+ }
+ else if(!settings.preserve && !settings.popup) {
+ module.refresh();
+ }
+ if( $popup && module.set.position() ) {
+ module.save.conditions();
+ if(settings.exclusive) {
+ module.hideAll();
+ }
+ module.animate.show(callback);
+ }
}
},
hide: function(callback) {
- callback = $.isFunction(callback) ? callback : function(){};
- module.remove.visible();
- module.unbind.close();
- if( module.is.visible() ) {
+ callback = callback || function(){};
+ if( module.is.visible() || module.is.animating() ) {
+ if(settings.onHide.call($popup, element) === false) {
+ module.debug('onHide callback returned false, cancelling popup animation');
+ return;
+ }
+ module.remove.visible();
+ module.unbind.close();
module.restore.conditions();
module.animate.hide(callback);
}
@@ -6034,38 +9916,37 @@ $.fn.popup = function(parameters) {
hideAll: function() {
$(selector.popup)
- .filter(':visible')
- .popup('hide')
+ .filter('.' + className.visible)
+ .each(function() {
+ $(this)
+ .data(metadata.activator)
+ .popup('hide')
+ ;
+ })
;
},
-
- hideGracefully: function(event) {
- // don't close on clicks inside popup
- if(event && $(event.target).closest(selector.popup).size() === 0) {
- module.debug('Click occurred outside popup hiding popup');
- module.hide();
- }
- else {
- module.debug('Click was inside popup, keeping popup open');
- }
- },
-
exists: function() {
if(!$popup) {
return false;
}
if(settings.inline || settings.popup) {
- return ( $popup.size() !== 0 );
+ return ( module.has.popup() );
}
else {
- return ( $popup.closest($context).size() );
+ return ( $popup.closest($context).length >= 1 )
+ ? true
+ : false
+ ;
}
},
removePopup: function() {
- module.debug('Removing popup');
- $.proxy(settings.onRemove, $popup)(element);
- $popup.remove();
+ if( module.has.popup() && !settings.popup) {
+ module.debug('Removing popup', $popup);
+ $popup.remove();
+ $popup = undefined;
+ settings.onRemove.call($popup, element);
+ }
},
save: {
@@ -6081,7 +9962,6 @@ $.fn.popup = function(parameters) {
},
restore: {
conditions: function() {
- element.blur();
if(module.cache && module.cache.title) {
$module.attr('title', module.cache.title);
module.verbose('Restoring original attributes', module.cache.title);
@@ -6103,27 +9983,23 @@ $.fn.popup = function(parameters) {
duration : settings.duration,
onComplete : function() {
module.bind.close();
- $.proxy(callback, $popup)(element);
- $.proxy(settings.onVisible, $popup)(element);
+ callback.call($popup, element);
+ settings.onVisible.call($popup, element);
}
})
;
}
else {
- module.set.visible();
- $popup
- .stop()
- .fadeIn(settings.duration, settings.easing, function() {
- module.bind.close();
- $.proxy(callback, element)();
- })
- ;
+ module.error(error.noTransition);
}
- $.proxy(settings.onShow, $popup)(element);
},
hide: function(callback) {
callback = $.isFunction(callback) ? callback : function(){};
module.debug('Hiding pop-up');
+ if(settings.onHide.call($popup, element) === false) {
+ module.debug('onHide callback returned false, cancelling popup animation');
+ return;
+ }
if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
$popup
.transition({
@@ -6134,26 +10010,119 @@ $.fn.popup = function(parameters) {
verbose : settings.verbose,
onComplete : function() {
module.reset();
- $.proxy(callback, $popup)(element);
- $.proxy(settings.onHidden, $popup)(element);
+ callback.call($popup, element);
+ settings.onHidden.call($popup, element);
}
})
;
}
else {
- $popup
- .stop()
- .fadeOut(settings.duration, settings.easing, function() {
- module.reset();
- callback();
- })
- ;
+ module.error(error.noTransition);
}
- $.proxy(settings.onHide, $popup)(element);
+ }
+ },
+
+ change: {
+ content: function(html) {
+ $popup.html(html);
}
},
get: {
+ html: function() {
+ $module.removeData(metadata.html);
+ return $module.data(metadata.html) || settings.html;
+ },
+ title: function() {
+ $module.removeData(metadata.title);
+ return $module.data(metadata.title) || settings.title;
+ },
+ content: function() {
+ $module.removeData(metadata.content);
+ return $module.data(metadata.content) || $module.attr('title') || settings.content;
+ },
+ variation: function() {
+ $module.removeData(metadata.variation);
+ return $module.data(metadata.variation) || settings.variation;
+ },
+ popup: function() {
+ return $popup;
+ },
+ popupOffset: function() {
+ return $popup.offset();
+ },
+ calculations: function() {
+ var
+ targetElement = $target[0],
+ targetPosition = (settings.inline || (settings.popup && settings.movePopup))
+ ? $target.position()
+ : $target.offset(),
+ calculations = {},
+ screen
+ ;
+ calculations = {
+ // element which is launching popup
+ target : {
+ element : $target[0],
+ width : $target.outerWidth(),
+ height : $target.outerHeight(),
+ top : targetPosition.top,
+ left : targetPosition.left,
+ margin : {}
+ },
+ // popup itself
+ popup : {
+ width : $popup.outerWidth(),
+ height : $popup.outerHeight()
+ },
+ // offset container (or 3d context)
+ parent : {
+ width : $offsetParent.outerWidth(),
+ height : $offsetParent.outerHeight()
+ },
+ // screen boundaries
+ screen : {
+ scroll: {
+ top : $window.scrollTop(),
+ left : $window.scrollLeft()
+ },
+ width : $window.width(),
+ height : $window.height()
+ }
+ };
+
+ // add in container calcs if fluid
+ if( settings.setFluidWidth && module.is.fluid() ) {
+ calculations.container = {
+ width: $popup.parent().outerWidth()
+ };
+ calculations.popup.width = calculations.container.width;
+ }
+
+ // add in margins if inline
+ calculations.target.margin.top = (settings.inline)
+ ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10)
+ : 0
+ ;
+ calculations.target.margin.left = (settings.inline)
+ ? module.is.rtl()
+ ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-right'), 10)
+ : parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-left') , 10)
+ : 0
+ ;
+ // calculate screen boundaries
+ screen = calculations.screen;
+ calculations.boundary = {
+ top : screen.scroll.top,
+ bottom : screen.scroll.top + screen.height,
+ left : screen.scroll.left,
+ right : screen.scroll.left + screen.width
+ };
+ return calculations;
+ },
+ id: function() {
+ return id;
+ },
startEvent: function() {
if(settings.on == 'hover') {
return 'mouseenter';
@@ -6163,6 +10132,9 @@ $.fn.popup = function(parameters) {
}
return false;
},
+ scrollEvent: function() {
+ return 'scroll';
+ },
endEvent: function() {
if(settings.on == 'hover') {
return 'mouseleave';
@@ -6172,41 +10144,55 @@ $.fn.popup = function(parameters) {
}
return false;
},
- offstagePosition: function(position) {
+ distanceFromBoundary: function(offset, calculations) {
var
- position = position || false,
- boundary = {
- top : $(window).scrollTop(),
- bottom : $(window).scrollTop() + $(window).height(),
- left : 0,
- right : $(window).width()
- },
- popup = {
- width : $popup.width(),
- height : $popup.height(),
- offset : $popup.offset()
- },
- offstage = {},
- offstagePositions = []
- ;
- if(popup.offset && position) {
- module.verbose('Checking if outside viewable area', popup.offset);
- offstage = {
- top : (popup.offset.top < boundary.top),
- bottom : (popup.offset.top + popup.height > boundary.bottom),
- right : (popup.offset.left + popup.width > boundary.right),
- left : (popup.offset.left < boundary.left)
+ distanceFromBoundary = {},
+ popup,
+ boundary
+ ;
+ offset = offset || module.get.offset();
+ calculations = calculations || module.get.calculations();
+
+ // shorthand
+ popup = calculations.popup;
+ boundary = calculations.boundary;
+
+ if(offset) {
+ distanceFromBoundary = {
+ top : (offset.top - boundary.top),
+ left : (offset.left - boundary.left),
+ right : (boundary.right - (offset.left + popup.width) ),
+ bottom : (boundary.bottom - (offset.top + popup.height) )
};
+ module.verbose('Distance from boundaries determined', offset, distanceFromBoundary);
}
- // return only boundaries that have been surpassed
- $.each(offstage, function(direction, isOffstage) {
- if(isOffstage) {
- offstagePositions.push(direction);
+ return distanceFromBoundary;
+ },
+ offsetParent: function($target) {
+ var
+ element = ($target !== undefined)
+ ? $target[0]
+ : $module[0],
+ parentNode = element.parentNode,
+ $node = $(parentNode)
+ ;
+ if(parentNode) {
+ var
+ is2D = ($node.css('transform') === 'none'),
+ isStatic = ($node.css('position') === 'static'),
+ isHTML = $node.is('html')
+ ;
+ while(parentNode && !isHTML && isStatic && is2D) {
+ parentNode = parentNode.parentNode;
+ $node = $(parentNode);
+ is2D = ($node.css('transform') === 'none');
+ isStatic = ($node.css('position') === 'static');
+ isHTML = $node.is('html');
}
- });
- return (offstagePositions.length > 0)
- ? offstagePositions.join(' ')
- : false
+ }
+ return ($node && $node.length > 0)
+ ? $node
+ : $()
;
},
positions: function() {
@@ -6281,123 +10267,134 @@ $.fn.popup = function(parameters) {
},
set: {
- position: function(position, arrowOffset) {
- var
- windowWidth = $(window).width(),
- windowHeight = $(window).height(),
+ position: function(position, calculations) {
- targetWidth = $target.outerWidth(),
- targetHeight = $target.outerHeight(),
-
- popupWidth = $popup.outerWidth(),
- popupHeight = $popup.outerHeight(),
-
- parentWidth = $offsetParent.outerWidth(),
- parentHeight = $offsetParent.outerHeight(),
-
- distanceAway = settings.distanceAway,
-
- targetElement = $target[0],
+ // exit conditions
+ if($target.length === 0 || $popup.length === 0) {
+ module.error(error.notFound);
+ return;
+ }
+ var
+ offset,
+ distanceAway,
+ target,
+ popup,
+ parent,
+ positioning,
+ popupOffset,
+ distanceFromBoundary
+ ;
- marginTop = (settings.inline)
- ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10)
- : 0,
- marginLeft = (settings.inline)
- ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-left'), 10)
- : 0,
+ calculations = calculations || module.get.calculations();
+ position = position || $module.data(metadata.position) || settings.position;
- target = (settings.inline || settings.popup)
- ? $target.position()
- : $target.offset(),
+ offset = $module.data(metadata.offset) || settings.offset;
+ distanceAway = settings.distanceAway;
- positioning,
- offstagePosition
- ;
- position = position || $module.data(metadata.position) || settings.position;
- arrowOffset = arrowOffset || $module.data(metadata.offset) || settings.offset;
+ // shorthand
+ target = calculations.target;
+ popup = calculations.popup;
+ parent = calculations.parent;
- if(searchDepth == settings.maxSearchDepth && settings.lastResort) {
- module.debug('Using last resort position to display', settings.lastResort);
- position = settings.lastResort;
+ if(target.width === 0 && target.height === 0 && !(target.element instanceof SVGGraphicsElement)) {
+ module.debug('Popup target is hidden, no action taken');
+ return false;
}
if(settings.inline) {
- module.debug('Adding targets margin to calculation');
+ module.debug('Adding margin to calculation', target.margin);
if(position == 'left center' || position == 'right center') {
- arrowOffset += marginTop;
- distanceAway += -marginLeft;
+ offset += target.margin.top;
+ distanceAway += -target.margin.left;
}
else if (position == 'top left' || position == 'top center' || position == 'top right') {
- arrowOffset += marginLeft;
- distanceAway -= marginTop;
+ offset += target.margin.left;
+ distanceAway -= target.margin.top;
}
else {
- arrowOffset += marginLeft;
- distanceAway += marginTop;
+ offset += target.margin.left;
+ distanceAway += target.margin.top;
}
}
- module.debug('Calculating popup positioning', position);
- switch(position) {
+
+ module.debug('Determining popup position from calculations', position, calculations);
+
+ if (module.is.rtl()) {
+ position = position.replace(/left|right/g, function (match) {
+ return (match == 'left')
+ ? 'right'
+ : 'left'
+ ;
+ });
+ module.debug('RTL: Popup position updated', position);
+ }
+
+ // if last attempt use specified last resort position
+ if(searchDepth == settings.maxSearchDepth && typeof settings.lastResort === 'string') {
+ position = settings.lastResort;
+ }
+
+ switch (position) {
case 'top left':
positioning = {
top : 'auto',
- bottom : parentHeight - target.top + distanceAway,
- left : target.left + arrowOffset,
+ bottom : parent.height - target.top + distanceAway,
+ left : target.left + offset,
right : 'auto'
};
break;
case 'top center':
positioning = {
- bottom : parentHeight - target.top + distanceAway,
- left : target.left + (targetWidth / 2) - (popupWidth / 2) + arrowOffset,
+ bottom : parent.height - target.top + distanceAway,
+ left : target.left + (target.width / 2) - (popup.width / 2) + offset,
top : 'auto',
right : 'auto'
};
break;
case 'top right':
positioning = {
- bottom : parentHeight - target.top + distanceAway,
- right : parentWidth - target.left - targetWidth - arrowOffset,
+ bottom : parent.height - target.top + distanceAway,
+ right : parent.width - target.left - target.width - offset,
top : 'auto',
left : 'auto'
};
break;
case 'left center':
positioning = {
- top : target.top + (targetHeight / 2) - (popupHeight / 2) + arrowOffset,
- right : parentWidth - target.left + distanceAway,
+ top : target.top + (target.height / 2) - (popup.height / 2) + offset,
+ right : parent.width - target.left + distanceAway,
left : 'auto',
bottom : 'auto'
};
break;
case 'right center':
positioning = {
- top : target.top + (targetHeight / 2) - (popupHeight / 2) + arrowOffset,
- left : target.left + targetWidth + distanceAway,
+ top : target.top + (target.height / 2) - (popup.height / 2) + offset,
+ left : target.left + target.width + distanceAway,
bottom : 'auto',
right : 'auto'
};
break;
case 'bottom left':
positioning = {
- top : target.top + targetHeight + distanceAway,
- left : target.left + arrowOffset,
+ top : target.top + target.height + distanceAway,
+ left : target.left + offset,
bottom : 'auto',
right : 'auto'
};
break;
case 'bottom center':
positioning = {
- top : target.top + targetHeight + distanceAway,
- left : target.left + (targetWidth / 2) - (popupWidth / 2) + arrowOffset,
+ top : target.top + target.height + distanceAway,
+ left : target.left + (target.width / 2) - (popup.width / 2) + offset,
bottom : 'auto',
right : 'auto'
};
break;
case 'bottom right':
positioning = {
- top : target.top + targetHeight + distanceAway,
- right : parentWidth - target.left - targetWidth - arrowOffset,
+ top : target.top + target.height + distanceAway,
+ right : parent.width - target.left - target.width - offset,
left : 'auto',
bottom : 'auto'
};
@@ -6407,6 +10404,8 @@ $.fn.popup = function(parameters) {
module.error(error.invalidPosition, position);
}
+ module.debug('Calculated popup positioning values', positioning);
+
// tentatively place on stage
$popup
.css(positioning)
@@ -6414,41 +10413,57 @@ $.fn.popup = function(parameters) {
.addClass(position)
.addClass(className.loading)
;
- // check if is offstage
- offstagePosition = module.get.offstagePosition(position);
- // recursively find new positioning
- if(offstagePosition) {
- module.debug('Popup cant fit into viewport', offstagePosition);
+ popupOffset = module.get.popupOffset();
+
+ // see if any boundaries are surpassed with this tentative position
+ distanceFromBoundary = module.get.distanceFromBoundary(popupOffset, calculations);
+
+ if( module.is.offstage(distanceFromBoundary, position) ) {
+ module.debug('Position is outside viewport', position);
if(searchDepth < settings.maxSearchDepth) {
searchDepth++;
position = module.get.nextPosition(position);
module.debug('Trying new position', position);
return ($popup)
- ? module.set.position(position)
+ ? module.set.position(position, calculations)
: false
;
}
- else if(!settings.lastResort) {
- module.debug('Popup could not find a position in view', $popup);
- module.error(error.cannotPlace);
- module.remove.attempts();
- module.remove.loading();
- module.reset();
- return false;
+ else {
+ if(settings.lastResort) {
+ module.debug('No position found, showing with last position');
+ }
+ else {
+ module.debug('Popup could not find a position to display', $popup);
+ module.error(error.cannotPlace, element);
+ module.remove.attempts();
+ module.remove.loading();
+ module.reset();
+ return false;
+ }
}
}
-
module.debug('Position is on stage', position);
module.remove.attempts();
- module.set.fluidWidth();
module.remove.loading();
+ if( settings.setFluidWidth && module.is.fluid() ) {
+ module.set.fluidWidth(calculations);
+ }
return true;
},
- fluidWidth: function() {
- if( settings.setFluidWidth && $popup.hasClass(className.fluid) ) {
- $popup.css('width', $offsetParent.width());
+ fluidWidth: function(calculations) {
+ calculations = calculations || module.get.calculations();
+ module.debug('Automatically setting element width to parent width', calculations.parent.width);
+ $popup.css('width', calculations.container.width);
+ },
+
+ variation: function(variation) {
+ variation = variation || module.get.variation();
+ if(variation && module.has.popup() ) {
+ module.verbose('Adding variation to popup', variation);
+ $popup.addClass(variation);
}
},
@@ -6461,6 +10476,13 @@ $.fn.popup = function(parameters) {
loading: function() {
$popup.removeClass(className.loading);
},
+ variation: function(variation) {
+ variation = variation || module.get.variation();
+ if(variation) {
+ module.verbose('Removing variation', variation);
+ $popup.removeClass(variation);
+ }
+ },
visible: function() {
$module.removeClass(className.visible);
},
@@ -6472,32 +10494,62 @@ $.fn.popup = function(parameters) {
},
bind: {
+ events: function() {
+ module.debug('Binding popup events to module');
+ if(settings.on == 'click') {
+ $module
+ .on('click' + eventNamespace, module.toggle)
+ ;
+ }
+ if(settings.on == 'hover' && hasTouch) {
+ $module
+ .on('touchstart' + eventNamespace, module.event.touchstart)
+ ;
+ }
+ if( module.get.startEvent() ) {
+ $module
+ .on(module.get.startEvent() + eventNamespace, module.event.start)
+ .on(module.get.endEvent() + eventNamespace, module.event.end)
+ ;
+ }
+ if(settings.target) {
+ module.debug('Target set to element', $target);
+ }
+ $window.on('resize' + elementNamespace, module.event.resize);
+ },
popup: function() {
module.verbose('Allowing hover events on popup to prevent closing');
- if($popup && $popup.size() > 0) {
+ if( $popup && module.has.popup() ) {
$popup
.on('mouseenter' + eventNamespace, module.event.start)
.on('mouseleave' + eventNamespace, module.event.end)
;
}
},
- close:function() {
- if(settings.hideOnScroll === true || settings.hideOnScroll == 'auto' && settings.on != 'click') {
+ close: function() {
+ if(settings.hideOnScroll === true || (settings.hideOnScroll == 'auto' && settings.on != 'click')) {
$document
- .one('touchmove' + eventNamespace, module.hideGracefully)
- .one('scroll' + eventNamespace, module.hideGracefully)
+ .one(module.get.scrollEvent() + elementNamespace, module.event.hideGracefully)
;
$context
- .one('touchmove' + eventNamespace, module.hideGracefully)
- .one('scroll' + eventNamespace, module.hideGracefully)
+ .one(module.get.scrollEvent() + elementNamespace, module.event.hideGracefully)
+ ;
+ }
+ if(settings.on == 'hover' && openedWithTouch) {
+ module.verbose('Binding popup close event to document');
+ $document
+ .on('touchstart' + elementNamespace, function(event) {
+ module.verbose('Touched away from popup');
+ module.event.hideGracefully.call(element, event);
+ })
;
}
if(settings.on == 'click' && settings.closable) {
module.verbose('Binding popup close event to document');
$document
- .on('click' + eventNamespace, function(event) {
- module.verbose('Pop-up clickaway intent detected');
- $.proxy(module.hideGracefully, element)(event);
+ .on('click' + elementNamespace, function(event) {
+ module.verbose('Clicked away from popup');
+ module.event.hideGracefully.call(element, event);
})
;
}
@@ -6506,44 +10558,80 @@ $.fn.popup = function(parameters) {
unbind: {
close: function() {
- if(settings.hideOnScroll === true || settings.hideOnScroll == 'auto' && settings.on != 'click') {
+ if(settings.hideOnScroll === true || (settings.hideOnScroll == 'auto' && settings.on != 'click')) {
$document
- .off('scroll' + eventNamespace, module.hide)
+ .off('scroll' + elementNamespace, module.hide)
;
$context
- .off('scroll' + eventNamespace, module.hide)
+ .off('scroll' + elementNamespace, module.hide)
+ ;
+ }
+ if(settings.on == 'hover' && openedWithTouch) {
+ $document
+ .off('touchstart' + elementNamespace)
;
+ openedWithTouch = false;
}
if(settings.on == 'click' && settings.closable) {
module.verbose('Removing close event from document');
$document
- .off('click' + eventNamespace)
+ .off('click' + elementNamespace)
;
}
}
},
+ has: {
+ popup: function() {
+ return ($popup && $popup.length > 0);
+ }
+ },
+
is: {
+ offstage: function(distanceFromBoundary, position) {
+ var
+ offstage = []
+ ;
+ // return boundaries that have been surpassed
+ $.each(distanceFromBoundary, function(direction, distance) {
+ if(distance < -settings.jitter) {
+ module.debug('Position exceeds allowable distance from edge', direction, distance, position);
+ offstage.push(direction);
+ }
+ });
+ if(offstage.length > 0) {
+ return true;
+ }
+ else {
+ return false;
+ }
+ },
active: function() {
return $module.hasClass(className.active);
},
animating: function() {
- return ( $popup && $popup.is(':animated') || $popup.hasClass(className.animating) );
+ return ( $popup && $popup.hasClass(className.animating) );
+ },
+ fluid: function() {
+ return ( $popup && $popup.hasClass(className.fluid));
},
visible: function() {
- return $popup && $popup.is(':visible');
+ return $popup && $popup.hasClass(className.visible);
},
dropdown: function() {
return $module.hasClass(className.dropdown);
},
hidden: function() {
return !module.is.visible();
+ },
+ rtl: function () {
+ return $module.css('direction') == 'rtl';
}
},
reset: function() {
module.remove.visible();
- if(settings.preserve || settings.popup) {
+ if(settings.preserve) {
if($.fn.transition !== undefined) {
$popup
.transition('remove transition')
@@ -6623,7 +10711,7 @@ $.fn.popup = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -6717,7 +10805,7 @@ $.fn.popup = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
@@ -6734,62 +10822,122 @@ $.fn.popup.settings = {
name : 'Popup',
+ // module settings
debug : false,
- verbose : true,
+ verbose : false,
performance : true,
namespace : 'popup',
+ // callback only when element added to dom
onCreate : function(){},
+
+ // callback before element removed from dom
onRemove : function(){},
+ // callback before show animation
onShow : function(){},
+
+ // callback after show animation
onVisible : function(){},
+
+ // callback before hide animation
onHide : function(){},
+
+ // callback after hide animation
onHidden : function(){},
+ // when to show popup
+ on : 'hover',
+
+ // whether to add touchstart events when using hover
+ addTouchEvents : true,
+
+ // default position relative to element
+ position : 'top left',
+
+ // name of variation to use
variation : '',
+
+ // whether popup should be moved to context
+ movePopup : true,
+
+ // element which popup should be relative to
+ target : false,
+
+ // jq selector or element that should be used as popup
+ popup : false,
+
+ // popup should remain inline next to activator
+ inline : false,
+
+ // popup should be removed from page on hide
+ preserve : false,
+
+ // popup should not close when being hovered on
+ hoverable : false,
+
+ // explicitly set content
content : false,
+
+ // explicitly set html
html : false,
+
+ // explicitly set title
title : false,
- on : 'hover',
+ // whether automatically close on clickaway when on click
closable : true,
+
+ // automatically hide on scroll
hideOnScroll : 'auto',
+ // hide other popups on show
+ exclusive : false,
+
+ // context to attach popups
context : 'body',
- position : 'top left',
+ // position to prefer when calculating new position
prefer : 'opposite',
+
+ // specify position to appear even if it doesn't fit
lastResort : false,
+ // delay used to prevent accidental refiring of animations due to user error
delay : {
- show : 30,
- hide : 0
+ show : 50,
+ hide : 70
},
+ // whether fluid variation should assign width explicitly
setFluidWidth : true,
- target : false,
- popup : false,
- inline : false,
- preserve : true,
- hoverable : false,
-
+ // transition settings
duration : 200,
- easing : 'easeOutQuint',
transition : 'scale',
+ // distance away from activating element in px
distanceAway : 0,
+
+ // number of pixels an element is allowed to be "offstage" for a position to be chosen (allows for rounding)
+ jitter : 2,
+
+ // offset on aligning axis from calculated position
offset : 0,
- maxSearchDepth : 20,
+
+ // maximum times to look for a position before failing (9 positions total)
+ maxSearchDepth : 15,
error: {
invalidPosition : 'The position you specified is not a valid position',
- cannotPlace : 'No visible position could be found for the popup',
- method : 'The method you called is not defined.'
+ cannotPlace : 'Popup does not fit within the boundaries of the viewport',
+ method : 'The method you called is not defined.',
+ noTransition : 'This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>',
+ notFound : 'The target or popup you specified does not exist on the page'
},
metadata: {
+ activator : 'activator',
content : 'content',
html : 'html',
offset : 'offset',
@@ -6856,22 +11004,15 @@ $.fn.popup.settings = {
};
-// Adds easing
-$.extend( $.easing, {
- easeOutQuad: function (x, t, b, c, d) {
- return -c *(t/=d)*(t-2) + b;
- }
-});
+})( jQuery, window, document );
-})( jQuery, window , document );
-
-/*
- * # Semantic - Progress
+/*!
+ * # Semantic UI 2.1.6 - Progress
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -6920,15 +11061,23 @@ $.fn.progress = function(parameters) {
element = this,
instance = $module.data(moduleNamespace),
+
+ animating = false,
+ transitionEnd,
module
;
module = {
initialize: function() {
- module.debug('Initializing progress', settings);
+ module.debug('Initializing progress bar', settings);
+
+ module.set.duration();
+ module.set.transitionEvent();
+
module.read.metadata();
- module.set.initials();
+ module.read.settings();
+
module.instantiate();
},
@@ -6939,9 +11088,9 @@ $.fn.progress = function(parameters) {
.data(moduleNamespace, module)
;
},
-
destroy: function() {
module.verbose('Destroying previous progress for', $module);
+ clearInterval(instance.interval);
module.remove.state();
$module.removeData(moduleNamespace);
instance = undefined;
@@ -6949,6 +11098,7 @@ $.fn.progress = function(parameters) {
reset: function() {
module.set.percent(0);
+ module.set.value(0);
},
complete: function() {
@@ -6959,111 +11109,187 @@ $.fn.progress = function(parameters) {
read: {
metadata: function() {
- if( $module.data(metadata.percent) ) {
- module.verbose('Current percent value set from metadata');
- module.percent = $module.data(metadata.percent);
+ var
+ data = {
+ percent : $module.data(metadata.percent),
+ total : $module.data(metadata.total),
+ value : $module.data(metadata.value)
+ }
+ ;
+ if(data.percent) {
+ module.debug('Current percent value set from metadata', data.percent);
+ module.set.percent(data.percent);
}
- if( $module.data(metadata.total) ) {
- module.verbose('Total value set from metadata');
- module.total = $module.data(metadata.total);
+ if(data.total) {
+ module.debug('Total value set from metadata', data.total);
+ module.set.total(data.total);
}
- if( $module.data(metadata.value) ) {
- module.verbose('Current value set from metadata');
- module.value = $module.data(metadata.value);
+ if(data.value) {
+ module.debug('Current value set from metadata', data.value);
+ module.set.value(data.value);
+ module.set.progress(data.value);
}
},
- currentValue: function() {
- return (module.value !== undefined)
- ? module.value
- : false
- ;
+ settings: function() {
+ if(settings.total !== false) {
+ module.debug('Current total set in settings', settings.total);
+ module.set.total(settings.total);
+ }
+ if(settings.value !== false) {
+ module.debug('Current value set in settings', settings.value);
+ module.set.value(settings.value);
+ module.set.progress(module.value);
+ }
+ if(settings.percent !== false) {
+ module.debug('Current percent set in settings', settings.percent);
+ module.set.percent(settings.percent);
+ }
}
},
increment: function(incrementValue) {
var
- total = module.total || false,
- edgeValue,
+ maxValue,
startValue,
newValue
;
- if(total) {
- startValue = module.value || 0;
+ if( module.has.total() ) {
+ startValue = module.get.value();
incrementValue = incrementValue || 1;
+
newValue = startValue + incrementValue;
- edgeValue = module.total;
- module.debug('Incrementing value by', incrementValue, startValue, edgeValue);
- if(newValue > edgeValue ) {
- module.debug('Value cannot increment above total', edgeValue);
- newValue = edgeValue;
+ maxValue = module.get.total();
+
+ module.debug('Incrementing value', startValue, newValue, maxValue);
+ if(newValue > maxValue ) {
+ module.debug('Value cannot increment above total', maxValue);
+ newValue = maxValue;
}
- module.set.progress(newValue);
}
else {
- startValue = module.percent || 0;
+ startValue = module.get.percent();
incrementValue = incrementValue || module.get.randomValue();
+
newValue = startValue + incrementValue;
- edgeValue = 100;
- module.debug('Incrementing percentage by', incrementValue, startValue);
- if(newValue > edgeValue ) {
+ maxValue = 100;
+
+ module.debug('Incrementing percentage by', startValue, newValue);
+ if(newValue > maxValue ) {
module.debug('Value cannot increment above 100 percent');
- newValue = edgeValue;
+ newValue = maxValue;
}
- module.set.progress(newValue);
}
+ module.set.progress(newValue);
},
decrement: function(decrementValue) {
var
- total = module.total || false,
- edgeValue = 0,
+ total = module.get.total(),
startValue,
newValue
;
if(total) {
- startValue = module.value || 0;
+ startValue = module.get.value();
decrementValue = decrementValue || 1;
newValue = startValue - decrementValue;
module.debug('Decrementing value by', decrementValue, startValue);
}
else {
- startValue = module.percent || 0;
+ startValue = module.get.percent();
decrementValue = decrementValue || module.get.randomValue();
newValue = startValue - decrementValue;
module.debug('Decrementing percentage by', decrementValue, startValue);
}
- if(newValue < edgeValue) {
+ if(newValue < 0) {
module.debug('Value cannot decrement below 0');
newValue = 0;
}
module.set.progress(newValue);
},
+ has: {
+ total: function() {
+ return (module.get.total() !== false);
+ }
+ },
+
get: {
text: function(templateText) {
var
- value = module.value || 0,
- total = module.total || 0,
- percent = module.percent || 0
+ value = module.value || 0,
+ total = module.total || 0,
+ percent = (animating)
+ ? module.get.displayPercent()
+ : module.percent || 0,
+ left = (module.total > 0)
+ ? (total - value)
+ : (100 - percent)
;
templateText = templateText || '';
templateText = templateText
.replace('{value}', value)
.replace('{total}', total)
+ .replace('{left}', left)
.replace('{percent}', percent)
;
module.debug('Adding variables to progress bar text', templateText);
return templateText;
},
+
+
randomValue: function() {
module.debug('Generating random increment percentage');
return Math.floor((Math.random() * settings.random.max) + settings.random.min);
},
+
+ numericValue: function(value) {
+ return (typeof value === 'string')
+ ? (value.replace(/[^\d.]/g, '') !== '')
+ ? +(value.replace(/[^\d.]/g, ''))
+ : false
+ : value
+ ;
+ },
+
+ transitionEnd: function() {
+ var
+ element = document.createElement('element'),
+ transitions = {
+ 'transition' :'transitionend',
+ 'OTransition' :'oTransitionEnd',
+ 'MozTransition' :'transitionend',
+ 'WebkitTransition' :'webkitTransitionEnd'
+ },
+ transition
+ ;
+ for(transition in transitions){
+ if( element.style[transition] !== undefined ){
+ return transitions[transition];
+ }
+ }
+ },
+
+ // gets current displayed percentage (if animating values this is the intermediary value)
+ displayPercent: function() {
+ var
+ barWidth = $bar.width(),
+ totalWidth = $module.width(),
+ minDisplay = parseInt($bar.css('min-width'), 10),
+ displayPercent = (barWidth > minDisplay)
+ ? (barWidth / totalWidth * 100)
+ : module.percent
+ ;
+ return (settings.precision > 0)
+ ? Math.round(displayPercent * (10 * settings.precision)) / (10 * settings.precision)
+ : Math.round(displayPercent)
+ ;
+ },
+
percent: function() {
return module.percent || 0;
},
value: function() {
- return module.value || false;
+ return module.value || 0;
},
total: function() {
return module.total || false;
@@ -7079,6 +11305,12 @@ $.fn.progress = function(parameters) {
},
error: function() {
return $module.hasClass(className.error);
+ },
+ active: function() {
+ return $module.hasClass(className.active);
+ },
+ visible: function() {
+ return $module.is(':visible');
}
},
@@ -7119,80 +11351,104 @@ $.fn.progress = function(parameters) {
$bar
.css('width', value + '%')
;
+ $module
+ .attr('data-percent', parseInt(value, 10))
+ ;
}
},
- initials: function() {
-
- if(settings.total !== false) {
- module.verbose('Current total set in settings', settings.total);
- module.total = settings.total;
- }
- if(settings.value !== false) {
- module.verbose('Current value set in settings', settings.value);
- module.value = settings.value;
- }
- if(settings.percent !== false) {
- module.verbose('Current percent set in settings', settings.percent);
- module.percent = settings.percent;
- }
-
- if(module.percent !== undefined) {
- module.set.percent(module.percent);
- }
- else if(module.value !== undefined) {
- module.set.progress(module.value);
- }
+ duration: function(duration) {
+ duration = duration || settings.duration;
+ duration = (typeof duration == 'number')
+ ? duration + 'ms'
+ : duration
+ ;
+ module.verbose('Setting progress bar transition duration', duration);
+ $bar
+ .css({
+ 'transition-duration': duration
+ })
+ ;
},
percent: function(percent) {
percent = (typeof percent == 'string')
? +(percent.replace('%', ''))
: percent
;
- if(percent > 0 && percent < 1) {
- module.verbose('Module percentage passed as decimal, converting');
- percent = percent * 100;
- }
- // round percentage
- if(settings.precision === 0) {
- percent = Math.round(percent);
- }
- else {
- percent = Math.round(percent * (10 * settings.precision) / (10 * settings.precision) );
- }
+ // round display percentage
+ percent = (settings.precision > 0)
+ ? Math.round(percent * (10 * settings.precision)) / (10 * settings.precision)
+ : Math.round(percent)
+ ;
module.percent = percent;
- if(module.total) {
- module.value = Math.round( (percent / 100) * module.total);
- }
- if(settings.limitValues) {
- module.value = (module.value > 100)
- ? 100
- : (module.value < 0)
- ? 0
- : module.value
+ if( !module.has.total() ) {
+ module.value = (settings.precision > 0)
+ ? Math.round( (percent / 100) * module.total * (10 * settings.precision)) / (10 * settings.precision)
+ : Math.round( (percent / 100) * module.total * 10) / 10
;
+ if(settings.limitValues) {
+ module.value = (module.value > 100)
+ ? 100
+ : (module.value < 0)
+ ? 0
+ : module.value
+ ;
+ }
}
module.set.barWidth(percent);
+ module.set.labelInterval();
+ module.set.labels();
+ settings.onChange.call(element, percent, module.value, module.total);
+ },
+ labelInterval: function() {
+ var
+ animationCallback = function() {
+ module.verbose('Bar finished animating, removing continuous label updates');
+ clearInterval(module.interval);
+ animating = false;
+ module.set.labels();
+ }
+ ;
+ clearInterval(module.interval);
+ $bar.one(transitionEnd + eventNamespace, animationCallback);
+ module.timer = setTimeout(animationCallback, settings.duration + 100);
+ animating = true;
+ module.interval = setInterval(module.set.labels, settings.framerate);
+ },
+ labels: function() {
+ module.verbose('Setting both bar progress and outer label text');
module.set.barLabel();
+ module.set.state();
+ },
+ label: function(text) {
+ text = text || '';
+ if(text) {
+ text = module.get.text(text);
+ module.debug('Setting label to text', text);
+ $label.text(text);
+ }
+ },
+ state: function(percent) {
+ percent = (percent !== undefined)
+ ? percent
+ : module.percent
+ ;
if(percent === 100) {
if(settings.autoSuccess && !(module.is.warning() || module.is.error())) {
module.set.success();
module.debug('Automatically triggering success at 100%');
}
else {
+ module.verbose('Reached 100% removing active state');
module.remove.active();
}
}
else if(percent > 0) {
+ module.verbose('Adjusting active progress bar label', percent);
module.set.active();
}
- $.proxy(settings.onChange, element)(percent, module.value, module.total);
- },
- label: function(text) {
- text = text || '';
- if(text) {
- text = module.get.text(text);
- module.debug('Setting label to text', text);
- $label.text(text);
+ else {
+ module.remove.active();
+ module.set.label(settings.text.active);
}
},
barLabel: function(text) {
@@ -7211,7 +11467,7 @@ $.fn.progress = function(parameters) {
active: function(text) {
text = text || settings.text.active;
module.debug('Setting active state');
- if(settings.showActivity) {
+ if(settings.showActivity && !module.is.active() ) {
$module.addClass(className.active);
}
module.remove.warning();
@@ -7220,7 +11476,7 @@ $.fn.progress = function(parameters) {
if(text) {
module.set.label(text);
}
- $.proxy(settings.onActive, element)(module.value, module.total);
+ settings.onActive.call(element, module.value, module.total);
},
success : function(text) {
text = text || settings.text.success;
@@ -7233,7 +11489,7 @@ $.fn.progress = function(parameters) {
if(text) {
module.set.label(text);
}
- $.proxy(settings.onSuccess, element)(module.total);
+ settings.onSuccess.call(element, module.total);
},
warning : function(text) {
text = text || settings.text.warning;
@@ -7246,7 +11502,7 @@ $.fn.progress = function(parameters) {
if(text) {
module.set.label(text);
}
- $.proxy(settings.onWarning, element)(module.value, module.total);
+ settings.onWarning.call(element, module.value, module.total);
},
error : function(text) {
text = text || settings.text.error;
@@ -7259,25 +11515,27 @@ $.fn.progress = function(parameters) {
if(text) {
module.set.label(text);
}
- $.proxy(settings.onError, element)(module.value, module.total);
+ settings.onError.call(element, module.value, module.total);
+ },
+ transitionEvent: function() {
+ transitionEnd = module.get.transitionEnd();
},
total: function(totalValue) {
module.total = totalValue;
},
+ value: function(value) {
+ module.value = value;
+ },
progress: function(value) {
var
- numericValue = (typeof value === 'string')
- ? (value.replace(/[^\d.]/g, '') !== '')
- ? +(value.replace(/[^\d.]/g, ''))
- : false
- : value,
+ numericValue = module.get.numericValue(value),
percentComplete
;
if(numericValue === false) {
module.error(error.nonNumeric, value);
}
- if(module.total) {
- module.value = numericValue;
+ if( module.has.total() ) {
+ module.set.value(numericValue);
percentComplete = (numericValue / module.total) * 100;
module.debug('Calculating percent complete from total', percentComplete);
module.set.percent( percentComplete );
@@ -7359,7 +11617,7 @@ $.fn.progress = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -7454,7 +11712,7 @@ $.fn.progress = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
@@ -7473,7 +11731,7 @@ $.fn.progress.settings = {
namespace : 'progress',
debug : false,
- verbose : true,
+ verbose : false,
performance : true,
random : {
@@ -7481,12 +11739,15 @@ $.fn.progress.settings = {
max : 5
},
+ duration : 300,
+
autoSuccess : true,
showActivity : true,
limitValues : true,
label : 'percent',
- precision : 1,
+ precision : 0,
+ framerate : (1000 / 30), /// 30 fps
percent : false,
total : false,
@@ -7540,13 +11801,13 @@ $.fn.progress.settings = {
};
-})( jQuery, window , document );
-/*
- * # Semantic - Rating
+})( jQuery, window, document );
+/*!
+ * # Semantic UI 2.1.6 - Rating
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -7599,7 +11860,7 @@ $.fn.rating = function(parameters) {
initialize: function() {
module.verbose('Initializing rating module', settings);
- if($icon.size() === 0) {
+ if($icon.length === 0) {
module.setup.layout();
}
@@ -7609,14 +11870,7 @@ $.fn.rating = function(parameters) {
else {
module.disable();
}
- if(settings.initialRating) {
- module.debug('Setting initial rating');
- module.setRating(settings.initialRating);
- }
- if( $module.data(metadata.rating) ) {
- module.debug('Rating found in metadata');
- module.setRating( $module.data(metadata.rating) );
- }
+ module.set.rating( module.get.initialRating() );
module.instantiate();
},
@@ -7630,12 +11884,10 @@ $.fn.rating = function(parameters) {
destroy: function() {
module.verbose('Destroying previous instance', instance);
+ module.remove.events();
$module
.removeData(moduleNamespace)
;
- $icon
- .off(eventNamespace)
- ;
},
refresh: function() {
@@ -7645,11 +11897,12 @@ $.fn.rating = function(parameters) {
setup: {
layout: function() {
var
- maxRating = $module.data(metadata.maxRating) || settings.maxRating
+ maxRating = module.get.maxRating(),
+ html = $.fn.rating.settings.templates.icon(maxRating)
;
module.debug('Generating icon html dynamically');
$module
- .html($.fn.rating.settings.templates.icon(maxRating))
+ .html(html)
;
module.refresh();
}
@@ -7684,41 +11937,49 @@ $.fn.rating = function(parameters) {
click: function() {
var
$activeIcon = $(this),
- currentRating = module.getRating(),
+ currentRating = module.get.rating(),
rating = $icon.index($activeIcon) + 1,
canClear = (settings.clearable == 'auto')
- ? ($icon.size() === 1)
+ ? ($icon.length === 1)
: settings.clearable
;
if(canClear && currentRating == rating) {
module.clearRating();
}
else {
- module.setRating( rating );
+ module.set.rating( rating );
}
}
},
clearRating: function() {
module.debug('Clearing current rating');
- module.setRating(0);
+ module.set.rating(0);
},
- getRating: function() {
- var
- currentRating = $icon.filter('.' + className.active).size()
- ;
- module.verbose('Current rating retrieved', currentRating);
- return currentRating;
+ bind: {
+ events: function() {
+ module.verbose('Binding events');
+ $module
+ .on('mouseenter' + eventNamespace, selector.icon, module.event.mouseenter)
+ .on('mouseleave' + eventNamespace, selector.icon, module.event.mouseleave)
+ .on('click' + eventNamespace, selector.icon, module.event.click)
+ ;
+ }
+ },
+
+ remove: {
+ events: function() {
+ module.verbose('Removing events');
+ $module
+ .off(eventNamespace)
+ ;
+ }
},
enable: function() {
module.debug('Setting rating to interactive mode');
- $icon
- .on('mouseenter' + eventNamespace, module.event.mouseenter)
- .on('mouseleave' + eventNamespace, module.event.mouseleave)
- .on('click' + eventNamespace, module.event.click)
- ;
+ module.bind.events();
$module
.removeClass(className.disabled)
;
@@ -7726,37 +11987,61 @@ $.fn.rating = function(parameters) {
disable: function() {
module.debug('Setting rating to read-only mode');
- $icon
- .off(eventNamespace)
- ;
+ module.remove.events();
$module
.addClass(className.disabled)
;
},
- setRating: function(rating) {
- var
- ratingIndex = (rating - 1 >= 0)
- ? (rating - 1)
- : 0,
- $activeIcon = $icon.eq(ratingIndex)
- ;
- $module
- .removeClass(className.selected)
- ;
- $icon
- .removeClass(className.selected)
- .removeClass(className.active)
- ;
- if(rating > 0) {
- module.verbose('Setting current rating to', rating);
- $activeIcon
- .prevAll()
- .andSelf()
- .addClass(className.active)
+ get: {
+ initialRating: function() {
+ if($module.data(metadata.rating) !== undefined) {
+ $module.removeData(metadata.rating);
+ return $module.data(metadata.rating);
+ }
+ return settings.initialRating;
+ },
+ maxRating: function() {
+ if($module.data(metadata.maxRating) !== undefined) {
+ $module.removeData(metadata.maxRating);
+ return $module.data(metadata.maxRating);
+ }
+ return settings.maxRating;
+ },
+ rating: function() {
+ var
+ currentRating = $icon.filter('.' + className.active).length
+ ;
+ module.verbose('Current rating retrieved', currentRating);
+ return currentRating;
+ }
+ },
+
+ set: {
+ rating: function(rating) {
+ var
+ ratingIndex = (rating - 1 >= 0)
+ ? (rating - 1)
+ : 0,
+ $activeIcon = $icon.eq(ratingIndex)
+ ;
+ $module
+ .removeClass(className.selected)
;
+ $icon
+ .removeClass(className.selected)
+ .removeClass(className.active)
+ ;
+ if(rating > 0) {
+ module.verbose('Setting current rating to', rating);
+ $activeIcon
+ .prevAll()
+ .andSelf()
+ .addClass(className.active)
+ ;
+ }
+ settings.onRate.call(element, rating);
}
- $.proxy(settings.onRate, element)(rating);
},
setting: function(name, value) {
@@ -7828,7 +12113,7 @@ $.fn.rating = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -7844,8 +12129,8 @@ $.fn.rating = function(parameters) {
if(moduleSelector) {
title += ' \'' + moduleSelector + '\'';
}
- if($allModules.size() > 1) {
- title += ' ' + '(' + $allModules.size() + ')';
+ if($allModules.length > 1) {
+ title += ' ' + '(' + $allModules.length + ')';
}
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
console.groupCollapsed(title);
@@ -7924,7 +12209,7 @@ $.fn.rating = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
@@ -7943,7 +12228,7 @@ $.fn.rating.settings = {
namespace : 'rating',
debug : false,
- verbose : true,
+ verbose : false,
performance : true,
initialRating : 0,
@@ -7991,14 +12276,14 @@ $.fn.rating.settings = {
};
-})( jQuery, window , document );
+})( jQuery, window, document );
-/*
- * # Semantic - Search
+/*!
+ * # Semantic UI 2.1.6 - Search
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -8024,9 +12309,14 @@ $.fn.search = function(parameters) {
$(this)
.each(function() {
var
- settings = $.extend(true, {}, $.fn.search.settings, parameters),
+ settings = ( $.isPlainObject(parameters) )
+ ? $.extend(true, {}, $.fn.search.settings, parameters)
+ : $.extend({}, $.fn.search.settings),
className = settings.className,
+ metadata = settings.metadata,
+ regExp = settings.regExp,
+ fields = settings.fields,
selector = settings.selector,
error = settings.error,
namespace = settings.namespace,
@@ -8046,36 +12336,15 @@ $.fn.search = function(parameters) {
module
;
+
module = {
initialize: function() {
module.verbose('Initializing module');
- var
- prompt = $prompt[0],
- inputEvent = (prompt !== undefined && prompt.oninput !== undefined)
- ? 'input'
- : (prompt !== undefined && prompt.onpropertychange !== undefined)
- ? 'propertychange'
- : 'keyup'
- ;
- if(settings.automatic) {
- $prompt
- .on(inputEvent + eventNamespace, module.search.throttle)
- ;
- }
- $prompt
- .on('focus' + eventNamespace, module.event.focus)
- .on('blur' + eventNamespace, module.event.blur)
- .on('keydown' + eventNamespace, module.handleKeyboard)
- ;
- $searchButton
- .on('click' + eventNamespace, module.search.query)
- ;
- $results
- .on('mousedown' + eventNamespace, module.event.mousedown)
- .on('mouseup' + eventNamespace, module.event.mouseup)
- .on('click' + eventNamespace, selector.result, module.results.select)
- ;
+ module.determine.searchFields();
+ module.bind.events();
+ module.set.type();
+ module.create.results();
module.instantiate();
},
instantiate: function() {
@@ -8088,76 +12357,145 @@ $.fn.search = function(parameters) {
destroy: function() {
module.verbose('Destroying instance');
$module
- .removeData(moduleNamespace)
- ;
- $prompt
- .off(eventNamespace)
- ;
- $searchButton
- .off(eventNamespace)
- ;
- $results
.off(eventNamespace)
+ .removeData(moduleNamespace)
;
},
- event: {
- focus: function() {
+
+ bind: {
+ events: function() {
+ module.verbose('Binding events to search');
+ if(settings.automatic) {
+ $module
+ .on(module.get.inputEvent() + eventNamespace, selector.prompt, module.event.input)
+ ;
+ $prompt
+ .attr('autocomplete', 'off')
+ ;
+ }
$module
- .addClass(className.focus)
+ // prompt
+ .on('focus' + eventNamespace, selector.prompt, module.event.focus)
+ .on('blur' + eventNamespace, selector.prompt, module.event.blur)
+ .on('keydown' + eventNamespace, selector.prompt, module.handleKeyboard)
+ // search button
+ .on('click' + eventNamespace, selector.searchButton, module.query)
+ // results
+ .on('mousedown' + eventNamespace, selector.results, module.event.result.mousedown)
+ .on('mouseup' + eventNamespace, selector.results, module.event.result.mouseup)
+ .on('click' + eventNamespace, selector.result, module.event.result.click)
;
- clearTimeout(module.timer);
- module.search.throttle();
- if(module.has.minimum()) {
- module.results.show();
+ }
+ },
+
+ determine: {
+ searchFields: function() {
+ // this makes sure $.extend does not add specified search fields to default fields
+ // this is the only setting which should not extend defaults
+ if(parameters && parameters.searchFields !== undefined) {
+ settings.searchFields = parameters.searchFields;
}
+ }
+ },
+
+ event: {
+ input: function() {
+ clearTimeout(module.timer);
+ module.timer = setTimeout(module.query, settings.searchDelay);
},
- mousedown: function() {
- module.resultsClicked = true;
- },
- mouseup: function() {
- module.resultsClicked = false;
+ focus: function() {
+ module.set.focus();
+ if( module.has.minimumCharacters() ) {
+ module.query();
+ if( module.can.show() ) {
+ module.showResults();
+ }
+ }
},
blur: function(event) {
- module.search.cancel();
- $module
- .removeClass(className.focus)
+ var
+ pageLostFocus = (document.activeElement === this)
;
- if(!module.resultsClicked) {
- module.timer = setTimeout(module.results.hide, settings.hideDelay);
+ if(!pageLostFocus && !module.resultsClicked) {
+ module.cancel.query();
+ module.remove.focus();
+ module.timer = setTimeout(module.hideResults, settings.hideDelay);
+ }
+ },
+ result: {
+ mousedown: function() {
+ module.resultsClicked = true;
+ },
+ mouseup: function() {
+ module.resultsClicked = false;
+ },
+ click: function(event) {
+ module.debug('Search result selected');
+ var
+ $result = $(this),
+ $title = $result.find(selector.title).eq(0),
+ $link = $result.find('a[href]').eq(0),
+ href = $link.attr('href') || false,
+ target = $link.attr('target') || false,
+ title = $title.html(),
+ // title is used for result lookup
+ value = ($title.length > 0)
+ ? $title.text()
+ : false,
+ results = module.get.results(),
+ result = $result.data(metadata.result) || module.get.result(value, results),
+ returnedValue
+ ;
+ if( $.isFunction(settings.onSelect) ) {
+ if(settings.onSelect.call(element, result, results) === false) {
+ module.debug('Custom onSelect callback cancelled default select action');
+ return;
+ }
+ }
+ module.hideResults();
+ if(value) {
+ module.set.value(value);
+ }
+ if(href) {
+ module.verbose('Opening search link found in result', $link);
+ if(target == '_blank' || event.ctrlKey) {
+ window.open(href);
+ }
+ else {
+ window.location.href = (href);
+ }
+ }
}
}
},
handleKeyboard: function(event) {
var
- // force latest jq dom
- $result = $module.find(selector.result),
- $category = $module.find(selector.category),
- keyCode = event.which,
- keys = {
+ // force selector refresh
+ $result = $module.find(selector.result),
+ $category = $module.find(selector.category),
+ currentIndex = $result.index( $result.filter('.' + className.active) ),
+ resultSize = $result.length,
+
+ keyCode = event.which,
+ keys = {
backspace : 8,
enter : 13,
escape : 27,
upArrow : 38,
downArrow : 40
},
- activeClass = className.active,
- currentIndex = $result.index( $result.filter('.' + activeClass) ),
- resultSize = $result.size(),
newIndex
;
// search shortcuts
if(keyCode == keys.escape) {
module.verbose('Escape key pressed, blurring search field');
- $prompt
- .trigger('blur')
- ;
+ module.trigger.blur();
}
- // result shortcuts
- if($results.filter(':visible').size() > 0) {
+ if( module.is.visible() ) {
if(keyCode == keys.enter) {
module.verbose('Enter key pressed, selecting active result');
- if( $result.filter('.' + activeClass).size() > 0 ) {
- $.proxy(module.results.select, $result.filter('.' + activeClass) )(event);
+ if( $result.filter('.' + className.active).length > 0 ) {
+ module.event.result.click.call($result.filter('.' + className.active), event);
event.preventDefault();
return false;
}
@@ -8169,14 +12507,14 @@ $.fn.search = function(parameters) {
: currentIndex - 1
;
$category
- .removeClass(activeClass)
+ .removeClass(className.active)
;
$result
- .removeClass(activeClass)
+ .removeClass(className.active)
.eq(newIndex)
- .addClass(activeClass)
+ .addClass(className.active)
.closest($category)
- .addClass(activeClass)
+ .addClass(className.active)
;
event.preventDefault();
}
@@ -8187,14 +12525,14 @@ $.fn.search = function(parameters) {
: currentIndex + 1
;
$category
- .removeClass(activeClass)
+ .removeClass(className.active)
;
$result
- .removeClass(activeClass)
+ .removeClass(className.active)
.eq(newIndex)
- .addClass(activeClass)
+ .addClass(className.active)
.closest($category)
- .addClass(activeClass)
+ .addClass(className.active)
;
event.preventDefault();
}
@@ -8203,280 +12541,606 @@ $.fn.search = function(parameters) {
// query shortcuts
if(keyCode == keys.enter) {
module.verbose('Enter key pressed, executing query');
- module.search.query();
- $searchButton
- .addClass(className.down)
- ;
- $prompt
- .one('keyup', function(){
- $searchButton
- .removeClass(className.down)
- ;
- })
- ;
+ module.query();
+ module.set.buttonPressed();
+ $prompt.one('keyup', module.remove.buttonFocus);
}
}
},
- has: {
- minimum: function() {
+
+ setup: {
+ api: function() {
var
- searchTerm = $prompt.val(),
- numCharacters = searchTerm.length
+ apiSettings = {
+ debug : settings.debug,
+ on : false,
+ cache : 'local',
+ action : 'search',
+ onError : module.error
+ },
+ searchHTML
;
- return (numCharacters >= settings.minCharacters);
+ module.verbose('First request, initializing API');
+ $module.api(apiSettings);
}
},
- search: {
- cancel: function() {
+
+ can: {
+ useAPI: function() {
+ return $.fn.api !== undefined;
+ },
+ show: function() {
+ return module.is.focused() && !module.is.visible() && !module.is.empty();
+ },
+ transition: function() {
+ return settings.transition && $.fn.transition !== undefined && $module.transition('is supported');
+ }
+ },
+
+ is: {
+ empty: function() {
+ return ($results.html() === '');
+ },
+ visible: function() {
+ return ($results.filter(':visible').length > 0);
+ },
+ focused: function() {
+ return ($prompt.filter(':focus').length > 0);
+ }
+ },
+
+ trigger: {
+ blur: function() {
var
- xhr = $module.data('xhr') || false
+ events = document.createEvent('HTMLEvents'),
+ promptElement = $prompt[0]
;
- if( xhr && xhr.state() != 'resolved') {
- module.debug('Cancelling last search');
- xhr.abort();
+ if(promptElement) {
+ module.verbose('Triggering native blur event');
+ events.initEvent('blur', false, false);
+ promptElement.dispatchEvent(events);
}
+ }
+ },
+
+ get: {
+ inputEvent: function() {
+ var
+ prompt = $prompt[0],
+ inputEvent = (prompt !== undefined && prompt.oninput !== undefined)
+ ? 'input'
+ : (prompt !== undefined && prompt.onpropertychange !== undefined)
+ ? 'propertychange'
+ : 'keyup'
+ ;
+ return inputEvent;
},
- throttle: function() {
- clearTimeout(module.timer);
- if(module.has.minimum()) {
- module.timer = setTimeout(module.search.query, settings.searchDelay);
+ value: function() {
+ return $prompt.val();
+ },
+ results: function() {
+ var
+ results = $module.data(metadata.results)
+ ;
+ return results;
+ },
+ result: function(value, results) {
+ var
+ lookupFields = ['title', 'id'],
+ result = false
+ ;
+ value = (value !== undefined)
+ ? value
+ : module.get.value()
+ ;
+ results = (results !== undefined)
+ ? results
+ : module.get.results()
+ ;
+ if(settings.type === 'category') {
+ module.debug('Finding result that matches', value);
+ $.each(results, function(index, category) {
+ if($.isArray(category.results)) {
+ result = module.search.object(value, category.results, lookupFields)[0];
+ // don't continue searching if a result is found
+ if(result) {
+ return false;
+ }
+ }
+ });
}
else {
- module.results.hide();
+ module.debug('Finding result in results object', value);
+ result = module.search.object(value, results, lookupFields)[0];
}
+ return result || false;
},
- query: function() {
- var
- searchTerm = $prompt.val(),
- cachedHTML = module.search.cache.read(searchTerm)
+ },
+
+ set: {
+ focus: function() {
+ $module.addClass(className.focus);
+ },
+ loading: function() {
+ $module.addClass(className.loading);
+ },
+ value: function(value) {
+ module.verbose('Setting search input value', value);
+ $prompt
+ .val(value)
;
- if(cachedHTML) {
- module.debug("Reading result for '" + searchTerm + "' from cache");
- module.results.add(cachedHTML);
+ },
+ type: function(type) {
+ type = type || settings.type;
+ if(settings.type == 'category') {
+ $module.addClass(settings.type);
+ }
+ },
+ buttonPressed: function() {
+ $searchButton.addClass(className.pressed);
+ }
+ },
+
+ remove: {
+ loading: function() {
+ $module.removeClass(className.loading);
+ },
+ focus: function() {
+ $module.removeClass(className.focus);
+ },
+ buttonPressed: function() {
+ $searchButton.removeClass(className.pressed);
+ }
+ },
+
+ query: function() {
+ var
+ searchTerm = module.get.value(),
+ cache = module.read.cache(searchTerm)
+ ;
+ if( module.has.minimumCharacters() ) {
+ if(cache) {
+ module.debug('Reading result from cache', searchTerm);
+ module.save.results(cache.results);
+ module.addResults(cache.html);
+ module.inject.id(cache.results);
}
else {
- module.debug("Querying for '" + searchTerm + "'");
+ module.debug('Querying for', searchTerm);
if($.isPlainObject(settings.source) || $.isArray(settings.source)) {
module.search.local(searchTerm);
}
- else if(settings.apiSettings) {
- module.search.remote(searchTerm);
- }
- else if($.fn.api !== undefined && $.api.settings.api.search !== undefined) {
- module.debug('Searching with default search API endpoint');
- settings.apiSettings = {
- action: 'search'
- };
+ else if( module.can.useAPI() ) {
module.search.remote(searchTerm);
}
else {
module.error(error.source);
}
- $.proxy(settings.onSearchQuery, $module)(searchTerm);
}
- },
+ settings.onSearchQuery.call(element, searchTerm);
+ }
+ else {
+ module.hideResults();
+ }
+ },
+
+ search: {
local: function(searchTerm) {
var
- results = [],
- fullTextResults = [],
- searchFields = $.isArray(settings.searchFields)
- ? settings.searchFields
- : [settings.searchFields],
- searchRegExp = new RegExp('(?:\s|^)' + searchTerm, 'i'),
- fullTextRegExp = new RegExp(searchTerm, 'i'),
+ results = module.search.object(searchTerm, settings.content),
searchHTML
;
+ module.set.loading();
+ module.save.results(results);
+ module.debug('Returned local search results', results);
+
+ searchHTML = module.generateResults({
+ results: results
+ });
+ module.remove.loading();
+ module.addResults(searchHTML);
+ module.inject.id(results);
+ module.write.cache(searchTerm, {
+ html : searchHTML,
+ results : results
+ });
+ },
+ remote: function(searchTerm) {
+ var
+ apiSettings = {
+ onSuccess : function(response) {
+ module.parse.response.call(element, response, searchTerm);
+ },
+ onFailure: function() {
+ module.displayMessage(error.serverError);
+ },
+ urlData: {
+ query: searchTerm
+ }
+ }
+ ;
+ if( !$module.api('get request') ) {
+ module.setup.api();
+ }
+ $.extend(true, apiSettings, settings.apiSettings);
+ module.debug('Executing search', apiSettings);
+ module.cancel.query();
$module
- .addClass(className.loading)
+ .api('setting', apiSettings)
+ .api('query')
+ ;
+ },
+ object: function(searchTerm, source, searchFields) {
+ var
+ results = [],
+ fuzzyResults = [],
+ searchExp = searchTerm.toString().replace(regExp.escape, '\\$&'),
+ matchRegExp = new RegExp(regExp.beginsWith + searchExp, 'i'),
+
+ // avoid duplicates when pushing results
+ addResult = function(array, result) {
+ var
+ notResult = ($.inArray(result, results) == -1),
+ notFuzzyResult = ($.inArray(result, fuzzyResults) == -1)
+ ;
+ if(notResult && notFuzzyResult) {
+ array.push(result);
+ }
+ }
;
- // iterate through search fields in array order
+ source = source || settings.source;
+ searchFields = (searchFields !== undefined)
+ ? searchFields
+ : settings.searchFields
+ ;
+
+ // search fields should be array to loop correctly
+ if(!$.isArray(searchFields)) {
+ searchFields = [searchFields];
+ }
+
+ // exit conditions if no source
+ if(source === undefined || source === false) {
+ module.error(error.source);
+ return [];
+ }
+
+ // iterate through search fields looking for matches
$.each(searchFields, function(index, field) {
- $.each(settings.source, function(label, content) {
+ $.each(source, function(label, content) {
var
- fieldExists = (typeof content[field] == 'string'),
- notAlreadyResult = ($.inArray(content, results) == -1 && $.inArray(content, fullTextResults) == -1)
+ fieldExists = (typeof content[field] == 'string')
;
- if(fieldExists && notAlreadyResult) {
- if( searchRegExp.test( content[field] ) ) {
- results.push(content);
+ if(fieldExists) {
+ if( content[field].search(matchRegExp) !== -1) {
+ // content starts with value (first in results)
+ addResult(results, content);
}
- else if( settings.searchFullText && fullTextRegExp.test( content[field] ) ) {
- fullTextResults.push(content);
+ else if(settings.searchFullText && module.fuzzySearch(searchTerm, content[field]) ) {
+ // content fuzzy matches (last in results)
+ addResult(fuzzyResults, content);
}
}
});
});
- searchHTML = module.results.generate({
- results: $.merge(results, fullTextResults)
- });
- $module
- .removeClass(className.loading)
+ return $.merge(results, fuzzyResults);
+ }
+ },
+
+ fuzzySearch: function(query, term) {
+ var
+ termLength = term.length,
+ queryLength = query.length
+ ;
+ if(typeof query !== 'string') {
+ return false;
+ }
+ query = query.toLowerCase();
+ term = term.toLowerCase();
+ if(queryLength > termLength) {
+ return false;
+ }
+ if(queryLength === termLength) {
+ return (query === term);
+ }
+ search: for (var characterIndex = 0, nextCharacterIndex = 0; characterIndex < queryLength; characterIndex++) {
+ var
+ queryCharacter = query.charCodeAt(characterIndex)
;
- module.search.cache.write(searchTerm, searchHTML);
- module.results.add(searchHTML);
- },
- remote: function(searchTerm) {
+ while(nextCharacterIndex < termLength) {
+ if(term.charCodeAt(nextCharacterIndex++) === queryCharacter) {
+ continue search;
+ }
+ }
+ return false;
+ }
+ return true;
+ },
+
+ parse: {
+ response: function(response, searchTerm) {
var
- apiSettings = {
- stateContext : $module,
- urlData : {
- query: searchTerm
- },
- onSuccess : function(response) {
- searchHTML = module.results.generate(response);
- module.search.cache.write(searchTerm, searchHTML);
- module.results.add(searchHTML);
- },
- onFailure : module.error
- },
- searchHTML
+ searchHTML = module.generateResults(response)
+ ;
+ module.verbose('Parsing server response', response);
+ if(response !== undefined) {
+ if(searchTerm !== undefined && response[fields.results] !== undefined) {
+ module.addResults(searchHTML);
+ module.inject.id(response[fields.results]);
+ module.write.cache(searchTerm, {
+ html : searchHTML,
+ results : response[fields.results]
+ });
+ module.save.results(response[fields.results]);
+ }
+ }
+ }
+ },
+
+ cancel: {
+ query: function() {
+ if( module.can.useAPI() ) {
+ $module.api('abort');
+ }
+ }
+ },
+
+ has: {
+ minimumCharacters: function() {
+ var
+ searchTerm = module.get.value(),
+ numCharacters = searchTerm.length
;
- module.search.cancel();
- module.debug('Executing search');
- $.extend(true, apiSettings, settings.apiSettings);
- $.api(apiSettings);
- },
+ return (numCharacters >= settings.minCharacters);
+ }
+ },
- cache: {
- read: function(name) {
- var
- cache = $module.data('cache')
- ;
- return (settings.cache && (typeof cache == 'object') && (cache[name] !== undefined) )
+ clear: {
+ cache: function(value) {
+ var
+ cache = $module.data(metadata.cache)
+ ;
+ if(!value) {
+ module.debug('Clearing cache', value);
+ $module.removeData(metadata.cache);
+ }
+ else if(value && cache && cache[value]) {
+ module.debug('Removing value from cache', value);
+ delete cache[value];
+ $module.data(metadata.cache, cache);
+ }
+ }
+ },
+
+ read: {
+ cache: function(name) {
+ var
+ cache = $module.data(metadata.cache)
+ ;
+ if(settings.cache) {
+ module.verbose('Checking cache for generated html for query', name);
+ return (typeof cache == 'object') && (cache[name] !== undefined)
? cache[name]
: false
;
- },
- write: function(name, value) {
- var
- cache = ($module.data('cache') !== undefined)
- ? $module.data('cache')
- : {}
- ;
- cache[name] = value;
- $module
- .data('cache', cache)
- ;
}
+ return false;
}
},
- results: {
- generate: function(response) {
- module.debug('Generating html from response', response);
+ create: {
+ id: function(resultIndex, categoryIndex) {
var
- template = settings.templates[settings.type],
- html = ''
- ;
- if(($.isPlainObject(response.results) && !$.isEmptyObject(response.results)) || ($.isArray(response.results) && response.results.length > 0) ) {
- if(settings.maxResults > 0) {
- response.results = $.isArray(response.results)
- ? response.results.slice(0, settings.maxResults)
- : response.results
- ;
- }
- if($.isFunction(template)) {
- html = template(response);
- }
- else {
- module.error(error.noTemplate, false);
- }
+ resultID = (resultIndex + 1), // not zero indexed
+ categoryID = (categoryIndex + 1),
+ firstCharCode,
+ letterID,
+ id
+ ;
+ if(categoryIndex !== undefined) {
+ // start char code for "A"
+ letterID = String.fromCharCode(97 + categoryIndex);
+ id = letterID + resultID;
+ module.verbose('Creating category result id', id);
}
else {
- html = module.message(error.noResults, 'empty');
+ id = resultID;
+ module.verbose('Creating result id', id);
}
- $.proxy(settings.onResults, $module)(response);
- return html;
+ return id;
},
- add: function(html) {
- if(settings.onResultsAdd == 'default' || $.proxy(settings.onResultsAdd, $results)(html) == 'default') {
- $results
- .html(html)
+ results: function() {
+ if($results.length === 0) {
+ $results = $('<div />')
+ .addClass(className.results)
+ .appendTo($module)
;
}
- module.results.show();
+ }
+ },
+
+ inject: {
+ result: function(result, resultIndex, categoryIndex) {
+ module.verbose('Injecting result into results');
+ var
+ $selectedResult = (categoryIndex !== undefined)
+ ? $results
+ .children().eq(categoryIndex)
+ .children(selector.result).eq(resultIndex)
+ : $results
+ .children(selector.result).eq(resultIndex)
+ ;
+ module.verbose('Injecting results metadata', $selectedResult);
+ $selectedResult
+ .data(metadata.result, result)
+ ;
},
- show: function() {
- if( ($results.filter(':visible').size() === 0) && ($prompt.filter(':focus').size() > 0) && $results.html() !== '') {
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported') && !$results.transition('is inward')) {
- module.debug('Showing results with css animations');
- $results
- .transition({
- animation : settings.transition + ' in',
- duration : settings.duration,
- queue : true
- })
- ;
- }
- else {
- module.debug('Showing results with javascript');
- $results
- .stop()
- .fadeIn(settings.duration, settings.easing)
- ;
- }
- $.proxy(settings.onResultsOpen, $results)();
+ id: function(results) {
+ module.debug('Injecting unique ids into results');
+ var
+ // since results may be object, we must use counters
+ categoryIndex = 0,
+ resultIndex = 0
+ ;
+ if(settings.type === 'category') {
+ // iterate through each category result
+ $.each(results, function(index, category) {
+ resultIndex = 0;
+ $.each(category.results, function(index, value) {
+ var
+ result = category.results[index]
+ ;
+ if(result.id === undefined) {
+ result.id = module.create.id(resultIndex, categoryIndex);
+ }
+ module.inject.result(result, resultIndex, categoryIndex);
+ resultIndex++;
+ });
+ categoryIndex++;
+ });
}
- },
- hide: function() {
- if($results.filter(':visible').size() > 0) {
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported') && !$results.transition('is outward')) {
- module.debug('Hiding results with css animations');
- $results
- .transition({
- animation : settings.transition + ' out',
- duration : settings.duration,
- queue : true
- })
- ;
- }
- else {
- module.debug('Hiding results with javascript');
- $results
- .stop()
- .fadeIn(settings.duration, settings.easing)
+ else {
+ // top level
+ $.each(results, function(index, value) {
+ var
+ result = results[index]
;
- }
- $.proxy(settings.onResultsClose, $results)();
+ if(result.id === undefined) {
+ result.id = module.create.id(resultIndex);
+ }
+ module.inject.result(result, resultIndex);
+ resultIndex++;
+ });
}
- },
- select: function(event) {
- module.debug('Search result selected');
+ return results;
+ }
+ },
+
+ save: {
+ results: function(results) {
+ module.verbose('Saving current search results to metadata', results);
+ $module.data(metadata.results, results);
+ }
+ },
+
+ write: {
+ cache: function(name, value) {
var
- $result = $(this),
- $title = $result.find('.title'),
- title = $title.html()
+ cache = ($module.data(metadata.cache) !== undefined)
+ ? $module.data(metadata.cache)
+ : {}
;
- if(settings.onSelect == 'default' || $.proxy(settings.onSelect, this)(event) == 'default') {
- var
- $link = $result.find('a[href]').eq(0),
- $title = $result.find(selector.title).eq(0),
- href = $link.attr('href') || false,
- target = $link.attr('target') || false,
- name = ($title.size() > 0)
- ? $title.text()
- : false
+ if(settings.cache) {
+ module.verbose('Writing generated html to cache', name, value);
+ cache[name] = value;
+ $module
+ .data(metadata.cache, cache)
;
- module.results.hide();
- if(name) {
- $prompt.val(name);
- }
- if(href) {
- if(target == '_blank' || event.ctrlKey) {
- window.open(href);
- }
- else {
- window.location.href = (href);
+ }
+ }
+ },
+
+ addResults: function(html) {
+ if( $.isFunction(settings.onResultsAdd) ) {
+ if( settings.onResultsAdd.call($results, html) === false ) {
+ module.debug('onResultsAdd callback cancelled default action');
+ return false;
+ }
+ }
+ $results
+ .html(html)
+ ;
+ if( module.can.show() ) {
+ module.showResults();
+ }
+ },
+
+ showResults: function() {
+ if(!module.is.visible()) {
+ if( module.can.transition() ) {
+ module.debug('Showing results with css animations');
+ $results
+ .transition({
+ animation : settings.transition + ' in',
+ debug : settings.debug,
+ verbose : settings.verbose,
+ duration : settings.duration,
+ queue : true
+ })
+ ;
+ }
+ else {
+ module.debug('Showing results with javascript');
+ $results
+ .stop()
+ .fadeIn(settings.duration, settings.easing)
+ ;
+ }
+ settings.onResultsOpen.call($results);
+ }
+ },
+ hideResults: function() {
+ if( module.is.visible() ) {
+ if( module.can.transition() ) {
+ module.debug('Hiding results with css animations');
+ $results
+ .transition({
+ animation : settings.transition + ' out',
+ debug : settings.debug,
+ verbose : settings.verbose,
+ duration : settings.duration,
+ queue : true
+ })
+ ;
+ }
+ else {
+ module.debug('Hiding results with javascript');
+ $results
+ .stop()
+ .fadeOut(settings.duration, settings.easing)
+ ;
+ }
+ settings.onResultsClose.call($results);
+ }
+ },
+
+ generateResults: function(response) {
+ module.debug('Generating html from response', response);
+ var
+ template = settings.templates[settings.type],
+ isProperObject = ($.isPlainObject(response[fields.results]) && !$.isEmptyObject(response[fields.results])),
+ isProperArray = ($.isArray(response[fields.results]) && response[fields.results].length > 0),
+ html = ''
+ ;
+ if(isProperObject || isProperArray ) {
+ if(settings.maxResults > 0) {
+ if(isProperObject) {
+ if(settings.type == 'standard') {
+ module.error(error.maxResults);
}
}
+ else {
+ response[fields.results] = response[fields.results].slice(0, settings.maxResults);
+ }
}
+ if($.isFunction(template)) {
+ html = template(response, fields);
+ }
+ else {
+ module.error(error.noTemplate, false);
+ }
+ }
+ else {
+ html = module.displayMessage(error.noResults, 'empty');
}
+ settings.onResults.call(element, response);
+ return html;
},
- // displays mesage visibly in search results
- message: function(text, type) {
+ displayMessage: function(text, type) {
type = type || 'standard';
- module.results.add( settings.templates.message(text, type) );
+ module.debug('Displaying message', text, type);
+ module.addResults( settings.templates.message(text, type) );
return settings.templates.message(text, type);
},
@@ -8548,7 +13212,7 @@ $.fn.search = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -8564,8 +13228,8 @@ $.fn.search = function(parameters) {
if(moduleSelector) {
title += ' \'' + moduleSelector + '\'';
}
- if($allModules.size() > 1) {
- title += ' ' + '(' + $allModules.size() + ')';
+ if($allModules.length > 1) {
+ title += ' ' + '(' + $allModules.length + ')';
}
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
console.groupCollapsed(title);
@@ -8618,7 +13282,7 @@ $.fn.search = function(parameters) {
}
});
}
- if ( $.isFunction( found ) ) {
+ if( $.isFunction( found ) ) {
response = found.apply(context, passedArguments);
}
else if(found !== undefined) {
@@ -8644,7 +13308,7 @@ $.fn.search = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
@@ -8660,40 +13324,62 @@ $.fn.search = function(parameters) {
$.fn.search.settings = {
- name : 'Search Module',
+ name : 'Search',
namespace : 'search',
debug : false,
- verbose : true,
+ verbose : false,
performance : true,
- // api config
- apiSettings : false,
type : 'standard',
+ // template to use (specified in settings.templates)
+
minCharacters : 1,
+ // minimum characters required to search
+
+ apiSettings : false,
+ // API config
source : false,
+ // object to search
+
searchFields : [
'title',
'description'
],
+ // fields to search
+
+ displayField : '',
+ // field to display in standard results template
+
searchFullText : true,
+ // whether to include fuzzy results in local search
+
+ automatic : true,
+ // whether to add events to prompt automatically
- automatic : 'true',
hideDelay : 0,
- searchDelay : 300,
+ // delay before hiding menu after blur
+
+ searchDelay : 200,
+ // delay before searching
+
maxResults : 7,
+ // maximum results returned from local
+
cache : true,
+ // whether to store lookups in local cache
+ // transition settings
transition : 'scale',
- duration : 300,
+ duration : 200,
easing : 'easeOutExpo',
- // onSelect default action is defined in module
- onSelect : 'default',
- onResultsAdd : 'default',
+ // callbacks
+ onSelect : false,
+ onResultsAdd : false,
- onSearchQuery : function(){},
+ onSearchQuery : function(query){},
onResults : function(response){},
onResultsOpen : function(){},
@@ -8701,21 +13387,51 @@ $.fn.search.settings = {
className: {
active : 'active',
- down : 'down',
- focus : 'focus',
empty : 'empty',
- loading : 'loading'
+ focus : 'focus',
+ loading : 'loading',
+ results : 'results',
+ pressed : 'down'
},
error : {
source : 'Cannot search. No source used, and Semantic API module was not included',
noResults : 'Your search returned no results',
logging : 'Error in debug logging, exiting.',
+ noEndpoint : 'No search endpoint was specified',
noTemplate : 'A valid template name was not specified.',
- serverError : 'There was an issue with querying the server.',
+ serverError : 'There was an issue querying the server.',
+ maxResults : 'Results must be an array to use maxResults setting',
method : 'The method you called is not defined.'
},
+ metadata: {
+ cache : 'cache',
+ results : 'results',
+ result : 'result'
+ },
+
+ regExp: {
+ escape : /[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,
+ beginsWith : '(?:\s|^)'
+ },
+
+ // maps api response attributes to internal representation
+ fields: {
+ categories : 'results', // array of categories (category view)
+ categoryName : 'name', // name of category (category view)
+ categoryResults : 'results', // array of results (category view)
+ description : 'description', // result description
+ image : 'image', // result image
+ price : 'price', // result price
+ results : 'results', // array of results (standard)
+ title : 'title', // result title
+ url : 'url', // result url
+ action : 'action', // "view more" object name
+ actionText : 'text', // "view more" text
+ actionURL : 'url' // "view more" url
+ },
+
selector : {
prompt : '.prompt',
searchButton : '.search.button',
@@ -8769,95 +13485,98 @@ $.fn.search.settings = {
}
return html;
},
- category: function(response) {
+ category: function(response, fields) {
var
html = '',
escape = $.fn.search.settings.templates.escape
;
- if(response.results !== undefined) {
+ if(response[fields.categoryResults] !== undefined) {
+
// each category
- $.each(response.results, function(index, category) {
- if(category.results !== undefined && category.results.length > 0) {
- html += ''
- + '<div class="category">'
- + '<div class="name">' + category.name + '</div>'
- ;
+ $.each(response[fields.categoryResults], function(index, category) {
+ if(category[fields.results] !== undefined && category.results.length > 0) {
+
+ html += '<div class="category">';
+
+ if(category[fields.categoryName] !== undefined) {
+ html += '<div class="name">' + category[fields.categoryName] + '</div>';
+ }
+
// each item inside category
$.each(category.results, function(index, result) {
- html += '<div class="result">';
- if(result.url) {
- html += '<a href="' + result.url + '"></a>';
+ if(result[fields.url]) {
+ html += '<a class="result" href="' + result[fields.url] + '">';
}
- if(result.image !== undefined) {
- result.image = escape(result.image);
+ else {
+ html += '<a class="result">';
+ }
+ if(result[fields.image] !== undefined) {
html += ''
+ '<div class="image">'
- + ' <img src="' + result.image + '" alt="">'
+ + ' <img src="' + result[fields.image] + '">'
+ '</div>'
;
}
html += '<div class="content">';
- if(result.price !== undefined) {
- result.price = escape(result.price);
- html += '<div class="price">' + result.price + '</div>';
+ if(result[fields.price] !== undefined) {
+ html += '<div class="price">' + result[fields.price] + '</div>';
}
- if(result.title !== undefined) {
- result.title = escape(result.title);
- html += '<div class="title">' + result.title + '</div>';
+ if(result[fields.title] !== undefined) {
+ html += '<div class="title">' + result[fields.title] + '</div>';
}
- if(result.description !== undefined) {
- html += '<div class="description">' + result.description + '</div>';
+ if(result[fields.description] !== undefined) {
+ html += '<div class="description">' + result[fields.description] + '</div>';
}
html += ''
+ '</div>'
- + '</div>'
;
+ html += '</a>';
});
html += ''
+ '</div>'
;
}
});
- if(response.action) {
+ if(response[fields.action]) {
html += ''
- + '<a href="' + response.action.url + '" class="action">'
- + response.action.text
+ + '<a href="' + response[fields.action][fields.actionURL] + '" class="action">'
+ + response[fields.action][fields.actionText]
+ '</a>';
}
return html;
}
return false;
},
- standard: function(response) {
+ standard: function(response, fields) {
var
html = ''
;
- if(response.results !== undefined) {
+ if(response[fields.results] !== undefined) {
// each result
- $.each(response.results, function(index, result) {
- if(result.url) {
- html += '<a class="result" href="' + result.url + '">';
+ $.each(response[fields.results], function(index, result) {
+ if(result[fields.url]) {
+ html += '<a class="result" href="' + result[fields.url] + '">';
}
else {
html += '<a class="result">';
}
- if(result.image !== undefined) {
+ if(result[fields.image] !== undefined) {
html += ''
+ '<div class="image">'
- + ' <img src="' + result.image + '">'
+ + ' <img src="' + result[fields.image] + '">'
+ '</div>'
;
}
html += '<div class="content">';
- if(result.price !== undefined) {
- html += '<div class="price">' + result.price + '</div>';
+ if(result[fields.price] !== undefined) {
+ html += '<div class="price">' + result[fields.price] + '</div>';
}
- if(result.title !== undefined) {
- html += '<div class="title">' + result.title + '</div>';
+ if(result[fields.title] !== undefined) {
+ html += '<div class="title">' + result[fields.title] + '</div>';
}
- if(result.description !== undefined) {
- html += '<div class="description">' + result.description + '</div>';
+ if(result[fields.description] !== undefined) {
+ html += '<div class="description">' + result[fields.description] + '</div>';
}
html += ''
+ '</div>'
@@ -8865,10 +13584,10 @@ $.fn.search.settings = {
html += '</a>';
});
- if(response.action) {
+ if(response[fields.action]) {
html += ''
- + '<a href="' + response.action.url + '" class="action">'
- + response.action.text
+ + '<a href="' + response[fields.action][fields.actionURL] + '" class="action">'
+ + response[fields.action][fields.actionText]
+ '</a>';
}
return html;
@@ -8878,14 +13597,14 @@ $.fn.search.settings = {
}
};
-})( jQuery, window , document );
+})( jQuery, window, document );
-/*
- * # Semantic - Shape
+/*!
+ * # Semantic UI 2.1.6 - Shape
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -8919,8 +13638,10 @@ $.fn.shape = function(parameters) {
$allModules
.each(function() {
var
- moduleSelector = $allModules.selector || '',
- settings = $.extend(true, {}, $.fn.shape.settings, parameters),
+ moduleSelector = $allModules.selector || '',
+ settings = ( $.isPlainObject(parameters) )
+ ? $.extend(true, {}, $.fn.shape.settings, parameters)
+ : $.extend({}, $.fn.shape.settings),
// internal aliases
namespace = settings.namespace,
@@ -8982,7 +13703,7 @@ $.fn.shape = function(parameters) {
repaint: function() {
module.verbose('Forcing repaint event');
var
- shape = $sides.get(0) || document.createElement('div'),
+ shape = $sides[0] || document.createElement('div'),
fakeAssignment = shape.offsetWidth
;
},
@@ -8997,7 +13718,7 @@ $.fn.shape = function(parameters) {
module.reset();
module.set.active();
};
- $.proxy(settings.beforeChange, $nextSide[0])();
+ settings.beforeChange.call($nextSide[0]);
if(module.get.transitionEvent()) {
module.verbose('Starting CSS animation');
$module
@@ -9071,7 +13792,7 @@ $.fn.shape = function(parameters) {
defaultSide: function() {
$activeSide = $module.find('.' + settings.className.active);
- $nextSide = ( $activeSide.next(selector.side).size() > 0 )
+ $nextSide = ( $activeSide.next(selector.side).length > 0 )
? $activeSide.next(selector.side)
: $module.find(selector.side).first()
;
@@ -9087,13 +13808,29 @@ $.fn.shape = function(parameters) {
: duration
;
module.verbose('Setting animation duration', duration);
- $sides.add($side)
+ if(settings.duration || settings.duration === 0) {
+ $sides.add($side)
+ .css({
+ '-webkit-transition-duration': duration,
+ '-moz-transition-duration': duration,
+ '-ms-transition-duration': duration,
+ '-o-transition-duration': duration,
+ 'transition-duration': duration
+ })
+ ;
+ }
+ },
+
+ currentStageSize: function() {
+ var
+ $activeSide = $module.find('.' + settings.className.active),
+ width = $activeSide.outerWidth(true),
+ height = $activeSide.outerHeight(true)
+ ;
+ $module
.css({
- '-webkit-transition-duration': duration,
- '-moz-transition-duration': duration,
- '-ms-transition-duration': duration,
- '-o-transition-duration': duration,
- 'transition-duration': duration
+ width: width,
+ height: height
})
;
},
@@ -9104,17 +13841,18 @@ $.fn.shape = function(parameters) {
$activeSide = $clone.find('.' + settings.className.active),
$nextSide = (nextIndex)
? $clone.find(selector.side).eq(nextIndex)
- : ( $activeSide.next(selector.side).size() > 0 )
+ : ( $activeSide.next(selector.side).length > 0 )
? $activeSide.next(selector.side)
: $clone.find(selector.side).first(),
newSize = {}
;
+ module.set.currentStageSize();
$activeSide.removeClass(className.active);
$nextSide.addClass(className.active);
$clone.insertAfter($module);
newSize = {
- width : $nextSide.outerWidth(),
- height : $nextSide.outerHeight()
+ width : $nextSide.outerWidth(true),
+ height : $nextSide.outerHeight(true)
};
$clone.remove();
$module
@@ -9127,7 +13865,7 @@ $.fn.shape = function(parameters) {
nextIndex = selector;
$nextSide = $side.filter(selector);
nextIndex = $side.index($nextSide);
- if($nextSide.size() === 0) {
+ if($nextSide.length === 0) {
module.set.defaultSide();
module.error(error.side);
}
@@ -9142,7 +13880,7 @@ $.fn.shape = function(parameters) {
$nextSide
.addClass(className.active)
;
- $.proxy(settings.onChange, $nextSide[0])();
+ settings.onChange.call($nextSide[0]);
module.set.defaultSide();
}
},
@@ -9253,8 +13991,8 @@ $.fn.shape = function(parameters) {
up: function() {
var
translate = {
- y: -(($activeSide.outerHeight() - $nextSide.outerHeight()) / 2),
- z: -($activeSide.outerHeight() / 2)
+ y: -(($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2),
+ z: -($activeSide.outerHeight(true) / 2)
}
;
return {
@@ -9265,8 +14003,8 @@ $.fn.shape = function(parameters) {
down: function() {
var
translate = {
- y: -(($activeSide.outerHeight() - $nextSide.outerHeight()) / 2),
- z: -($activeSide.outerHeight() / 2)
+ y: -(($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2),
+ z: -($activeSide.outerHeight(true) / 2)
}
;
return {
@@ -9277,8 +14015,8 @@ $.fn.shape = function(parameters) {
left: function() {
var
translate = {
- x : -(($activeSide.outerWidth() - $nextSide.outerWidth()) / 2),
- z : -($activeSide.outerWidth() / 2)
+ x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2),
+ z : -($activeSide.outerWidth(true) / 2)
}
;
return {
@@ -9289,8 +14027,8 @@ $.fn.shape = function(parameters) {
right: function() {
var
translate = {
- x : -(($activeSide.outerWidth() - $nextSide.outerWidth()) / 2),
- z : -($activeSide.outerWidth() / 2)
+ x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2),
+ z : -($activeSide.outerWidth(true) / 2)
}
;
return {
@@ -9301,7 +14039,7 @@ $.fn.shape = function(parameters) {
over: function() {
var
translate = {
- x : -(($activeSide.outerWidth() - $nextSide.outerWidth()) / 2)
+ x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2)
}
;
return {
@@ -9312,7 +14050,7 @@ $.fn.shape = function(parameters) {
back: function() {
var
translate = {
- x : -(($activeSide.outerWidth() - $nextSide.outerWidth()) / 2)
+ x : -(($activeSide.outerWidth(true) - $nextSide.outerWidth(true)) / 2)
}
;
return {
@@ -9340,7 +14078,7 @@ $.fn.shape = function(parameters) {
},
nextSide: function() {
- return ( $activeSide.next(selector.side).size() > 0 )
+ return ( $activeSide.next(selector.side).length > 0 )
? $activeSide.next(selector.side)
: $module.find(selector.side).first()
;
@@ -9353,14 +14091,19 @@ $.fn.shape = function(parameters) {
above: function() {
var
box = {
- origin : (($activeSide.outerHeight() - $nextSide.outerHeight()) / 2),
+ origin : (($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2),
depth : {
- active : ($nextSide.outerHeight() / 2),
- next : ($activeSide.outerHeight() / 2)
+ active : ($nextSide.outerHeight(true) / 2),
+ next : ($activeSide.outerHeight(true) / 2)
}
}
;
module.verbose('Setting the initial animation position as above', $nextSide, box);
+ $sides
+ .css({
+ 'transform' : 'translateZ(-' + box.depth.active + 'px)'
+ })
+ ;
$activeSide
.css({
'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)'
@@ -9369,7 +14112,6 @@ $.fn.shape = function(parameters) {
$nextSide
.addClass(className.animating)
.css({
- 'display' : 'block',
'top' : box.origin + 'px',
'transform' : 'rotateX(90deg) translateZ(' + box.depth.next + 'px)'
})
@@ -9379,14 +14121,19 @@ $.fn.shape = function(parameters) {
below: function() {
var
box = {
- origin : (($activeSide.outerHeight() - $nextSide.outerHeight()) / 2),
+ origin : (($activeSide.outerHeight(true) - $nextSide.outerHeight(true)) / 2),
depth : {
- active : ($nextSide.outerHeight() / 2),
- next : ($activeSide.outerHeight() / 2)
+ active : ($nextSide.outerHeight(true) / 2),
+ next : ($activeSide.outerHeight(true) / 2)
}
}
;
module.verbose('Setting the initial animation position as below', $nextSide, box);
+ $sides
+ .css({
+ 'transform' : 'translateZ(-' + box.depth.active + 'px)'
+ })
+ ;
$activeSide
.css({
'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)'
@@ -9395,7 +14142,6 @@ $.fn.shape = function(parameters) {
$nextSide
.addClass(className.animating)
.css({
- 'display' : 'block',
'top' : box.origin + 'px',
'transform' : 'rotateX(-90deg) translateZ(' + box.depth.next + 'px)'
})
@@ -9404,15 +14150,24 @@ $.fn.shape = function(parameters) {
left: function() {
var
+ height = {
+ active : $activeSide.outerWidth(true),
+ next : $nextSide.outerWidth(true)
+ },
box = {
- origin : ( ( $activeSide.outerWidth() - $nextSide.outerWidth() ) / 2),
+ origin : ( ( height.active - height.next ) / 2),
depth : {
- active : ($nextSide.outerWidth() / 2),
- next : ($activeSide.outerWidth() / 2)
+ active : (height.next / 2),
+ next : (height.active / 2)
}
}
;
module.verbose('Setting the initial animation position as left', $nextSide, box);
+ $sides
+ .css({
+ 'transform' : 'translateZ(-' + box.depth.active + 'px)'
+ })
+ ;
$activeSide
.css({
'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)'
@@ -9421,7 +14176,6 @@ $.fn.shape = function(parameters) {
$nextSide
.addClass(className.animating)
.css({
- 'display' : 'block',
'left' : box.origin + 'px',
'transform' : 'rotateY(-90deg) translateZ(' + box.depth.next + 'px)'
})
@@ -9430,15 +14184,24 @@ $.fn.shape = function(parameters) {
right: function() {
var
+ height = {
+ active : $activeSide.outerWidth(true),
+ next : $nextSide.outerWidth(true)
+ },
box = {
- origin : ( ( $activeSide.outerWidth() - $nextSide.outerWidth() ) / 2),
+ origin : ( ( height.active - height.next ) / 2),
depth : {
- active : ($nextSide.outerWidth() / 2),
- next : ($activeSide.outerWidth() / 2)
+ active : (height.next / 2),
+ next : (height.active / 2)
}
}
;
module.verbose('Setting the initial animation position as left', $nextSide, box);
+ $sides
+ .css({
+ 'transform' : 'translateZ(-' + box.depth.active + 'px)'
+ })
+ ;
$activeSide
.css({
'transform' : 'rotateY(0deg) translateZ(' + box.depth.active + 'px)'
@@ -9447,7 +14210,6 @@ $.fn.shape = function(parameters) {
$nextSide
.addClass(className.animating)
.css({
- 'display' : 'block',
'left' : box.origin + 'px',
'transform' : 'rotateY(90deg) translateZ(' + box.depth.next + 'px)'
})
@@ -9456,11 +14218,15 @@ $.fn.shape = function(parameters) {
behind: function() {
var
+ height = {
+ active : $activeSide.outerWidth(true),
+ next : $nextSide.outerWidth(true)
+ },
box = {
- origin : ( ( $activeSide.outerWidth() - $nextSide.outerWidth() ) / 2),
+ origin : ( ( height.active - height.next ) / 2),
depth : {
- active : ($nextSide.outerWidth() / 2),
- next : ($activeSide.outerWidth() / 2)
+ active : (height.next / 2),
+ next : (height.active / 2)
}
}
;
@@ -9473,7 +14239,6 @@ $.fn.shape = function(parameters) {
$nextSide
.addClass(className.animating)
.css({
- 'display' : 'block',
'left' : box.origin + 'px',
'transform' : 'rotateY(-180deg)'
})
@@ -9549,7 +14314,7 @@ $.fn.shape = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -9565,8 +14330,8 @@ $.fn.shape = function(parameters) {
if(moduleSelector) {
title += ' \'' + moduleSelector + '\'';
}
- if($allModules.size() > 1) {
- title += ' ' + '(' + $allModules.size() + ')';
+ if($allModules.length > 1) {
+ title += ' ' + '(' + $allModules.length + ')';
}
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
console.groupCollapsed(title);
@@ -9646,7 +14411,7 @@ $.fn.shape = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
@@ -9668,7 +14433,7 @@ $.fn.shape.settings = {
debug : false,
// verbose debug output
- verbose : true,
+ verbose : false,
// performance data output
performance: true,
@@ -9684,7 +14449,7 @@ $.fn.shape.settings = {
allowRepeats: false,
// animation duration
- duration : 700,
+ duration : false,
// possible errors
error: {
@@ -9709,13 +14474,13 @@ $.fn.shape.settings = {
};
-})( jQuery, window , document );
-/*
- * # Semantic - Sidebar
+})( jQuery, window, document );
+/*!
+ * # Semantic UI 2.1.6 - Sidebar
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -9727,19 +14492,20 @@ $.fn.shape.settings = {
$.fn.sidebar = function(parameters) {
var
- $allModules = $(this),
- $window = $(window),
- $document = $(document),
- $head = $('head'),
+ $allModules = $(this),
+ $window = $(window),
+ $document = $(document),
+ $html = $('html'),
+ $head = $('head'),
- moduleSelector = $allModules.selector || '',
+ moduleSelector = $allModules.selector || '',
- time = new Date().getTime(),
- performance = [],
+ time = new Date().getTime(),
+ performance = [],
- query = arguments[0],
- methodInvoked = (typeof query == 'string'),
- queryArguments = [].slice.call(arguments, 1),
+ query = arguments[0],
+ methodInvoked = (typeof query == 'string'),
+ queryArguments = [].slice.call(arguments, 1),
requestAnimationFrame = window.requestAnimationFrame
|| window.mozRequestAnimationFrame
@@ -9760,6 +14526,7 @@ $.fn.sidebar = function(parameters) {
selector = settings.selector,
className = settings.className,
namespace = settings.namespace,
+ regExp = settings.regExp,
error = settings.error,
eventNamespace = '.' + namespace,
@@ -9769,6 +14536,7 @@ $.fn.sidebar = function(parameters) {
$context = $(settings.context),
$sidebars = $module.children(selector.sidebar),
+ $fixed = $context.children(selector.fixed),
$pusher = $context.children(selector.pusher),
$style,
@@ -9788,19 +14556,25 @@ $.fn.sidebar = function(parameters) {
initialize: function() {
module.debug('Initializing sidebar', parameters);
+ module.create.id();
+
transitionEvent = module.get.transitionEvent();
- // cache on initialize
- if( module.is.legacy() || settings.legacy) {
- settings.transition = 'overlay';
- settings.useLegacy = true;
+ if(module.is.ios()) {
+ module.set.ios();
}
- id = module.get.uniqueID();
- elementNamespace = '.' + id;
-
// avoids locking rendering if initialized in onReady
- requestAnimationFrame(module.setup.layout);
+ if(settings.delaySetup) {
+ requestAnimationFrame(module.setup.layout);
+ }
+ else {
+ module.setup.layout();
+ }
+
+ requestAnimationFrame(function() {
+ module.setup.cache();
+ });
module.instantiate();
},
@@ -9813,13 +14587,23 @@ $.fn.sidebar = function(parameters) {
;
},
+ create: {
+ id: function() {
+ id = (Math.random().toString(16) + '000000000').substr(2,8);
+ elementNamespace = '.' + id;
+ module.verbose('Creating unique id for element', id);
+ }
+ },
+
destroy: function() {
module.verbose('Destroying previous module for', $module);
- module.remove.direction();
$module
.off(eventNamespace)
.removeData(moduleNamespace)
;
+ if(module.is.ios()) {
+ module.remove.ios();
+ }
// bound by uuid
$context.off(elementNamespace);
$window.off(elementNamespace);
@@ -9828,10 +14612,18 @@ $.fn.sidebar = function(parameters) {
event: {
clickaway: function(event) {
- if( $(event.target).closest(selector.sidebar).size() === 0 ) {
+ var
+ clickedInPusher = ($pusher.find(event.target).length > 0 || $pusher.is(event.target)),
+ clickedContext = ($context.is(event.target))
+ ;
+ if(clickedInPusher) {
module.verbose('User clicked on dimmed page');
module.hide();
}
+ if(clickedContext) {
+ module.verbose('User clicked on dimmable context (scaled out page)');
+ module.hide();
+ }
},
touch: function(event) {
//event.stopPropagation();
@@ -9845,7 +14637,7 @@ $.fn.sidebar = function(parameters) {
}
},
scroll: function(event) {
- if( $(event.target).closest(selector.sidebar).size() === 0 ) {
+ if( $(event.target).closest(selector.sidebar).length === 0 ) {
event.preventDefault();
}
}
@@ -9856,7 +14648,7 @@ $.fn.sidebar = function(parameters) {
module.verbose('Adding clickaway events to context', $context);
if(settings.closable) {
$context
- .on('click' + elementNamespace, module.event.clickaway)
+ .on('click' + elementNamespace, module.event.clickaway)
.on('touchend' + elementNamespace, module.event.clickaway)
;
}
@@ -9891,75 +14683,82 @@ $.fn.sidebar = function(parameters) {
},
add: {
- bodyCSS: function(direction, distance) {
+ inlineCSS: function() {
var
- width = $module.outerWidth(),
- height = $module.outerHeight(),
+ width = module.cache.width || $module.outerWidth(),
+ height = module.cache.height || $module.outerHeight(),
+ isRTL = module.is.rtl(),
+ direction = module.get.direction(),
+ distance = {
+ left : width,
+ right : -width,
+ top : height,
+ bottom : -height
+ },
style
;
- style = ''
- + '<style title="' + namespace + '">'
- + ' .ui.visible.left.sidebar ~ .fixed,'
- + ' .ui.visible.left.sidebar ~ .pusher {'
- + ' -webkit-transform: translate3d('+ width + 'px, 0, 0);'
- + ' transform: translate3d('+ width + 'px, 0, 0);'
- + ' }'
- + ' .ui.visible.right.sidebar ~ .fixed,'
- + ' .ui.visible.right.sidebar ~ .pusher {'
- + ' -webkit-transform: translate3d(-'+ width + 'px, 0, 0);'
- + ' transform: translate3d(-'+ width + 'px, 0, 0);'
- + ' }'
- + ' .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .fixed,'
- + ' .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher,'
- + ' .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .fixed,'
- + ' .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher {'
- + ' -webkit-transform: translate3d(0px, 0, 0);'
- + ' transform: translate3d(0px, 0, 0);'
- + ' }'
- + ' .ui.visible.top.sidebar ~ .fixed,'
- + ' .ui.visible.top.sidebar ~ .pusher {'
- + ' -webkit-transform: translate3d(0, ' + height + 'px, 0);'
- + ' transform: translate3d(0, ' + height + 'px, 0);'
- + ' }'
- + ' .ui.visible.bottom.sidebar ~ .fixed,'
- + ' .ui.visible.bottom.sidebar ~ .pusher {'
- + ' -webkit-transform: translate3d(0, -' + height + 'px, 0);'
- + ' transform: translate3d(0, -' + height + 'px, 0);'
- + ' }'
- ;
+
+ if(isRTL){
+ module.verbose('RTL detected, flipping widths');
+ distance.left = -width;
+ distance.right = width;
+ }
+
+ style = '<style>';
+
+ if(direction === 'left' || direction === 'right') {
+ module.debug('Adding CSS rules for animation distance', width);
+ style += ''
+ + ' .ui.visible.' + direction + '.sidebar ~ .fixed,'
+ + ' .ui.visible.' + direction + '.sidebar ~ .pusher {'
+ + ' -webkit-transform: translate3d('+ distance[direction] + 'px, 0, 0);'
+ + ' transform: translate3d('+ distance[direction] + 'px, 0, 0);'
+ + ' }'
+ ;
+ }
+ else if(direction === 'top' || direction == 'bottom') {
+ style += ''
+ + ' .ui.visible.' + direction + '.sidebar ~ .fixed,'
+ + ' .ui.visible.' + direction + '.sidebar ~ .pusher {'
+ + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);'
+ + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);'
+ + ' }'
+ ;
+ }
/* IE is only browser not to create context with transforms */
/* https://www.w3.org/Bugs/Public/show_bug.cgi?id=16328 */
if( module.is.ie() ) {
+ if(direction === 'left' || direction === 'right') {
+ module.debug('Adding CSS rules for animation distance', width);
+ style += ''
+ + ' body.pushable > .ui.visible.' + direction + '.sidebar ~ .pusher:after {'
+ + ' -webkit-transform: translate3d('+ distance[direction] + 'px, 0, 0);'
+ + ' transform: translate3d('+ distance[direction] + 'px, 0, 0);'
+ + ' }'
+ ;
+ }
+ else if(direction === 'top' || direction == 'bottom') {
+ style += ''
+ + ' body.pushable > .ui.visible.' + direction + '.sidebar ~ .pusher:after {'
+ + ' -webkit-transform: translate3d(0, ' + distance[direction] + 'px, 0);'
+ + ' transform: translate3d(0, ' + distance[direction] + 'px, 0);'
+ + ' }'
+ ;
+ }
+ /* opposite sides visible forces content overlay */
style += ''
- + ' .ui.visible.left.sidebar ~ .pusher:after {'
- + ' -webkit-transform: translate3d('+ width + 'px, 0, 0);'
- + ' transform: translate3d('+ width + 'px, 0, 0);'
- + ' }'
- + ' .ui.visible.right.sidebar ~ .pusher:after {'
- + ' -webkit-transform: translate3d(-'+ width + 'px, 0, 0);'
- + ' transform: translate3d(-'+ width + 'px, 0, 0);'
- + ' }'
- + ' .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher:after,'
- + ' .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher:after {'
+ + ' body.pushable > .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher:after,'
+ + ' body.pushable > .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher:after {'
+ ' -webkit-transform: translate3d(0px, 0, 0);'
+ ' transform: translate3d(0px, 0, 0);'
+ ' }'
- + ' .ui.visible.top.sidebar ~ .pusher:after {'
- + ' -webkit-transform: translate3d(0, ' + height + 'px, 0);'
- + ' transform: translate3d(0, ' + height + 'px, 0);'
- + ' }'
- + ' .ui.visible.bottom.sidebar ~ .pusher:after {'
- + ' -webkit-transform: translate3d(0, -' + height + 'px, 0);'
- + ' transform: translate3d(0, -' + height + 'px, 0);'
- + ' }'
;
}
-
- style += '</style>';
-
- $head.append(style);
- $style = $('style[title=' + namespace + ']');
+ style += '</style>';
+ $style = $(style)
+ .appendTo($head)
+ ;
module.debug('Adding sizing css to head', $style);
}
},
@@ -9969,6 +14768,8 @@ $.fn.sidebar = function(parameters) {
$context = $(settings.context);
$sidebars = $context.children(selector.sidebar);
$pusher = $context.children(selector.pusher);
+ $fixed = $context.children(selector.fixed);
+ module.clear.cache();
},
refreshSidebars: function() {
@@ -9978,15 +14779,22 @@ $.fn.sidebar = function(parameters) {
repaint: function() {
module.verbose('Forcing repaint event');
- element.style.display='none';
- element.offsetHeight;
+ element.style.display = 'none';
+ var ignored = element.offsetHeight;
element.scrollTop = element.scrollTop;
- element.style.display='';
+ element.style.display = '';
},
setup: {
+ cache: function() {
+ module.cache = {
+ width : $module.outerWidth(),
+ height : $module.outerHeight(),
+ rtl : ($module.css('direction') == 'rtl')
+ };
+ },
layout: function() {
- if( $context.children(selector.pusher).size() === 0 ) {
+ if( $context.children(selector.pusher).length === 0 ) {
module.debug('Adding wrapper element for sidebar');
module.error(error.pusher);
$pusher = $('<div class="pusher" />');
@@ -9998,12 +14806,13 @@ $.fn.sidebar = function(parameters) {
;
module.refresh();
}
- if($module.nextAll(selector.pusher).size() === 0 || $module.nextAll(selector.pusher)[0] !== $pusher[0]) {
+ if($module.nextAll(selector.pusher).length === 0 || $module.nextAll(selector.pusher)[0] !== $pusher[0]) {
module.debug('Moved sidebar to correct parent element');
module.error(error.movedSidebar, element);
$module.detach().prependTo($context);
module.refresh();
}
+ module.clear.cache();
module.set.pushable();
module.set.direction();
}
@@ -10017,7 +14826,7 @@ $.fn.sidebar = function(parameters) {
? module[event]
: module.toggle
;
- if($toggle.size() > 0) {
+ if($toggle.length > 0) {
module.debug('Attaching sidebar events to element', selector, event);
$toggle
.on('click' + eventNamespace, event)
@@ -10029,11 +14838,6 @@ $.fn.sidebar = function(parameters) {
},
show: function(callback) {
- var
- animateMethod = (settings.useLegacy)
- ? module.legacyPushPage
- : module.pushPage
- ;
callback = $.isFunction(callback)
? callback
: function(){}
@@ -10045,18 +14849,28 @@ $.fn.sidebar = function(parameters) {
settings.transition = 'overlay';
}
module.refresh();
- if(module.othersVisible() && module.get.transition() != 'overlay') {
- module.debug('Other sidebars currently open');
+ if(module.othersActive()) {
+ module.debug('Other sidebars currently visible');
if(settings.exclusive) {
- module.hideOthers();
+ // if not overlay queue animation after hide
+ if(settings.transition != 'overlay') {
+ module.hideOthers(module.show);
+ return;
+ }
+ else {
+ module.hideOthers();
+ }
+ }
+ else {
+ settings.transition = 'overlay';
}
}
- animateMethod(function() {
- $.proxy(callback, element)();
- $.proxy(settings.onShow, element)();
+ module.pushPage(function() {
+ callback.call(element);
+ settings.onShow.call(element);
});
- $.proxy(settings.onChange, element)();
- $.proxy(settings.onVisible, element)();
+ settings.onChange.call(element);
+ settings.onVisible.call(element);
}
else {
module.debug('Sidebar is already visible');
@@ -10064,11 +14878,6 @@ $.fn.sidebar = function(parameters) {
},
hide: function(callback) {
- var
- animateMethod = (settings.useLegacy)
- ? module.legacyPullPage
- : module.pullPage
- ;
callback = $.isFunction(callback)
? callback
: function(){}
@@ -10076,26 +14885,32 @@ $.fn.sidebar = function(parameters) {
if(module.is.visible() || module.is.animating()) {
module.debug('Hiding sidebar', callback);
module.refreshSidebars();
- animateMethod(function() {
- $.proxy(callback, element)();
- $.proxy(settings.onHidden, element)();
+ module.pullPage(function() {
+ callback.call(element);
+ settings.onHidden.call(element);
});
- $.proxy(settings.onChange, element)();
- $.proxy(settings.onHide, element)();
+ settings.onChange.call(element);
+ settings.onHide.call(element);
}
},
+ othersAnimating: function() {
+ return ($sidebars.not($module).filter('.' + className.animating).length > 0);
+ },
othersVisible: function() {
- return ($sidebars.not($module).filter('.' + className.visible).size() > 0);
+ return ($sidebars.not($module).filter('.' + className.visible).length > 0);
+ },
+ othersActive: function() {
+ return(module.othersVisible() || module.othersAnimating());
},
hideOthers: function(callback) {
var
$otherSidebars = $sidebars.not($module).filter('.' + className.visible),
- callback = callback || function(){},
- sidebarCount = $otherSidebars.size(),
+ sidebarCount = $otherSidebars.length,
callbackCount = 0
;
+ callback = callback || function(){};
$otherSidebars
.sidebar('hide', function() {
callbackCount++;
@@ -10119,55 +14934,53 @@ $.fn.sidebar = function(parameters) {
pushPage: function(callback) {
var
transition = module.get.transition(),
- $transition = (transition == 'safe')
- ? $context
- : (transition == 'overlay' || module.othersVisible())
- ? $module
- : $pusher,
+ $transition = (transition === 'overlay' || module.othersActive())
+ ? $module
+ : $pusher,
animate,
+ dim,
transitionEnd
;
callback = $.isFunction(callback)
? callback
: function(){}
;
- if(settings.transition == 'scale down' || (module.is.mobile() && transition !== 'overlay')) {
+ if(settings.transition == 'scale down') {
module.scrollToTop();
}
- module.set.transition();
+ module.set.transition(transition);
module.repaint();
animate = function() {
module.bind.clickaway();
- module.add.bodyCSS();
+ module.add.inlineCSS();
module.set.animating();
module.set.visible();
- if(!module.othersVisible()) {
- if(settings.dimPage) {
- $pusher.addClass(className.dimmed);
- }
- }
+ };
+ dim = function() {
+ module.set.dimmed();
};
transitionEnd = function(event) {
if( event.target == $transition[0] ) {
$transition.off(transitionEvent + elementNamespace, transitionEnd);
module.remove.animating();
module.bind.scrollLock();
- $.proxy(callback, element)();
+ callback.call(element);
}
};
$transition.off(transitionEvent + elementNamespace);
$transition.on(transitionEvent + elementNamespace, transitionEnd);
requestAnimationFrame(animate);
+ if(settings.dimPage && !module.othersVisible()) {
+ requestAnimationFrame(dim);
+ }
},
pullPage: function(callback) {
var
transition = module.get.transition(),
- $transition = (transition == 'safe')
- ? $context
- : (transition == 'overlay' || module.othersVisible())
- ? $module
- : $pusher,
+ $transition = (transition == 'overlay' || module.othersActive())
+ ? $module
+ : $pusher,
animate,
transitionEnd
;
@@ -10181,6 +14994,7 @@ $.fn.sidebar = function(parameters) {
module.unbind.scrollLock();
animate = function() {
+ module.set.transition(transition);
module.set.animating();
module.remove.visible();
if(settings.dimPage && !module.othersVisible()) {
@@ -10192,11 +15006,11 @@ $.fn.sidebar = function(parameters) {
$transition.off(transitionEvent + elementNamespace, transitionEnd);
module.remove.animating();
module.remove.transition();
- module.remove.bodyCSS();
+ module.remove.inlineCSS();
if(transition == 'scale down' || (settings.returnScroll && module.is.mobile()) ) {
module.scrollBack();
}
- $.proxy(callback, element)();
+ callback.call(element);
}
};
$transition.off(transitionEvent + elementNamespace);
@@ -10204,62 +15018,6 @@ $.fn.sidebar = function(parameters) {
requestAnimationFrame(animate);
},
- legacyPushPage: function(callback) {
- var
- distance = $module.width(),
- direction = module.get.direction(),
- properties = {}
- ;
- distance = distance || $module.width();
- callback = $.isFunction(callback)
- ? callback
- : function(){}
- ;
- properties[direction] = distance;
- module.debug('Using javascript to push context', properties);
- module.set.visible();
- module.set.transition();
- module.set.animating();
- if(settings.dimPage) {
- $pusher.addClass(className.dimmed);
- }
- $context
- .css('position', 'relative')
- .animate(properties, settings.duration, settings.easing, function() {
- module.remove.animating();
- module.bind.clickaway();
- $.proxy(callback, module)();
- })
- ;
- },
- legacyPullPage: function(callback) {
- var
- distance = 0,
- direction = module.get.direction(),
- properties = {}
- ;
- distance = distance || $module.width();
- callback = $.isFunction(callback)
- ? callback
- : function(){}
- ;
- properties[direction] = '0px';
- module.debug('Using javascript to pull context', properties);
- module.unbind.clickaway();
- module.set.animating();
- module.remove.visible();
- if(settings.dimPage && !module.othersVisible()) {
- $pusher.removeClass(className.dimmed);
- }
- $context
- .css('position', 'relative')
- .animate(properties, settings.duration, settings.easing, function() {
- module.remove.animating();
- $.proxy(callback, module)();
- })
- ;
- },
-
scrollToTop: function() {
module.verbose('Scrolling to top of page to avoid animation issues');
currentScroll = $(window).scrollTop();
@@ -10272,7 +15030,20 @@ $.fn.sidebar = function(parameters) {
window.scrollTo(0, currentScroll);
},
+ clear: {
+ cache: function() {
+ module.verbose('Clearing cached dimensions');
+ module.cache = {};
+ }
+ },
+
set: {
+
+ // ios only (scroll on html not document). This prevent auto-resize canvas/scroll in ios
+ ios: function() {
+ $html.addClass(className.ios);
+ },
+
// container
pushed: function() {
$context.addClass(className.pushed);
@@ -10281,6 +15052,11 @@ $.fn.sidebar = function(parameters) {
$context.addClass(className.pushable);
},
+ // pusher
+ dimmed: function() {
+ $pusher.addClass(className.dimmed);
+ },
+
// sidebar
active: function() {
$module.addClass(className.active);
@@ -10305,13 +15081,18 @@ $.fn.sidebar = function(parameters) {
},
remove: {
- bodyCSS: function() {
- module.debug('Removing body css styles', $style);
- if($style.size() > 0) {
+ inlineCSS: function() {
+ module.debug('Removing inline css styles', $style);
+ if($style && $style.length > 0) {
$style.remove();
}
},
+ // ios scroll on html not document
+ ios: function() {
+ $html.removeClass(className.ios);
+ },
+
// context
pushed: function() {
$context.removeClass(className.pushed);
@@ -10361,7 +15142,7 @@ $.fn.sidebar = function(parameters) {
direction = module.get.direction(),
transition
;
- return ( module.is.mobile() )
+ transition = ( module.is.mobile() )
? (settings.mobileTransition == 'auto')
? settings.defaultTransition.mobile[direction]
: settings.mobileTransition
@@ -10369,6 +15150,8 @@ $.fn.sidebar = function(parameters) {
? settings.defaultTransition.computer[direction]
: settings.transition
;
+ module.verbose('Determined transition', transition);
+ return transition;
},
transitionEvent: function() {
var
@@ -10386,9 +15169,6 @@ $.fn.sidebar = function(parameters) {
return transitions[transition];
}
}
- },
- uniqueID: function() {
- return (Math.random().toString(16) + '000000000').substr(2,8);
}
},
@@ -10402,35 +15182,24 @@ $.fn.sidebar = function(parameters) {
return (isIE11 || isIE);
},
- legacy: function() {
+ ios: function() {
var
- element = document.createElement('div'),
- transforms = {
- 'webkitTransform' :'-webkit-transform',
- 'OTransform' :'-o-transform',
- 'msTransform' :'-ms-transform',
- 'MozTransform' :'-moz-transform',
- 'transform' :'transform'
- },
- has3D
+ userAgent = navigator.userAgent,
+ isIOS = userAgent.match(regExp.ios),
+ isMobileChrome = userAgent.match(regExp.mobileChrome)
;
-
- // Add it to the body to get the computed style.
- document.body.insertBefore(element, null);
- for (var transform in transforms) {
- if (element.style[transform] !== undefined) {
- element.style[transform] = "translate3d(1px,1px,1px)";
- has3D = window.getComputedStyle(element).getPropertyValue(transforms[transform]);
- }
+ if(isIOS && !isMobileChrome) {
+ module.verbose('Browser was found to be iOS', userAgent);
+ return true;
+ }
+ else {
+ return false;
}
- document.body.removeChild(element);
- return !(has3D !== undefined && has3D.length > 0 && has3D !== 'none');
},
mobile: function() {
var
userAgent = navigator.userAgent,
- mobileRegExp = /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/,
- isMobile = mobileRegExp.test(userAgent)
+ isMobile = userAgent.match(regExp.mobile)
;
if(isMobile) {
module.verbose('Browser was found to be mobile', userAgent);
@@ -10459,6 +15228,12 @@ $.fn.sidebar = function(parameters) {
},
animating: function() {
return $context.hasClass(className.animating);
+ },
+ rtl: function () {
+ if(module.cache.rtl === undefined) {
+ module.cache.rtl = ($module.css('direction') == 'rtl');
+ }
+ return module.cache.rtl;
}
},
@@ -10531,7 +15306,7 @@ $.fn.sidebar = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -10645,7 +15420,7 @@ $.fn.sidebar.settings = {
namespace : 'sidebar',
debug : false,
- verbose : true,
+ verbose : false,
performance : true,
transition : 'auto',
@@ -10672,10 +15447,9 @@ $.fn.sidebar.settings = {
dimPage : true,
scrollLock : false,
returnScroll : false,
+ delaySetup : false,
- useLegacy : false,
duration : 500,
- easing : 'easeInOutQuint',
onChange : function(){},
onShow : function(){},
@@ -10688,6 +15462,7 @@ $.fn.sidebar.settings = {
active : 'active',
animating : 'animating',
dimmed : 'dimmed',
+ ios : 'ios',
pushable : 'pushable',
pushed : 'pushed',
right : 'right',
@@ -10704,6 +15479,12 @@ $.fn.sidebar.settings = {
sidebar : '.ui.sidebar'
},
+ regExp: {
+ ios : /(iPad|iPhone|iPod)/g,
+ mobileChrome : /(CriOS)/g,
+ mobile : /Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/g
+ },
+
error : {
method : 'The method you called is not defined.',
pusher : 'Had to add pusher element. For optimal performance make sure body content is inside a pusher element',
@@ -10714,23 +15495,15 @@ $.fn.sidebar.settings = {
};
-// Adds easing
-$.extend( $.easing, {
- easeInOutQuint: function (x, t, b, c, d) {
- if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
- return c/2*((t-=2)*t*t*t*t + 2) + b;
- }
-});
-
-})( jQuery, window , document );
+})( jQuery, window, document );
- /*
- * # Semantic - Sticky
+/*!
+ * # Semantic UI 2.1.6 - Sticky
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributors
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -10757,7 +15530,9 @@ $.fn.sticky = function(parameters) {
$allModules
.each(function() {
var
- settings = $.extend(true, {}, $.fn.sticky.settings, parameters),
+ settings = ( $.isPlainObject(parameters) )
+ ? $.extend(true, {}, $.fn.sticky.settings, parameters)
+ : $.extend({}, $.fn.sticky.settings),
className = settings.className,
namespace = settings.namespace,
@@ -10768,8 +15543,8 @@ $.fn.sticky = function(parameters) {
$module = $(this),
$window = $(window),
- $container = $module.offsetParent(),
$scroll = $(settings.scrollContext),
+ $container,
$context,
selector = $module.selector || '',
@@ -10789,37 +15564,18 @@ $.fn.sticky = function(parameters) {
module = {
initialize: function() {
- if(settings.context) {
- $context = $(settings.context);
- }
- else {
- $context = $container;
- }
- if($context.size() === 0) {
- module.error(error.invalidContext, settings.context, $module);
- return;
- }
+
+ module.determineContainer();
+ module.determineContext();
module.verbose('Initializing sticky', settings, $container);
+
module.save.positions();
+ module.checkErrors();
+ module.bind.events();
- // error conditions
- if( module.is.hidden() ) {
- module.error(error.visible, $module);
- }
- if(module.cache.element.height > module.cache.context.height) {
- module.reset();
- module.error(error.elementSize, $module);
- return;
+ if(settings.observeChanges) {
+ module.observeChanges();
}
-
- $window
- .on('resize' + eventNamespace, module.event.resize)
- ;
- $scroll
- .on('scroll' + eventNamespace, module.event.scroll)
- ;
-
- module.observeChanges();
module.instantiate();
},
@@ -10832,17 +15588,19 @@ $.fn.sticky = function(parameters) {
},
destroy: function() {
- module.verbose('Destroying previous module');
+ module.verbose('Destroying previous instance');
module.reset();
+ if(observer) {
+ observer.disconnect();
+ }
$window
+ .off('load' + eventNamespace, module.event.load)
.off('resize' + eventNamespace, module.event.resize)
;
$scroll
- .off('scroll' + eventNamespace, module.event.scroll)
- ;
- $module
- .removeData(moduleNamespace)
+ .off('scrollchange' + eventNamespace, module.event.scrollchange)
;
+ $module.removeData(moduleNamespace);
},
observeChanges: function() {
@@ -10853,9 +15611,9 @@ $.fn.sticky = function(parameters) {
observer = new MutationObserver(function(mutations) {
clearTimeout(module.timer);
module.timer = setTimeout(function() {
- module.verbose('DOM tree modified, updating sticky menu');
+ module.verbose('DOM tree modified, updating sticky menu', mutations);
module.refresh();
- }, 200);
+ }, 100);
});
observer.observe(element, {
childList : true,
@@ -10869,52 +15627,104 @@ $.fn.sticky = function(parameters) {
}
},
+ determineContainer: function() {
+ $container = $module.offsetParent();
+ },
+
+ determineContext: function() {
+ if(settings.context) {
+ $context = $(settings.context);
+ }
+ else {
+ $context = $container;
+ }
+ if($context.length === 0) {
+ module.error(error.invalidContext, settings.context, $module);
+ return;
+ }
+ },
+
+ checkErrors: function() {
+ if( module.is.hidden() ) {
+ module.error(error.visible, $module);
+ }
+ if(module.cache.element.height > module.cache.context.height) {
+ module.reset();
+ module.error(error.elementSize, $module);
+ return;
+ }
+ },
+
+ bind: {
+ events: function() {
+ $window
+ .on('load' + eventNamespace, module.event.load)
+ .on('resize' + eventNamespace, module.event.resize)
+ ;
+ // pub/sub pattern
+ $scroll
+ .off('scroll' + eventNamespace)
+ .on('scroll' + eventNamespace, module.event.scroll)
+ .on('scrollchange' + eventNamespace, module.event.scrollchange)
+ ;
+ }
+ },
+
event: {
+ load: function() {
+ module.verbose('Page contents finished loading');
+ requestAnimationFrame(module.refresh);
+ },
resize: function() {
- requestAnimationFrame(function() {
- module.refresh();
- module.stick();
- });
+ module.verbose('Window resized');
+ requestAnimationFrame(module.refresh);
},
scroll: function() {
requestAnimationFrame(function() {
- module.stick();
- $.proxy(settings.onScroll, element)();
+ $scroll.triggerHandler('scrollchange' + eventNamespace, $scroll.scrollTop() );
});
+ },
+ scrollchange: function(event, scrollPosition) {
+ module.stick(scrollPosition);
+ settings.onScroll.call(element);
}
},
refresh: function(hardRefresh) {
module.reset();
+ if(!settings.context) {
+ module.determineContext();
+ }
if(hardRefresh) {
- $container = $module.offsetParent();
+ module.determineContainer();
}
module.save.positions();
module.stick();
- $.proxy(settings.onReposition, element)();
+ settings.onReposition.call(element);
},
supports: {
sticky: function() {
var
$element = $('<div/>'),
- element = $element.get()
- ;
- $element
- .addClass(className.supported)
+ element = $element[0]
;
+ $element.addClass(className.supported);
return($element.css('position').match('sticky'));
}
},
save: {
- scroll: function(scroll) {
+ lastScroll: function(scroll) {
module.lastScroll = scroll;
},
+ elementScroll: function(scroll) {
+ module.elementScroll = scroll;
+ },
positions: function() {
var
- window = {
- height: $window.height()
+ scrollContext = {
+ height : $scroll.height()
},
element = {
margin: {
@@ -10926,14 +15736,28 @@ $.fn.sticky = function(parameters) {
height : $module.outerHeight()
},
context = {
- offset: $context.offset(),
- height: $context.outerHeight()
+ offset : $context.offset(),
+ height : $context.outerHeight()
+ },
+ container = {
+ height: $container.outerHeight()
}
;
+ if( !module.is.standardScroll() ) {
+ module.debug('Non-standard scroll. Removing scroll offset from element offset');
+
+ scrollContext.top = $scroll.scrollTop();
+ scrollContext.left = $scroll.scrollLeft();
+
+ element.offset.top += scrollContext.top;
+ context.offset.top += scrollContext.top;
+ element.offset.left += scrollContext.left;
+ context.offset.left += scrollContext.left;
+ }
module.cache = {
- fits : ( element.height < window.height ),
- window: {
- height: window.height
+ fits : ( element.height < scrollContext.height ),
+ scrollContext : {
+ height : scrollContext.height
},
element: {
margin : element.margin,
@@ -10944,9 +15768,9 @@ $.fn.sticky = function(parameters) {
bottom : element.offset.top + element.height
},
context: {
- top : context.offset.top,
- height : context.height,
- bottom : context.offset.top + context.height
+ top : context.offset.top,
+ height : context.height,
+ bottom : context.offset.top + context.height
}
};
module.set.containerSize();
@@ -10980,26 +15804,29 @@ $.fn.sticky = function(parameters) {
;
},
currentElementScroll: function() {
+ if(module.elementScroll) {
+ return module.elementScroll;
+ }
return ( module.is.top() )
? Math.abs(parseInt($module.css('top'), 10)) || 0
: Math.abs(parseInt($module.css('bottom'), 10)) || 0
;
},
+
elementScroll: function(scroll) {
scroll = scroll || $scroll.scrollTop();
var
element = module.cache.element,
- window = module.cache.window,
+ scrollContext = module.cache.scrollContext,
delta = module.get.scrollChange(scroll),
- maxScroll = (element.height - window.height + settings.offset),
- currentScroll = module.get.currentElementScroll(),
- possibleScroll = (currentScroll + delta),
- elementScroll
+ maxScroll = (element.height - scrollContext.height + settings.offset),
+ elementScroll = module.get.currentElementScroll(),
+ possibleScroll = (elementScroll + delta)
;
if(module.cache.fits || possibleScroll < 0) {
elementScroll = 0;
}
- else if (possibleScroll > maxScroll ) {
+ else if(possibleScroll > maxScroll ) {
elementScroll = maxScroll;
}
else {
@@ -11010,6 +15837,12 @@ $.fn.sticky = function(parameters) {
},
remove: {
+ lastScroll: function() {
+ delete module.lastScroll;
+ },
+ elementScroll: function(scroll) {
+ delete module.elementScroll;
+ },
offset: function() {
$module.css('margin-top', '');
}
@@ -11018,7 +15851,9 @@ $.fn.sticky = function(parameters) {
set: {
offset: function() {
module.verbose('Setting offset on element', settings.offset);
- $module.css('margin-top', settings.offset);
+ $module
+ .css('margin-top', settings.offset)
+ ;
},
containerSize: function() {
var
@@ -11027,15 +15862,30 @@ $.fn.sticky = function(parameters) {
if(tagName === 'HTML' || tagName == 'body') {
// this can trigger for too many reasons
//module.error(error.container, tagName, $module);
- $container = $module.offsetParent();
+ module.determineContainer();
}
else {
- module.debug('Settings container size', module.cache.context.height);
- $container.height(module.cache.context.height);
+ if( Math.abs($container.outerHeight() - module.cache.context.height) > settings.jitter) {
+ module.debug('Context has padding, specifying exact height for container', module.cache.context.height);
+ $container.css({
+ height: module.cache.context.height
+ });
+ }
}
},
+ minimumSize: function() {
+ var
+ element = module.cache.element
+ ;
+ $container
+ .css('min-height', element.height)
+ ;
+ },
scroll: function(scroll) {
module.debug('Setting scroll on element', scroll);
+ if(module.elementScroll == scroll) {
+ return;
+ }
if( module.is.top() ) {
$module
.css('bottom', '')
@@ -11051,17 +15901,16 @@ $.fn.sticky = function(parameters) {
},
size: function() {
if(module.cache.element.height !== 0 && module.cache.element.width !== 0) {
- $module
- .css({
- width : module.cache.element.width,
- height : module.cache.element.height
- })
- ;
+ element.style.setProperty('width', module.cache.element.width + 'px', 'important');
+ element.style.setProperty('height', module.cache.element.height + 'px', 'important');
}
}
},
is: {
+ standardScroll: function() {
+ return ($scroll[0] == window);
+ },
top: function() {
return $module.hasClass(className.top);
},
@@ -11082,54 +15931,67 @@ $.fn.sticky = function(parameters) {
}
},
- stick: function() {
+ stick: function(scroll) {
var
+ cachedPosition = scroll || $scroll.scrollTop(),
cache = module.cache,
fits = cache.fits,
element = cache.element,
- window = cache.window,
+ scrollContext = cache.scrollContext,
context = cache.context,
offset = (module.is.bottom() && settings.pushing)
? settings.bottomOffset
: settings.offset,
scroll = {
- top : $scroll.scrollTop() + offset,
- bottom : $scroll.scrollTop() + offset + window.height
+ top : cachedPosition + offset,
+ bottom : cachedPosition + offset + scrollContext.height
},
direction = module.get.direction(scroll.top),
- elementScroll = module.get.elementScroll(scroll.top),
+ elementScroll = (fits)
+ ? 0
+ : module.get.elementScroll(scroll.top),
// shorthand
doesntFit = !fits,
elementVisible = (element.height !== 0)
;
- // save current scroll for next run
- module.save.scroll(scroll.top);
-
if(elementVisible) {
if( module.is.initialPosition() ) {
- if(scroll.top >= element.top) {
- module.debug('Element passed, fixing element to page');
- module.fixTop();
+ if(scroll.top >= context.bottom) {
+ module.debug('Initial element position is bottom of container');
+ module.bindBottom();
}
+ else if(scroll.top > element.top) {
+ if( (element.height + scroll.top - elementScroll) >= context.bottom ) {
+ module.debug('Initial element position is bottom of container');
+ module.bindBottom();
+ }
+ else {
+ module.debug('Initial element position is fixed');
+ module.fixTop();
+ }
+ }
+
}
else if( module.is.fixed() ) {
// currently fixed top
if( module.is.top() ) {
- if( scroll.top < element.top ) {
+ if( scroll.top <= element.top ) {
module.debug('Fixed element reached top of container');
module.setInitialPosition();
}
- else if( (element.height + scroll.top - elementScroll) > context.bottom ) {
+ else if( (element.height + scroll.top - elementScroll) >= context.bottom ) {
module.debug('Fixed element reached bottom of container');
module.bindBottom();
}
// scroll element if larger than screen
else if(doesntFit) {
module.set.scroll(elementScroll);
+ module.save.lastScroll(scroll.top);
+ module.save.elementScroll(elementScroll);
}
}
@@ -11137,33 +15999,41 @@ $.fn.sticky = function(parameters) {
else if(module.is.bottom() ) {
// top edge
- if( (scroll.bottom - element.height) < element.top) {
+ if( (scroll.bottom - element.height) <= element.top) {
module.debug('Bottom fixed rail has reached top of container');
module.setInitialPosition();
}
// bottom edge
- else if(scroll.bottom > context.bottom) {
+ else if(scroll.bottom >= context.bottom) {
module.debug('Bottom fixed rail has reached bottom of container');
module.bindBottom();
}
// scroll element if larger than screen
else if(doesntFit) {
module.set.scroll(elementScroll);
+ module.save.lastScroll(scroll.top);
+ module.save.elementScroll(elementScroll);
}
}
}
else if( module.is.bottom() ) {
- if(settings.pushing) {
- if(module.is.bound() && scroll.bottom < context.bottom ) {
- module.debug('Fixing bottom attached element to bottom of browser.');
- module.fixBottom();
- }
+ if( scroll.top <= element.top ) {
+ module.debug('Jumped from bottom fixed to top fixed, most likely used home/end button');
+ module.setInitialPosition();
}
else {
- if(module.is.bound() && (scroll.top < context.bottom - element.height) ) {
- module.debug('Fixing bottom attached element to top of browser.');
- module.fixTop();
+ if(settings.pushing) {
+ if(module.is.bound() && scroll.bottom <= context.bottom ) {
+ module.debug('Fixing bottom attached element to bottom of browser.');
+ module.fixBottom();
+ }
+ }
+ else {
+ if(module.is.bound() && (scroll.top <= context.bottom - element.height) ) {
+ module.debug('Fixing bottom attached element to top of browser.');
+ module.fixTop();
+ }
}
}
}
@@ -11174,34 +16044,38 @@ $.fn.sticky = function(parameters) {
module.debug('Binding element to top of parent container');
module.remove.offset();
$module
- .css('left' , '')
- .css('top' , '')
- .css('bottom' , '')
+ .css({
+ left : '',
+ top : '',
+ marginBottom : ''
+ })
.removeClass(className.fixed)
.removeClass(className.bottom)
.addClass(className.bound)
.addClass(className.top)
;
- $.proxy(settings.onTop, element)();
- $.proxy(settings.onUnstick, element)();
+ settings.onTop.call(element);
+ settings.onUnstick.call(element);
},
bindBottom: function() {
module.debug('Binding element to bottom of parent container');
module.remove.offset();
$module
- .css('left' , '')
- .css('top' , '')
- .css('bottom' , '')
+ .css({
+ left : '',
+ top : ''
+ })
.removeClass(className.fixed)
.removeClass(className.top)
.addClass(className.bound)
.addClass(className.bottom)
;
- $.proxy(settings.onBottom, element)();
- $.proxy(settings.onUnstick, element)();
+ settings.onBottom.call(element);
+ settings.onUnstick.call(element);
},
setInitialPosition: function() {
+ module.debug('Returning to initial position');
module.unfix();
module.unbind();
},
@@ -11209,49 +16083,63 @@ $.fn.sticky = function(parameters) {
fixTop: function() {
module.debug('Fixing element to top of page');
+ module.set.minimumSize();
module.set.offset();
$module
- .css('left', module.cache.element.left)
+ .css({
+ left : module.cache.element.left,
+ bottom : '',
+ marginBottom : ''
+ })
.removeClass(className.bound)
.removeClass(className.bottom)
.addClass(className.fixed)
.addClass(className.top)
;
- $.proxy(settings.onStick, element)();
+ settings.onStick.call(element);
},
fixBottom: function() {
module.debug('Sticking element to bottom of page');
+ module.set.minimumSize();
module.set.offset();
$module
- .css('left', module.cache.element.left)
+ .css({
+ left : module.cache.element.left,
+ bottom : '',
+ marginBottom : ''
+ })
.removeClass(className.bound)
.removeClass(className.top)
.addClass(className.fixed)
.addClass(className.bottom)
;
- $.proxy(settings.onStick, element)();
+ settings.onStick.call(element);
},
unbind: function() {
- module.debug('Removing absolute position on element');
- module.remove.offset();
- $module
- .removeClass(className.bound)
- .removeClass(className.top)
- .removeClass(className.bottom)
- ;
+ if( module.is.bound() ) {
+ module.debug('Removing container bound position on element');
+ module.remove.offset();
+ $module
+ .removeClass(className.bound)
+ .removeClass(className.top)
+ .removeClass(className.bottom)
+ ;
+ }
},
unfix: function() {
- module.debug('Removing fixed position on element');
- module.remove.offset();
- $module
- .removeClass(className.fixed)
- .removeClass(className.top)
- .removeClass(className.bottom)
- ;
- $.proxy(settings.onUnstick, this)();
+ if( module.is.fixed() ) {
+ module.debug('Removing fixed position on element');
+ module.remove.offset();
+ $module
+ .removeClass(className.fixed)
+ .removeClass(className.top)
+ .removeClass(className.bottom)
+ ;
+ settings.onUnstick.call(element);
+ }
},
reset: function() {
@@ -11259,13 +16147,13 @@ $.fn.sticky = function(parameters) {
module.unbind();
module.unfix();
module.resetCSS();
+ module.remove.offset();
+ module.remove.lastScroll();
},
resetCSS: function() {
$module
.css({
- top : '',
- bottom : '',
width : '',
height : ''
})
@@ -11439,7 +16327,7 @@ $.fn.sticky = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
@@ -11454,25 +16342,49 @@ $.fn.sticky = function(parameters) {
$.fn.sticky.settings = {
- name : 'Sticky',
- namespace : 'sticky',
+ name : 'Sticky',
+ namespace : 'sticky',
- debug : false,
- verbose : false,
- performance : false,
+ debug : false,
+ verbose : true,
+ performance : true,
- pushing : false,
- context : false,
- scrollContext : window,
- offset : 0,
- bottomOffset : 0,
+ // whether to stick in the opposite direction on scroll up
+ pushing : false,
+
+ context : false,
+
+ // Context to watch scroll events
+ scrollContext : window,
+
+ // Offset to adjust scroll
+ offset : 0,
+
+ // Offset to adjust scroll when attached to bottom of screen
+ bottomOffset : 0,
+
+ jitter : 5, // will only set container height if difference between context and container is larger than this number
+
+ // Whether to automatically observe changes with Mutation Observers
+ observeChanges : false,
- onReposition : function(){},
- onScroll : function(){},
- onStick : function(){},
- onUnstick : function(){},
- onTop : function(){},
- onBottom : function(){},
+ // Called when position is recalculated
+ onReposition : function(){},
+
+ // Called on each scroll
+ onScroll : function(){},
+
+ // Called when element is stuck to viewport
+ onStick : function(){},
+
+ // Called when element is unstuck from viewport
+ onUnstick : function(){},
+
+ // Called when element reaches top of context
+ onTop : function(){},
+
+ // Called when element reaches bottom of context
+ onBottom : function(){},
error : {
container : 'Sticky element must be inside a relative container',
@@ -11492,14 +16404,13 @@ $.fn.sticky.settings = {
};
-})( jQuery, window , document );
-
- /*
- * # Semantic - Tab
+})( jQuery, window, document );
+/*!
+ * # Semantic UI 2.1.6 - Tab
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributors
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -11509,7 +16420,7 @@ $.fn.sticky.settings = {
"use strict";
-$.tab = $.fn.tab = function(parameters) {
+$.fn.tab = function(parameters) {
var
// use window context if none specified
@@ -11517,10 +16428,6 @@ $.tab = $.fn.tab = function(parameters) {
? $(window)
: $(this),
- settings = ( $.isPlainObject(parameters) )
- ? $.extend(true, {}, $.fn.tab.settings, parameters)
- : $.extend({}, $.fn.tab.settings),
-
moduleSelector = $allModules.selector || '',
time = new Date().getTime(),
performance = [],
@@ -11529,65 +16436,94 @@ $.tab = $.fn.tab = function(parameters) {
methodInvoked = (typeof query == 'string'),
queryArguments = [].slice.call(arguments, 1),
- module,
+ initializedHistory = false,
returnedValue
;
-
$allModules
.each(function() {
var
- className = settings.className,
- metadata = settings.metadata,
- selector = settings.selector,
- error = settings.error,
-
- eventNamespace = '.' + settings.namespace,
- moduleNamespace = 'module-' + settings.namespace,
+ settings = ( $.isPlainObject(parameters) )
+ ? $.extend(true, {}, $.fn.tab.settings, parameters)
+ : $.extend({}, $.fn.tab.settings),
- $module = $(this),
+ className = settings.className,
+ metadata = settings.metadata,
+ selector = settings.selector,
+ error = settings.error,
- cache = {},
- firstLoad = true,
- recursionDepth = 0,
+ eventNamespace = '.' + settings.namespace,
+ moduleNamespace = 'module-' + settings.namespace,
+ $module = $(this),
$context,
$tabs,
+
+ cache = {},
+ firstLoad = true,
+ recursionDepth = 0,
+ element = this,
+ instance = $module.data(moduleNamespace),
+
activeTabPath,
parameterArray,
- historyEvent,
+ module,
+
+ historyEvent
- element = this,
- instance = $module.data(moduleNamespace)
;
module = {
initialize: function() {
module.debug('Initializing tab menu item', $module);
-
+ module.fix.callbacks();
module.determineTabs();
- module.debug('Determining tabs', settings.context, $tabs);
+ module.debug('Determining tabs', settings.context, $tabs);
// set up automatic routing
if(settings.auto) {
- module.verbose('Setting up automatic tab retrieval from server');
- settings.apiSettings = {
- url: settings.path + '/{$tab}'
- };
+ module.set.auto();
}
+ module.bind.events();
- // attach events if navigation wasn't set to window
- if( !$.isWindow( element ) ) {
- module.debug('Attaching tab activation events to element', $module);
- $module
- .on('click' + eventNamespace, module.event.click)
- ;
+ if(settings.history && !initializedHistory) {
+ module.initializeHistory();
+ initializedHistory = true;
}
+
module.instantiate();
},
+ instantiate: function () {
+ module.verbose('Storing instance of module', module);
+ instance = module;
+ $module
+ .data(moduleNamespace, module)
+ ;
+ },
+
+ destroy: function() {
+ module.debug('Destroying tabs', $module);
+ $module
+ .removeData(moduleNamespace)
+ .off(eventNamespace)
+ ;
+ },
+
+ bind: {
+ events: function() {
+ // if using $.tab don't add events
+ if( !$.isWindow( element ) ) {
+ module.debug('Attaching tab activation events to element', $module);
+ $module
+ .on('click' + eventNamespace, module.event.click)
+ ;
+ }
+ }
+ },
+
determineTabs: function() {
var
$reference
@@ -11595,9 +16531,9 @@ $.tab = $.fn.tab = function(parameters) {
// determine tab context
if(settings.context === 'parent') {
- if($module.closest(selector.ui).size() > 0) {
+ if($module.closest(selector.ui).length > 0) {
$reference = $module.closest(selector.ui);
- module.verbose('Using closest UI element for determining parent', $reference);
+ module.verbose('Using closest UI element as parent', $reference);
}
else {
$reference = $module;
@@ -11612,7 +16548,6 @@ $.tab = $.fn.tab = function(parameters) {
else {
$context = $('body');
}
-
// find tabs
if(settings.childrenOnly) {
$tabs = $context.children(selector.tabs);
@@ -11624,47 +16559,48 @@ $.tab = $.fn.tab = function(parameters) {
}
},
- initializeHistory: function() {
- if(settings.history) {
- module.debug('Initializing page state');
- if( $.address === undefined ) {
- module.error(error.state);
- return false;
- }
- else {
- if(settings.historyType == 'state') {
- module.debug('Using HTML5 to manage state');
- if(settings.path !== false) {
- $.address
- .history(true)
- .state(settings.path)
- ;
- }
- else {
- module.error(error.path);
- return false;
- }
+ fix: {
+ callbacks: function() {
+ if( $.isPlainObject(parameters) && (parameters.onTabLoad || parameters.onTabInit) ) {
+ if(parameters.onTabLoad) {
+ parameters.onLoad = parameters.onTabLoad;
+ delete parameters.onTabLoad;
+ module.error(error.legacyLoad, parameters.onLoad);
}
- $.address
- .bind('change', module.event.history.change)
- ;
+ if(parameters.onTabInit) {
+ parameters.onFirstLoad = parameters.onTabInit;
+ delete parameters.onTabInit;
+ module.error(error.legacyInit, parameters.onFirstLoad);
+ }
+ settings = $.extend(true, {}, $.fn.tab.settings, parameters);
}
}
},
- instantiate: function () {
- module.verbose('Storing instance of module', module);
- $module
- .data(moduleNamespace, module)
- ;
- },
-
- destroy: function() {
- module.debug('Destroying tabs', $module);
- $module
- .removeData(moduleNamespace)
- .off(eventNamespace)
- ;
+ initializeHistory: function() {
+ module.debug('Initializing page state');
+ if( $.address === undefined ) {
+ module.error(error.state);
+ return false;
+ }
+ else {
+ if(settings.historyType == 'state') {
+ module.debug('Using HTML5 to manage state');
+ if(settings.path !== false) {
+ $.address
+ .history(true)
+ .state(settings.path)
+ ;
+ }
+ else {
+ module.error(error.path);
+ return false;
+ }
+ }
+ $.address
+ .bind('change', module.event.history.change)
+ ;
+ }
},
event: {
@@ -11734,6 +16670,39 @@ $.tab = $.fn.tab = function(parameters) {
},
set: {
+ auto: function() {
+ var
+ url = (typeof settings.path == 'string')
+ ? settings.path.replace(/\/$/, '') + '/{$tab}'
+ : '/{$tab}'
+ ;
+ module.verbose('Setting up automatic tab retrieval from server', url);
+ if($.isPlainObject(settings.apiSettings)) {
+ settings.apiSettings.url = url;
+ }
+ else {
+ settings.apiSettings = {
+ url: url
+ };
+ }
+ },
+ loading: function(tabPath) {
+ var
+ $tab = module.get.tabElement(tabPath),
+ isLoading = $tab.hasClass(className.loading)
+ ;
+ if(!isLoading) {
+ module.verbose('Setting loading state for', $tab);
+ $tab
+ .addClass(className.loading)
+ .siblings($tabs)
+ .removeClass(className.active + ' ' + className.loading)
+ ;
+ if($tab.length > 0) {
+ settings.onRequest.call($tab[0], tabPath);
+ }
+ }
+ },
state: function(state) {
$.address.value(state);
}
@@ -11744,7 +16713,7 @@ $.tab = $.fn.tab = function(parameters) {
pushStateAvailable = (window.history && window.history.pushState),
shouldIgnoreLoad = (pushStateAvailable && settings.ignoreFirstLoad && firstLoad),
remoteContent = (settings.auto || $.isPlainObject(settings.apiSettings) ),
- // only get default path if not remote content
+ // only add default path if not remote content
pathArray = (remoteContent && !shouldIgnoreLoad)
? module.utilities.pathToArray(tabPath)
: module.get.defaultPathArray(tabPath)
@@ -11767,9 +16736,8 @@ $.tab = $.fn.tab = function(parameters) {
module.verbose('Looking for tab', tab);
if(isTab) {
module.verbose('Tab was found', tab);
-
// scope up
- activeTabPath = currentPath;
+ activeTabPath = currentPath;
parameterArray = module.utilities.filterArray(pathArray, currentPathArray);
if(isLastIndex) {
@@ -11786,15 +16754,15 @@ $.tab = $.fn.tab = function(parameters) {
if(isLastTab && remoteContent) {
if(!shouldIgnoreLoad) {
module.activate.navigation(currentPath);
- module.content.fetch(currentPath, tabPath);
+ module.fetch.content(currentPath, tabPath);
}
else {
module.debug('Ignoring remote content on first tab load', currentPath);
firstLoad = false;
module.cache.add(tabPath, $tab.html());
module.activate.all(currentPath);
- $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent);
- $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
+ settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent);
+ settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent);
}
return false;
}
@@ -11804,25 +16772,32 @@ $.tab = $.fn.tab = function(parameters) {
if( !module.cache.read(currentPath) ) {
module.cache.add(currentPath, true);
module.debug('First time tab loaded calling tab init');
- $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent);
+ settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent);
}
- $.proxy(settings.onTabLoad, $tab)(currentPath, parameterArray, historyEvent);
+ settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent);
}
+
}
- else if(tabPath.search('/') == -1) {
+ else if(tabPath.search('/') == -1 && tabPath !== '') {
// look for in page anchor
- $anchor = $('#' + tabPath + ', a[name="' + tabPath + '"]'),
- currentPath = $anchor.closest('[data-tab]').data('tab');
+ $anchor = $('#' + tabPath + ', a[name="' + tabPath + '"]');
+ currentPath = $anchor.closest('[data-tab]').data(metadata.tab);
$tab = module.get.tabElement(currentPath);
// if anchor exists use parent tab
- if($anchor && $anchor.size() > 0 && currentPath) {
- module.debug('No tab found, but deep anchor link present, opening parent tab');
+ if($anchor && $anchor.length > 0 && currentPath) {
+ module.debug('Anchor link used, opening parent tab', $tab, $anchor);
+ if( !$tab.hasClass(className.active) ) {
+ setTimeout(function() {
+ module.scrollTo($anchor);
+ }, 0);
+ }
module.activate.all(currentPath);
if( !module.cache.read(currentPath) ) {
module.cache.add(currentPath, true);
module.debug('First time tab loaded calling tab init');
- $.proxy(settings.onTabInit, $tab)(currentPath, parameterArray, historyEvent);
+ settings.onFirstLoad.call($tab[0], currentPath, parameterArray, historyEvent);
}
+ settings.onLoad.call($tab[0], currentPath, parameterArray, historyEvent);
return false;
}
}
@@ -11833,17 +16808,55 @@ $.tab = $.fn.tab = function(parameters) {
});
},
- content: {
+ scrollTo: function($element) {
+ var
+ scrollOffset = ($element && $element.length > 0)
+ ? $element.offset().top
+ : false
+ ;
+ if(scrollOffset !== false) {
+ module.debug('Forcing scroll to an in-page link in a hidden tab', scrollOffset, $element);
+ $(document).scrollTop(scrollOffset);
+ }
+ },
- fetch: function(tabPath, fullTabPath) {
+ update: {
+ content: function(tabPath, html, evaluateScripts) {
var
- $tab = module.get.tabElement(tabPath),
- apiSettings = {
- dataType : 'html',
- stateContext : $tab,
- onSuccess : function(response) {
+ $tab = module.get.tabElement(tabPath),
+ tab = $tab[0]
+ ;
+ evaluateScripts = (evaluateScripts !== undefined)
+ ? evaluateScripts
+ : settings.evaluateScripts
+ ;
+ if(evaluateScripts) {
+ module.debug('Updating HTML and evaluating inline scripts', tabPath, html);
+ $tab.html(html);
+ }
+ else {
+ module.debug('Updating HTML', tabPath, html);
+ tab.innerHTML = html;
+ }
+ }
+ },
+
+ fetch: {
+
+ content: function(tabPath, fullTabPath) {
+ var
+ $tab = module.get.tabElement(tabPath),
+ apiSettings = {
+ dataType : 'html',
+ encodeParameters : false,
+ on : 'now',
+ cache : settings.alwaysRefresh,
+ headers : {
+ 'X-Remote': true
+ },
+ onSuccess : function(response) {
module.cache.add(fullTabPath, response);
- module.content.update(tabPath, response);
+ module.update.content(tabPath, response);
if(tabPath == activeTabPath) {
module.debug('Content loaded', tabPath);
module.activate.tab(tabPath);
@@ -11851,12 +16864,14 @@ $.tab = $.fn.tab = function(parameters) {
else {
module.debug('Content loaded in background', tabPath);
}
- $.proxy(settings.onTabInit, $tab)(tabPath, parameterArray, historyEvent);
- $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
+ settings.onFirstLoad.call($tab[0], tabPath, parameterArray, historyEvent);
+ settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent);
},
- urlData: { tab: fullTabPath }
+ urlData: {
+ tab: fullTabPath
+ }
},
- request = $tab.data(metadata.promise) || false,
+ request = $tab.api('get request') || false,
existingRequest = ( request && request.state() === 'pending' ),
requestSettings,
cachedContent
@@ -11865,36 +16880,31 @@ $.tab = $.fn.tab = function(parameters) {
fullTabPath = fullTabPath || tabPath;
cachedContent = module.cache.read(fullTabPath);
+
if(settings.cache && cachedContent) {
- module.debug('Showing existing content', fullTabPath);
- module.content.update(tabPath, cachedContent);
module.activate.tab(tabPath);
- $.proxy(settings.onTabLoad, $tab)(tabPath, parameterArray, historyEvent);
+ module.debug('Adding cached content', fullTabPath);
+ if(settings.evaluateScripts == 'once') {
+ module.update.content(tabPath, cachedContent, false);
+ }
+ else {
+ module.update.content(tabPath, cachedContent);
+ }
+ settings.onLoad.call($tab[0], tabPath, parameterArray, historyEvent);
}
else if(existingRequest) {
+ module.set.loading(tabPath);
module.debug('Content is already loading', fullTabPath);
- $tab
- .addClass(className.loading)
- ;
}
else if($.api !== undefined) {
- requestSettings = $.extend(true, { headers: { 'X-Remote': true } }, settings.apiSettings, apiSettings);
+ requestSettings = $.extend(true, {}, settings.apiSettings, apiSettings);
module.debug('Retrieving remote content', fullTabPath, requestSettings);
- $.api( requestSettings );
+ module.set.loading(tabPath);
+ $tab.api(requestSettings);
}
else {
module.error(error.api);
}
- },
-
- update: function(tabPath, html) {
- module.debug('Updating html for', tabPath);
- var
- $tab = module.get.tabElement(tabPath)
- ;
- $tab
- .html(html)
- ;
}
},
@@ -11905,25 +16915,34 @@ $.tab = $.fn.tab = function(parameters) {
},
tab: function(tabPath) {
var
- $tab = module.get.tabElement(tabPath)
+ $tab = module.get.tabElement(tabPath),
+ isActive = $tab.hasClass(className.active)
;
module.verbose('Showing tab content for', $tab);
- $tab
- .addClass(className.active)
- .siblings($tabs)
- .removeClass(className.active + ' ' + className.loading)
- ;
+ if(!isActive) {
+ $tab
+ .addClass(className.active)
+ .siblings($tabs)
+ .removeClass(className.active + ' ' + className.loading)
+ ;
+ if($tab.length > 0) {
+ settings.onVisible.call($tab[0], tabPath);
+ }
+ }
},
navigation: function(tabPath) {
var
- $navigation = module.get.navElement(tabPath)
+ $navigation = module.get.navElement(tabPath),
+ isActive = $navigation.hasClass(className.active)
;
module.verbose('Activating tab navigation for', $navigation, tabPath);
- $navigation
- .addClass(className.active)
- .siblings($allModules)
- .removeClass(className.active + ' ' + className.loading)
- ;
+ if(!isActive) {
+ $navigation
+ .addClass(className.active)
+ .siblings($allModules)
+ .removeClass(className.active + ' ' + className.loading)
+ ;
+ }
}
},
@@ -11947,7 +16966,7 @@ $.tab = $.fn.tab = function(parameters) {
is: {
tab: function(tabName) {
return (tabName !== undefined)
- ? ( module.get.tabElement(tabName).size() > 0 )
+ ? ( module.get.tabElement(tabName).length > 0 )
: false
;
}
@@ -11997,9 +17016,9 @@ $.tab = $.fn.tab = function(parameters) {
tabPath = tabPath || activeTabPath;
tabPathArray = module.utilities.pathToArray(tabPath);
lastTab = module.utilities.last(tabPathArray);
- $fullPathTab = $tabs.filter('[data-' + metadata.tab + '="' + lastTab + '"]');
- $simplePathTab = $tabs.filter('[data-' + metadata.tab + '="' + tabPath + '"]');
- return ($fullPathTab.size() > 0)
+ $fullPathTab = $tabs.filter('[data-' + metadata.tab + '="' + tabPath + '"]');
+ $simplePathTab = $tabs.filter('[data-' + metadata.tab + '="' + lastTab + '"]');
+ return ($fullPathTab.length > 0)
? $fullPathTab
: $simplePathTab
;
@@ -12107,7 +17126,7 @@ $.tab = $.fn.tab = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -12193,7 +17212,6 @@ $.tab = $.fn.tab = function(parameters) {
return found;
}
};
-
if(methodInvoked) {
if(instance === undefined) {
module.initialize();
@@ -12202,15 +17220,12 @@ $.tab = $.fn.tab = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
})
;
- if(module && !methodInvoked) {
- module.initializeHistory();
- }
return (returnedValue !== undefined)
? returnedValue
: this
@@ -12219,60 +17234,53 @@ $.tab = $.fn.tab = function(parameters) {
};
// shortcut for tabbed content with no defined navigation
-$.tab = function(settings) {
- $(window).tab(settings);
+$.tab = function() {
+ $(window).tab.apply(this, arguments);
};
$.fn.tab.settings = {
- name : 'Tab',
- namespace : 'tab',
-
- debug : false,
- verbose : true,
- performance : true,
-
- // uses pjax style endpoints fetching content from same url with remote-content headers
- auto : false,
- history : false,
- historyType : 'hash',
- path : false,
+ name : 'Tab',
+ namespace : 'tab',
- context : false,
- childrenOnly : false,
-
- // max depth a tab can be nested
- maxDepth : 25,
-
- // dont load content on first load
- ignoreFirstLoad : false,
+ debug : false,
+ verbose : false,
+ performance : true,
- // load tab content new every tab click
- alwaysRefresh : false,
+ auto : false, // uses pjax style endpoints fetching content from same url with remote-content headers
+ history : false, // use browser history
+ historyType : 'hash', // #/ or html5 state
+ path : false, // base path of url
- // cache the content requests to pull locally
- cache : true,
+ context : false, // specify a context that tabs must appear inside
+ childrenOnly : false, // use only tabs that are children of context
+ maxDepth : 25, // max depth a tab can be nested
- // settings for api call
- apiSettings : false,
+ alwaysRefresh : false, // load tab content new every tab click
+ cache : true, // cache the content requests to pull locally
+ ignoreFirstLoad : false, // don't load remote content on first load
- // only called first time a tab's content is loaded (when remote source)
- onTabInit : function(tabPath, parameterArray, historyEvent) {},
+ apiSettings : false, // settings for api call
+ evaluateScripts : 'once', // whether inline scripts should be parsed (true/false/once). Once will not re-evaluate on cached content
- // called on every load
- onTabLoad : function(tabPath, parameterArray, historyEvent) {},
+ onFirstLoad : function(tabPath, parameterArray, historyEvent) {}, // called first time loaded
+ onLoad : function(tabPath, parameterArray, historyEvent) {}, // called on every load
+ onVisible : function(tabPath, parameterArray, historyEvent) {}, // called every time tab visible
+ onRequest : function(tabPath, parameterArray, historyEvent) {}, // called ever time a tab beings loading remote content
templates : {
- determineTitle: function(tabArray) {}
+ determineTitle: function(tabArray) {} // returns page title for path
},
error: {
api : 'You attempted to load content without API module',
method : 'The method you called is not defined',
- missingTab : 'Activated tab cannot be found for this context.',
+ missingTab : 'Activated tab cannot be found. Tabs are case-sensitive.',
noContent : 'The tab you specified is missing a content url.',
path : 'History enabled, but no path was specified',
recursion : 'Max recursive depth reached',
+ legacyInit : 'onTabInit has been renamed to onFirstLoad in 2.0, please adjust your code.',
+ legacyLoad : 'onTabLoad has been renamed to onLoad in 2.0. Please adjust your code',
state : 'History requires Asual\'s Address library <https://github.com/asual/jquery-address>'
},
@@ -12294,13 +17302,14 @@ $.fn.tab.settings = {
};
-})( jQuery, window , document );
-/*
- * # Semantic - Transition
+})( jQuery, window, document );
+
+/*!
+ * # Semantic UI 2.1.6 - Transition
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -12332,7 +17341,7 @@ $.fn.transition = function() {
returnedValue
;
$allModules
- .each(function() {
+ .each(function(index) {
var
$module = $(this),
element = this,
@@ -12344,7 +17353,6 @@ $.fn.transition = function() {
error,
className,
metadata,
- animationStart,
animationEnd,
animationName,
@@ -12359,32 +17367,41 @@ $.fn.transition = function() {
initialize: function() {
// get full settings
- moduleNamespace = 'module-' + namespace;
settings = module.get.settings.apply(element, moduleArguments);
+
+ // shorthand
className = settings.className;
+ error = settings.error;
metadata = settings.metadata;
- animationStart = module.get.animationStartEvent();
- animationEnd = module.get.animationEndEvent();
- animationName = module.get.animationName();
- error = settings.error;
- namespace = settings.namespace;
+ // define namespace
eventNamespace = '.' + settings.namespace;
+ moduleNamespace = 'module-' + settings.namespace;
instance = $module.data(moduleNamespace) || module;
+ // get vendor specific events
+ animationEnd = module.get.animationEndEvent();
+
if(methodInvoked) {
methodInvoked = module.invoke(query);
}
- // no internal method was found matching query or query not made
+
+ // method not invoked, lets run an animation
if(methodInvoked === false) {
module.verbose('Converted arguments into settings object', settings);
- module.animate();
+ if(settings.interval) {
+ module.delay(settings.animate);
+ }
+ else {
+ module.animate();
+ }
module.instantiate();
}
},
instantiate: function() {
module.verbose('Storing instance of module', module);
+ instance = module;
$module
.data(moduleNamespace, instance)
;
@@ -12408,7 +17425,7 @@ $.fn.transition = function() {
$parentElement = $module.parent(),
$nextElement = $module.next()
;
- if($nextElement.size() === 0) {
+ if($nextElement.length === 0) {
$module.detach().appendTo($parentElement);
}
else {
@@ -12423,6 +17440,31 @@ $.fn.transition = function() {
;
},
+ delay: function(interval) {
+ var
+ direction = module.get.animationDirection(),
+ shouldReverse,
+ delay
+ ;
+ if(!direction) {
+ direction = module.can.transition()
+ ? module.get.direction()
+ : 'static'
+ ;
+ }
+ interval = (interval !== undefined)
+ ? interval
+ : settings.interval
+ ;
+ shouldReverse = (settings.reverse == 'auto' && direction == className.outward);
+ delay = (shouldReverse || settings.reverse == true)
+ ? ($allModules.length - index) * settings.interval
+ : index * settings.interval
+ ;
+ module.debug('Delaying animation by', delay);
+ setTimeout(module.animate, delay);
+ },
+
animate: function(overrideSettings) {
settings = overrideSettings || settings;
if(!module.is.supported()) {
@@ -12432,29 +17474,34 @@ $.fn.transition = function() {
module.debug('Preparing animation', settings.animation);
if(module.is.animating()) {
if(settings.queue) {
- if(!settings.allowRepeats && module.has.direction() && module.is.occuring() && module.queuing !== true) {
- module.error(error.repeated, settings.animation, $module);
+ if(!settings.allowRepeats && module.has.direction() && module.is.occurring() && module.queuing !== true) {
+ module.debug('Animation is currently occurring, preventing queueing same animation', settings.animation);
}
else {
module.queue(settings.animation);
}
return false;
}
+ else if(!settings.allowRepeats && module.is.occurring()) {
+ module.debug('Animation is already occurring, will not execute repeated animation', settings.animation);
+ return false;
+ }
else {
-
+ module.debug('New animation started, completing previous early', settings.animation);
+ instance.complete();
}
}
if( module.can.animate() ) {
module.set.animating(settings.animation);
}
else {
- module.error(error.noAnimation, settings.animation);
+ module.error(error.noAnimation, settings.animation, element);
}
},
reset: function() {
module.debug('Resetting animation to beginning conditions');
- module.remove.animationEndCallback();
+ module.remove.animationCallbacks();
module.restore.conditions();
module.remove.animating();
},
@@ -12463,7 +17510,7 @@ $.fn.transition = function() {
module.debug('Queueing animation of', animation);
module.queuing = true;
$module
- .one(animationEnd + eventNamespace, function() {
+ .one(animationEnd + '.queue' + eventNamespace, function() {
module.queuing = false;
module.repaint();
module.animate.apply(this, settings);
@@ -12471,41 +17518,84 @@ $.fn.transition = function() {
;
},
- complete: function () {
- module.verbose('CSS animation complete', settings.animation);
- module.remove.animationEndCallback();
+ complete: function (event) {
+ module.debug('Animation complete', settings.animation);
+ module.remove.completeCallback();
module.remove.failSafe();
if(!module.is.looping()) {
if( module.is.outward() ) {
module.verbose('Animation is outward, hiding element');
module.restore.conditions();
module.hide();
- $.proxy(settings.onHide, this)();
}
else if( module.is.inward() ) {
module.verbose('Animation is outward, showing element');
module.restore.conditions();
module.show();
- module.set.display();
- $.proxy(settings.onShow, this)();
}
else {
+ module.verbose('Static animation completed');
module.restore.conditions();
+ settings.onComplete.call(element);
+ }
+ }
+ },
+
+ force: {
+ visible: function() {
+ var
+ style = $module.attr('style'),
+ userStyle = module.get.userStyle(),
+ displayType = module.get.displayType(),
+ overrideStyle = userStyle + 'display: ' + displayType + ' !important;',
+ currentDisplay = $module.css('display'),
+ emptyStyle = (style === undefined || style === '')
+ ;
+ if(currentDisplay !== displayType) {
+ module.verbose('Overriding default display to show element', displayType);
+ $module
+ .attr('style', overrideStyle)
+ ;
+ }
+ else if(emptyStyle) {
+ $module.removeAttr('style');
+ }
+ },
+ hidden: function() {
+ var
+ style = $module.attr('style'),
+ currentDisplay = $module.css('display'),
+ emptyStyle = (style === undefined || style === '')
+ ;
+ if(currentDisplay !== 'none' && !module.is.hidden()) {
+ module.verbose('Overriding default display to hide element');
+ $module
+ .css('display', 'none')
+ ;
+ }
+ else if(emptyStyle) {
+ $module
+ .removeAttr('style')
+ ;
}
- module.remove.animation();
- module.remove.animating();
}
- $.proxy(settings.onComplete, this)();
},
has: {
direction: function(animation) {
+ var
+ hasDirection = false
+ ;
animation = animation || settings.animation;
- if( animation.search(className.inward) !== -1 || animation.search(className.outward) !== -1) {
- module.debug('Direction already set in animation');
- return true;
+ if(typeof animation === 'string') {
+ animation = animation.split(' ');
+ $.each(animation, function(index, word){
+ if(word === className.inward || word === className.outward) {
+ hasDirection = true;
+ }
+ });
}
- return false;
+ return hasDirection;
},
inlineDisplay: function() {
var
@@ -12517,29 +17607,28 @@ $.fn.transition = function() {
set: {
animating: function(animation) {
- animation = animation || settings.animation;
- if(!module.is.animating()) {
- module.save.conditions();
- }
- module.remove.direction();
- module.remove.animationEndCallback();
- if(module.can.transition() && !module.has.direction()) {
- module.set.direction();
- }
- module.remove.hidden();
- module.set.display();
- $module
- .addClass(className.animating)
- .addClass(className.transition)
- .addClass(animation)
- .one(animationEnd + '.complete' + eventNamespace, module.complete)
+ var
+ animationClass,
+ direction
;
- if(settings.useFailSafe) {
- module.add.failSafe();
- }
- module.set.duration(settings.duration);
- $.proxy(settings.onStart, this)();
- module.debug('Starting tween', animation, $module.attr('class'));
+ // remove previous callbacks
+ module.remove.completeCallback();
+
+ // determine exact animation
+ animation = animation || settings.animation;
+ animationClass = module.get.animationClass(animation);
+
+ // save animation class in cache to restore class names
+ module.save.animation(animationClass);
+
+ // override display if necessary so animation appears visibly
+ module.force.visible();
+
+ module.remove.hidden();
+ module.remove.direction();
+
+ module.start.animation(animationClass);
+
},
duration: function(animationName, duration) {
duration = duration || settings.duration;
@@ -12547,46 +17636,22 @@ $.fn.transition = function() {
? duration + 'ms'
: duration
;
- module.verbose('Setting animation duration', duration);
- $module
- .css({
- '-webkit-animation-duration': duration,
- '-moz-animation-duration': duration,
- '-ms-animation-duration': duration,
- '-o-animation-duration': duration,
- 'animation-duration': duration
- })
- ;
- },
- display: function() {
- var
- style = module.get.style(),
- displayType = module.get.displayType(),
- overrideStyle = style + 'display: ' + displayType + ' !important;'
- ;
- $module.css('display', '');
- module.refresh();
- if( $module.css('display') !== displayType ) {
- module.verbose('Setting inline visibility to', displayType);
+ if(duration || duration === 0) {
+ module.verbose('Setting animation duration', duration);
$module
- .attr('style', overrideStyle)
+ .css({
+ 'animation-duration': duration
+ })
;
}
},
- direction: function() {
- if($module.is(':visible') && !module.is.hidden()) {
- module.debug('Automatically determining the direction of animation', 'Outward');
- $module
- .removeClass(className.inward)
- .addClass(className.outward)
- ;
+ direction: function(direction) {
+ direction = direction || module.get.direction();
+ if(direction == className.inward) {
+ module.set.inward();
}
else {
- module.debug('Automatically determining the direction of animation', 'Inward');
- $module
- .removeClass(className.outward)
- .addClass(className.inward)
- ;
+ module.set.outward();
}
},
looping: function() {
@@ -12596,18 +17661,24 @@ $.fn.transition = function() {
;
},
hidden: function() {
- if(!module.is.hidden()) {
- $module
- .addClass(className.transition)
- .addClass(className.hidden)
- ;
- if($module.css('display') !== 'none') {
- module.verbose('Overriding default display to hide element');
- $module
- .css('display', 'none')
- ;
- }
- }
+ $module
+ .addClass(className.transition)
+ .addClass(className.hidden)
+ ;
+ },
+ inward: function() {
+ module.debug('Setting direction to inward');
+ $module
+ .removeClass(className.outward)
+ .addClass(className.inward)
+ ;
+ },
+ outward: function() {
+ module.debug('Setting direction to outward');
+ $module
+ .removeClass(className.inward)
+ .addClass(className.outward)
+ ;
},
visible: function() {
$module
@@ -12617,48 +17688,52 @@ $.fn.transition = function() {
}
},
+ start: {
+ animation: function(animationClass) {
+ animationClass = animationClass || module.get.animationClass();
+ module.debug('Starting tween', animationClass);
+ $module
+ .addClass(animationClass)
+ .one(animationEnd + '.complete' + eventNamespace, module.complete)
+ ;
+ if(settings.useFailSafe) {
+ module.add.failSafe();
+ }
+ module.set.duration(settings.duration);
+ settings.onStart.call(element);
+ }
+ },
+
save: {
+ animation: function(animation) {
+ if(!module.cache) {
+ module.cache = {};
+ }
+ module.cache.animation = animation;
+ },
displayType: function(displayType) {
- $module.data(metadata.displayType, displayType);
+ if(displayType !== 'none') {
+ $module.data(metadata.displayType, displayType);
+ }
},
transitionExists: function(animation, exists) {
$.fn.transition.exists[animation] = exists;
module.verbose('Saving existence of transition', animation, exists);
- },
- conditions: function() {
- var
- clasName = $module.attr('class') || false,
- style = $module.attr('style') || ''
- ;
- $module.removeClass(settings.animation);
- module.remove.direction();
- module.cache = {
- className : $module.attr('class'),
- style : module.get.style()
- };
- module.verbose('Saving original attributes', module.cache);
}
},
restore: {
conditions: function() {
- if(module.cache === undefined) {
- return false;
- }
- if(module.cache.className) {
- $module.attr('class', module.cache.className);
- }
- else {
- $module.removeAttr('class');
- }
- if(module.cache.style) {
- module.verbose('Restoring original style attribute', module.cache.style);
- $module.attr('style', module.cache.style);
- }
- if(module.is.looping()) {
- module.remove.looping();
+ var
+ animation = module.get.currentAnimation()
+ ;
+ if(animation) {
+ $module
+ .removeClass(animation)
+ ;
+ module.verbose('Removing animation class', module.cache);
}
- module.verbose('Restoring original attributes', module.cache);
+ module.remove.duration();
}
},
@@ -12667,7 +17742,9 @@ $.fn.transition = function() {
var
duration = module.get.duration()
;
- module.timer = setTimeout(module.complete, duration + 100);
+ module.timer = setTimeout(function() {
+ $module.triggerHandler(animationEnd);
+ }, duration + settings.failSafeDelay);
module.verbose('Adding fail safe timer', module.timer);
}
},
@@ -12676,19 +17753,15 @@ $.fn.transition = function() {
animating: function() {
$module.removeClass(className.animating);
},
- animation: function() {
- $module
- .css({
- '-webkit-animation' : '',
- '-moz-animation' : '',
- '-ms-animation' : '',
- '-o-animation' : '',
- 'animation' : ''
- })
- ;
+ animationCallbacks: function() {
+ module.remove.queueCallback();
+ module.remove.completeCallback();
+ },
+ queueCallback: function() {
+ $module.off('.queue' + eventNamespace);
},
- animationEndCallback: function() {
- $module.off('.complete');
+ completeCallback: function() {
+ $module.off('.complete' + eventNamespace);
},
display: function() {
$module.css('display', '');
@@ -12699,6 +17772,11 @@ $.fn.transition = function() {
.removeClass(className.outward)
;
},
+ duration: function() {
+ $module
+ .css('animation-duration', '')
+ ;
+ },
failSafe: function() {
module.verbose('Removing fail safe timer', module.timer);
if(module.timer) {
@@ -12713,10 +17791,12 @@ $.fn.transition = function() {
},
looping: function() {
module.debug('Transitions are no longer looping');
- $module
- .removeClass(className.looping)
- ;
- module.forceRepaint();
+ if( module.is.looping() ) {
+ module.reset();
+ $module
+ .removeClass(className.looping)
+ ;
+ }
},
transition: function() {
$module
@@ -12767,9 +17847,66 @@ $.fn.transition = function() {
}
return $.fn.transition.settings;
},
+ animationClass: function(animation) {
+ var
+ animationClass = animation || settings.animation,
+ directionClass = (module.can.transition() && !module.has.direction())
+ ? module.get.direction() + ' '
+ : ''
+ ;
+ return className.animating + ' '
+ + className.transition + ' '
+ + directionClass
+ + animationClass
+ ;
+ },
+ currentAnimation: function() {
+ return (module.cache && module.cache.animation !== undefined)
+ ? module.cache.animation
+ : false
+ ;
+ },
+ currentDirection: function() {
+ return module.is.inward()
+ ? className.inward
+ : className.outward
+ ;
+ },
+ direction: function() {
+ return module.is.hidden() || !module.is.visible()
+ ? className.inward
+ : className.outward
+ ;
+ },
+ animationDirection: function(animation) {
+ var
+ direction
+ ;
+ animation = animation || settings.animation;
+ if(typeof animation === 'string') {
+ animation = animation.split(' ');
+ // search animation name for out/in class
+ $.each(animation, function(index, word){
+ if(word === className.inward) {
+ direction = className.inward;
+ }
+ else if(word === className.outward) {
+ direction = className.outward;
+ }
+ });
+ }
+ // return found direction
+ if(direction) {
+ return direction;
+ }
+ return false;
+ },
duration: function(duration) {
duration = duration || settings.duration;
- return (typeof settings.duration === 'string')
+ if(duration === false) {
+ duration = $module.css('animation-duration') || 0;
+ }
+ return (typeof duration === 'string')
? (duration.indexOf('ms') > -1)
? parseFloat(duration)
: parseFloat(duration) * 1000
@@ -12786,32 +17923,12 @@ $.fn.transition = function() {
}
return $module.data(metadata.displayType);
},
- style: function() {
- var
- style = $module.attr('style') || ''
- ;
+ userStyle: function(style) {
+ style = style || $module.attr('style') || '';
return style.replace(/display.*?;/, '');
},
transitionExists: function(animation) {
- return $.fn.transition.exists[animation];
- },
- animationName: function() {
- var
- element = document.createElement('div'),
- animations = {
- 'animation' :'animationName',
- 'OAnimation' :'oAnimationName',
- 'MozAnimation' :'mozAnimationName',
- 'WebkitAnimation' :'webkitAnimationName'
- },
- animation
- ;
- for(animation in animations){
- if( element.style[animation] !== undefined ){
- return animations[animation];
- }
- }
- return false;
+ return true; //$.fn.transition.exists[animation];
},
animationStartEvent: function() {
var
@@ -12855,10 +17972,10 @@ $.fn.transition = function() {
can: {
transition: function(forced) {
var
- elementClass = $module.attr('class'),
- tagName = $module.prop('tagName'),
animation = settings.animation,
transitionExists = module.get.transitionExists(animation),
+ elementClass,
+ tagName,
$clone,
currentAnimation,
inAnimation,
@@ -12867,6 +17984,9 @@ $.fn.transition = function() {
;
if( transitionExists === undefined || forced) {
module.verbose('Determining whether animation exists');
+ elementClass = $module.attr('class');
+ tagName = $module.prop('tagName');
+
$clone = $('<' + tagName + ' />').addClass( elementClass ).insertAfter($module);
currentAnimation = $clone
.addClass(animation)
@@ -12874,11 +17994,11 @@ $.fn.transition = function() {
.removeClass(className.outward)
.addClass(className.animating)
.addClass(className.transition)
- .css(animationName)
+ .css('animationName')
;
inAnimation = $clone
.addClass(className.inward)
- .css(animationName)
+ .css('animationName')
;
displayType = $clone
.attr('class', elementClass)
@@ -12889,6 +18009,8 @@ $.fn.transition = function() {
.css('display')
;
module.verbose('Determining final display state', displayType);
+ module.save.displayType(displayType);
+
$clone.remove();
if(currentAnimation != inAnimation) {
module.debug('Direction exists for animation', animation);
@@ -12902,7 +18024,6 @@ $.fn.transition = function() {
module.debug('Static animation found', animation, displayType);
directionExists = false;
}
- module.save.displayType(displayType);
module.save.transitionExists(animation, directionExists);
}
return (transitionExists !== undefined)
@@ -12929,10 +18050,10 @@ $.fn.transition = function() {
looping: function() {
return $module.hasClass(className.looping);
},
- occuring: function(animation) {
+ occurring: function(animation) {
animation = animation || settings.animation;
- animation = animation.replace(' ', '.');
- return ( $module.filter(animation).size() > 0 );
+ animation = '.' + animation.replace(' ', '.');
+ return ( $module.filter(animation).length > 0 );
},
visible: function() {
return $module.is(':visible');
@@ -12941,7 +18062,7 @@ $.fn.transition = function() {
return $module.css('visibility') === 'hidden';
},
supported: function() {
- return(animationName !== false && animationEnd !== false);
+ return(animationEnd !== false);
}
},
@@ -12950,34 +18071,63 @@ $.fn.transition = function() {
if( module.is.animating() ) {
module.reset();
}
+ element.blur(); // IE will trigger focus change if element is not blurred before hiding
module.remove.display();
module.remove.visible();
module.set.hidden();
- module.repaint();
+ module.force.hidden();
+ settings.onHide.call(element);
+ settings.onComplete.call(element);
+ // module.repaint();
},
show: function(display) {
module.verbose('Showing element', display);
module.remove.hidden();
module.set.visible();
- module.repaint();
+ module.force.visible();
+ settings.onShow.call(element);
+ settings.onComplete.call(element);
+ // module.repaint();
+ },
+
+ toggle: function() {
+ if( module.is.visible() ) {
+ module.hide();
+ }
+ else {
+ module.show();
+ }
},
- start: function() {
+ stop: function() {
+ module.debug('Stopping current animation');
+ $module.triggerHandler(animationEnd);
+ },
+
+ stopAll: function() {
+ module.debug('Stopping all animation');
+ module.remove.queueCallback();
+ $module.triggerHandler(animationEnd);
+ },
+
+ clear: {
+ queue: function() {
+ module.debug('Clearing animation queue');
+ module.remove.queueCallback();
+ }
+ },
+
+ enable: function() {
module.verbose('Starting animation');
$module.removeClass(className.disabled);
},
- stop: function() {
+ disable: function() {
module.debug('Stopping animation');
$module.addClass(className.disabled);
},
- toggle: function() {
- module.debug('Toggling play status');
- $module.toggleClass(className.disabled);
- },
-
setting: function(name, value) {
module.debug('Changing setting', name, value);
if( $.isPlainObject(name) ) {
@@ -13047,7 +18197,7 @@ $.fn.transition = function() {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 600);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -13063,8 +18213,8 @@ $.fn.transition = function() {
if(moduleSelector) {
title += ' \'' + moduleSelector + '\'';
}
- if($allModules.size() > 1) {
- title += ' ' + '(' + $allModules.size() + ')';
+ if($allModules.length > 1) {
+ title += ' ' + '(' + $allModules.length + ')';
}
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
console.groupCollapsed(title);
@@ -13155,41 +18305,50 @@ $.fn.transition.exists = {};
$.fn.transition.settings = {
// module info
- name : 'Transition',
+ name : 'Transition',
// debug content outputted to console
- debug : false,
+ debug : false,
// verbose debug output
- verbose : true,
+ verbose : false,
// performance data output
- performance : true,
+ performance : true,
// event namespace
- namespace : 'transition',
+ namespace : 'transition',
- // animation complete event
- onStart : function() {},
- onComplete : function() {},
- onShow : function() {},
- onHide : function() {},
+ // delay between animations in group
+ interval : 0,
+
+ // whether group animations should be reversed
+ reverse : 'auto',
+
+ // animation callback event
+ onStart : function() {},
+ onComplete : function() {},
+ onShow : function() {},
+ onHide : function() {},
// whether timeout should be used to ensure callback fires in cases animationend does not
- useFailSafe : false,
+ useFailSafe : true,
+
+ // delay in ms for fail safe
+ failSafeDelay : 100,
// whether EXACT animation can occur twice in a row
- allowRepeats : false,
+ allowRepeats : false,
// Override final display type on visible
- displayType : false,
+ displayType : false,
// animation duration
- animation : 'fade',
- duration : '500ms',
+ animation : 'fade',
+ duration : false,
// new animations will occur after previous ones
- queue : true,
+ queue : true,
metadata : {
displayType: 'display'
@@ -13209,7 +18368,7 @@ $.fn.transition.settings = {
// possible errors
error: {
- noAnimation : 'There is no css animation matching the one you specified.',
+ noAnimation : 'There is no css animation matching the one you specified. Please make sure your css is vendor prefixed, and you have included transition css.',
repeated : 'That animation is already occurring, cancelling repeated animation',
method : 'The method you called is not defined',
support : 'This browser does not support CSS animations'
@@ -13218,561 +18377,23 @@ $.fn.transition.settings = {
};
-})( jQuery, window , document );
+})( jQuery, window, document );
- /*
- * # Semantic - Video
+/*!
+ * # Semantic UI 2.1.6 - API
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributors
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
*/
-;(function ($, window, document, undefined) {
+;(function ( $, window, document, undefined ) {
"use strict";
-$.fn.video = function(parameters) {
-
- var
- $allModules = $(this),
-
- moduleSelector = $allModules.selector || '',
-
- time = new Date().getTime(),
- performance = [],
-
- query = arguments[0],
- methodInvoked = (typeof query == 'string'),
- queryArguments = [].slice.call(arguments, 1),
-
- requestAnimationFrame = window.requestAnimationFrame
- || window.mozRequestAnimationFrame
- || window.webkitRequestAnimationFrame
- || window.msRequestAnimationFrame
- || function(callback) { setTimeout(callback, 0); },
-
- returnedValue
- ;
-
- $allModules
- .each(function() {
- var
- settings = ( $.isPlainObject(parameters) )
- ? $.extend(true, {}, $.fn.video.settings, parameters)
- : $.extend({}, $.fn.video.settings),
-
- selector = settings.selector,
- className = settings.className,
- error = settings.error,
- metadata = settings.metadata,
- namespace = settings.namespace,
- templates = settings.templates,
-
- eventNamespace = '.' + namespace,
- moduleNamespace = 'module-' + namespace,
-
- $window = $(window),
- $module = $(this),
- $placeholder = $module.find(selector.placeholder),
- $playButton = $module.find(selector.playButton),
- $embed = $module.find(selector.embed),
-
- element = this,
- instance = $module.data(moduleNamespace),
- module
- ;
-
- module = {
-
- initialize: function() {
- module.debug('Initializing video');
- module.create();
- $placeholder
- .on('click' + eventNamespace, module.play)
- ;
- $playButton
- .on('click' + eventNamespace, module.play)
- ;
- module.instantiate();
- },
-
- instantiate: function() {
- module.verbose('Storing instance of module', module);
- instance = module;
- $module
- .data(moduleNamespace, module)
- ;
- },
-
- create: function() {
- var
- image = $module.data(metadata.image),
- html = templates.video(image)
- ;
- $module.html(html);
- module.refresh();
- if(!image) {
- module.play();
- }
- module.debug('Creating html for video element', html);
- },
-
- destroy: function() {
- module.verbose('Destroying previous instance of video');
- module.reset();
- $module
- .removeData(moduleNamespace)
- .off(eventNamespace)
- ;
- $placeholder
- .off(eventNamespace)
- ;
- $playButton
- .off(eventNamespace)
- ;
- },
-
- refresh: function() {
- module.verbose('Refreshing selector cache');
- $placeholder = $module.find(selector.placeholder);
- $playButton = $module.find(selector.playButton);
- $embed = $module.find(selector.embed);
- },
-
- // sets new video
- change: function(source, id, url) {
- module.debug('Changing video to ', source, id, url);
- $module
- .data(metadata.source, source)
- .data(metadata.id, id)
- .data(metadata.url, url)
- ;
- settings.onChange();
- },
-
- // clears video embed
- reset: function() {
- module.debug('Clearing video embed and showing placeholder');
- $module
- .removeClass(className.active)
- ;
- $embed
- .html(' ')
- ;
- $placeholder
- .show()
- ;
- settings.onReset();
- },
-
- // plays current video
- play: function() {
- module.debug('Playing video');
- var
- source = $module.data(metadata.source) || false,
- url = $module.data(metadata.url) || false,
- id = $module.data(metadata.id) || false
- ;
- $embed
- .html( module.generate.html(source, id, url) )
- ;
- $module
- .addClass(className.active)
- ;
- settings.onPlay();
- },
-
- get: {
- source: function(url) {
- if(typeof url !== 'string') {
- return false;
- }
- if(url.search('youtube.com') !== -1) {
- return 'youtube';
- }
- else if(url.search('vimeo.com') !== -1) {
- return 'vimeo';
- }
- return false;
- },
- id: function(url) {
- if(settings.regExp.youtube.test(url)) {
- return url.match(settings.regExp.youtube)[1];
- }
- else if(settings.regExp.vimeo.test(url)) {
- return url.match(settings.regExp.vimeo)[2];
- }
- return false;
- }
- },
-
- generate: {
- // generates iframe html
- html: function(source, id, url) {
- module.debug('Generating embed html');
- var
- html
- ;
- // allow override of settings
- source = source || settings.source;
- id = id || settings.id;
- if((source && id) || url) {
- if(!source || !id) {
- source = module.get.source(url);
- id = module.get.id(url);
- }
- if(source == 'vimeo') {
- html = ''
- + '<iframe src="http://player.vimeo.com/video/' + id + '?=' + module.generate.url(source) + '"'
- + ' width="100%" height="100%"'
- + ' frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'
- ;
- }
- else if(source == 'youtube') {
- html = ''
- + '<iframe src="http://www.youtube.com/embed/' + id + '?=' + module.generate.url(source) + '"'
- + ' width="100%" height="100%"'
- + ' frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'
- ;
- }
- }
- else {
- module.error(error.noVideo);
- }
- return html;
- },
-
- // generate url parameters
- url: function(source) {
- var
- api = (settings.api)
- ? 1
- : 0,
- autoplay = (settings.autoplay === 'auto')
- ? ($module.data('image') !== undefined)
- : settings.autoplay,
- hd = (settings.hd)
- ? 1
- : 0,
- showUI = (settings.showUI)
- ? 1
- : 0,
- // opposite used for some params
- hideUI = !(settings.showUI)
- ? 1
- : 0,
- url = ''
- ;
- if(source == 'vimeo') {
- url = ''
- + 'api=' + api
- + '&amp;title=' + showUI
- + '&amp;byline=' + showUI
- + '&amp;portrait=' + showUI
- + '&amp;autoplay=' + autoplay
- ;
- if(settings.color) {
- url += '&amp;color=' + settings.color;
- }
- }
- if(source == 'ustream') {
- url = ''
- + 'autoplay=' + autoplay
- ;
- if(settings.color) {
- url += '&amp;color=' + settings.color;
- }
- }
- else if(source == 'youtube') {
- url = ''
- + 'enablejsapi=' + api
- + '&amp;autoplay=' + autoplay
- + '&amp;autohide=' + hideUI
- + '&amp;hq=' + hd
- + '&amp;modestbranding=1'
- ;
- if(settings.color) {
- url += '&amp;color=' + settings.color;
- }
- }
- return url;
- }
- },
-
- setting: function(name, value) {
- module.debug('Changing setting', name, value);
- if( $.isPlainObject(name) ) {
- $.extend(true, settings, name);
- }
- else if(value !== undefined) {
- settings[name] = value;
- }
- else {
- return settings[name];
- }
- },
- internal: function(name, value) {
- if( $.isPlainObject(name) ) {
- $.extend(true, module, name);
- }
- else if(value !== undefined) {
- module[name] = value;
- }
- else {
- return module[name];
- }
- },
- debug: function() {
- if(settings.debug) {
- if(settings.performance) {
- module.performance.log(arguments);
- }
- else {
- module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
- module.debug.apply(console, arguments);
- }
- }
- },
- verbose: function() {
- if(settings.verbose && settings.debug) {
- if(settings.performance) {
- module.performance.log(arguments);
- }
- else {
- module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
- module.verbose.apply(console, arguments);
- }
- }
- },
- error: function() {
- module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
- module.error.apply(console, arguments);
- },
- performance: {
- log: function(message) {
- var
- currentTime,
- executionTime,
- previousTime
- ;
- if(settings.performance) {
- currentTime = new Date().getTime();
- previousTime = time || currentTime;
- executionTime = currentTime - previousTime;
- time = currentTime;
- performance.push({
- 'Name' : message[0],
- 'Arguments' : [].slice.call(message, 1) || '',
- 'Element' : element,
- 'Execution Time' : executionTime
- });
- }
- clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
- },
- display: function() {
- var
- title = settings.name + ':',
- totalTime = 0
- ;
- time = false;
- clearTimeout(module.performance.timer);
- $.each(performance, function(index, data) {
- totalTime += data['Execution Time'];
- });
- title += ' ' + totalTime + 'ms';
- if(moduleSelector) {
- title += ' \'' + moduleSelector + '\'';
- }
- if($allModules.size() > 1) {
- title += ' ' + '(' + $allModules.size() + ')';
- }
- if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
- console.groupCollapsed(title);
- if(console.table) {
- console.table(performance);
- }
- else {
- $.each(performance, function(index, data) {
- console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
- });
- }
- console.groupEnd();
- }
- performance = [];
- }
- },
- invoke: function(query, passedArguments, context) {
- var
- object = instance,
- maxDepth,
- found,
- response
- ;
- passedArguments = passedArguments || queryArguments;
- context = element || context;
- if(typeof query == 'string' && object !== undefined) {
- query = query.split(/[\. ]/);
- maxDepth = query.length - 1;
- $.each(query, function(depth, value) {
- var camelCaseValue = (depth != maxDepth)
- ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
- : query
- ;
- if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
- object = object[camelCaseValue];
- }
- else if( object[camelCaseValue] !== undefined ) {
- found = object[camelCaseValue];
- return false;
- }
- else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
- object = object[value];
- }
- else if( object[value] !== undefined ) {
- found = object[value];
- return false;
- }
- else {
- return false;
- }
- });
- }
- if ( $.isFunction( found ) ) {
- response = found.apply(context, passedArguments);
- }
- else if(found !== undefined) {
- response = found;
- }
- if($.isArray(returnedValue)) {
- returnedValue.push(response);
- }
- else if(returnedValue !== undefined) {
- returnedValue = [returnedValue, response];
- }
- else if(response !== undefined) {
- returnedValue = response;
- }
- return found;
- }
- };
-
- if(methodInvoked) {
- if(instance === undefined) {
- module.initialize();
- }
- module.invoke(query);
- }
- else {
- if(instance !== undefined) {
- module.destroy();
- }
- module.initialize();
- }
- })
- ;
- return (returnedValue !== undefined)
- ? returnedValue
- : this
- ;
-};
-
-$.fn.video.settings = {
-
- name : 'Video',
- namespace : 'video',
-
- debug : false,
- verbose : true,
- performance : true,
-
- metadata : {
- id : 'id',
- image : 'image',
- source : 'source',
- url : 'url'
- },
-
- source : false,
- url : false,
- id : false,
-
- aspectRatio : (16/9),
-
- onPlay : function(){},
- onReset : function(){},
- onChange : function(){},
-
- // callbacks not coded yet (needs to use jsapi)
- onPause : function() {},
- onStop : function() {},
-
- width : 'auto',
- height : 'auto',
-
- autoplay : 'auto',
- color : '#442359',
- hd : true,
- showUI : false,
- api : true,
-
- regExp : {
- youtube : /^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/,
- vimeo : /http:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/
- },
-
- error : {
- noVideo : 'No video specified',
- method : 'The method you called is not defined'
- },
-
- className : {
- active : 'active'
- },
-
- selector : {
- embed : '.embed',
- placeholder : '.placeholder',
- playButton : '.play'
- }
-};
-
-$.fn.video.settings.templates = {
- video: function(image) {
- var
- html = ''
- ;
- if(image) {
- html += ''
- + '<i class="video play icon"></i>'
- + '<img class="placeholder" src="' + image + '">'
- ;
- }
- html += '<div class="embed"></div>';
- return html;
- }
-};
-
-
-})( jQuery, window , document );
-
-/*
- * # Semantic - API
- * http://github.com/semantic-org/semantic-ui/
- *
- *
- * Copyright 2014 Contributor
- * Released under the MIT license
- * http://opensource.org/licenses/MIT
- *
- */
-
-;(function ( $, window, document, undefined ) {
-
$.api = $.fn.api = function(parameters) {
var
@@ -13823,10 +18444,11 @@ $.api = $.fn.api = function(parameters) {
requestSettings,
url,
data,
+ requestStartTime,
// standard module
element = this,
- context = $context.get(),
+ context = $context[0],
instance = $module.data(moduleNamespace),
module
;
@@ -13834,20 +18456,8 @@ $.api = $.fn.api = function(parameters) {
module = {
initialize: function() {
- var
- triggerEvent = module.get.event()
- ;
- // bind events
if(!methodInvoked) {
- if( triggerEvent ) {
- module.debug('Attaching API events to element', triggerEvent);
- $module
- .on(triggerEvent + eventNamespace, module.event.trigger)
- ;
- }
- else {
- module.query();
- }
+ module.bind.events();
}
module.instantiate();
},
@@ -13868,16 +18478,87 @@ $.api = $.fn.api = function(parameters) {
;
},
+ bind: {
+ events: function() {
+ var
+ triggerEvent = module.get.event()
+ ;
+ if( triggerEvent ) {
+ module.verbose('Attaching API events to element', triggerEvent);
+ $module
+ .on(triggerEvent + eventNamespace, module.event.trigger)
+ ;
+ }
+ else if(settings.on == 'now') {
+ module.debug('Querying API endpoint immediately');
+ module.query();
+ }
+ }
+ },
+
+ decode: {
+ json: function(response) {
+ if(response !== undefined && typeof response == 'string') {
+ try {
+ response = JSON.parse(response);
+ }
+ catch(e) {
+ // isnt json string
+ }
+ }
+ return response;
+ }
+ },
+
+ read: {
+ cachedResponse: function(url) {
+ var
+ response
+ ;
+ if(window.Storage === undefined) {
+ module.error(error.noStorage);
+ return;
+ }
+ response = sessionStorage.getItem(url);
+ module.debug('Using cached response', url, response);
+ response = module.decode.json(response);
+ return false;
+ }
+ },
+ write: {
+ cachedResponse: function(url, response) {
+ if(response && response === '') {
+ module.debug('Response empty, not caching', response);
+ return;
+ }
+ if(window.Storage === undefined) {
+ module.error(error.noStorage);
+ return;
+ }
+ if( $.isPlainObject(response) ) {
+ response = JSON.stringify(response);
+ }
+ sessionStorage.setItem(url, response);
+ module.verbose('Storing cached response for url', url, response);
+ }
+ },
+
query: function() {
if(module.is.disabled()) {
module.debug('Element is disabled API request aborted');
return;
}
- // determine if an api event already occurred
- if(module.is.loading() && settings.throttle === 0 ) {
- module.debug('Cancelling request, previous request is still pending');
- return;
+
+ if(module.is.loading()) {
+ if(settings.interruptRequests) {
+ module.debug('Interrupting previous request');
+ module.abort();
+ }
+ else {
+ module.debug('Cancelling request, previous request is still pending');
+ return;
+ }
}
// pass element metadata to url (value, text)
@@ -13886,49 +18567,39 @@ $.api = $.fn.api = function(parameters) {
}
// Add form content
- if(settings.serializeForm !== false || $context.is('form')) {
- if(settings.serializeForm == 'json') {
- $.extend(true, settings.data, module.get.formData());
- }
- else {
- settings.data = module.get.formData();
- }
+ if(settings.serializeForm) {
+ settings.data = module.add.formData(settings.data);
}
// call beforesend and get any settings changes
requestSettings = module.get.settings();
- // check if beforesend cancelled request
+ // check if before send cancelled request
if(requestSettings === false) {
+ module.cancelled = true;
module.error(error.beforeSend);
return;
}
-
- if(settings.url) {
- // override with url if specified
- module.debug('Using specified url', url);
- url = module.add.urlData( settings.url );
- }
else {
- // otherwise find url from api endpoints
- url = module.add.urlData( module.get.templateURL() );
- module.debug('Added URL Data to url', url);
+ module.cancelled = false;
}
- // exit conditions reached, missing url parameters
- if( !url ) {
- if($module.is('form')) {
- module.debug('No url or action specified, defaulting to form action');
- url = $module.attr('action');
- }
- else {
- module.error(error.missingURL, settings.action);
- return;
- }
+ // get url
+ url = module.get.templatedURL();
+
+ if(!url && !module.is.mocked()) {
+ module.error(error.missingURL);
+ return;
+ }
+
+ // replace variables
+ url = module.add.urlData( url );
+
+ // missing url parameters
+ if( !url && !module.is.mocked()) {
+ return;
}
- // add loading state
- module.set.loading();
// look for jQuery ajax parameters in settings
ajaxSettings = $.extend(true, {}, settings, {
@@ -13941,33 +18612,94 @@ $.api = $.fn.api = function(parameters) {
complete : function() {}
});
- module.verbose('Creating AJAX request with settings', ajaxSettings);
+ module.debug('Querying URL', ajaxSettings.url);
+ module.verbose('Using AJAX settings', ajaxSettings);
- if( !module.is.loading() ) {
+ if(settings.cache === 'local' && module.read.cachedResponse(url)) {
+ module.debug('Response returned from local cache');
module.request = module.create.request();
- module.xhr = module.create.xhr();
+ module.request.resolveWith(context, [ module.read.cachedResponse(url) ]);
+ return;
+ }
+
+ if( !settings.throttle ) {
+ module.debug('Sending request', data, ajaxSettings.method);
+ module.send.request();
}
else {
- // throttle additional requests
- module.timer = setTimeout(function() {
- module.request = module.create.request();
- module.xhr = module.create.xhr();
- }, settings.throttle);
+ if(!settings.throttleFirstRequest && !module.timer) {
+ module.debug('Sending request', data, ajaxSettings.method);
+ module.send.request();
+ module.timer = setTimeout(function(){}, settings.throttle);
+ }
+ else {
+ module.debug('Throttling request', settings.throttle);
+ clearTimeout(module.timer);
+ module.timer = setTimeout(function() {
+ if(module.timer) {
+ delete module.timer;
+ }
+ module.debug('Sending throttled request', data, ajaxSettings.method);
+ module.send.request();
+ }, settings.throttle);
+ }
}
},
+ should: {
+ removeError: function() {
+ return ( settings.hideError === true || (settings.hideError === 'auto' && !module.is.form()) );
+ }
+ },
is: {
disabled: function() {
- return ($module.filter(settings.filter).size() > 0);
+ return ($module.filter(selector.disabled).length > 0);
+ },
+ form: function() {
+ return $module.is('form') || $context.is('form');
+ },
+ mocked: function() {
+ return (settings.mockResponse || settings.mockResponseAsync);
+ },
+ input: function() {
+ return $module.is('input');
},
loading: function() {
return (module.request && module.request.state() == 'pending');
+ },
+ abortedRequest: function(xhr) {
+ if(xhr && xhr.readyState !== undefined && xhr.readyState === 0) {
+ module.verbose('XHR request determined to be aborted');
+ return true;
+ }
+ else {
+ module.verbose('XHR request was not aborted');
+ return false;
+ }
+ },
+ validResponse: function(response) {
+ if( (settings.dataType !== 'json' && settings.dataType !== 'jsonp') || !$.isFunction(settings.successTest) ) {
+ module.verbose('Response is not JSON, skipping validation', settings.successTest, response);
+ return true;
+ }
+ module.debug('Checking JSON returned success', settings.successTest, response);
+ if( settings.successTest(response) ) {
+ module.debug('Response passed success test', response);
+ return true;
+ }
+ else {
+ module.debug('Response failed success test', response);
+ return false;
+ }
}
},
was: {
+ cancelled: function() {
+ return (module.cancelled || false);
+ },
succesful: function() {
return (module.request && module.request.state() == 'resolved');
},
@@ -14013,6 +18745,10 @@ $.api = $.fn.api = function(parameters) {
}
else {
module.verbose('Found required variable', variable, value);
+ value = (settings.encodeParameters)
+ ? module.get.urlEncodedValue(value)
+ : value
+ ;
url = url.replace(templatedString, value);
}
});
@@ -14052,6 +18788,48 @@ $.api = $.fn.api = function(parameters) {
}
}
return url;
+ },
+ formData: function(data) {
+ var
+ canSerialize = ($.fn.serializeObject !== undefined),
+ formData = (canSerialize)
+ ? $form.serializeObject()
+ : $form.serialize(),
+ hasOtherData
+ ;
+ data = data || settings.data;
+ hasOtherData = $.isPlainObject(data);
+
+ if(hasOtherData) {
+ if(canSerialize) {
+ module.debug('Extending existing data with form data', data, formData);
+ data = $.extend(true, {}, data, formData);
+ }
+ else {
+ module.error(error.missingSerialize);
+ module.debug('Cant extend data. Replacing data with form data', data, formData);
+ data = formData;
+ }
+ }
+ else {
+ module.debug('Adding form data', formData);
+ data = formData;
+ }
+ return data;
+ }
+ },
+
+ send: {
+ request: function() {
+ module.set.loading();
+ module.request = module.create.request();
+ if( module.is.mocked() ) {
+ module.mockedXHR = module.create.mockedXHR();
+ }
+ else {
+ module.xhr = module.create.xhr();
+ }
+ settings.onRequest.call(context, module.request, module.xhr);
}
},
@@ -14064,130 +18842,192 @@ $.api = $.fn.api = function(parameters) {
},
xhr: {
always: function() {
- // calculate if loading time was below minimum threshold
+ // nothing special
},
- done: function(response) {
+ done: function(response, textStatus, xhr) {
var
- context = this,
- elapsedTime = (new Date().getTime() - time),
- timeLeft = (settings.loadingDuration - elapsedTime)
+ context = this,
+ elapsedTime = (new Date().getTime() - requestStartTime),
+ timeLeft = (settings.loadingDuration - elapsedTime),
+ translatedResponse = ( $.isFunction(settings.onResponse) )
+ ? settings.onResponse.call(context, $.extend(true, {}, response))
+ : false
;
timeLeft = (timeLeft > 0)
? timeLeft
: 0
;
+ if(translatedResponse) {
+ module.debug('Modified API response in onResponse callback', settings.onResponse, translatedResponse, response);
+ response = translatedResponse;
+ }
+ if(timeLeft > 0) {
+ module.debug('Response completed early delaying state change by', timeLeft);
+ }
setTimeout(function() {
- module.request.resolveWith(context, [response]);
+ if( module.is.validResponse(response) ) {
+ module.request.resolveWith(context, [response, xhr]);
+ }
+ else {
+ module.request.rejectWith(context, [xhr, 'invalid']);
+ }
}, timeLeft);
},
fail: function(xhr, status, httpMessage) {
var
context = this,
- elapsedTime = (new Date().getTime() - time),
+ elapsedTime = (new Date().getTime() - requestStartTime),
timeLeft = (settings.loadingDuration - elapsedTime)
;
timeLeft = (timeLeft > 0)
? timeLeft
: 0
;
- // page triggers abort on navigation, dont show error
+ if(timeLeft > 0) {
+ module.debug('Response completed early delaying state change by', timeLeft);
+ }
setTimeout(function() {
- if(status !== 'abort') {
- module.request.rejectWith(context, [xhr, status, httpMessage]);
+ if( module.is.abortedRequest(xhr) ) {
+ module.request.rejectWith(context, [xhr, 'aborted', httpMessage]);
}
else {
- module.reset();
+ module.request.rejectWith(context, [xhr, 'error', status, httpMessage]);
}
}, timeLeft);
}
},
request: {
- complete: function(response) {
- module.remove.loading();
- $.proxy(settings.onComplete, context)(response, $module);
+ done: function(response, xhr) {
+ module.debug('Successful API Response', response);
+ if(settings.cache === 'local' && url) {
+ module.write.cachedResponse(url, response);
+ module.debug('Saving server response locally', module.cache);
+ }
+ settings.onSuccess.call(context, response, $module, xhr);
},
- done: function(response) {
- module.debug('API Response Received', response);
- if(settings.dataType == 'json') {
- if( $.isFunction(settings.successTest) ) {
- module.debug('Checking JSON returned success', settings.successTest, response);
- if( settings.successTest(response) ) {
- $.proxy(settings.onSuccess, context)(response, $module);
- }
- else {
- module.debug('JSON test specified by user and response failed', response);
- $.proxy(settings.onFailure, context)(response, $module);
- }
- }
- else {
- $.proxy(settings.onSuccess, context)(response, $module);
- }
+ complete: function(firstParameter, secondParameter) {
+ var
+ xhr,
+ response
+ ;
+ // have to guess callback parameters based on request success
+ if( module.was.succesful() ) {
+ response = firstParameter;
+ xhr = secondParameter;
}
else {
- $.proxy(settings.onSuccess, context)(response, $module);
+ xhr = firstParameter;
+ response = module.get.responseFromXHR(xhr);
}
+ module.remove.loading();
+ settings.onComplete.call(context, response, $module, xhr);
},
- error: function(xhr, status, httpMessage) {
+ fail: function(xhr, status, httpMessage) {
var
- errorMessage = (settings.error[status] !== undefined)
- ? settings.error[status]
- : httpMessage,
- response
+ // pull response from xhr if available
+ response = module.get.responseFromXHR(xhr),
+ errorMessage = module.get.errorFromRequest(response, status, httpMessage)
;
- // let em know unless request aborted
- if(xhr !== undefined) {
- // readyState 4 = done, anything less is not really sent
- if(xhr.readyState !== undefined && xhr.readyState == 4) {
-
- // if http status code returned and json returned error, look for it
+ if(status == 'aborted') {
+ module.debug('XHR Aborted (Most likely caused by page navigation or CORS Policy)', status, httpMessage);
+ settings.onAbort.call(context, status, $module, xhr);
+ }
+ else if(status == 'invalid') {
+ module.debug('JSON did not pass success test. A server-side error has most likely occurred', response);
+ }
+ else if(status == 'error') {
+ if(xhr !== undefined) {
+ module.debug('XHR produced a server error', status, httpMessage);
+ // make sure we have an error to display to console
if( xhr.status != 200 && httpMessage !== undefined && httpMessage !== '') {
- module.error(error.statusMessage + httpMessage);
- }
- else {
- if(status == 'error' && settings.dataType == 'json') {
- try {
- response = $.parseJSON(xhr.responseText);
- if(response && response.error !== undefined) {
- errorMessage = response.error;
- }
- }
- catch(e) {
- module.error(error.JSONParse);
- }
- }
- }
- module.remove.loading();
- module.set.error();
- // show error state only for duration specified in settings
- if(settings.errorDuration) {
- setTimeout(module.remove.error, settings.errorDuration);
+ module.error(error.statusMessage + httpMessage, ajaxSettings.url);
}
- module.debug('API Request error:', errorMessage);
- $.proxy(settings.onError, context)(errorMessage, context);
+ settings.onError.call(context, errorMessage, $module, xhr);
}
- else {
- $.proxy(settings.onAbort, context)(errorMessage, context);
- module.debug('Request Aborted (Most likely caused by page change or CORS Policy)', status, httpMessage);
+ }
+
+ if(settings.errorDuration && status !== 'aborted') {
+ module.debug('Adding error state');
+ module.set.error();
+ if( module.should.removeError() ) {
+ setTimeout(module.remove.error, settings.errorDuration);
}
}
+ module.debug('API Request failed', errorMessage, xhr);
+ settings.onFailure.call(context, response, $module, xhr);
}
}
},
create: {
+
request: function() {
+ // api request promise
return $.Deferred()
.always(module.event.request.complete)
.done(module.event.request.done)
- .fail(module.event.request.error)
+ .fail(module.event.request.fail)
+ ;
+ },
+
+ mockedXHR: function () {
+ var
+ // xhr does not simulate these properties of xhr but must return them
+ textStatus = false,
+ status = false,
+ httpMessage = false,
+ asyncCallback,
+ response,
+ mockedXHR
;
+
+ mockedXHR = $.Deferred()
+ .always(module.event.xhr.complete)
+ .done(module.event.xhr.done)
+ .fail(module.event.xhr.fail)
+ ;
+
+ if(settings.mockResponse) {
+ if( $.isFunction(settings.mockResponse) ) {
+ module.debug('Using mocked callback returning response', settings.mockResponse);
+ response = settings.mockResponse.call(context, settings);
+ }
+ else {
+ module.debug('Using specified response', settings.mockResponse);
+ response = settings.mockResponse;
+ }
+ // simulating response
+ mockedXHR.resolveWith(context, [ response, textStatus, { responseText: response }]);
+ }
+ else if( $.isFunction(settings.mockResponseAsync) ) {
+ asyncCallback = function(response) {
+ module.debug('Async callback returned response', response);
+
+ if(response) {
+ mockedXHR.resolveWith(context, [ response, textStatus, { responseText: response }]);
+ }
+ else {
+ mockedXHR.rejectWith(context, [{ responseText: response }, status, httpMessage]);
+ }
+ };
+ module.debug('Using async mocked response', settings.mockResponseAsync);
+ settings.mockResponseAsync.call(context, settings, asyncCallback);
+ }
+ return mockedXHR;
},
+
xhr: function() {
- $.ajax(ajaxSettings)
+ var
+ xhr
+ ;
+ // ajax request promise
+ xhr = $.ajax(ajaxSettings)
.always(module.event.xhr.always)
.done(module.event.xhr.done)
.fail(module.event.xhr.fail)
;
+ module.verbose('Created server request', xhr);
+ return xhr;
}
},
@@ -14199,6 +19039,7 @@ $.api = $.fn.api = function(parameters) {
loading: function() {
module.verbose('Adding loading state to element', $context);
$context.addClass(className.loading);
+ requestStartTime = new Date().getTime();
}
},
@@ -14214,6 +19055,22 @@ $.api = $.fn.api = function(parameters) {
},
get: {
+ responseFromXHR: function(xhr) {
+ return $.isPlainObject(xhr)
+ ? (settings.dataType == 'json' || settings.dataType == 'jsonp')
+ ? module.decode.json(xhr.responseText)
+ : xhr.responseText
+ : false
+ ;
+ },
+ errorFromRequest: function(response, status, httpMessage) {
+ return ($.isPlainObject(response) && response.error !== undefined)
+ ? response.error // use json error message
+ : (settings.error[status] !== undefined) // use server error message
+ ? settings.error[status]
+ : httpMessage
+ ;
+ },
request: function() {
return module.request || false;
},
@@ -14224,7 +19081,7 @@ $.api = $.fn.api = function(parameters) {
var
runSettings
;
- runSettings = $.proxy(settings.beforeSend, $module)(settings);
+ runSettings = settings.beforeSend.call(context, settings);
if(runSettings) {
if(runSettings.success !== undefined) {
module.debug('Legacy success callback detected', runSettings);
@@ -14250,15 +19107,28 @@ $.api = $.fn.api = function(parameters) {
: settings
;
},
+ urlEncodedValue: function(value) {
+ var
+ decodedValue = window.decodeURIComponent(value),
+ encodedValue = window.encodeURIComponent(value),
+ alreadyEncoded = (decodedValue !== value)
+ ;
+ if(alreadyEncoded) {
+ module.debug('URL value is already encoded, avoiding double encoding', value);
+ return value;
+ }
+ module.verbose('Encoding value using encodeURIComponent', value, encodedValue);
+ return encodedValue;
+ },
defaultData: function() {
var
data = {}
;
if( !$.isWindow(element) ) {
- if( $module.is('input') ) {
+ if( module.is.input() ) {
data.value = $module.val();
}
- else if( $module.is('form') ) {
+ else if( !module.is.form() ) {
}
else {
@@ -14292,39 +19162,39 @@ $.api = $.fn.api = function(parameters) {
return settings.on;
}
},
- formData: function() {
- var
- formData
- ;
- if($(this).serializeObject() !== undefined) {
- formData = $form.serializeObject();
- }
- else {
- module.error(error.missingSerialize);
- formData = $form.serialize();
+ templatedURL: function(action) {
+ action = action || $module.data(metadata.action) || settings.action || false;
+ url = $module.data(metadata.url) || settings.url || false;
+ if(url) {
+ module.debug('Using specified url', url);
+ return url;
}
- module.debug('Retrieved form data', formData);
- return formData;
- },
- templateURL: function(action) {
- var
- url
- ;
- action = action || $module.data(settings.metadata.action) || settings.action || false;
if(action) {
module.debug('Looking up url for action', action, settings.api);
- if(settings.api[action] !== undefined) {
- url = settings.api[action];
- module.debug('Found template url', url);
- }
- else {
+ if(settings.api[action] === undefined && !module.is.mocked()) {
module.error(error.missingAction, settings.action, settings.api);
+ return;
}
+ url = settings.api[action];
+ }
+ else if( module.is.form() ) {
+ url = $module.attr('action') || $context.attr('action') || false;
+ module.debug('No url or action specified, defaulting to form action', url);
}
return url;
}
},
+ abort: function() {
+ var
+ xhr = module.get.xhr()
+ ;
+ if( xhr && xhr.state() !== 'resolved') {
+ module.debug('Cancelling API request');
+ xhr.abort();
+ }
+ },
+
// reset state
reset: function() {
module.remove.error();
@@ -14400,7 +19270,7 @@ $.api = $.fn.api = function(parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -14495,7 +19365,7 @@ $.api = $.fn.api = function(parameters) {
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
@@ -14510,48 +19380,94 @@ $.api = $.fn.api = function(parameters) {
$.api.settings = {
- name : 'API',
- namespace : 'api',
+ name : 'API',
+ namespace : 'api',
- debug : false,
- verbose : true,
- performance : true,
+ debug : false,
+ verbose : false,
+ performance : true,
+
+ // object containing all templates endpoints
+ api : {},
+
+ // whether to cache responses
+ cache : true,
+
+ // whether new requests should abort previous requests
+ interruptRequests : true,
// event binding
- on : 'auto',
- filter : '.disabled',
- stateContext : false,
+ on : 'auto',
- // state
- loadingDuration : 0,
- errorDuration : 2000,
+ // context for applying state classes
+ stateContext : false,
- // templating
- action : false,
- url : false,
- base : '',
+ // duration for loading state
+ loadingDuration : 0,
- // data
- urlData : {},
+ // whether to hide errors after a period of time
+ hideError : 'auto',
- // ui
- defaultData : true,
- serializeForm : false,
- throttle : 0,
+ // duration for error state
+ errorDuration : 2000,
- // jQ ajax
- method : 'get',
- data : {},
- dataType : 'json',
+ // whether parameters should be encoded with encodeURIComponent
+ encodeParameters : true,
- // callbacks
+ // API action to use
+ action : false,
+
+ // templated URL to use
+ url : false,
+
+ // base URL to apply to all endpoints
+ base : '',
+
+ // data that will
+ urlData : {},
+
+ // whether to add default data to url data
+ defaultData : true,
+
+ // whether to serialize closest form
+ serializeForm : false,
+
+ // how long to wait before request should occur
+ throttle : 0,
+
+ // whether to throttle first request or only repeated
+ throttleFirstRequest : true,
+
+ // standard ajax settings
+ method : 'get',
+ data : {},
+ dataType : 'json',
+
+ // mock response
+ mockResponse : false,
+ mockResponseAsync : false,
+
+ // callbacks before request
beforeSend : function(settings) { return settings; },
beforeXHR : function(xhr) {},
+ onRequest : function(promise, xhr) {},
+
+ // after request
+ onResponse : false, // function(response) { },
+ // response was successful, if JSON passed validation
onSuccess : function(response, $module) {},
+
+ // request finished without aborting
onComplete : function(response, $module) {},
- onFailure : function(errorMessage, $module) {},
+
+ // failed JSON success test
+ onFailure : function(response, $module) {},
+
+ // server error
onError : function(errorMessage, $module) {},
+
+ // request aborted
onAbort : function(errorMessage, $module) {},
successTest : false,
@@ -14563,10 +19479,12 @@ $.api.settings = {
exitConditions : 'API Request Aborted. Exit conditions met',
JSONParse : 'JSON could not be parsed during error handling',
legacyParameters : 'You are using legacy API success callback names',
+ method : 'The method you called is not defined',
missingAction : 'API action used but no url was defined',
- missingSerialize : 'Required dependency jquery-serialize-object missing, using basic serialize',
+ missingSerialize : 'jquery-serialize-object is required to add form data to an existing data object',
missingURL : 'No URL specified for api event',
noReturnedValue : 'The beforeSend callback must return a settings object, beforeSend ignored.',
+ noStorage : 'Caching responses locally requires session storage',
parseError : 'There was an error parsing your request',
requiredParameter : 'Missing a required URL parameter: ',
statusMessage : 'Server gave an error: ',
@@ -14574,8 +19492,8 @@ $.api.settings = {
},
regExp : {
- required: /\{\$*[A-z0-9]+\}/g,
- optional: /\{\/\$*[A-z0-9]+\}/g,
+ required : /\{\$*[A-z0-9]+\}/g,
+ optional : /\{\/\$*[A-z0-9]+\}/g,
},
className: {
@@ -14584,27 +19502,26 @@ $.api.settings = {
},
selector: {
- form: 'form'
+ disabled : '.disabled',
+ form : 'form'
},
metadata: {
action : 'action',
- request : 'request',
- xhr : 'xhr'
+ url : 'url'
}
};
-$.api.settings.api = {};
+})( jQuery, window, document );
-})( jQuery, window , document );
-/*
- * # Semantic - Form Validation
+/*!
+ * # Semantic UI 2.1.6 - State
* http://github.com/semantic-org/semantic-ui/
*
*
- * Copyright 2014 Contributor
+ * Copyright 2015 Contributors
* Released under the MIT license
* http://opensource.org/licenses/MIT
*
@@ -14612,54 +19529,73 @@ $.api.settings.api = {};
;(function ( $, window, document, undefined ) {
-$.fn.form = function(fields, parameters) {
+"use strict";
+
+$.fn.state = function(parameters) {
var
$allModules = $(this),
- settings = $.extend(true, {}, $.fn.form.settings, parameters),
- validation = $.extend({}, $.fn.form.settings.defaults, fields),
-
- namespace = settings.namespace,
- metadata = settings.metadata,
- selector = settings.selector,
- className = settings.className,
- error = settings.error,
-
- eventNamespace = '.' + namespace,
- moduleNamespace = 'module-' + namespace,
-
moduleSelector = $allModules.selector || '',
+ hasTouch = ('ontouchstart' in document.documentElement),
time = new Date().getTime(),
performance = [],
query = arguments[0],
methodInvoked = (typeof query == 'string'),
queryArguments = [].slice.call(arguments, 1),
+
returnedValue
;
$allModules
.each(function() {
var
- $module = $(this),
- $field = $(this).find(selector.field),
- $group = $(this).find(selector.group),
- $message = $(this).find(selector.message),
- $prompt = $(this).find(selector.prompt),
- $submit = $(this).find(selector.submit),
+ settings = ( $.isPlainObject(parameters) )
+ ? $.extend(true, {}, $.fn.state.settings, parameters)
+ : $.extend({}, $.fn.state.settings),
- formErrors = [],
+ error = settings.error,
+ metadata = settings.metadata,
+ className = settings.className,
+ namespace = settings.namespace,
+ states = settings.states,
+ text = settings.text,
+
+ eventNamespace = '.' + namespace,
+ moduleNamespace = namespace + '-module',
+
+ $module = $(this),
+
+ element = this,
+ instance = $module.data(moduleNamespace),
- element = this,
- instance = $module.data(moduleNamespace),
module
;
-
- module = {
+ module = {
initialize: function() {
- module.verbose('Initializing form validation', $module, validation, settings);
- module.bindEvents();
+ module.verbose('Initializing module');
+
+ // allow module to guess desired state based on element
+ if(settings.automatic) {
+ module.add.defaults();
+ }
+
+ // bind events with delegated events
+ if(settings.context && moduleSelector !== '') {
+ $(settings.context)
+ .on(moduleSelector, 'mouseenter' + eventNamespace, module.change.text)
+ .on(moduleSelector, 'mouseleave' + eventNamespace, module.reset.text)
+ .on(moduleSelector, 'click' + eventNamespace, module.toggle.state)
+ ;
+ }
+ else {
+ $module
+ .on('mouseenter' + eventNamespace, module.change.text)
+ .on('mouseleave' + eventNamespace, module.reset.text)
+ .on('click' + eventNamespace, module.toggle.state)
+ ;
+ }
module.instantiate();
},
@@ -14673,382 +19609,1555 @@ $.fn.form = function(fields, parameters) {
destroy: function() {
module.verbose('Destroying previous module', instance);
- module.removeEvents();
$module
+ .off(eventNamespace)
.removeData(moduleNamespace)
;
},
refresh: function() {
module.verbose('Refreshing selector cache');
- $field = $module.find(selector.field);
+ $module = $(element);
},
- submit: function() {
- module.verbose('Submitting form', $module);
- $module
- .submit()
- ;
+ add: {
+ defaults: function() {
+ var
+ userStates = parameters && $.isPlainObject(parameters.states)
+ ? parameters.states
+ : {}
+ ;
+ $.each(settings.defaults, function(type, typeStates) {
+ if( module.is[type] !== undefined && module.is[type]() ) {
+ module.verbose('Adding default states', type, element);
+ $.extend(settings.states, typeStates, userStates);
+ }
+ });
+ }
},
- attachEvents: function(selector, action) {
- action = action || 'submit';
- $(selector)
- .on('click', function(event) {
- module[action]();
- event.preventDefault();
- })
- ;
- },
+ is: {
- bindEvents: function() {
+ active: function() {
+ return $module.hasClass(className.active);
+ },
+ loading: function() {
+ return $module.hasClass(className.loading);
+ },
+ inactive: function() {
+ return !( $module.hasClass(className.active) );
+ },
+ state: function(state) {
+ if(className[state] === undefined) {
+ return false;
+ }
+ return $module.hasClass( className[state] );
+ },
- if(settings.keyboardShortcuts) {
- $field
- .on('keydown' + eventNamespace, module.event.field.keydown)
- ;
+ enabled: function() {
+ return !( $module.is(settings.filter.active) );
+ },
+ disabled: function() {
+ return ( $module.is(settings.filter.active) );
+ },
+ textEnabled: function() {
+ return !( $module.is(settings.filter.text) );
+ },
+
+ // definitions for automatic type detection
+ button: function() {
+ return $module.is('.button:not(a, .submit)');
+ },
+ input: function() {
+ return $module.is('input');
+ },
+ progress: function() {
+ return $module.is('.ui.progress');
}
- $module
- .on('submit' + eventNamespace, module.validate.form)
- ;
- $field
- .on('blur' + eventNamespace, module.event.field.blur)
- ;
- // attach submit events
- module.attachEvents($submit, 'submit');
+ },
- $field
- .each(function() {
- var
- type = $(this).prop('type'),
- inputEvent = module.get.changeEvent(type)
- ;
- $(this)
- .on(inputEvent + eventNamespace, module.event.field.change)
- ;
- })
- ;
+ allow: function(state) {
+ module.debug('Now allowing state', state);
+ states[state] = true;
+ },
+ disallow: function(state) {
+ module.debug('No longer allowing', state);
+ states[state] = false;
},
- removeEvents: function() {
- $module
- .off(eventNamespace)
- ;
- $field
- .off(eventNamespace)
- ;
- $submit
- .off(eventNamespace)
- ;
- $field
- .off(eventNamespace)
- ;
+ allows: function(state) {
+ return states[state] || false;
},
- event: {
- field: {
- keydown: function(event) {
- var
- $field = $(this),
- key = event.which,
- keyCode = {
- enter : 13,
- escape : 27
+ enable: function() {
+ $module.removeClass(className.disabled);
+ },
+
+ disable: function() {
+ $module.addClass(className.disabled);
+ },
+
+ setState: function(state) {
+ if(module.allows(state)) {
+ $module.addClass( className[state] );
+ }
+ },
+
+ removeState: function(state) {
+ if(module.allows(state)) {
+ $module.removeClass( className[state] );
+ }
+ },
+
+ toggle: {
+ state: function() {
+ var
+ apiRequest,
+ requestCancelled
+ ;
+ if( module.allows('active') && module.is.enabled() ) {
+ module.refresh();
+ if($.fn.api !== undefined) {
+ apiRequest = $module.api('get request');
+ requestCancelled = $module.api('was cancelled');
+ if( requestCancelled ) {
+ module.debug('API Request cancelled by beforesend');
+ settings.activateTest = function(){ return false; };
+ settings.deactivateTest = function(){ return false; };
+ }
+ else if(apiRequest) {
+ module.listenTo(apiRequest);
+ return;
}
- ;
- if( key == keyCode.escape) {
- module.verbose('Escape key pressed blurring field');
- $field
- .blur()
- ;
}
- if(!event.ctrlKey && key == keyCode.enter && $field.is(selector.input) && $field.not(selector.checkbox).size() > 0 ) {
- module.debug('Enter key pressed, submitting form');
- $submit
- .addClass(className.down)
- ;
- $field
- .one('keyup' + eventNamespace, module.event.field.keyup)
- ;
+ module.change.state();
+ }
+ }
+ },
+
+ listenTo: function(apiRequest) {
+ module.debug('API request detected, waiting for state signal', apiRequest);
+ if(apiRequest) {
+ if(text.loading) {
+ module.update.text(text.loading);
+ }
+ $.when(apiRequest)
+ .then(function() {
+ if(apiRequest.state() == 'resolved') {
+ module.debug('API request succeeded');
+ settings.activateTest = function(){ return true; };
+ settings.deactivateTest = function(){ return true; };
+ }
+ else {
+ module.debug('API request failed');
+ settings.activateTest = function(){ return false; };
+ settings.deactivateTest = function(){ return false; };
+ }
+ module.change.state();
+ })
+ ;
+ }
+ },
+
+ // checks whether active/inactive state can be given
+ change: {
+
+ state: function() {
+ module.debug('Determining state change direction');
+ // inactive to active change
+ if( module.is.inactive() ) {
+ module.activate();
+ }
+ else {
+ module.deactivate();
+ }
+ if(settings.sync) {
+ module.sync();
+ }
+ settings.onChange.call(element);
+ },
+
+ text: function() {
+ if( module.is.textEnabled() ) {
+ if(module.is.disabled() ) {
+ module.verbose('Changing text to disabled text', text.hover);
+ module.update.text(text.disabled);
+ }
+ else if( module.is.active() ) {
+ if(text.hover) {
+ module.verbose('Changing text to hover text', text.hover);
+ module.update.text(text.hover);
+ }
+ else if(text.deactivate) {
+ module.verbose('Changing text to deactivating text', text.deactivate);
+ module.update.text(text.deactivate);
+ }
}
- },
- keyup: function() {
- module.verbose('Doing keyboard shortcut form submit');
- $submit.removeClass(className.down);
- module.submit();
- },
- blur: function() {
- var
- $field = $(this),
- $fieldGroup = $field.closest($group)
- ;
- if( $fieldGroup.hasClass(className.error) ) {
- module.debug('Revalidating field', $field, module.get.validation($field));
- module.validate.field( module.get.validation($field) );
+ else {
+ if(text.hover) {
+ module.verbose('Changing text to hover text', text.hover);
+ module.update.text(text.hover);
+ }
+ else if(text.activate){
+ module.verbose('Changing text to activating text', text.activate);
+ module.update.text(text.activate);
+ }
}
- else if(settings.on == 'blur' || settings.on == 'change') {
- module.validate.field( module.get.validation($field) );
+ }
+ }
+
+ },
+
+ activate: function() {
+ if( settings.activateTest.call(element) ) {
+ module.debug('Setting state to active');
+ $module
+ .addClass(className.active)
+ ;
+ module.update.text(text.active);
+ settings.onActivate.call(element);
+ }
+ },
+
+ deactivate: function() {
+ if( settings.deactivateTest.call(element) ) {
+ module.debug('Setting state to inactive');
+ $module
+ .removeClass(className.active)
+ ;
+ module.update.text(text.inactive);
+ settings.onDeactivate.call(element);
+ }
+ },
+
+ sync: function() {
+ module.verbose('Syncing other buttons to current state');
+ if( module.is.active() ) {
+ $allModules
+ .not($module)
+ .state('activate');
+ }
+ else {
+ $allModules
+ .not($module)
+ .state('deactivate')
+ ;
+ }
+ },
+
+ get: {
+ text: function() {
+ return (settings.selector.text)
+ ? $module.find(settings.selector.text).text()
+ : $module.html()
+ ;
+ },
+ textFor: function(state) {
+ return text[state] || false;
+ }
+ },
+
+ flash: {
+ text: function(text, duration, callback) {
+ var
+ previousText = module.get.text()
+ ;
+ module.debug('Flashing text message', text, duration);
+ text = text || settings.text.flash;
+ duration = duration || settings.flashDuration;
+ callback = callback || function() {};
+ module.update.text(text);
+ setTimeout(function(){
+ module.update.text(previousText);
+ callback.call(element);
+ }, duration);
+ }
+ },
+
+ reset: {
+ // on mouseout sets text to previous value
+ text: function() {
+ var
+ activeText = text.active || $module.data(metadata.storedText),
+ inactiveText = text.inactive || $module.data(metadata.storedText)
+ ;
+ if( module.is.textEnabled() ) {
+ if( module.is.active() && activeText) {
+ module.verbose('Resetting active text', activeText);
+ module.update.text(activeText);
}
- },
- change: function() {
- var
- $field = $(this),
- $fieldGroup = $field.closest($group)
- ;
- if(settings.on == 'change' || ( $fieldGroup.hasClass(className.error) && settings.revalidate) ) {
- clearTimeout(module.timer);
- module.timer = setTimeout(function() {
- module.debug('Revalidating field', $field, module.get.validation($field));
- module.validate.field( module.get.validation($field) );
- }, settings.delay);
+ else if(inactiveText) {
+ module.verbose('Resetting inactive text', activeText);
+ module.update.text(inactiveText);
}
}
}
+ },
+ update: {
+ text: function(text) {
+ var
+ currentText = module.get.text()
+ ;
+ if(text && text !== currentText) {
+ module.debug('Updating text', text);
+ if(settings.selector.text) {
+ $module
+ .data(metadata.storedText, text)
+ .find(settings.selector.text)
+ .text(text)
+ ;
+ }
+ else {
+ $module
+ .data(metadata.storedText, text)
+ .html(text)
+ ;
+ }
+ }
+ else {
+ module.debug('Text is already set, ignoring update', text);
+ }
+ }
},
- get: {
- changeEvent: function(type) {
- if(type == 'checkbox' || type == 'radio' || type == 'hidden') {
- return 'change';
+ setting: function(name, value) {
+ module.debug('Changing setting', name, value);
+ if( $.isPlainObject(name) ) {
+ $.extend(true, settings, name);
+ }
+ else if(value !== undefined) {
+ settings[name] = value;
+ }
+ else {
+ return settings[name];
+ }
+ },
+ internal: function(name, value) {
+ if( $.isPlainObject(name) ) {
+ $.extend(true, module, name);
+ }
+ else if(value !== undefined) {
+ module[name] = value;
+ }
+ else {
+ return module[name];
+ }
+ },
+ debug: function() {
+ if(settings.debug) {
+ if(settings.performance) {
+ module.performance.log(arguments);
}
else {
- return (document.createElement('input').oninput !== undefined)
- ? 'input'
- : (document.createElement('input').onpropertychange !== undefined)
- ? 'propertychange'
- : 'keyup'
- ;
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
+ module.debug.apply(console, arguments);
}
- },
- field: function(identifier) {
- module.verbose('Finding field with identifier', identifier);
- if( $field.filter('#' + identifier).size() > 0 ) {
- return $field.filter('#' + identifier);
+ }
+ },
+ verbose: function() {
+ if(settings.verbose && settings.debug) {
+ if(settings.performance) {
+ module.performance.log(arguments);
}
- else if( $field.filter('[name="' + identifier +'"]').size() > 0 ) {
- return $field.filter('[name="' + identifier +'"]');
+ else {
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
+ module.verbose.apply(console, arguments);
}
- else if( $field.filter('[data-' + metadata.validate + '="'+ identifier +'"]').size() > 0 ) {
- return $field.filter('[data-' + metadata.validate + '="'+ identifier +'"]');
+ }
+ },
+ error: function() {
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
+ module.error.apply(console, arguments);
+ },
+ performance: {
+ log: function(message) {
+ var
+ currentTime,
+ executionTime,
+ previousTime
+ ;
+ if(settings.performance) {
+ currentTime = new Date().getTime();
+ previousTime = time || currentTime;
+ executionTime = currentTime - previousTime;
+ time = currentTime;
+ performance.push({
+ 'Name' : message[0],
+ 'Arguments' : [].slice.call(message, 1) || '',
+ 'Element' : element,
+ 'Execution Time' : executionTime
+ });
}
- return $('<input/>');
+ clearTimeout(module.performance.timer);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
- validation: function($field) {
+ display: function() {
var
- rules
+ title = settings.name + ':',
+ totalTime = 0
;
- $.each(validation, function(fieldName, field) {
- if( module.get.field(field.identifier).get(0) == $field.get(0) ) {
- rules = field;
- }
+ time = false;
+ clearTimeout(module.performance.timer);
+ $.each(performance, function(index, data) {
+ totalTime += data['Execution Time'];
});
- return rules || false;
+ title += ' ' + totalTime + 'ms';
+ if(moduleSelector) {
+ title += ' \'' + moduleSelector + '\'';
+ }
+ if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
+ console.groupCollapsed(title);
+ if(console.table) {
+ console.table(performance);
+ }
+ else {
+ $.each(performance, function(index, data) {
+ console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
+ });
+ }
+ console.groupEnd();
+ }
+ performance = [];
}
},
+ invoke: function(query, passedArguments, context) {
+ var
+ object = instance,
+ maxDepth,
+ found,
+ response
+ ;
+ passedArguments = passedArguments || queryArguments;
+ context = element || context;
+ if(typeof query == 'string' && object !== undefined) {
+ query = query.split(/[\. ]/);
+ maxDepth = query.length - 1;
+ $.each(query, function(depth, value) {
+ var camelCaseValue = (depth != maxDepth)
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
+ : query
+ ;
+ if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
+ object = object[camelCaseValue];
+ }
+ else if( object[camelCaseValue] !== undefined ) {
+ found = object[camelCaseValue];
+ return false;
+ }
+ else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
+ object = object[value];
+ }
+ else if( object[value] !== undefined ) {
+ found = object[value];
+ return false;
+ }
+ else {
+ module.error(error.method, query);
+ return false;
+ }
+ });
+ }
+ if ( $.isFunction( found ) ) {
+ response = found.apply(context, passedArguments);
+ }
+ else if(found !== undefined) {
+ response = found;
+ }
+ if($.isArray(returnedValue)) {
+ returnedValue.push(response);
+ }
+ else if(returnedValue !== undefined) {
+ returnedValue = [returnedValue, response];
+ }
+ else if(response !== undefined) {
+ returnedValue = response;
+ }
+ return found;
+ }
+ };
- has: {
+ if(methodInvoked) {
+ if(instance === undefined) {
+ module.initialize();
+ }
+ module.invoke(query);
+ }
+ else {
+ if(instance !== undefined) {
+ instance.invoke('destroy');
+ }
+ module.initialize();
+ }
+ })
+ ;
- field: function(identifier) {
- module.verbose('Checking for existence of a field with identifier', identifier);
- if( $field.filter('#' + identifier).size() > 0 ) {
- return true;
+ return (returnedValue !== undefined)
+ ? returnedValue
+ : this
+ ;
+};
+
+$.fn.state.settings = {
+
+ // module info
+ name : 'State',
+
+ // debug output
+ debug : false,
+
+ // verbose debug output
+ verbose : false,
+
+ // namespace for events
+ namespace : 'state',
+
+ // debug data includes performance
+ performance : true,
+
+ // callback occurs on state change
+ onActivate : function() {},
+ onDeactivate : function() {},
+ onChange : function() {},
+
+ // state test functions
+ activateTest : function() { return true; },
+ deactivateTest : function() { return true; },
+
+ // whether to automatically map default states
+ automatic : true,
+
+ // activate / deactivate changes all elements instantiated at same time
+ sync : false,
+
+ // default flash text duration, used for temporarily changing text of an element
+ flashDuration : 1000,
+
+ // selector filter
+ filter : {
+ text : '.loading, .disabled',
+ active : '.disabled'
+ },
+
+ context : false,
+
+ // error
+ error: {
+ beforeSend : 'The before send function has cancelled state change',
+ method : 'The method you called is not defined.'
+ },
+
+ // metadata
+ metadata: {
+ promise : 'promise',
+ storedText : 'stored-text'
+ },
+
+ // change class on state
+ className: {
+ active : 'active',
+ disabled : 'disabled',
+ error : 'error',
+ loading : 'loading',
+ success : 'success',
+ warning : 'warning'
+ },
+
+ selector: {
+ // selector for text node
+ text: false
+ },
+
+ defaults : {
+ input: {
+ disabled : true,
+ loading : true,
+ active : true
+ },
+ button: {
+ disabled : true,
+ loading : true,
+ active : true,
+ },
+ progress: {
+ active : true,
+ success : true,
+ warning : true,
+ error : true
+ }
+ },
+
+ states : {
+ active : true,
+ disabled : true,
+ error : true,
+ loading : true,
+ success : true,
+ warning : true
+ },
+
+ text : {
+ disabled : false,
+ flash : false,
+ hover : false,
+ active : false,
+ inactive : false,
+ activate : false,
+ deactivate : false
+ }
+
+};
+
+
+
+})( jQuery, window, document );
+
+/*!
+ * # Semantic UI 2.1.6 - Visibility
+ * http://github.com/semantic-org/semantic-ui/
+ *
+ *
+ * Copyright 2015 Contributors
+ * Released under the MIT license
+ * http://opensource.org/licenses/MIT
+ *
+ */
+
+;(function ( $, window, document, undefined ) {
+
+"use strict";
+
+$.fn.visibility = function(parameters) {
+ var
+ $allModules = $(this),
+ moduleSelector = $allModules.selector || '',
+
+ time = new Date().getTime(),
+ performance = [],
+
+ query = arguments[0],
+ methodInvoked = (typeof query == 'string'),
+ queryArguments = [].slice.call(arguments, 1),
+ returnedValue
+ ;
+
+ $allModules
+ .each(function() {
+ var
+ settings = ( $.isPlainObject(parameters) )
+ ? $.extend(true, {}, $.fn.visibility.settings, parameters)
+ : $.extend({}, $.fn.visibility.settings),
+
+ className = settings.className,
+ namespace = settings.namespace,
+ error = settings.error,
+ metadata = settings.metadata,
+
+ eventNamespace = '.' + namespace,
+ moduleNamespace = 'module-' + namespace,
+
+ $window = $(window),
+
+ $module = $(this),
+ $context = $(settings.context),
+
+ $placeholder,
+
+ selector = $module.selector || '',
+ instance = $module.data(moduleNamespace),
+
+ requestAnimationFrame = window.requestAnimationFrame
+ || window.mozRequestAnimationFrame
+ || window.webkitRequestAnimationFrame
+ || window.msRequestAnimationFrame
+ || function(callback) { setTimeout(callback, 0); },
+
+ element = this,
+ disabled = false,
+
+ observer,
+ module
+ ;
+
+ module = {
+
+ initialize: function() {
+ module.debug('Initializing', settings);
+
+ module.setup.cache();
+
+ if( module.should.trackChanges() ) {
+
+ if(settings.type == 'image') {
+ module.setup.image();
}
- else if( $field.filter('[name="' + identifier +'"]').size() > 0 ) {
- return true;
+ if(settings.type == 'fixed') {
+ module.setup.fixed();
}
- else if( $field.filter('[data-' + metadata.validate + '="'+ identifier +'"]').size() > 0 ) {
- return true;
+
+ if(settings.observeChanges) {
+ module.observeChanges();
}
- return false;
+ module.bind.events();
+ }
+
+ module.save.position();
+ if( !module.is.visible() ) {
+ module.error(error.visible, $module);
}
+ if(settings.initialCheck) {
+ module.checkVisibility();
+ }
+ module.instantiate();
},
- add: {
- prompt: function(identifier, errors) {
- var
- $field = module.get.field(identifier),
- $fieldGroup = $field.closest($group),
- $prompt = $fieldGroup.find(selector.prompt),
- promptExists = ($prompt.size() !== 0)
- ;
- errors = (typeof errors == 'string')
- ? [errors]
- : errors
+ instantiate: function() {
+ module.debug('Storing instance', module);
+ $module
+ .data(moduleNamespace, module)
+ ;
+ instance = module;
+ },
+
+ destroy: function() {
+ module.verbose('Destroying previous module');
+ if(observer) {
+ observer.disconnect();
+ }
+ $window
+ .off('load' + eventNamespace, module.event.load)
+ .off('resize' + eventNamespace, module.event.resize)
+ ;
+ $context
+ .off('scrollchange' + eventNamespace, module.event.scrollchange)
+ ;
+ $module
+ .off(eventNamespace)
+ .removeData(moduleNamespace)
+ ;
+ },
+
+ observeChanges: function() {
+ if('MutationObserver' in window) {
+ observer = new MutationObserver(function(mutations) {
+ module.verbose('DOM tree modified, updating visibility calculations');
+ module.timer = setTimeout(function() {
+ module.verbose('DOM tree modified, updating sticky menu');
+ module.refresh();
+ }, 100);
+ });
+ observer.observe(element, {
+ childList : true,
+ subtree : true
+ });
+ module.debug('Setting up mutation observer', observer);
+ }
+ },
+
+ bind: {
+ events: function() {
+ module.verbose('Binding visibility events to scroll and resize');
+ if(settings.refreshOnLoad) {
+ $window
+ .on('load' + eventNamespace, module.event.load)
+ ;
+ }
+ $window
+ .on('resize' + eventNamespace, module.event.resize)
;
- module.verbose('Adding field error state', identifier);
- $fieldGroup
- .addClass(className.error)
+ // pub/sub pattern
+ $context
+ .off('scroll' + eventNamespace)
+ .on('scroll' + eventNamespace, module.event.scroll)
+ .on('scrollchange' + eventNamespace, module.event.scrollchange)
;
- if(settings.inline) {
- if(!promptExists) {
- $prompt = settings.templates.prompt(errors);
- $prompt
- .appendTo($fieldGroup)
- ;
- }
- $prompt
- .html(errors[0])
- ;
- if(!promptExists) {
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
- module.verbose('Displaying error with css transition', settings.transition);
- $prompt.transition(settings.transition + ' in', settings.duration);
- }
- else {
- module.verbose('Displaying error with fallback javascript animation');
- $prompt
- .fadeIn(settings.duration)
- ;
+ }
+ },
+
+ event: {
+ resize: function() {
+ module.debug('Window resized');
+ if(settings.refreshOnResize) {
+ requestAnimationFrame(module.refresh);
+ }
+ },
+ load: function() {
+ module.debug('Page finished loading');
+ requestAnimationFrame(module.refresh);
+ },
+ // publishes scrollchange event on one scroll
+ scroll: function() {
+ if(settings.throttle) {
+ clearTimeout(module.timer);
+ module.timer = setTimeout(function() {
+ $context.triggerHandler('scrollchange' + eventNamespace, [ $context.scrollTop() ]);
+ }, settings.throttle);
+ }
+ else {
+ requestAnimationFrame(function() {
+ $context.triggerHandler('scrollchange' + eventNamespace, [ $context.scrollTop() ]);
+ });
+ }
+ },
+ // subscribes to scrollchange
+ scrollchange: function(event, scrollPosition) {
+ module.checkVisibility(scrollPosition);
+ },
+ },
+
+ precache: function(images, callback) {
+ if (!(images instanceof Array)) {
+ images = [images];
+ }
+ var
+ imagesLength = images.length,
+ loadedCounter = 0,
+ cache = [],
+ cacheImage = document.createElement('img'),
+ handleLoad = function() {
+ loadedCounter++;
+ if (loadedCounter >= images.length) {
+ if ($.isFunction(callback)) {
+ callback();
}
}
- else {
- module.verbose('Inline errors are disabled, no inline error added', identifier);
- }
}
+ ;
+ while (imagesLength--) {
+ cacheImage = document.createElement('img');
+ cacheImage.onload = handleLoad;
+ cacheImage.onerror = handleLoad;
+ cacheImage.src = images[imagesLength];
+ cache.push(cacheImage);
+ }
+ },
+
+ enableCallbacks: function() {
+ module.debug('Allowing callbacks to occur');
+ disabled = false;
+ },
+
+ disableCallbacks: function() {
+ module.debug('Disabling all callbacks temporarily');
+ disabled = true;
+ },
+
+ should: {
+ trackChanges: function() {
+ if(methodInvoked) {
+ module.debug('One time query, no need to bind events');
+ return false;
+ }
+ module.debug('Callbacks being attached');
+ return true;
+ }
+ },
+
+ setup: {
+ cache: function() {
+ module.cache = {
+ occurred : {},
+ screen : {},
+ element : {},
+ };
},
- errors: function(errors) {
- module.debug('Adding form error messages', errors);
- $message
- .html( settings.templates.error(errors) )
+ image: function() {
+ var
+ src = $module.data(metadata.src)
+ ;
+ if(src) {
+ module.verbose('Lazy loading image', src);
+ settings.once = true;
+ settings.observeChanges = false;
+
+ // show when top visible
+ settings.onOnScreen = function() {
+ module.debug('Image on screen', element);
+ module.precache(src, function() {
+ module.set.image(src);
+ });
+ };
+ }
+ },
+ fixed: function() {
+ module.debug('Setting up fixed');
+ settings.once = false;
+ settings.observeChanges = false;
+ settings.initialCheck = true;
+ settings.refreshOnLoad = true;
+ if(!parameters.transition) {
+ settings.transition = false;
+ }
+ module.create.placeholder();
+ module.debug('Added placeholder', $placeholder);
+ settings.onTopPassed = function() {
+ module.debug('Element passed, adding fixed position', $module);
+ module.show.placeholder();
+ module.set.fixed();
+ if(settings.transition) {
+ if($.fn.transition !== undefined) {
+ $module.transition(settings.transition, settings.duration);
+ }
+ }
+ };
+ settings.onTopPassedReverse = function() {
+ module.debug('Element returned to position, removing fixed', $module);
+ module.hide.placeholder();
+ module.remove.fixed();
+ };
+ }
+ },
+
+ create: {
+ placeholder: function() {
+ module.verbose('Creating fixed position placeholder');
+ $placeholder = $module
+ .clone(false)
+ .css('display', 'none')
+ .addClass(className.placeholder)
+ .insertAfter($module)
;
}
},
- remove: {
- prompt: function(field) {
- var
- $field = module.get.field(field.identifier),
- $fieldGroup = $field.closest($group),
- $prompt = $fieldGroup.find(selector.prompt)
+ show: {
+ placeholder: function() {
+ module.verbose('Showing placeholder');
+ $placeholder
+ .css('display', 'block')
+ .css('visibility', 'hidden')
;
- $fieldGroup
- .removeClass(className.error)
+ }
+ },
+ hide: {
+ placeholder: function() {
+ module.verbose('Hiding placeholder');
+ $placeholder
+ .css('display', 'none')
+ .css('visibility', '')
;
- if(settings.inline && $prompt.is(':visible')) {
- module.verbose('Removing prompt for field', field);
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
- $prompt.transition(settings.transition + ' out', settings.duration, function() {
- $prompt.remove();
- });
- }
- else {
- $prompt
- .fadeOut(settings.duration, function(){
- $prompt.remove();
- })
- ;
- }
- }
}
},
set: {
- success: function() {
+ fixed: function() {
+ module.verbose('Setting element to fixed position');
$module
- .removeClass(className.error)
- .addClass(className.success)
+ .addClass(className.fixed)
+ .css({
+ position : 'fixed',
+ top : settings.offset + 'px',
+ left : 'auto',
+ zIndex : '1'
+ })
;
},
- error: function() {
+ image: function(src) {
$module
- .removeClass(className.success)
- .addClass(className.error)
+ .attr('src', src)
;
+ if(settings.transition) {
+ if( $.fn.transition !== undefined ) {
+ $module.transition(settings.transition, settings.duration);
+ }
+ else {
+ $module.fadeIn(settings.duration);
+ }
+ }
+ else {
+ $module.show();
+ }
}
},
- validate: {
-
- form: function(event) {
+ is: {
+ onScreen: function() {
var
- allValid = true,
- apiRequest
+ calculations = module.get.elementCalculations()
;
- // reset errors
- formErrors = [];
- $.each(validation, function(fieldName, field) {
- if( !( module.validate.field(field) ) ) {
- allValid = false;
+ return calculations.onScreen;
+ },
+ offScreen: function() {
+ var
+ calculations = module.get.elementCalculations()
+ ;
+ return calculations.offScreen;
+ },
+ visible: function() {
+ if(module.cache && module.cache.element) {
+ return !(module.cache.element.width === 0 && module.cache.element.offset.top === 0);
+ }
+ return false;
+ }
+ },
+
+ refresh: function() {
+ module.debug('Refreshing constants (width/height)');
+ if(settings.type == 'fixed') {
+ module.remove.fixed();
+ module.remove.occurred();
+ }
+ module.reset();
+ module.save.position();
+ if(settings.checkOnRefresh) {
+ module.checkVisibility();
+ }
+ settings.onRefresh.call(element);
+ },
+
+ reset: function() {
+ module.verbose('Reseting all cached values');
+ if( $.isPlainObject(module.cache) ) {
+ module.cache.screen = {};
+ module.cache.element = {};
+ }
+ },
+
+ checkVisibility: function(scroll) {
+ module.verbose('Checking visibility of element', module.cache.element);
+
+ if( !disabled && module.is.visible() ) {
+
+ // save scroll position
+ module.save.scroll(scroll);
+
+ // update calculations derived from scroll
+ module.save.calculations();
+
+ // percentage
+ module.passed();
+
+ // reverse (must be first)
+ module.passingReverse();
+ module.topVisibleReverse();
+ module.bottomVisibleReverse();
+ module.topPassedReverse();
+ module.bottomPassedReverse();
+
+ // one time
+ module.onScreen();
+ module.offScreen();
+ module.passing();
+ module.topVisible();
+ module.bottomVisible();
+ module.topPassed();
+ module.bottomPassed();
+
+ // on update callback
+ if(settings.onUpdate) {
+ settings.onUpdate.call(element, module.get.elementCalculations());
+ }
+ }
+ },
+
+ passed: function(amount, newCallback) {
+ var
+ calculations = module.get.elementCalculations(),
+ amountInPixels
+ ;
+ // assign callback
+ if(amount && newCallback) {
+ settings.onPassed[amount] = newCallback;
+ }
+ else if(amount !== undefined) {
+ return (module.get.pixelsPassed(amount) > calculations.pixelsPassed);
+ }
+ else if(calculations.passing) {
+ $.each(settings.onPassed, function(amount, callback) {
+ if(calculations.bottomVisible || calculations.pixelsPassed > module.get.pixelsPassed(amount)) {
+ module.execute(callback, amount);
+ }
+ else if(!settings.once) {
+ module.remove.occurred(callback);
}
});
- if(allValid) {
- module.debug('Form has no validation errors, submitting');
- module.set.success();
- return $.proxy(settings.onSuccess, this)(event);
+ }
+ },
+
+ onScreen: function(newCallback) {
+ var
+ calculations = module.get.elementCalculations(),
+ callback = newCallback || settings.onOnScreen,
+ callbackName = 'onScreen'
+ ;
+ if(newCallback) {
+ module.debug('Adding callback for onScreen', newCallback);
+ settings.onOnScreen = newCallback;
+ }
+ if(calculations.onScreen) {
+ module.execute(callback, callbackName);
+ }
+ else if(!settings.once) {
+ module.remove.occurred(callbackName);
+ }
+ if(newCallback !== undefined) {
+ return calculations.onOnScreen;
+ }
+ },
+
+ offScreen: function(newCallback) {
+ var
+ calculations = module.get.elementCalculations(),
+ callback = newCallback || settings.onOffScreen,
+ callbackName = 'offScreen'
+ ;
+ if(newCallback) {
+ module.debug('Adding callback for offScreen', newCallback);
+ settings.onOffScreen = newCallback;
+ }
+ if(calculations.offScreen) {
+ module.execute(callback, callbackName);
+ }
+ else if(!settings.once) {
+ module.remove.occurred(callbackName);
+ }
+ if(newCallback !== undefined) {
+ return calculations.onOffScreen;
+ }
+ },
+
+ passing: function(newCallback) {
+ var
+ calculations = module.get.elementCalculations(),
+ callback = newCallback || settings.onPassing,
+ callbackName = 'passing'
+ ;
+ if(newCallback) {
+ module.debug('Adding callback for passing', newCallback);
+ settings.onPassing = newCallback;
+ }
+ if(calculations.passing) {
+ module.execute(callback, callbackName);
+ }
+ else if(!settings.once) {
+ module.remove.occurred(callbackName);
+ }
+ if(newCallback !== undefined) {
+ return calculations.passing;
+ }
+ },
+
+
+ topVisible: function(newCallback) {
+ var
+ calculations = module.get.elementCalculations(),
+ callback = newCallback || settings.onTopVisible,
+ callbackName = 'topVisible'
+ ;
+ if(newCallback) {
+ module.debug('Adding callback for top visible', newCallback);
+ settings.onTopVisible = newCallback;
+ }
+ if(calculations.topVisible) {
+ module.execute(callback, callbackName);
+ }
+ else if(!settings.once) {
+ module.remove.occurred(callbackName);
+ }
+ if(newCallback === undefined) {
+ return calculations.topVisible;
+ }
+ },
+
+ bottomVisible: function(newCallback) {
+ var
+ calculations = module.get.elementCalculations(),
+ callback = newCallback || settings.onBottomVisible,
+ callbackName = 'bottomVisible'
+ ;
+ if(newCallback) {
+ module.debug('Adding callback for bottom visible', newCallback);
+ settings.onBottomVisible = newCallback;
+ }
+ if(calculations.bottomVisible) {
+ module.execute(callback, callbackName);
+ }
+ else if(!settings.once) {
+ module.remove.occurred(callbackName);
+ }
+ if(newCallback === undefined) {
+ return calculations.bottomVisible;
+ }
+ },
+
+ topPassed: function(newCallback) {
+ var
+ calculations = module.get.elementCalculations(),
+ callback = newCallback || settings.onTopPassed,
+ callbackName = 'topPassed'
+ ;
+ if(newCallback) {
+ module.debug('Adding callback for top passed', newCallback);
+ settings.onTopPassed = newCallback;
+ }
+ if(calculations.topPassed) {
+ module.execute(callback, callbackName);
+ }
+ else if(!settings.once) {
+ module.remove.occurred(callbackName);
+ }
+ if(newCallback === undefined) {
+ return calculations.topPassed;
+ }
+ },
+
+ bottomPassed: function(newCallback) {
+ var
+ calculations = module.get.elementCalculations(),
+ callback = newCallback || settings.onBottomPassed,
+ callbackName = 'bottomPassed'
+ ;
+ if(newCallback) {
+ module.debug('Adding callback for bottom passed', newCallback);
+ settings.onBottomPassed = newCallback;
+ }
+ if(calculations.bottomPassed) {
+ module.execute(callback, callbackName);
+ }
+ else if(!settings.once) {
+ module.remove.occurred(callbackName);
+ }
+ if(newCallback === undefined) {
+ return calculations.bottomPassed;
+ }
+ },
+
+ passingReverse: function(newCallback) {
+ var
+ calculations = module.get.elementCalculations(),
+ callback = newCallback || settings.onPassingReverse,
+ callbackName = 'passingReverse'
+ ;
+ if(newCallback) {
+ module.debug('Adding callback for passing reverse', newCallback);
+ settings.onPassingReverse = newCallback;
+ }
+ if(!calculations.passing) {
+ if(module.get.occurred('passing')) {
+ module.execute(callback, callbackName);
}
- else {
- module.debug('Form has errors');
- module.set.error();
- if(!settings.inline) {
- module.add.errors(formErrors);
+ }
+ else if(!settings.once) {
+ module.remove.occurred(callbackName);
+ }
+ if(newCallback !== undefined) {
+ return !calculations.passing;
+ }
+ },
+
+
+ topVisibleReverse: function(newCallback) {
+ var
+ calculations = module.get.elementCalculations(),
+ callback = newCallback || settings.onTopVisibleReverse,
+ callbackName = 'topVisibleReverse'
+ ;
+ if(newCallback) {
+ module.debug('Adding callback for top visible reverse', newCallback);
+ settings.onTopVisibleReverse = newCallback;
+ }
+ if(!calculations.topVisible) {
+ if(module.get.occurred('topVisible')) {
+ module.execute(callback, callbackName);
+ }
+ }
+ else if(!settings.once) {
+ module.remove.occurred(callbackName);
+ }
+ if(newCallback === undefined) {
+ return !calculations.topVisible;
+ }
+ },
+
+ bottomVisibleReverse: function(newCallback) {
+ var
+ calculations = module.get.elementCalculations(),
+ callback = newCallback || settings.onBottomVisibleReverse,
+ callbackName = 'bottomVisibleReverse'
+ ;
+ if(newCallback) {
+ module.debug('Adding callback for bottom visible reverse', newCallback);
+ settings.onBottomVisibleReverse = newCallback;
+ }
+ if(!calculations.bottomVisible) {
+ if(module.get.occurred('bottomVisible')) {
+ module.execute(callback, callbackName);
+ }
+ }
+ else if(!settings.once) {
+ module.remove.occurred(callbackName);
+ }
+ if(newCallback === undefined) {
+ return !calculations.bottomVisible;
+ }
+ },
+
+ topPassedReverse: function(newCallback) {
+ var
+ calculations = module.get.elementCalculations(),
+ callback = newCallback || settings.onTopPassedReverse,
+ callbackName = 'topPassedReverse'
+ ;
+ if(newCallback) {
+ module.debug('Adding callback for top passed reverse', newCallback);
+ settings.onTopPassedReverse = newCallback;
+ }
+ if(!calculations.topPassed) {
+ if(module.get.occurred('topPassed')) {
+ module.execute(callback, callbackName);
+ }
+ }
+ else if(!settings.once) {
+ module.remove.occurred(callbackName);
+ }
+ if(newCallback === undefined) {
+ return !calculations.onTopPassed;
+ }
+ },
+
+ bottomPassedReverse: function(newCallback) {
+ var
+ calculations = module.get.elementCalculations(),
+ callback = newCallback || settings.onBottomPassedReverse,
+ callbackName = 'bottomPassedReverse'
+ ;
+ if(newCallback) {
+ module.debug('Adding callback for bottom passed reverse', newCallback);
+ settings.onBottomPassedReverse = newCallback;
+ }
+ if(!calculations.bottomPassed) {
+ if(module.get.occurred('bottomPassed')) {
+ module.execute(callback, callbackName);
+ }
+ }
+ else if(!settings.once) {
+ module.remove.occurred(callbackName);
+ }
+ if(newCallback === undefined) {
+ return !calculations.bottomPassed;
+ }
+ },
+
+ execute: function(callback, callbackName) {
+ var
+ calculations = module.get.elementCalculations(),
+ screen = module.get.screenCalculations()
+ ;
+ callback = callback || false;
+ if(callback) {
+ if(settings.continuous) {
+ module.debug('Callback being called continuously', callbackName, calculations);
+ callback.call(element, calculations, screen);
+ }
+ else if(!module.get.occurred(callbackName)) {
+ module.debug('Conditions met', callbackName, calculations);
+ callback.call(element, calculations, screen);
+ }
+ }
+ module.save.occurred(callbackName);
+ },
+
+ remove: {
+ fixed: function() {
+ module.debug('Removing fixed position');
+ $module
+ .removeClass(className.fixed)
+ .css({
+ position : '',
+ top : '',
+ left : '',
+ zIndex : ''
+ })
+ ;
+ },
+ occurred: function(callback) {
+ if(callback) {
+ var
+ occurred = module.cache.occurred
+ ;
+ if(occurred[callback] !== undefined && occurred[callback] === true) {
+ module.debug('Callback can now be called again', callback);
+ module.cache.occurred[callback] = false;
}
- // prevent ajax submit
- if($module.data('moduleApi') !== undefined) {
- event.stopImmediatePropagation();
+ }
+ else {
+ module.cache.occurred = {};
+ }
+ }
+ },
+
+ save: {
+ calculations: function() {
+ module.verbose('Saving all calculations necessary to determine positioning');
+ module.save.direction();
+ module.save.screenCalculations();
+ module.save.elementCalculations();
+ },
+ occurred: function(callback) {
+ if(callback) {
+ if(module.cache.occurred[callback] === undefined || (module.cache.occurred[callback] !== true)) {
+ module.verbose('Saving callback occurred', callback);
+ module.cache.occurred[callback] = true;
}
- return $.proxy(settings.onFailure, this)(formErrors);
}
},
-
- // takes a validation object and returns whether field passes validation
- field: function(field) {
+ scroll: function(scrollPosition) {
+ scrollPosition = scrollPosition + settings.offset || $context.scrollTop() + settings.offset;
+ module.cache.scroll = scrollPosition;
+ },
+ direction: function() {
var
- $field = module.get.field(field.identifier),
- fieldValid = true,
- fieldErrors = []
+ scroll = module.get.scroll(),
+ lastScroll = module.get.lastScroll(),
+ direction
;
- if(field.optional && $.trim($field.val()) === ''){
- module.debug('Field is optional and empty. Skipping', field.identifier);
- fieldValid = true;
+ if(scroll > lastScroll && lastScroll) {
+ direction = 'down';
}
- else if(field.rules !== undefined) {
- $.each(field.rules, function(index, rule) {
- if( module.has.field(field.identifier) && !( module.validate.rule(field, rule) ) ) {
- module.debug('Field is invalid', field.identifier, rule.type);
- fieldErrors.push(rule.prompt);
- fieldValid = false;
- }
- });
- }
- if(fieldValid) {
- module.remove.prompt(field, fieldErrors);
- $.proxy(settings.onValid, $field)();
+ else if(scroll < lastScroll && lastScroll) {
+ direction = 'up';
}
else {
- formErrors = formErrors.concat(fieldErrors);
- module.add.prompt(field.identifier, fieldErrors);
- $.proxy(settings.onInvalid, $field)(fieldErrors);
- return false;
+ direction = 'static';
}
- return true;
+ module.cache.direction = direction;
+ return module.cache.direction;
},
+ elementPosition: function() {
+ var
+ element = module.cache.element,
+ screen = module.get.screenSize()
+ ;
+ module.verbose('Saving element position');
+ // (quicker than $.extend)
+ element.fits = (element.height < screen.height);
+ element.offset = $module.offset();
+ element.width = $module.outerWidth();
+ element.height = $module.outerHeight();
+ // store
+ module.cache.element = element;
+ return element;
+ },
+ elementCalculations: function() {
+ var
+ screen = module.get.screenCalculations(),
+ element = module.get.elementPosition()
+ ;
+ // offset
+ if(settings.includeMargin) {
+ element.margin = {};
+ element.margin.top = parseInt($module.css('margin-top'), 10);
+ element.margin.bottom = parseInt($module.css('margin-bottom'), 10);
+ element.top = element.offset.top - element.margin.top;
+ element.bottom = element.offset.top + element.height + element.margin.bottom;
+ }
+ else {
+ element.top = element.offset.top;
+ element.bottom = element.offset.top + element.height;
+ }
- // takes validation rule and returns whether field passes rule
- rule: function(field, validation) {
+ // visibility
+ element.topVisible = (screen.bottom >= element.top);
+ element.topPassed = (screen.top >= element.top);
+ element.bottomVisible = (screen.bottom >= element.bottom);
+ element.bottomPassed = (screen.top >= element.bottom);
+ element.pixelsPassed = 0;
+ element.percentagePassed = 0;
+
+ // meta calculations
+ element.onScreen = (element.topVisible && !element.bottomPassed);
+ element.passing = (element.topPassed && !element.bottomPassed);
+ element.offScreen = (!element.onScreen);
+
+ // passing calculations
+ if(element.passing) {
+ element.pixelsPassed = (screen.top - element.top);
+ element.percentagePassed = (screen.top - element.top) / element.height;
+ }
+ module.cache.element = element;
+ module.verbose('Updated element calculations', element);
+ return element;
+ },
+ screenCalculations: function() {
var
- $field = module.get.field(field.identifier),
- type = validation.type,
- value = $.trim($field.val() + ''),
+ scroll = module.get.scroll()
+ ;
+ module.save.direction();
+ module.cache.screen.top = scroll;
+ module.cache.screen.bottom = scroll + module.cache.screen.height;
+ return module.cache.screen;
+ },
+ screenSize: function() {
+ module.verbose('Saving window position');
+ module.cache.screen = {
+ height: $context.height()
+ };
+ },
+ position: function() {
+ module.save.screenSize();
+ module.save.elementPosition();
+ }
+ },
- bracketRegExp = /\[(.*)\]/i,
- bracket = bracketRegExp.exec(type),
- isValid = true,
- ancillary,
- functionType
+ get: {
+ pixelsPassed: function(amount) {
+ var
+ element = module.get.elementCalculations()
;
- // if bracket notation is used, pass in extra parameters
- if(bracket !== undefined && bracket !== null) {
- ancillary = '' + bracket[1];
- functionType = type.replace(bracket[0], '');
- isValid = $.proxy(settings.rules[functionType], $module)(value, ancillary);
+ if(amount.search('%') > -1) {
+ return ( element.height * (parseInt(amount, 10) / 100) );
}
- // normal notation
- else {
- isValid = $.proxy(settings.rules[type], $field)(value);
+ return parseInt(amount, 10);
+ },
+ occurred: function(callback) {
+ return (module.cache.occurred !== undefined)
+ ? module.cache.occurred[callback] || false
+ : false
+ ;
+ },
+ direction: function() {
+ if(module.cache.direction === undefined) {
+ module.save.direction();
+ }
+ return module.cache.direction;
+ },
+ elementPosition: function() {
+ if(module.cache.element === undefined) {
+ module.save.elementPosition();
+ }
+ return module.cache.element;
+ },
+ elementCalculations: function() {
+ if(module.cache.element === undefined) {
+ module.save.elementCalculations();
+ }
+ return module.cache.element;
+ },
+ screenCalculations: function() {
+ if(module.cache.screen === undefined) {
+ module.save.screenCalculations();
+ }
+ return module.cache.screen;
+ },
+ screenSize: function() {
+ if(module.cache.screen === undefined) {
+ module.save.screenSize();
+ }
+ return module.cache.screen;
+ },
+ scroll: function() {
+ if(module.cache.scroll === undefined) {
+ module.save.scroll();
+ }
+ return module.cache.scroll;
+ },
+ lastScroll: function() {
+ if(module.cache.screen === undefined) {
+ module.debug('First scroll event, no last scroll could be found');
+ return false;
}
- return isValid;
+ return module.cache.screen.top;
}
},
@@ -15120,7 +21229,7 @@ $.fn.form = function(fields, parameters) {
});
}
clearTimeout(module.performance.timer);
- module.performance.timer = setTimeout(module.performance.display, 100);
+ module.performance.timer = setTimeout(module.performance.display, 500);
},
display: function() {
var
@@ -15136,9 +21245,6 @@ $.fn.form = function(fields, parameters) {
if(moduleSelector) {
title += ' \'' + moduleSelector + '\'';
}
- if($allModules.size() > 1) {
- title += ' ' + '(' + $allModules.size() + ')';
- }
if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
console.groupCollapsed(title);
if(console.table) {
@@ -15186,6 +21292,7 @@ $.fn.form = function(fields, parameters) {
return false;
}
else {
+ module.error(error.method, query);
return false;
}
});
@@ -15208,19 +21315,21 @@ $.fn.form = function(fields, parameters) {
return found;
}
};
+
if(methodInvoked) {
if(instance === undefined) {
module.initialize();
}
+ instance.save.scroll();
+ instance.save.calculations();
module.invoke(query);
}
else {
if(instance !== undefined) {
- module.destroy();
+ instance.invoke('destroy');
}
module.initialize();
}
-
})
;
@@ -15230,191 +21339,92 @@ $.fn.form = function(fields, parameters) {
;
};
-$.fn.form.settings = {
+$.fn.visibility.settings = {
- name : 'Form',
- namespace : 'form',
+ name : 'Visibility',
+ namespace : 'visibility',
- debug : false,
- verbose : true,
- performance : true,
+ debug : false,
+ verbose : false,
+ performance : true,
+ // whether to use mutation observers to follow changes
+ observeChanges : true,
- keyboardShortcuts : true,
- on : 'submit',
- inline : false,
+ // check position immediately on init
+ initialCheck : true,
- delay : 200,
- revalidate : true,
+ // whether to refresh calculations after all page images load
+ refreshOnLoad : true,
- transition : 'scale',
- duration : 200,
+ // whether to refresh calculations after page resize event
+ refreshOnResize : true,
+ // should call callbacks on refresh event (resize, etc)
+ checkOnRefresh : true,
- onValid : function() {},
- onInvalid : function() {},
- onSuccess : function() { return true; },
- onFailure : function() { return false; },
+ // callback should only occur one time
+ once : true,
- metadata : {
- validate: 'validate'
- },
+ // callback should fire continuously whe evaluates to true
+ continuous : false,
- selector : {
- message : '.error.message',
- field : 'input, textarea, select',
- group : '.field',
- checkbox: 'input[type="checkbox"], input[type="radio"]',
- input : 'input',
- prompt : '.prompt',
- submit : '.submit'
- },
+ // offset to use with scroll top
+ offset : 0,
- className : {
- error : 'error',
- success : 'success',
- down : 'down',
- label : 'ui prompt label'
- },
+ // whether to include margin in elements position
+ includeMargin : false,
- error: {
- method : 'The method you called is not defined.'
- },
+ // scroll context for visibility checks
+ context : window,
- templates: {
- error: function(errors) {
- var
- html = '<ul class="list">'
- ;
- $.each(errors, function(index, value) {
- html += '<li>' + value + '</li>';
- });
- html += '</ul>';
- return $(html);
- },
- prompt: function(errors) {
- return $('<div/>')
- .addClass('ui red pointing prompt label')
- .html(errors[0])
- ;
- }
- },
+ // visibility check delay in ms (defaults to animationFrame)
+ throttle : false,
- rules: {
+ // special visibility type (image, fixed)
+ type : false,
- // checkbox checked
- checked: function() {
- return ($(this).filter(':checked').size() > 0);
- },
+ // image only animation settings
+ transition : 'fade in',
+ duration : 1000,
- // value contains (text)
- contains: function(value, text) {
- text = text.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
- return (value.search(text) !== -1);
- },
+ // array of callbacks for percentage
+ onPassed : {},
- // is most likely an email
- email: function(value){
- var
- emailRegExp = new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", "i")
- ;
- return emailRegExp.test(value);
- },
+ // standard callbacks
+ onOnScreen : false,
+ onOffScreen : false,
+ onPassing : false,
+ onTopVisible : false,
+ onBottomVisible : false,
+ onTopPassed : false,
+ onBottomPassed : false,
- // is not empty or blank string
- empty: function(value) {
- return !(value === undefined || '' === value);
- },
+ // reverse callbacks
+ onPassingReverse : false,
+ onTopVisibleReverse : false,
+ onBottomVisibleReverse : false,
+ onTopPassedReverse : false,
+ onBottomPassedReverse : false,
- // is valid integer
- integer: function(value, range) {
- var
- intRegExp = /^\-?\d+$/,
- min,
- max,
- parts
- ;
- if (range === undefined || range === '' || range === '..') {
- // do nothing
- }
- else if (range.indexOf('..') == -1) {
- if (intRegExp.test(range)) {
- min = max = range - 0;
- }
- }
- else {
- parts = range.split('..', 2);
- if (intRegExp.test(parts[0])) {
- min = parts[0] - 0;
- }
- if (intRegExp.test(parts[1])) {
- max = parts[1] - 0;
- }
- }
- return (
- intRegExp.test(value) &&
- (min === undefined || value >= min) &&
- (max === undefined || value <= max)
- );
- },
+ // utility callbacks
+ onUpdate : false, // disabled by default for performance
+ onRefresh : function(){},
- // is exactly value
- is: function(value, text) {
- return (value == text);
- },
-
- // is at least string length
- length: function(value, requiredLength) {
- return (value !== undefined)
- ? (value.length >= requiredLength)
- : false
- ;
- },
-
- // matches another field
- match: function(value, fieldIdentifier) {
- // use either id or name of field
- var
- $form = $(this),
- matchingValue
- ;
- if($form.find('#' + fieldIdentifier).size() > 0) {
- matchingValue = $form.find('#' + fieldIdentifier).val();
- }
- else if($form.find('[name="' + fieldIdentifier +'"]').size() > 0) {
- matchingValue = $form.find('[name="' + fieldIdentifier + '"]').val();
- }
- else if( $form.find('[data-validate="'+ fieldIdentifier +'"]').size() > 0 ) {
- matchingValue = $form.find('[data-validate="'+ fieldIdentifier +'"]').val();
- }
- return (matchingValue !== undefined)
- ? ( value.toString() == matchingValue.toString() )
- : false
- ;
- },
-
- // string length is less than max length
- maxLength: function(value, maxLength) {
- return (value !== undefined)
- ? (value.length <= maxLength)
- : false
- ;
- },
+ metadata : {
+ src: 'src'
+ },
- // value is not exactly notValue
- not: function(value, notValue) {
- return (value != notValue);
- },
+ className: {
+ fixed : 'fixed',
+ placeholder : 'placeholder'
+ },
- // value is most likely url
- url: function(value) {
- var
- urlRegExp = /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/
- ;
- return urlRegExp.test(value);
- }
+ error : {
+ method : 'The method you called is not defined.',
+ visible : 'Element is hidden, you must call refresh after element becomes visible'
}
};
-})( jQuery, window , document );
+})( jQuery, window, document );
diff --git a/src/js/semantic.min.js b/src/js/semantic.min.js
index 12392b3..088eb26 100644
--- a/src/js/semantic.min.js
+++ b/src/js/semantic.min.js
@@ -1,5 +1,5 @@
/*
- * # Semantic UI
+ * # Semantic UI - 2.1.6
* https://github.com/Semantic-Org/Semantic-UI
* http://www.semantic-ui.com/
*
@@ -8,9 +8,12 @@
* http://opensource.org/licenses/MIT
*
*/
-!function(e,t,n,i){e.site=e.fn.site=function(o){var r,a,s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1),m=e.isPlainObject(o)?e.extend(!0,{},e.site.settings,o):e.extend({},e.site.settings),f=m.namespace,p=m.error,g="module-"+f,b=e(n),v=b,h=this,y=v.data(g);return r={initialize:function(){r.instantiate()},instantiate:function(){r.verbose("Storing instance of site",r),y=r,v.data(g,r)},normalize:function(){r.fix.console(),r.fix.requestAnimationFrame()},fix:{console:function(){r.debug("Normalizing window.console"),(console===i||console.log===i)&&(r.verbose("Console not available, normalizing events"),r.disable.console()),("undefined"==typeof console.group||"undefined"==typeof console.groupEnd||"undefined"==typeof console.groupCollapsed)&&(r.verbose("Console group not available, normalizing events"),t.console.group=function(){},t.console.groupEnd=function(){},t.console.groupCollapsed=function(){}),"undefined"==typeof console.markTimeline&&(r.verbose("Mark timeline not available, normalizing events"),t.console.markTimeline=function(){})},consoleClear:function(){r.debug("Disabling programmatic console clearing"),t.console.clear=function(){}},requestAnimationFrame:function(){r.debug("Normalizing requestAnimationFrame"),t.requestAnimationFrame===i&&(r.debug("RequestAnimationFrame not available, normailizing event"),t.requestAnimationFrame=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)})}},moduleExists:function(t){return e.fn[t]!==i&&e.fn[t].settings!==i},enabled:{modules:function(t){var n=[];return t=t||m.modules,e.each(t,function(e,t){r.moduleExists(t)&&n.push(t)}),n}},disabled:{modules:function(t){var n=[];return t=t||m.modules,e.each(t,function(e,t){r.moduleExists(t)||n.push(t)}),n}},change:{setting:function(t,n,o,a){o="string"==typeof o?"all"===o?m.modules:[o]:o||m.modules,a=a!==i?a:!0,e.each(o,function(i,o){var s,c=r.moduleExists(o)?e.fn[o].settings.namespace||!1:!0;r.moduleExists(o)&&(r.verbose("Changing default setting",t,n,o),e.fn[o].settings[t]=n,a&&c&&(s=e(":data(module-"+c+")"),s.size()>0&&(r.verbose("Modifying existing settings",s),s[o]("setting",t,n))))})},settings:function(t,n,o){n="string"==typeof n?[n]:n||m.modules,o=o!==i?o:!0,e.each(n,function(n,i){var a;r.moduleExists(i)&&(r.verbose("Changing default setting",t,i),e.extend(!0,e.fn[i].settings,t),o&&f&&(a=e(":data(module-"+f+")"),a.size()>0&&(r.verbose("Modifying existing settings",a),a[i]("setting",t))))})}},enable:{console:function(){r.console(!0)},debug:function(e,t){e=e||m.modules,r.debug("Enabling debug for modules",e),r.change.setting("debug",!0,e,t)},verbose:function(e,t){e=e||m.modules,r.debug("Enabling verbose debug for modules",e),r.change.setting("verbose",!0,e,t)}},disable:{console:function(){r.console(!1)},debug:function(e,t){e=e||m.modules,r.debug("Disabling debug for modules",e),r.change.setting("debug",!1,e,t)},verbose:function(e,t){e=e||m.modules,r.debug("Disabling verbose debug for modules",e),r.change.setting("verbose",!1,e,t)}},console:function(e){if(e){if(y.cache.console===i)return void r.error(p.console);r.debug("Restoring console function"),t.console=y.cache.console}else r.debug("Disabling console function"),y.cache.console=t.console,t.console={clear:function(){},error:function(){},group:function(){},groupCollapsed:function(){},groupEnd:function(){},info:function(){},log:function(){},markTimeline:function(){},warn:function(){}}},destroy:function(){r.verbose("Destroying previous site for",v),v.removeData(g)},cache:{},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,m,t);else{if(n===i)return m[t];m[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,r,t);else{if(n===i)return r[t];r[t]=n}},debug:function(){m.debug&&(m.performance?r.performance.log(arguments):(r.debug=Function.prototype.bind.call(console.info,console,m.name+":"),r.debug.apply(console,arguments)))},verbose:function(){m.verbose&&m.debug&&(m.performance?r.performance.log(arguments):(r.verbose=Function.prototype.bind.call(console.info,console,m.name+":"),r.verbose.apply(console,arguments)))},error:function(){r.error=Function.prototype.bind.call(console.error,console,m.name+":"),r.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;m.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Element:h,Name:e[0],Arguments:[].slice.call(e,1)||"","Execution Time":n})),clearTimeout(r.performance.timer),r.performance.timer=setTimeout(r.performance.display,100)},display:function(){var t=m.name+":",n=0;s=!1,clearTimeout(r.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,o){var s,c,l,u=y;return n=n||d,o=h||o,"string"==typeof t&&u!==i&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(n,o){var a=n!=s?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(u[a])&&n!=s)u=u[a];else{if(u[a]!==i)return c=u[a],!1;if(!e.isPlainObject(u[o])||n==s)return u[o]!==i?(c=u[o],!1):(r.error(p.method,t),!1);u=u[o]}})),e.isFunction(c)?l=c.apply(o,n):c!==i&&(l=c),e.isArray(a)?a.push(l):a!==i?a=[a,l]:l!==i&&(a=l),c}},u?(y===i&&r.initialize(),r.invoke(l)):(y!==i&&r.destroy(),r.initialize()),a!==i?a:this},e.site.settings={name:"Site",namespace:"site",error:{console:"Console cannot be restored, most likely it was overwritten outside of module",method:"The method you called is not defined."},debug:!1,verbose:!0,performance:!0,modules:["accordion","api","checkbox","dimmer","dropdown","form","modal","nag","popup","rating","shape","sidebar","state","sticky","tab","transition","video","visit","visibility"],siteNamespace:"site",namespaceStub:{cache:{},config:{},sections:{},section:{},utilities:{}}},e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(n){return!!e.data(n,t)}}):function(t,n,i){return!!e.data(t,i[3])}})}(jQuery,window,document),function(e,t,n,i){e.fn.form=function(t,o){var r,a=e(this),s=e.extend(!0,{},e.fn.form.settings,o),c=e.extend({},e.fn.form.settings.defaults,t),l=s.namespace,u=s.metadata,d=s.selector,m=s.className,f=(s.error,"."+l),p="module-"+l,g=a.selector||"",b=(new Date).getTime(),v=[],h=arguments[0],y="string"==typeof h,x=[].slice.call(arguments,1);return a.each(function(){var t,o=e(this),l=e(this).find(d.field),w=e(this).find(d.group),C=e(this).find(d.message),T=(e(this).find(d.prompt),e(this).find(d.submit)),k=[],S=this,z=o.data(p);t={initialize:function(){t.verbose("Initializing form validation",o,c,s),t.bindEvents(),t.instantiate()},instantiate:function(){t.verbose("Storing instance of module",t),z=t,o.data(p,t)},destroy:function(){t.verbose("Destroying previous module",z),t.removeEvents(),o.removeData(p)},refresh:function(){t.verbose("Refreshing selector cache"),l=o.find(d.field)},submit:function(){t.verbose("Submitting form",o),o.submit()},attachEvents:function(n,i){i=i||"submit",e(n).on("click",function(e){t[i](),e.preventDefault()})},bindEvents:function(){s.keyboardShortcuts&&l.on("keydown"+f,t.event.field.keydown),o.on("submit"+f,t.validate.form),l.on("blur"+f,t.event.field.blur),t.attachEvents(T,"submit"),l.each(function(){var n=e(this).prop("type"),i=t.get.changeEvent(n);e(this).on(i+f,t.event.field.change)})},removeEvents:function(){o.off(f),l.off(f),T.off(f),l.off(f)},event:{field:{keydown:function(n){var i=e(this),o=n.which,r={enter:13,escape:27};o==r.escape&&(t.verbose("Escape key pressed blurring field"),i.blur()),!n.ctrlKey&&o==r.enter&&i.is(d.input)&&i.not(d.checkbox).size()>0&&(t.debug("Enter key pressed, submitting form"),T.addClass(m.down),i.one("keyup"+f,t.event.field.keyup))},keyup:function(){t.verbose("Doing keyboard shortcut form submit"),T.removeClass(m.down),t.submit()},blur:function(){var n=e(this),i=n.closest(w);i.hasClass(m.error)?(t.debug("Revalidating field",n,t.get.validation(n)),t.validate.field(t.get.validation(n))):("blur"==s.on||"change"==s.on)&&t.validate.field(t.get.validation(n))},change:function(){var n=e(this),i=n.closest(w);("change"==s.on||i.hasClass(m.error)&&s.revalidate)&&(clearTimeout(t.timer),t.timer=setTimeout(function(){t.debug("Revalidating field",n,t.get.validation(n)),t.validate.field(t.get.validation(n))},s.delay))}}},get:{changeEvent:function(e){return"checkbox"==e||"radio"==e||"hidden"==e?"change":n.createElement("input").oninput!==i?"input":n.createElement("input").onpropertychange!==i?"propertychange":"keyup"},field:function(n){return t.verbose("Finding field with identifier",n),l.filter("#"+n).size()>0?l.filter("#"+n):l.filter('[name="'+n+'"]').size()>0?l.filter('[name="'+n+'"]'):l.filter("[data-"+u.validate+'="'+n+'"]').size()>0?l.filter("[data-"+u.validate+'="'+n+'"]'):e("<input/>")},validation:function(n){var i;return e.each(c,function(e,o){t.get.field(o.identifier).get(0)==n.get(0)&&(i=o)}),i||!1}},has:{field:function(e){return t.verbose("Checking for existence of a field with identifier",e),l.filter("#"+e).size()>0?!0:l.filter('[name="'+e+'"]').size()>0?!0:l.filter("[data-"+u.validate+'="'+e+'"]').size()>0?!0:!1}},add:{prompt:function(n,r){var a=t.get.field(n),c=a.closest(w),l=c.find(d.prompt),u=0!==l.size();r="string"==typeof r?[r]:r,t.verbose("Adding field error state",n),c.addClass(m.error),s.inline&&(u||(l=s.templates.prompt(r),l.appendTo(c)),l.html(r[0]),u?t.verbose("Inline errors are disabled, no inline error added",n):s.transition&&e.fn.transition!==i&&o.transition("is supported")?(t.verbose("Displaying error with css transition",s.transition),l.transition(s.transition+" in",s.duration)):(t.verbose("Displaying error with fallback javascript animation"),l.fadeIn(s.duration)))},errors:function(e){t.debug("Adding form error messages",e),C.html(s.templates.error(e))}},remove:{prompt:function(n){var r=t.get.field(n.identifier),a=r.closest(w),c=a.find(d.prompt);a.removeClass(m.error),s.inline&&c.is(":visible")&&(t.verbose("Removing prompt for field",n),s.transition&&e.fn.transition!==i&&o.transition("is supported")?c.transition(s.transition+" out",s.duration,function(){c.remove()}):c.fadeOut(s.duration,function(){c.remove()}))}},set:{success:function(){o.removeClass(m.error).addClass(m.success)},error:function(){o.removeClass(m.success).addClass(m.error)}},validate:{form:function(n){var r=!0;return k=[],e.each(c,function(e,n){t.validate.field(n)||(r=!1)}),r?(t.debug("Form has no validation errors, submitting"),t.set.success(),e.proxy(s.onSuccess,this)(n)):(t.debug("Form has errors"),t.set.error(),s.inline||t.add.errors(k),o.data("moduleApi")!==i&&n.stopImmediatePropagation(),e.proxy(s.onFailure,this)(k))},field:function(n){var o=t.get.field(n.identifier),r=!0,a=[];return n.optional&&""===e.trim(o.val())?(t.debug("Field is optional and empty. Skipping",n.identifier),r=!0):n.rules!==i&&e.each(n.rules,function(e,i){t.has.field(n.identifier)&&!t.validate.rule(n,i)&&(t.debug("Field is invalid",n.identifier,i.type),a.push(i.prompt),r=!1)}),r?(t.remove.prompt(n,a),e.proxy(s.onValid,o)(),!0):(k=k.concat(a),t.add.prompt(n.identifier,a),e.proxy(s.onInvalid,o)(a),!1)},rule:function(n,r){var a,c,l=t.get.field(n.identifier),u=r.type,d=e.trim(l.val()+""),m=/\[(.*)\]/i,f=m.exec(u),p=!0;return f!==i&&null!==f?(a=""+f[1],c=u.replace(f[0],""),p=e.proxy(s.rules[c],o)(d,a)):p=e.proxy(s.rules[u],l)(d),p}},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,s,t);else{if(n===i)return s[t];s[t]=n}},internal:function(n,o){if(e.isPlainObject(n))e.extend(!0,t,n);else{if(o===i)return t[n];t[n]=o}},debug:function(){s.debug&&(s.performance?t.performance.log(arguments):(t.debug=Function.prototype.bind.call(console.info,console,s.name+":"),t.debug.apply(console,arguments)))},verbose:function(){s.verbose&&s.debug&&(s.performance?t.performance.log(arguments):(t.verbose=Function.prototype.bind.call(console.info,console,s.name+":"),t.verbose.apply(console,arguments)))},error:function(){t.error=Function.prototype.bind.call(console.error,console,s.name+":"),t.error.apply(console,arguments)},performance:{log:function(e){var n,i,o;s.performance&&(n=(new Date).getTime(),o=b||n,i=n-o,b=n,v.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:S,"Execution Time":i})),clearTimeout(t.performance.timer),t.performance.timer=setTimeout(t.performance.display,100)},display:function(){var n=s.name+":",o=0;b=!1,clearTimeout(t.performance.timer),e.each(v,function(e,t){o+=t["Execution Time"]}),n+=" "+o+"ms",g&&(n+=" '"+g+"'"),a.size()>1&&(n+=" ("+a.size()+")"),(console.group!==i||console.table!==i)&&v.length>0&&(console.groupCollapsed(n),console.table?console.table(v):e.each(v,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),v=[]}},invoke:function(t,n,o){var a,s,c,l=z;return n=n||x,o=S||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(r)?r.push(c):r!==i?r=[r,c]:c!==i&&(r=c),s}},y?(z===i&&t.initialize(),t.invoke(h)):(z!==i&&t.destroy(),t.initialize())}),r!==i?r:this},e.fn.form.settings={name:"Form",namespace:"form",debug:!1,verbose:!0,performance:!0,keyboardShortcuts:!0,on:"submit",inline:!1,delay:200,revalidate:!0,transition:"scale",duration:200,onValid:function(){},onInvalid:function(){},onSuccess:function(){return!0},onFailure:function(){return!1},metadata:{validate:"validate"},selector:{message:".error.message",field:"input, textarea, select",group:".field",checkbox:'input[type="checkbox"], input[type="radio"]',input:"input",prompt:".prompt",submit:".submit"},className:{error:"error",success:"success",down:"down",label:"ui prompt label"},error:{method:"The method you called is not defined."},templates:{error:function(t){var n='<ul class="list">';return e.each(t,function(e,t){n+="<li>"+t+"</li>"}),n+="</ul>",e(n)},prompt:function(t){return e("<div/>").addClass("ui red pointing prompt label").html(t[0])}},rules:{checked:function(){return e(this).filter(":checked").size()>0},contains:function(e,t){return t=t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),-1!==e.search(t)},email:function(e){var t=new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?","i");return t.test(e)},empty:function(e){return!(e===i||""===e)},integer:function(e,t){var n,o,r,a=/^\-?\d+$/;return t===i||""===t||".."===t||(-1==t.indexOf("..")?a.test(t)&&(n=o=t-0):(r=t.split("..",2),a.test(r[0])&&(n=r[0]-0),a.test(r[1])&&(o=r[1]-0))),a.test(e)&&(n===i||e>=n)&&(o===i||o>=e)},is:function(e,t){return e==t},length:function(e,t){return e!==i?e.length>=t:!1},match:function(t,n){var o,r=e(this);return r.find("#"+n).size()>0?o=r.find("#"+n).val():r.find('[name="'+n+'"]').size()>0?o=r.find('[name="'+n+'"]').val():r.find('[data-validate="'+n+'"]').size()>0&&(o=r.find('[data-validate="'+n+'"]').val()),o!==i?t.toString()==o.toString():!1},maxLength:function(e,t){return e!==i?e.length<=t:!1},not:function(e,t){return e!=t},url:function(e){var t=/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;return t.test(e)}}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.accordion=function(n){{var o,r=e(this),a=(new Date).getTime(),s=[],c=arguments[0],l="string"==typeof c,u=[].slice.call(arguments,1);t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)}}return r.each(function(){var d,m,f=e.isPlainObject(n)?e.extend(!0,{},e.fn.accordion.settings,n):e.extend({},e.fn.accordion.settings),p=f.className,g=f.namespace,b=f.selector,v=(f.error,"."+g),h="module-"+g,y=r.selector||"",x=e(this),w=x.find(b.title),C=x.find(b.content),T=this,k=x.data(h);m={initialize:function(){m.debug("Initializing accordion with bound events",x),x.on("click"+v,b.title,m.event.click),m.observeChanges(),m.instantiate()},instantiate:function(){k=m,x.data(h,m)},destroy:function(){m.debug("Destroying previous accordion for",x),x.removeData(h),w.off(v)},refresh:function(){w=x.find(b.title),C=x.find(b.content)},observeChanges:function(){"MutationObserver"in t&&(d=new MutationObserver(function(){m.debug("DOM tree modified, updating selector cache"),m.refresh()}),d.observe(T,{childList:!0,subtree:!0}),m.debug("Setting up mutation observer",d))},event:{click:function(){e.proxy(m.toggle,this)()}},toggle:function(t){var n=t!==i?"number"==typeof t?w.eq(t):e(t):e(this),o=n.next(C),r=o.is(":visible");m.debug("Toggling visibility of content",n),r?f.collapsible?e.proxy(m.close,n)():m.debug("Cannot close accordion content collapsing is disabled"):e.proxy(m.open,n)()},open:function(t){var n=t!==i?"number"==typeof t?w.eq(t):e(t):e(this),o=n.next(C),r=o.is(":animated"),a=o.hasClass(p.active);r||a||(m.debug("Opening accordion content",n),f.exclusive&&e.proxy(m.closeOthers,n)(),n.addClass(p.active),o.stop().children().stop().animate({opacity:1},f.duration,m.reset.display).end().slideDown(f.duration,f.easing,function(){o.addClass(p.active),e.proxy(m.reset.display,this)(),e.proxy(f.onOpen,this)(),e.proxy(f.onChange,this)()}))},close:function(t){var n=t!==i?"number"==typeof t?w.eq(t):e(t):e(this),o=n.next(C),r=o.hasClass(p.active);r&&(m.debug("Closing accordion content",o),n.removeClass(p.active),o.removeClass(p.active).show().stop().children().stop().animate({opacity:0},f.duration,m.reset.opacity).end().slideUp(f.duration,f.easing,function(){e.proxy(m.reset.display,this)(),e.proxy(f.onClose,this)(),e.proxy(f.onChange,this)()}))},closeOthers:function(t){var n,o,r,a=t!==i?w.eq(t):e(this),s=a.parents(b.content).prev(b.title),c=a.closest(b.accordion),l=b.title+"."+p.active+":visible",u=b.content+"."+p.active+":visible";f.closeNested?(n=c.find(l).not(s),r=n.next(C)):(n=c.find(l).not(s),o=c.find(u).find(l).not(s),n=n.not(o),r=n.next(C)),n.size()>0&&(m.debug("Exclusive enabled, closing other content",n),n.removeClass(p.active),r.stop().children().stop().animate({opacity:0},f.duration,m.resetOpacity).end().slideUp(f.duration,f.easing,function(){e(this).removeClass(p.active),e.proxy(m.reset.display,this)()}))},reset:{display:function(){m.verbose("Removing inline display from element",this),e(this).css("display",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")},opacity:function(){m.verbose("Removing inline opacity from element",this),e(this).css("opacity",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")}},setting:function(t,n){if(m.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},internal:function(t,n){return m.debug("Changing internal",t,n),n===i?m[t]:void(e.isPlainObject(t)?e.extend(!0,m,t):m[t]=n)},debug:function(){f.debug&&(f.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,f.name+":"),m.debug.apply(console,arguments)))},verbose:function(){f.verbose&&f.debug&&(f.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,f.name+":"),m.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;f.performance&&(t=(new Date).getTime(),i=a||t,n=t-i,a=t,s.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:T,"Execution Time":n})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,100)},display:function(){var t=f.name+":",n=0;a=!1,clearTimeout(m.performance.timer),e.each(s,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",y&&(t+=" '"+y+"'"),(console.group!==i||console.table!==i)&&s.length>0&&(console.groupCollapsed(t),console.table?console.table(s):e.each(s,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),s=[]}},invoke:function(t,n,r){var a,s,c,l=k;return n=n||u,r=T||r,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(r,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},l?(k===i&&m.initialize(),m.invoke(c)):(k!==i&&m.destroy(),m.initialize())}),o!==i?o:this},e.fn.accordion.settings={name:"Accordion",namespace:"accordion",debug:!1,verbose:!0,performance:!0,exclusive:!0,collapsible:!0,closeNested:!1,duration:500,easing:"easeInOutQuint",onOpen:function(){},onClose:function(){},onChange:function(){},error:{method:"The method you called is not defined"},className:{active:"active"},selector:{accordion:".accordion",title:".title",content:".content"}},e.extend(e.easing,{easeInOutQuint:function(e,t,n,i,o){return(t/=o/2)<1?i/2*t*t*t*t*t+n:i/2*((t-=2)*t*t*t*t+2)+n}})}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.checkbox=function(n){var o,r=e(this),a=r.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return r.each(function(){var r,m,f=e.extend(!0,{},e.fn.checkbox.settings,n),p=f.className,g=f.namespace,b=f.selector,v=f.error,h="."+g,y="module-"+g,x=e(this),w=e(this).find(b.label).first(),C=e(this).find(b.input),T=x.data(y),k=this;m={initialize:function(){m.verbose("Initializing checkbox",f),m.create.label(),m.add.events(),m.is.checked()?(m.set.checked(),f.fireOnInit&&e.proxy(f.onChecked,C.get())()):(m.remove.checked(),f.fireOnInit&&e.proxy(f.onUnchecked,C.get())()),m.observeChanges(),m.instantiate()},instantiate:function(){m.verbose("Storing instance of module",m),T=m,x.data(y,m)},destroy:function(){m.verbose("Destroying module"),m.remove.events(),x.removeData(y)},refresh:function(){x=e(this),w=e(this).find(b.label).first(),C=e(this).find(b.input)},observeChanges:function(){"MutationObserver"in t&&(r=new MutationObserver(function(){m.debug("DOM tree modified, updating selector cache"),m.refresh()}),r.observe(k,{childList:!0,subtree:!0}),m.debug("Setting up mutation observer",r))},attachEvents:function(t,n){var i=e(t);n=e.isFunction(m[n])?m[n]:m.toggle,i.size()>0?(m.debug("Attaching checkbox events to element",t,n),i.on("click"+h,n)):m.error(v.notFound)},event:{keydown:function(t){var n=t.which,i={enter:13,escape:27};n==i.escape&&(m.verbose("Escape key pressed blurring field"),x.blur()),t.ctrlKey||n!=i.enter||(m.verbose("Enter key pressed, toggling checkbox"),e.proxy(m.toggle,this)(),t.preventDefault())}},is:{radio:function(){return x.hasClass(p.radio)},checked:function(){return C.prop("checked")!==i&&C.prop("checked")},unchecked:function(){return!m.is.checked()}},can:{change:function(){return!(x.hasClass(p.disabled)||x.hasClass(p.readOnly)||C.prop("disabled"))},uncheck:function(){return"boolean"==typeof f.uncheckable?f.uncheckable:!m.is.radio()}},set:{checked:function(){x.addClass(p.checked)},tab:function(){C.attr("tabindex")===i&&C.attr("tabindex",0)}},create:{label:function(){C.prevAll(b.label).size()>0?(C.prev(b.label).detach().insertAfter(C),m.debug("Moving existing label",w)):m.has.label()||(w=e("<label>").insertAfter(C),m.debug("Creating label",w))}},has:{label:function(){return w.size()>0}},add:{events:function(){m.verbose("Attaching checkbox events"),x.on("click"+h,m.toggle).on("keydown"+h,b.input,m.event.keydown)}},remove:{checked:function(){x.removeClass(p.checked)},events:function(){m.debug("Removing events"),x.off(h).removeData(y),C.off(h,m.event.keydown),w.off(h)}},enable:function(){m.debug("Enabling checkbox functionality"),x.removeClass(p.disabled),C.prop("disabled",!1),e.proxy(f.onEnabled,C.get())()},disable:function(){m.debug("Disabling checkbox functionality"),x.addClass(p.disabled),C.prop("disabled","disabled"),e.proxy(f.onDisabled,C.get())()},check:function(){m.debug("Enabling checkbox",C),C.prop("checked",!0).trigger("change"),m.set.checked(),e.proxy(f.onChange,C.get())(),e.proxy(f.onChecked,C.get())()},uncheck:function(){m.debug("Disabling checkbox"),C.prop("checked",!1).trigger("change"),m.remove.checked(),e.proxy(f.onChange,C.get())(),e.proxy(f.onUnchecked,C.get())()},toggle:function(){return m.can.change()?(m.verbose("Determining new checkbox state"),void(m.is.unchecked()?m.check():m.is.checked()&&m.can.uncheck()&&m.uncheck())):(console.log(m.can.change()),void m.debug("Checkbox is read-only or disabled, ignoring toggle"))},setting:function(t,n){if(m.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,m,t);else{if(n===i)return m[t];m[t]=n}},debug:function(){f.debug&&(f.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,f.name+":"),m.debug.apply(console,arguments)))},verbose:function(){f.verbose&&f.debug&&(f.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,f.name+":"),m.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;f.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:k,"Execution Time":n})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,100)},display:function(){var t=f.name+":",n=0;s=!1,clearTimeout(m.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",a&&(t+=" '"+a+"'"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,r){var a,s,c,l=T;return n=n||d,r=k||r,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(r,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},u?(T===i&&m.initialize(),m.invoke(l)):(T!==i&&m.destroy(),m.initialize())}),o!==i?o:this},e.fn.checkbox.settings={name:"Checkbox",namespace:"checkbox",debug:!1,verbose:!0,performance:!0,uncheckable:"auto",fireOnInit:!0,onChange:function(){},onChecked:function(){},onUnchecked:function(){},onEnabled:function(){},onDisabled:function(){},className:{checked:"checked",disabled:"disabled",radio:"radio",readOnly:"read-only"},error:{method:"The method you called is not defined."},selector:{input:"input[type=checkbox], input[type=radio]",label:"label"}}}(jQuery,window,document),function(e,t,n,i){e.fn.dimmer=function(t){var o,r=e(this),a=(new Date).getTime(),s=[],c=arguments[0],l="string"==typeof c,u=[].slice.call(arguments,1);return r.each(function(){var d,m,f,p=e.isPlainObject(t)?e.extend(!0,{},e.fn.dimmer.settings,t):e.extend({},e.fn.dimmer.settings),g=p.selector,b=p.namespace,v=p.className,h=(p.error,"."+b),y="module-"+b,x=r.selector||"",w="ontouchstart"in n.documentElement?"touchstart":"click",C=e(this),T=this,k=C.data(y);f={preinitialize:function(){f.is.dimmer()?(m=C.parent(),d=C):(m=C,d=f.has.dimmer()?p.dimmerName?m.children(g.dimmer).filter("."+p.dimmerName):m.children(g.dimmer):f.create())},initialize:function(){f.debug("Initializing dimmer",p),"hover"==p.on?m.on("mouseenter"+h,f.show).on("mouseleave"+h,f.hide):"click"==p.on&&m.on(w+h,f.toggle),f.is.page()&&(f.debug("Setting as a page dimmer",m),f.set.pageDimmer()),f.is.closable()&&(f.verbose("Adding dimmer close event",d),d.on(w+h,f.event.click)),f.set.dimmable(),f.instantiate()},instantiate:function(){f.verbose("Storing instance of module",f),k=f,C.data(y,k)},destroy:function(){f.verbose("Destroying previous module",d),C.removeData(y),m.off(h),d.off(h)},event:{click:function(t){f.verbose("Determining if event occured on dimmer",t),(0===d.find(t.target).size()||e(t.target).is(g.content))&&(f.hide(),t.stopImmediatePropagation())}},addContent:function(t){var n=e(t);f.debug("Add content to dimmer",n),n.parent()[0]!==d[0]&&n.detach().appendTo(d)},create:function(){var t=e(p.template.dimmer());return p.variation&&(f.debug("Creating dimmer with variation",p.variation),t.addClass(v.variation)),p.dimmerName&&(f.debug("Creating named dimmer",p.dimmerName),t.addClass(p.dimmerName)),t.appendTo(m),t},show:function(t){t=e.isFunction(t)?t:function(){},f.debug("Showing dimmer",d,p),f.is.dimmed()&&!f.is.animating()||!f.is.enabled()?f.debug("Dimmer is already shown or disabled"):(f.animate.show(t),e.proxy(p.onShow,T)(),e.proxy(p.onChange,T)())},hide:function(t){t=e.isFunction(t)?t:function(){},f.is.dimmed()||f.is.animating()?(f.debug("Hiding dimmer",d),f.animate.hide(t),e.proxy(p.onHide,T)(),e.proxy(p.onChange,T)()):f.debug("Dimmer is not visible")},toggle:function(){f.verbose("Toggling dimmer visibility",d),f.is.dimmed()?f.hide():f.show()},animate:{show:function(t){t=e.isFunction(t)?t:function(){},p.useCSS&&e.fn.transition!==i&&d.transition("is supported")?d.transition({animation:p.transition+" in",queue:!1,duration:f.get.duration(),onStart:function(){f.set.dimmed()},onComplete:function(){f.set.active(),t()}}):(f.verbose("Showing dimmer animation with javascript"),f.set.dimmed(),d.stop().css({opacity:0,width:"100%",height:"100%"}).fadeTo(f.get.duration(),1,function(){d.removeAttr("style"),f.set.active(),t()}))},hide:function(t){t=e.isFunction(t)?t:function(){},p.useCSS&&e.fn.transition!==i&&d.transition("is supported")?(f.verbose("Hiding dimmer with css"),d.transition({animation:p.transition+" out",queue:!1,duration:f.get.duration(),onStart:function(){f.remove.dimmed()},onComplete:function(){f.remove.active(),t()}})):(f.verbose("Hiding dimmer with javascript"),f.remove.dimmed(),d.stop().fadeOut(f.get.duration(),function(){f.remove.active(),d.removeAttr("style"),t()}))}},get:{dimmer:function(){return d},duration:function(){return"object"==typeof p.duration?f.is.active()?p.duration.hide:p.duration.show:p.duration}},has:{dimmer:function(){return p.dimmerName?C.children(g.dimmer).filter("."+p.dimmerName).size()>0:C.children(g.dimmer).size()>0}},is:{active:function(){return d.hasClass(v.active)},animating:function(){return d.is(":animated")||d.hasClass(v.animating)},closable:function(){return"auto"==p.closable?"hover"==p.on?!1:!0:p.closable},dimmer:function(){return C.is(g.dimmer)},dimmable:function(){return C.is(g.dimmable)},dimmed:function(){return m.hasClass(v.dimmed)},disabled:function(){return m.hasClass(v.disabled)},enabled:function(){return!f.is.disabled()},page:function(){return m.is("body")},pageDimmer:function(){return d.hasClass(v.pageDimmer)}},can:{show:function(){return!d.hasClass(v.disabled)}},set:{active:function(){d.addClass(v.active)},dimmable:function(){m.addClass(v.dimmable)},dimmed:function(){m.addClass(v.dimmed)},pageDimmer:function(){d.addClass(v.pageDimmer)},disabled:function(){d.addClass(v.disabled)}},remove:{active:function(){d.removeClass(v.active)},dimmed:function(){m.removeClass(v.dimmed)},disabled:function(){d.removeClass(v.disabled)}},setting:function(t,n){if(f.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,p,t);else{if(n===i)return p[t];p[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},debug:function(){p.debug&&(p.performance?f.performance.log(arguments):(f.debug=Function.prototype.bind.call(console.info,console,p.name+":"),f.debug.apply(console,arguments)))},verbose:function(){p.verbose&&p.debug&&(p.performance?f.performance.log(arguments):(f.verbose=Function.prototype.bind.call(console.info,console,p.name+":"),f.verbose.apply(console,arguments)))
-},error:function(){f.error=Function.prototype.bind.call(console.error,console,p.name+":"),f.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;p.performance&&(t=(new Date).getTime(),i=a||t,n=t-i,a=t,s.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:T,"Execution Time":n})),clearTimeout(f.performance.timer),f.performance.timer=setTimeout(f.performance.display,100)},display:function(){var t=p.name+":",n=0;a=!1,clearTimeout(f.performance.timer),e.each(s,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",x&&(t+=" '"+x+"'"),r.size()>1&&(t+=" ("+r.size()+")"),(console.group!==i||console.table!==i)&&s.length>0&&(console.groupCollapsed(t),console.table?console.table(s):e.each(s,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),s=[]}},invoke:function(t,n,r){var a,s,c,l=k;return n=n||u,r=T||r,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(r,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},f.preinitialize(),l?(k===i&&f.initialize(),f.invoke(c)):(k!==i&&f.destroy(),f.initialize())}),o!==i?o:this},e.fn.dimmer.settings={name:"Dimmer",namespace:"dimmer",debug:!1,verbose:!0,performance:!0,dimmerName:!1,variation:!1,closable:"auto",transition:"fade",useCSS:!0,on:!1,duration:{show:500,hide:500},onChange:function(){},onShow:function(){},onHide:function(){},error:{method:"The method you called is not defined."},selector:{dimmable:".dimmable",dimmer:".ui.dimmer",content:".ui.dimmer > .content, .ui.dimmer > .content > .center"},template:{dimmer:function(){return e("<div />").attr("class","ui dimmer")}},className:{active:"active",animating:"animating",dimmable:"dimmable",dimmed:"dimmed",disabled:"disabled",hide:"hide",pageDimmer:"page",show:"show"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.dropdown=function(o){var r,a=e(this),s=e(n),c=a.selector||"",l="ontouchstart"in n.documentElement,u=(new Date).getTime(),d=[],m=arguments[0],f="string"==typeof m,p=[].slice.call(arguments,1);return a.each(function(){var n,g,b=e.isPlainObject(o)?e.extend(!0,{},e.fn.dropdown.settings,o):e.extend({},e.fn.dropdown.settings),v=b.className,h=b.metadata,y=b.namespace,x=b.selector,w=b.error,C="."+y,T="module-"+y,k=e(this),S=k.find(x.text),z=k.find(x.search),A=k.find(x.input),E=k.prev().find(x.text).size()>0?k.prev().find(x.text):k.prev(),F=k.children(x.menu),D=F.find(x.item),O=!1,P=!1,R=this,j=k.data(T);g={initialize:function(){g.debug("Initializing dropdown",b),g.setup.layout(),g.save.defaults(),g.set.selected(),l&&g.bind.touchEvents(),g.bind.mouseEvents(),g.bind.keyboardEvents(),g.observeChanges(),g.instantiate()},instantiate:function(){g.verbose("Storing instance of dropdown",g),j=g,k.data(T,g)},destroy:function(){g.verbose("Destroying previous dropdown for",k),g.remove.tabbable(),k.off(C).removeData(T)},observeChanges:function(){"MutationObserver"in t&&(n=new MutationObserver(function(){g.debug("DOM tree modified, updating selector cache"),g.refresh()}),n.observe(R,{childList:!0,subtree:!0}),g.debug("Setting up mutation observer",n))},setup:{layout:function(){k.is("select")&&g.setup.select(),g.is.search()&&!g.is.searchable()&&(z=e("<input />").addClass(v.search).insertBefore(S)),b.allowTab&&g.set.tabbable()},select:function(){var t=g.get.selectValues();g.debug("Dropdown initialized on a select",t),A=k,A.parents(x.dropdown).size()>0?(g.debug("Creating dropdown menu only from template"),k=A.closest(x.dropdown),0===k.find("."+v.dropdown).size()&&e("<div />").addClass(v.menu).html(b.templates.menu(t)).appendTo(k)):(g.debug("Creating entire dropdown from template"),k=e("<div />").attr("class",A.attr("class")).addClass(v.selection).addClass(v.dropdown).html(b.templates.dropdown(t)).insertBefore(A),A.removeAttr("class").prependTo(k)),g.refresh()}},refresh:function(){S=k.find(x.text),z=k.find(x.search),A=k.find(x.input),F=k.children(x.menu),D=F.find(x.item)},toggle:function(){g.verbose("Toggling menu visibility"),g.is.active()?g.hide():g.show()},show:function(){g.debug("Checking if dropdown can show"),g.is.active()||(g.animate.show(function(){g.can.click()&&g.bind.intent(),g.set.visible()}),e.proxy(b.onShow,R)())},hide:function(){g.is.active()&&(g.debug("Hiding dropdown"),g.animate.hide(function(){g.remove.visible()}),e.proxy(b.onHide,R)())},hideOthers:function(){g.verbose("Finding other dropdowns to hide"),a.not(k).has(x.menu+":visible:not(."+v.animating+")").dropdown("hide")},hideSubMenus:function(){var e=F.find(x.menu);e.transition("hide")},bind:{keyboardEvents:function(){g.debug("Binding keyboard events"),k.on("keydown"+C,g.event.keydown),g.is.searchable()&&k.on(g.get.inputEvent(),x.search,g.event.input)},touchEvents:function(){g.debug("Touch device detected binding additional touch events"),g.is.searchSelection()||k.on("touchstart"+C,g.event.test.toggle),F.on("touchstart"+C,x.item,g.event.item.mouseenter)},mouseEvents:function(){g.verbose("Mouse detected binding mouse events"),g.is.searchSelection()?k.on("mousedown"+C,x.menu,g.event.menu.activate).on("mouseup"+C,x.menu,g.event.menu.deactivate).on("focus"+C,x.search,g.event.searchFocus).on("click"+C,x.search,g.show).on("blur"+C,x.search,g.event.searchBlur):("click"==b.on?k.on("click"+C,g.event.test.toggle):"hover"==b.on?k.on("mouseenter"+C,g.delay.show).on("mouseleave"+C,g.delay.hide):k.on(b.on+C,g.toggle),k.on("mousedown"+C,g.event.mousedown).on("mouseup"+C,g.event.mouseup).on("focus"+C,g.event.focus).on("blur"+C,g.event.blur)),F.on("mouseenter"+C,x.item,g.event.item.mouseenter).on("mouseleave"+C,x.item,g.event.item.mouseleave).on("click"+C,x.item,g.event.item.click)},intent:function(){g.verbose("Binding hide intent event to document"),l&&s.on("touchstart"+C,g.event.test.touch).on("touchmove"+C,g.event.test.touch),s.on("click"+C,g.event.test.hide)}},unbind:{intent:function(){g.verbose("Removing hide intent event from document"),l&&s.off("touchstart"+C).off("touchmove"+C),s.off("click"+C)}},filter:function(t){var n,o,r=e(),a=new RegExp("(?:s|^)"+t,"i"),s=new RegExp(t,"i");D.each(function(){var t=e(this),n=t.data(h.text)!==i?t.data(h.text):b.preserveHTML?t.html():t.text(),o=t.data(h.value)!==i?t.data(h.value):"string"==typeof n?n.toLowerCase():n;a.test(n)||a.test(o)?r=r.add(t):b.fullTextSearch&&(s.test(n)||s.test(o))&&(r=r.add(t))}),o=D.not(r),n=o.size()==D.size(),g.remove.filteredItem(),g.remove.selectedItem(),o.addClass(v.filtered),D.not("."+v.filtered).eq(0).addClass(v.selected),n&&g.hide()},focusSearch:function(){g.is.search()&&z.focus()},event:{mousedown:function(){O=!0},mouseup:function(){O=!1},focus:function(){!O&&g.is.hidden()&&g.show()},blur:function(){O||g.hide()},searchFocus:function(){O=!0,g.show()},searchBlur:function(){P||g.hide()},input:function(){var e=z.val();g.is.searchSelection()&&(g.can.show()&&g.show(),g.set.filtered()),g.filter(e)},keydown:function(t){var n,i=D.not(v.filtered).filter("."+v.selected).eq(0),o=D.not("."+v.filtered),r=t.which,a={enter:13,escape:27,upArrow:38,downArrow:40},s=v.selected,c=o.index(i),l=i.size()>0;if(l||(i=D.filter("."+v.active).eq(0),l=i.size()>0),r==a.escape&&(g.verbose("Escape key pressed, closing dropdown"),g.hide()),g.is.visible()){if(r==a.enter&&l)return g.verbose("Enter key pressed, choosing selected item"),e.proxy(g.event.item.click,i)(t),t.preventDefault(),!1;r==a.upArrow?(n=l?i.prevAll(x.item+":not(."+v.filtered+")").eq(0):o.eq(0),0!==c&&(g.verbose("Up key pressed, changing active item"),D.removeClass(s),n.addClass(s),g.set.scrollPosition(n)),t.preventDefault()):r==a.downArrow&&(n=l?i.nextAll(x.item+":not(."+v.filtered+")").eq(0):o.eq(0),c+1<o.size()&&(g.verbose("Down key pressed, changing active item"),D.removeClass(s),n.addClass(s),g.set.scrollPosition(n)),t.preventDefault())}else r==a.enter&&g.show()},test:{toggle:function(e){g.determine.eventInMenu(e,g.toggle)&&e.preventDefault()},touch:function(e){g.determine.eventInMenu(e,function(){"touchstart"==e.type?g.timer=setTimeout(g.hide,b.delay.touch):"touchmove"==e.type&&clearTimeout(g.timer)}),e.stopPropagation()},hide:function(e){g.determine.eventInModule(e,g.hide)}},menu:{activate:function(){P=!0},deactivate:function(){P=!1}},item:{mouseenter:function(t){var n=e(this).children(x.menu),i=e(this).siblings(x.item).children(x.menu);n.size()>0&&(clearTimeout(g.itemTimer),g.itemTimer=setTimeout(function(){e.each(i,function(){g.animate.hide(!1,e(this))}),g.verbose("Showing sub-menu",n),g.animate.show(!1,n)},b.delay.show),t.preventDefault())},mouseleave:function(){var t=e(this).children(x.menu);t.size()>0&&(clearTimeout(g.itemTimer),g.itemTimer=setTimeout(function(){g.verbose("Hiding sub-menu",t),g.animate.hide(!1,t)},b.delay.hide))},click:function(){var t=e(this),n=t.data(h.text)!==i?t.data(h.text):b.preserveHTML?t.html():t.text(),o=t.data(h.value)!==i?t.data(h.value):"string"==typeof n?n.toLowerCase():n,r=function(){g.remove.searchTerm(),g.remove.filteredItem(),g.determine.selectAction(n,o)},a=t.find(x.menu).size()>0;a||r()}},resetStyle:function(){e(this).removeAttr("style")}},determine:{selectAction:function(t,n){g.verbose("Determining action",b.action),e.isFunction(g.action[b.action])?(g.verbose("Triggering preset action",b.action,t,n),g.action[b.action](t,n)):e.isFunction(b.action)?(g.verbose("Triggering user action",b.action,t,n),b.action(t,n)):g.error(w.action,b.action)},eventInModule:function(t,n){return n=n||function(){},0===e(t.target).closest(k).size()?(g.verbose("Triggering event",n),n(),!0):(g.verbose("Event occurred in dropdown, canceling callback"),!1)},eventInMenu:function(t,n){return n=n||function(){},0===e(t.target).closest(F).size()?(g.verbose("Triggering event",n),n(),!0):(g.verbose("Event occurred in dropdown menu, canceling callback"),!1)}},action:{nothing:function(){},hide:function(){g.hide()},select:function(e,t){t=t!==i?t:e,g.set.selected(t),g.set.value(t),g.hide()},activate:function(e,t){t=t!==i?t:e,g.set.selected(t),g.set.value(t),g.hide()},combo:function(e,t){t=t!==i?t:e,g.set.selected(t),g.set.value(t),g.hide()}},get:{text:function(){return S.text()},value:function(){return A.size()>0?A.val():k.data(h.value)},inputEvent:function(){var e=z[0];return e?e.oninput!==i?"input":e.onpropertychange!==i?"propertychange":"keyup":!1},selectValues:function(){var t={values:{}};return k.find("option").each(function(){var n=e(this).html(),o=e(this).attr("value")!==i?e(this).attr("value"):n;""===o?t.placeholder=n:t.values[o]=n}),g.debug("Retrieved values from select",t),t},item:function(t,n){var o=!1;return t=t!==i?t:g.get.value()!==i?g.get.value():g.get.text(),n=""===t||0===t?!0:n||!1,t!==i?D.each(function(){var r=e(this),a=r.data(h.text)!==i?r.data(h.text):b.preserveHTML?r.html():r.text(),s=r.data(h.value)!==i?r.data(h.value):"string"==typeof a?a.toLowerCase():a;n?(g.verbose("Ambiguous dropdown value using strict type check",r,t),s===t?o=e(this):o||a!==t||(o=e(this))):s==t?(g.verbose("Found select item by value",s,t),o=e(this)):o||a!=t||(g.verbose("Found select item by text",a,t),o=e(this))}):t=g.get.text(),o||!1}},restore:{defaults:function(){g.restore.defaultText(),g.restore.defaultValue()},defaultText:function(){var e=k.data(h.defaultText);g.debug("Restoring default text",e),g.set.text(e)},defaultValue:function(){var e=k.data(h.defaultValue);e!==i&&(g.debug("Restoring default value",e),g.set.selected(e),g.set.value(e))}},save:{defaults:function(){g.save.defaultText(),g.save.defaultValue()},defaultValue:function(){k.data(h.defaultValue,g.get.value())},defaultText:function(){k.data(h.defaultText,S.text())}},set:{filtered:function(){S.addClass(v.filtered)},tabbable:function(){g.is.searchable()?(g.debug("Searchable dropdown initialized"),z.val("").attr("tabindex",0),F.attr("tabindex","-1")):(g.debug("Simple selection dropdown initialized"),k.attr("tabindex")||(k.attr("tabindex",0),F.attr("tabindex","-1")))},scrollPosition:function(e){var t,n,i,o,r,a,s,c,e=e||g.get.item(),l=e&&e.size()>0,u=5;e&&l&&(a=F.height(),n=e.height(),r=F.scrollTop(),o=F.offset().top,i=e.offset().top,t=r-o+i,c=t+u>r+a,s=r>t-u,(s||c)&&(g.debug("Scrolling to active item"),F.scrollTop(t)))},text:function(e){"combo"==b.action?(g.debug("Changing combo button text",e,E),b.preserveHTML?E.html(e):E.text(e)):"select"!==b.action&&(g.debug("Changing text",e,S),S.removeClass(v.filtered).removeClass(v.placeholder),b.preserveHTML?S.html(e):S.text(e))},value:function(e){g.debug("Adding selected value to hidden input",e,A),A.size()>0?A.val(e).trigger("change"):k.data(h.value,e)},active:function(){k.addClass(v.active)},visible:function(){k.addClass(v.visible)},selected:function(t){var n,o=g.get.item(t);o&&(g.debug("Setting selected menu item to",o),n=o.data(h.text)!==i?o.data(h.text):b.preserveHTML?o.html():o.text(),g.remove.activeItem(),g.remove.selectedItem(),o.addClass(v.active).addClass(v.selected),g.set.text(n),e.proxy(b.onChange,R)(t,n,o))}},remove:{active:function(){k.removeClass(v.active)},visible:function(){k.removeClass(v.visible)},activeItem:function(){D.removeClass(v.active)},filteredItem:function(){D.removeClass(v.filtered)},searchTerm:function(){z.val("")},selectedItem:function(){D.removeClass(v.selected)},tabbable:function(){g.is.searchable()?(g.debug("Searchable dropdown initialized"),z.attr("tabindex","-1"),F.attr("tabindex","-1")):(g.debug("Simple selection dropdown initialized"),k.attr("tabindex","-1"),F.attr("tabindex","-1"))}},is:{search:function(){return k.hasClass(v.search)},searchable:function(){return z.size()>0},searchSelection:function(){return g.is.searchable()&&z.parent().is(k)},selection:function(){return k.hasClass(v.selection)},animating:function(e){return e?e.is(":animated")||e.transition&&e.transition("is animating"):F.is(":animated")||F.transition&&F.transition("is animating")},active:function(){return k.hasClass(v.active)},visible:function(e){return e?e.is(":visible"):F.is(":visible")},hidden:function(e){return e?e.is(":hidden"):F.is(":hidden")}},can:{click:function(){return l||"click"==b.on},show:function(){return!k.hasClass(v.disabled)}},animate:{show:function(t,n){var o=n||F,r=n?function(){}:function(){g.hideSubMenus(),g.hideOthers(),g.set.active(),g.set.scrollPosition()};t=t||function(){},g.verbose("Doing menu show animation",o),(g.is.hidden(o)||g.is.animating(o))&&("none"==b.transition?e.proxy(t,R)():e.fn.transition!==i&&k.transition("is supported")?o.transition({animation:b.transition+" in",debug:b.debug,verbose:b.verbose,duration:b.duration,queue:!0,onStart:r,onComplete:function(){e.proxy(t,R)()}}):"slide down"==b.transition?(r(),o.hide().clearQueue().children().clearQueue().css("opacity",0).delay(50).animate({opacity:1},b.duration,"easeOutQuad",g.event.resetStyle).end().slideDown(100,"easeOutQuad",function(){e.proxy(g.event.resetStyle,this)(),e.proxy(t,R)()})):"fade"==b.transition?(r(),o.hide().clearQueue().fadeIn(b.duration,function(){e.proxy(g.event.resetStyle,this)(),e.proxy(t,R)()})):g.error(w.transition,b.transition))},hide:function(t,n){var o=n||F,r=(n?.9*b.duration:b.duration,n?function(){}:function(){g.can.click()&&g.unbind.intent(),g.focusSearch(),g.remove.active()});t=t||function(){},(g.is.visible(o)||g.is.animating(o))&&(g.verbose("Doing menu hide animation",o),"none"==b.transition?e.proxy(t,R)():e.fn.transition!==i&&k.transition("is supported")?o.transition({animation:b.transition+" out",duration:b.duration,debug:b.debug,verbose:b.verbose,queue:!0,onStart:r,onComplete:function(){e.proxy(t,R)()}}):"slide down"==b.transition?(r(),o.show().clearQueue().children().clearQueue().css("opacity",1).animate({opacity:0},100,"easeOutQuad",g.event.resetStyle).end().delay(50).slideUp(100,"easeOutQuad",function(){e.proxy(g.event.resetStyle,this)(),e.proxy(t,R)()})):"fade"==b.transition?(r(),o.show().clearQueue().fadeOut(150,function(){e.proxy(g.event.resetStyle,this)(),e.proxy(t,R)()})):g.error(w.transition))}},delay:{show:function(){g.verbose("Delaying show event to ensure user intent"),clearTimeout(g.timer),g.timer=setTimeout(g.show,b.delay.show)},hide:function(){g.verbose("Delaying hide event to ensure user intent"),clearTimeout(g.timer),g.timer=setTimeout(g.hide,b.delay.hide)}},setting:function(t,n){if(g.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,b,t);else{if(n===i)return b[t];b[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,g,t);else{if(n===i)return g[t];g[t]=n}},debug:function(){b.debug&&(b.performance?g.performance.log(arguments):(g.debug=Function.prototype.bind.call(console.info,console,b.name+":"),g.debug.apply(console,arguments)))},verbose:function(){b.verbose&&b.debug&&(b.performance?g.performance.log(arguments):(g.verbose=Function.prototype.bind.call(console.info,console,b.name+":"),g.verbose.apply(console,arguments)))},error:function(){g.error=Function.prototype.bind.call(console.error,console,b.name+":"),g.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;b.performance&&(t=(new Date).getTime(),i=u||t,n=t-i,u=t,d.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:R,"Execution Time":n})),clearTimeout(g.performance.timer),g.performance.timer=setTimeout(g.performance.display,100)},display:function(){var t=b.name+":",n=0;u=!1,clearTimeout(g.performance.timer),e.each(d,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",c&&(t+=" '"+c+"'"),(console.group!==i||console.table!==i)&&d.length>0&&(console.groupCollapsed(t),console.table?console.table(d):e.each(d,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),d=[]}},invoke:function(t,n,o){var a,s,c,l=j;return n=n||p,o=R||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):(g.error(w.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(r)?r.push(c):r!==i?r=[r,c]:c!==i&&(r=c),s}},f?(j===i&&g.initialize(),g.invoke(m)):(j!==i&&g.destroy(),g.initialize())}),r!==i?r:this},e.fn.dropdown.settings={debug:!1,verbose:!0,performance:!0,on:"click",action:"activate",allowTab:!0,fullTextSearch:!0,preserveHTML:!0,delay:{show:200,hide:300,touch:50},transition:"slide down",duration:250,onChange:function(){},onShow:function(){},onHide:function(){},name:"Dropdown",namespace:"dropdown",error:{action:"You called a dropdown action that was not defined",method:"The method you called is not defined.",transition:"The requested transition was not found"},metadata:{defaultText:"defaultText",defaultValue:"defaultValue",text:"text",value:"value"},selector:{dropdown:".ui.dropdown",text:"> .text:not(.icon)",input:'> input[type="hidden"], > select',search:"> input.search, .menu > .search > input, .menu > input.search",menu:".menu",item:".item"},className:{active:"active",animating:"animating",disabled:"disabled",dropdown:"ui dropdown",filtered:"filtered",menu:"menu",placeholder:"default",search:"search",selected:"selected",selection:"selection",visible:"visible"}},e.fn.dropdown.settings.templates={menu:function(t){var n=(t.placeholder||!1,t.values||{},"");return e.each(t.values,function(e,t){n+='<div class="item" data-value="'+e+'">'+t+"</div>"}),n},dropdown:function(t){var n=t.placeholder||!1,i=(t.values||{},"");return i+='<i class="dropdown icon"></i>',i+=t.placeholder?'<div class="default text">'+n+"</div>":'<div class="text"></div>',i+='<div class="menu">',e.each(t.values,function(e,t){i+='<div class="item" data-value="'+e+'">'+t+"</div>"}),i+="</div>"}},e.extend(e.easing,{easeOutQuad:function(e,t,n,i,o){return-i*(t/=o)*(t-2)+n}})}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.modal=function(o){var r,a=e(this),s=e(t),c=e(n),l=e("body"),u=a.selector||"",d=(new Date).getTime(),m=[],f=arguments[0],p="string"==typeof f,g=[].slice.call(arguments,1),b=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)};return a.each(function(){var a,v,h,y,x,w,C,T,k,S=e.isPlainObject(o)?e.extend(!0,{},e.fn.modal.settings,o):e.extend({},e.fn.modal.settings),z=S.selector,A=S.className,E=S.namespace,F=S.error,D="."+E,O="module-"+E,P=e(this),R=e(S.context),j=P.find(z.close),q=this,N=P.data(O);k={initialize:function(){return k.verbose("Initializing dimmer",R),e.fn.dimmer===i?void k.error(F.dimmer):(C=k.get.uniqueID(),w="."+C,y=R.dimmer({debug:S.debug,dimmerName:"modals",closable:!1,useCSS:!0,duration:{show:.9*S.duration,hide:1.1*S.duration}}),S.detachable&&y.dimmer("add content",P),x=y.dimmer("get dimmer"),k.refreshModals(),k.verbose("Attaching close events",j),k.bind.events(),k.observeChanges(),void k.instantiate())},instantiate:function(){k.verbose("Storing instance of modal"),N=k,P.data(O,N)},destroy:function(){k.verbose("Destroying previous modal"),P.removeData(O).off(D),s.off(w),j.off(D),R.dimmer("destroy")},observeChanges:function(){"MutationObserver"in t&&(T=new MutationObserver(function(){k.debug("DOM tree modified, refreshing"),k.refresh()}),T.observe(q,{childList:!0,subtree:!0}),k.debug("Setting up mutation observer",T))},refresh:function(){k.remove.scrolling(),k.cacheSizes(),k.set.screenHeight(),k.set.type(),k.set.position()},refreshModals:function(){v=P.siblings(z.modal),a=v.add(P)},attachEvents:function(t,n){var i=e(t);n=e.isFunction(k[n])?k[n]:k.toggle,i.size()>0?(k.debug("Attaching modal events to element",t,n),i.off(D).on("click"+D,n)):k.error(F.notFound,t)},bind:{events:function(){j.on("click"+D,k.event.close),s.on("resize"+w,k.event.resize)}},get:{uniqueID:function(){return(Math.random().toString(16)+"000000000").substr(2,8)}},event:{close:function(){k.verbose("Closing element pressed"),e(this).is(z.approve)?e.proxy(S.onApprove,q)()!==!1?k.hide():k.verbose("Approve callback returned false cancelling hide"):e(this).is(z.deny)?e.proxy(S.onDeny,q)()!==!1?k.hide():k.verbose("Deny callback returned false cancelling hide"):k.hide()},click:function(t){0===e(t.target).closest(P).size()&&(k.debug("Dimmer clicked, hiding all modals"),k.is.active()&&(k.remove.clickaway(),S.allowMultiple?k.hide():k.hideAll()))},debounce:function(e,t){clearTimeout(k.timer),k.timer=setTimeout(e,t)},keyboard:function(e){var t=e.which,n=27;t==n&&(S.closable?(k.debug("Escape key pressed hiding modal"),k.hide()):k.debug("Escape key pressed, but closable is set to false"),e.preventDefault())},resize:function(){y.dimmer("is active")&&b(k.refresh)}},toggle:function(){k.is.active()||k.is.animating()?k.hide():k.show()},show:function(t){t=e.isFunction(t)?t:function(){},k.refreshModals(),k.showDimmer(),k.showModal(t)},hide:function(t){t=e.isFunction(t)?t:function(){},k.refreshModals(),k.othersActive()||k.hideDimmer(),k.hideModal(t)},showModal:function(t){t=e.isFunction(t)?t:function(){},k.is.active()?k.debug("Modal is already visible"):!S.allowMultiple&&v.filter(":visible").size()>0?(k.debug("Other modals visible, queueing show animation"),k.hideOthers(k.showModal)):(e.proxy(S.onShow,q)(),S.transition&&e.fn.transition!==i&&P.transition("is supported")?(k.debug("Showing modal with css animations"),k.cacheSizes(),k.set.position(),k.set.screenHeight(),k.set.type(),k.set.clickaway(),P.transition({debug:S.debug,animation:S.transition+" in",queue:!1,duration:S.duration,onComplete:function(){e.proxy(S.onVisible,q)(),k.add.keyboardShortcuts(),k.save.focus(),k.set.active(),k.set.autofocus(),t()}})):(k.debug("Showing modal with javascript"),P.fadeIn(S.duration,S.easing,function(){e.proxy(S.onVisible,q)(),k.add.keyboardShortcuts(),k.save.focus(),k.set.active(),t()})))},showDimmer:function(){y.dimmer("is active")?k.debug("Dimmer already visible"):(k.debug("Showing dimmer"),y.dimmer("show"))},hideDimmer:function(){return y.dimmer("is active")||y.dimmer("is animating")?(k.debug("Hiding dimmer"),void y.dimmer("hide",function(){S.transition&&e.fn.transition!==i&&P.transition("is supported")&&(k.remove.clickaway(),k.remove.screenHeight())})):void k.debug("Dimmer is not visible cannot hide")},hideModal:function(t){t=e.isFunction(t)?t:function(){},k.debug("Hiding modal"),e.proxy(S.onHide,q)(),S.transition&&e.fn.transition!==i&&P.transition("is supported")?(k.remove.active(),P.transition({debug:S.debug,animation:S.transition+" out",queue:!1,duration:S.duration,onStart:function(){k.remove.keyboardShortcuts()},onComplete:function(){e.proxy(S.onHidden,q)(),k.restore.focus(),t()}})):(k.remove.active(),k.remove.keyboardShortcuts(),P.fadeOut(S.duration,S.easing,function(){e.proxy(S.onHidden,q)(),k.restore.focus(),t()}))},hideAll:function(t){t=e.isFunction(t)?t:function(){},a.is(":visible")&&(k.debug("Hiding all visible modals"),k.hideDimmer(),a.filter(":visible").modal("hide modal",t))},hideOthers:function(t){t=e.isFunction(t)?t:function(){},v.is(":visible")&&(k.debug("Hiding other modals",v),v.filter(":visible").modal("hide modal",t))},othersActive:function(){return v.filter("."+A.active).size()>0},add:{keyboardShortcuts:function(){k.verbose("Adding keyboard shortcuts"),c.on("keyup"+D,k.event.keyboard)}},save:{focus:function(){h=e(n.activeElement).blur()}},restore:{focus:function(){h&&h.size()>0&&h.focus()}},remove:{active:function(){P.removeClass(A.active)},clickaway:function(){S.closable&&x.off("click"+w)},screenHeight:function(){k.cache.height>k.cache.pageHeight&&(k.debug("Removing page height"),l.css("height",""))},keyboardShortcuts:function(){k.verbose("Removing keyboard shortcuts"),c.off("keyup"+D)},scrolling:function(){y.removeClass(A.scrolling),P.removeClass(A.scrolling)}},cacheSizes:function(){var o=P.outerHeight();(k.cache===i||0!==o)&&(k.cache={pageHeight:e(n).outerHeight(),height:o+S.offset,contextHeight:"body"==S.context?e(t).height():y.height()}),k.debug("Caching modal and container sizes",k.cache)},can:{fit:function(){return k.cache.height<k.cache.contextHeight}},is:{active:function(){return P.hasClass(A.active)},animating:function(){return P.transition("is supported")?P.transition("is animating"):P.is(":visible")},scrolling:function(){return y.hasClass(A.scrolling)},modernBrowser:function(){return!(t.ActiveXObject||"ActiveXObject"in t)}},set:{autofocus:function(){if(S.autofocus){var e=P.find(":input:visible"),t=e.filter("[autofocus]"),n=t.size()>0?t:e;n.first().focus()}},clickaway:function(){S.closable&&x.on("click"+w,k.event.click)},screenHeight:function(){k.cache.height>k.cache.pageHeight?(k.debug("Modal is taller than page content, resizing page height"),l.css("height",k.cache.height+S.padding)):l.css("height","")},active:function(){P.addClass(A.active)},scrolling:function(){y.addClass(A.scrolling),P.addClass(A.scrolling)},type:function(){k.can.fit()?(k.verbose("Modal fits on screen"),k.othersActive||k.remove.scrolling()):(k.verbose("Modal cannot fit on screen setting to scrolling"),k.set.scrolling())},position:function(){k.verbose("Centering modal on page",k.cache),P.css(k.can.fit()?{top:"",marginTop:-(k.cache.height/2)}:{marginTop:"",top:c.scrollTop()})}},setting:function(t,n){if(k.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,S,t);else{if(n===i)return S[t];S[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,k,t);else{if(n===i)return k[t];k[t]=n}},debug:function(){S.debug&&(S.performance?k.performance.log(arguments):(k.debug=Function.prototype.bind.call(console.info,console,S.name+":"),k.debug.apply(console,arguments)))},verbose:function(){S.verbose&&S.debug&&(S.performance?k.performance.log(arguments):(k.verbose=Function.prototype.bind.call(console.info,console,S.name+":"),k.verbose.apply(console,arguments)))},error:function(){k.error=Function.prototype.bind.call(console.error,console,S.name+":"),k.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;S.performance&&(t=(new Date).getTime(),i=d||t,n=t-i,d=t,m.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:q,"Execution Time":n})),clearTimeout(k.performance.timer),k.performance.timer=setTimeout(k.performance.display,100)},display:function(){var t=S.name+":",n=0;d=!1,clearTimeout(k.performance.timer),e.each(m,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",u&&(t+=" '"+u+"'"),(console.group!==i||console.table!==i)&&m.length>0&&(console.groupCollapsed(t),console.table?console.table(m):e.each(m,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),m=[]}},invoke:function(t,n,o){var a,s,c,l=N;return n=n||g,o=q||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(r)?r.push(c):r!==i?r=[r,c]:c!==i&&(r=c),s}},p?(N===i&&k.initialize(),k.invoke(f)):(N!==i&&k.destroy(),k.initialize())}),r!==i?r:this},e.fn.modal.settings={name:"Modal",namespace:"modal",debug:!1,verbose:!0,performance:!0,allowMultiple:!1,detachable:!0,closable:!0,autofocus:!0,context:"body",duration:500,easing:"easeOutExpo",offset:0,transition:"scale",padding:30,onShow:function(){},onHide:function(){},onVisible:function(){},onHidden:function(){},onApprove:function(){return!0},onDeny:function(){return!0},selector:{close:".close, .actions .button",approve:".actions .positive, .actions .approve, .actions .ok",deny:".actions .negative, .actions .deny, .actions .cancel",modal:".ui.modal"},error:{dimmer:"UI Dimmer, a required component is not included in this page",method:"The method you called is not defined.",notFound:"The element you specified could not be found"},className:{active:"active",scrolling:"scrolling"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.nag=function(n){var o,r=e(this),a=r.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return r.each(function(){{var r,m=e.isPlainObject(n)?e.extend(!0,{},e.fn.nag.settings,n):e.extend({},e.fn.nag.settings),f=(m.className,m.selector),p=m.error,g=m.namespace,b="."+g,v=g+"-module",h=e(this),y=h.find(f.close),x=e(m.context?m.context:"body"),w=this,C=h.data(v);t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)}}r={initialize:function(){r.verbose("Initializing element"),h.data(v,r),y.on("click"+b,r.dismiss),m.detachable&&h.parent()[0]!==x[0]&&h.detach().prependTo(x),m.displayTime>0&&setTimeout(r.hide,m.displayTime),r.show()},destroy:function(){r.verbose("Destroying instance"),h.removeData(v).off(b)},show:function(){r.should.show()&&!h.is(":visible")&&(r.debug("Showing nag",m.animation.show),"fade"==m.animation.show?h.fadeIn(m.duration,m.easing):h.slideDown(m.duration,m.easing))},hide:function(){r.debug("Showing nag",m.animation.hide),"fade"==m.animation.show?h.fadeIn(m.duration,m.easing):h.slideUp(m.duration,m.easing)},onHide:function(){r.debug("Removing nag",m.animation.hide),h.remove(),m.onHide&&m.onHide()},dismiss:function(e){m.storageMethod&&r.storage.set(m.key,m.value),r.hide(),e.stopImmediatePropagation(),e.preventDefault()},should:{show:function(){return m.persist?(r.debug("Persistent nag is set, can show nag"),!0):r.storage.get(m.key)!=m.value.toString()?(r.debug("Stored value is not set, can show nag",r.storage.get(m.key)),!0):(r.debug("Stored value is set, cannot show nag",r.storage.get(m.key)),!1)}},get:{storageOptions:function(){var e={};return m.expires&&(e.expires=m.expires),m.domain&&(e.domain=m.domain),m.path&&(e.path=m.path),e}},clear:function(){r.storage.remove(m.key)},storage:{set:function(n,o){var a=r.get.storageOptions();if("localstorage"==m.storageMethod&&t.localStorage!==i)t.localStorage.setItem(n,o),r.debug("Value stored using local storage",n,o);else{if(e.cookie===i)return void r.error(p.noCookieStorage);e.cookie(n,o,a),r.debug("Value stored using cookie",n,o,a)}},get:function(n){var o;
-return"localstorage"==m.storageMethod&&t.localStorage!==i?o=t.localStorage.getItem(n):e.cookie!==i?o=e.cookie(n):r.error(p.noCookieStorage),("undefined"==o||"null"==o||o===i||null===o)&&(o=i),o},remove:function(n){var o=r.get.storageOptions();"local"==m.storageMethod&&t.store!==i?t.localStorage.removeItem(n):e.cookie!==i?e.removeCookie(n,o):r.error(p.noStorage)}},setting:function(t,n){if(r.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,m,t);else{if(n===i)return m[t];m[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,r,t);else{if(n===i)return r[t];r[t]=n}},debug:function(){m.debug&&(m.performance?r.performance.log(arguments):(r.debug=Function.prototype.bind.call(console.info,console,m.name+":"),r.debug.apply(console,arguments)))},verbose:function(){m.verbose&&m.debug&&(m.performance?r.performance.log(arguments):(r.verbose=Function.prototype.bind.call(console.info,console,m.name+":"),r.verbose.apply(console,arguments)))},error:function(){r.error=Function.prototype.bind.call(console.error,console,m.name+":"),r.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;m.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:w,"Execution Time":n})),clearTimeout(r.performance.timer),r.performance.timer=setTimeout(r.performance.display,100)},display:function(){var t=m.name+":",n=0;s=!1,clearTimeout(r.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",a&&(t+=" '"+a+"'"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,a){var s,c,l,u=C;return n=n||d,a=w||a,"string"==typeof t&&u!==i&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(n,o){var a=n!=s?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(u[a])&&n!=s)u=u[a];else{if(u[a]!==i)return c=u[a],!1;if(!e.isPlainObject(u[o])||n==s)return u[o]!==i?(c=u[o],!1):(r.error(p.method,t),!1);u=u[o]}})),e.isFunction(c)?l=c.apply(a,n):c!==i&&(l=c),e.isArray(o)?o.push(l):o!==i?o=[o,l]:l!==i&&(o=l),c}},u?(C===i&&r.initialize(),r.invoke(l)):(C!==i&&r.destroy(),r.initialize())}),o!==i?o:this},e.fn.nag.settings={name:"Nag",debug:!1,verbose:!0,performance:!0,namespace:"Nag",persist:!1,displayTime:0,animation:{show:"slide",hide:"slide"},context:!1,detachable:!1,expires:30,domain:!1,path:"/",storageMethod:"cookie",key:"nag",value:"dismiss",error:{noStorage:"Neither $.cookie or store is defined. A storage solution is required for storing state",method:"The method you called is not defined."},className:{bottom:"bottom",fixed:"fixed"},selector:{close:".close.icon"},speed:500,easing:"easeOutQuad",onHide:function(){}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.popup=function(o){var r,a=e(this),s=e(n),c=a.selector||"",l=("ontouchstart"in n.documentElement,(new Date).getTime()),u=[],d=arguments[0],m="string"==typeof d,f=[].slice.call(arguments,1);return a.each(function(){var n,a,p,g=e.isPlainObject(o)?e.extend(!0,{},e.fn.popup.settings,o):e.extend({},e.fn.popup.settings),b=g.selector,v=g.className,h=g.error,y=g.metadata,x=g.namespace,w="."+g.namespace,C="module-"+x,T=e(this),k=e(g.context),S=g.target?e(g.target):T,z=e(t),A=e("body"),E=0,F=!1,D=this,O=T.data(C);p={initialize:function(){p.debug("Initializing module",T),p.refresh(),"click"==g.on?T.on("click"+w,p.toggle):p.get.startEvent()&&T.on(p.get.startEvent()+w,p.event.start).on(p.get.endEvent()+w,p.event.end),g.target&&p.debug("Target set to element",S),z.on("resize"+w,p.event.resize),p.exists()?g.hoverable&&p.bind.popup():p.create(),p.instantiate()},instantiate:function(){p.verbose("Storing instance of module",p),O=p,T.data(C,O)},refresh:function(){g.popup?n=e(g.popup):g.inline&&(n=S.next(g.selector.popup)),g.popup?(n.addClass(v.loading),a=n.offsetParent(),n.removeClass(v.loading)):a=g.inline?S.offsetParent():A,a.is("html")&&(p.debug("Page is popups offset parent"),a=A)},reposition:function(){p.refresh(),p.set.position()},destroy:function(){p.debug("Destroying previous module"),n&&!g.preserve&&p.removePopup(),T.off(w).removeData(C)},event:{start:function(){var t=e.isPlainObject(g.delay)?g.delay.show:g.delay;clearTimeout(p.hideTimer),p.showTimer=setTimeout(function(){!p.is.hidden()||p.is.active()&&p.is.dropdown()||p.show()},t)},end:function(){var t=e.isPlainObject(g.delay)?g.delay.hide:g.delay;clearTimeout(p.showTimer),p.hideTimer=setTimeout(function(){p.is.visible()&&p.hide()},t)},resize:function(){p.is.visible()&&p.set.position()}},create:function(){var t=T.data(y.html)||g.html,i=T.data(y.variation)||g.variation,o=T.data(y.title)||g.title,r=T.data(y.content)||T.attr("title")||g.content;t||r||o?(p.debug("Creating pop-up html"),t||(t=g.templates.popup({title:o,content:r})),n=e("<div/>").addClass(v.popup).addClass(i).html(t),i&&n.addClass(i),g.inline?(p.verbose("Inserting popup element inline",n),n.insertAfter(T)):(p.verbose("Appending popup element to body",n),n.appendTo(k)),g.hoverable&&p.bind.popup(),e.proxy(g.onCreate,n)(D)):0!==S.next(g.selector.popup).size()?(p.verbose("Pre-existing popup found, reverting to inline"),g.inline=!0,p.refresh(),g.hoverable&&p.bind.popup()):p.debug("No content specified skipping display",D)},toggle:function(){p.debug("Toggling pop-up"),p.is.hidden()?(p.debug("Popup is hidden, showing pop-up"),p.unbind.close(),p.hideAll(),p.show()):(p.debug("Popup is visible, hiding pop-up"),p.hide())},show:function(t){t=e.isFunction(t)?t:function(){},p.debug("Showing pop-up",g.transition),g.preserve||g.popup||p.refresh(),p.exists()||p.create(),n&&p.set.position()&&(p.save.conditions(),p.animate.show(t))},hide:function(t){t=e.isFunction(t)?t:function(){},p.remove.visible(),p.unbind.close(),p.is.visible()&&(p.restore.conditions(),p.animate.hide(t))},hideAll:function(){e(b.popup).filter(":visible").popup("hide")},hideGracefully:function(t){t&&0===e(t.target).closest(b.popup).size()?(p.debug("Click occurred outside popup hiding popup"),p.hide()):p.debug("Click was inside popup, keeping popup open")},exists:function(){return n?g.inline||g.popup?0!==n.size():n.closest(k).size():!1},removePopup:function(){p.debug("Removing popup"),e.proxy(g.onRemove,n)(D),n.remove()},save:{conditions:function(){p.cache={title:T.attr("title")},p.cache.title&&T.removeAttr("title"),p.verbose("Saving original attributes",p.cache.title)}},restore:{conditions:function(){return D.blur(),p.cache&&p.cache.title&&(T.attr("title",p.cache.title),p.verbose("Restoring original attributes",p.cache.title)),!0}},animate:{show:function(t){t=e.isFunction(t)?t:function(){},g.transition&&e.fn.transition!==i&&T.transition("is supported")?(p.set.visible(),n.transition({animation:g.transition+" in",queue:!1,debug:g.debug,verbose:g.verbose,duration:g.duration,onComplete:function(){p.bind.close(),e.proxy(t,n)(D),e.proxy(g.onVisible,n)(D)}})):(p.set.visible(),n.stop().fadeIn(g.duration,g.easing,function(){p.bind.close(),e.proxy(t,D)()})),e.proxy(g.onShow,n)(D)},hide:function(t){t=e.isFunction(t)?t:function(){},p.debug("Hiding pop-up"),g.transition&&e.fn.transition!==i&&T.transition("is supported")?n.transition({animation:g.transition+" out",queue:!1,duration:g.duration,debug:g.debug,verbose:g.verbose,onComplete:function(){p.reset(),e.proxy(t,n)(D),e.proxy(g.onHidden,n)(D)}}):n.stop().fadeOut(g.duration,g.easing,function(){p.reset(),t()}),e.proxy(g.onHide,n)(D)}},get:{startEvent:function(){return"hover"==g.on?"mouseenter":"focus"==g.on?"focus":!1},endEvent:function(){return"hover"==g.on?"mouseleave":"focus"==g.on?"blur":!1},offstagePosition:function(i){var i=i||!1,o={top:e(t).scrollTop(),bottom:e(t).scrollTop()+e(t).height(),left:0,right:e(t).width()},r={width:n.width(),height:n.height(),offset:n.offset()},a={},s=[];return r.offset&&i&&(p.verbose("Checking if outside viewable area",r.offset),a={top:r.offset.top<o.top,bottom:r.offset.top+r.height>o.bottom,right:r.offset.left+r.width>o.right,left:r.offset.left<o.left}),e.each(a,function(e,t){t&&s.push(e)}),s.length>0?s.join(" "):!1},positions:function(){return{"top left":!1,"top center":!1,"top right":!1,"bottom left":!1,"bottom center":!1,"bottom right":!1,"left center":!1,"right center":!1}},nextPosition:function(e){var t=e.split(" "),n=t[0],i=t[1],o={top:"bottom",bottom:"top",left:"right",right:"left"},r={left:"center",center:"right",right:"left"},a={"top left":"top center","top center":"top right","top right":"right center","right center":"bottom right","bottom right":"bottom center","bottom center":"bottom left","bottom left":"left center","left center":"top left"},s="top"==n||"bottom"==n,c=!1,l=!1,u=!1;return F||(p.verbose("All available positions available"),F=p.get.positions()),p.debug("Recording last position tried",e),F[e]=!0,"opposite"===g.prefer&&(u=[o[n],i],u=u.join(" "),c=F[u]===!0,p.debug("Trying opposite strategy",u)),"adjacent"===g.prefer&&s&&(u=[n,r[i]],u=u.join(" "),l=F[u]===!0,p.debug("Trying adjacent strategy",u)),(l||c)&&(p.debug("Using backup position",u),u=a[e]),u}},set:{position:function(o,r){var s,c,l=(e(t).width(),e(t).height(),S.outerWidth()),u=S.outerHeight(),d=n.outerWidth(),m=n.outerHeight(),f=a.outerWidth(),b=a.outerHeight(),x=g.distanceAway,w=S[0],C=g.inline?parseInt(t.getComputedStyle(w).getPropertyValue("margin-top"),10):0,k=g.inline?parseInt(t.getComputedStyle(w).getPropertyValue("margin-left"),10):0,z=g.inline||g.popup?S.position():S.offset();switch(o=o||T.data(y.position)||g.position,r=r||T.data(y.offset)||g.offset,E==g.maxSearchDepth&&g.lastResort&&(p.debug("Using last resort position to display",g.lastResort),o=g.lastResort),g.inline&&(p.debug("Adding targets margin to calculation"),"left center"==o||"right center"==o?(r+=C,x+=-k):"top left"==o||"top center"==o||"top right"==o?(r+=k,x-=C):(r+=k,x+=C)),p.debug("Calculating popup positioning",o),o){case"top left":s={top:"auto",bottom:b-z.top+x,left:z.left+r,right:"auto"};break;case"top center":s={bottom:b-z.top+x,left:z.left+l/2-d/2+r,top:"auto",right:"auto"};break;case"top right":s={bottom:b-z.top+x,right:f-z.left-l-r,top:"auto",left:"auto"};break;case"left center":s={top:z.top+u/2-m/2+r,right:f-z.left+x,left:"auto",bottom:"auto"};break;case"right center":s={top:z.top+u/2-m/2+r,left:z.left+l+x,bottom:"auto",right:"auto"};break;case"bottom left":s={top:z.top+u+x,left:z.left+r,bottom:"auto",right:"auto"};break;case"bottom center":s={top:z.top+u+x,left:z.left+l/2-d/2+r,bottom:"auto",right:"auto"};break;case"bottom right":s={top:z.top+u+x,right:f-z.left-l-r,left:"auto",bottom:"auto"}}if(s===i&&p.error(h.invalidPosition,o),n.css(s).removeClass(v.position).addClass(o).addClass(v.loading),c=p.get.offstagePosition(o)){if(p.debug("Popup cant fit into viewport",c),E<g.maxSearchDepth)return E++,o=p.get.nextPosition(o),p.debug("Trying new position",o),n?p.set.position(o):!1;if(!g.lastResort)return p.debug("Popup could not find a position in view",n),p.error(h.cannotPlace),p.remove.attempts(),p.remove.loading(),p.reset(),!1}return p.debug("Position is on stage",o),p.remove.attempts(),p.set.fluidWidth(),p.remove.loading(),!0},fluidWidth:function(){g.setFluidWidth&&n.hasClass(v.fluid)&&n.css("width",a.width())},visible:function(){T.addClass(v.visible)}},remove:{loading:function(){n.removeClass(v.loading)},visible:function(){T.removeClass(v.visible)},attempts:function(){p.verbose("Resetting all searched positions"),E=0,F=!1}},bind:{popup:function(){p.verbose("Allowing hover events on popup to prevent closing"),n&&n.size()>0&&n.on("mouseenter"+w,p.event.start).on("mouseleave"+w,p.event.end)},close:function(){(g.hideOnScroll===!0||"auto"==g.hideOnScroll&&"click"!=g.on)&&(s.one("touchmove"+w,p.hideGracefully).one("scroll"+w,p.hideGracefully),k.one("touchmove"+w,p.hideGracefully).one("scroll"+w,p.hideGracefully)),"click"==g.on&&g.closable&&(p.verbose("Binding popup close event to document"),s.on("click"+w,function(t){p.verbose("Pop-up clickaway intent detected"),e.proxy(p.hideGracefully,D)(t)}))}},unbind:{close:function(){(g.hideOnScroll===!0||"auto"==g.hideOnScroll&&"click"!=g.on)&&(s.off("scroll"+w,p.hide),k.off("scroll"+w,p.hide)),"click"==g.on&&g.closable&&(p.verbose("Removing close event from document"),s.off("click"+w))}},is:{active:function(){return T.hasClass(v.active)},animating:function(){return n&&n.is(":animated")||n.hasClass(v.animating)},visible:function(){return n&&n.is(":visible")},dropdown:function(){return T.hasClass(v.dropdown)},hidden:function(){return!p.is.visible()}},reset:function(){p.remove.visible(),g.preserve||g.popup?e.fn.transition!==i&&n.transition("remove transition"):p.removePopup()},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,g,t);else{if(n===i)return g[t];g[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,p,t);else{if(n===i)return p[t];p[t]=n}},debug:function(){g.debug&&(g.performance?p.performance.log(arguments):(p.debug=Function.prototype.bind.call(console.info,console,g.name+":"),p.debug.apply(console,arguments)))},verbose:function(){g.verbose&&g.debug&&(g.performance?p.performance.log(arguments):(p.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),p.verbose.apply(console,arguments)))},error:function(){p.error=Function.prototype.bind.call(console.error,console,g.name+":"),p.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;g.performance&&(t=(new Date).getTime(),i=l||t,n=t-i,l=t,u.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:D,"Execution Time":n})),clearTimeout(p.performance.timer),p.performance.timer=setTimeout(p.performance.display,100)},display:function(){var t=g.name+":",n=0;l=!1,clearTimeout(p.performance.timer),e.each(u,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",c&&(t+=" '"+c+"'"),(console.group!==i||console.table!==i)&&u.length>0&&(console.groupCollapsed(t),console.table?console.table(u):e.each(u,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),u=[]}},invoke:function(t,n,o){var a,s,c,l=O;return n=n||f,o=D||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(r)?r.push(c):r!==i?r=[r,c]:c!==i&&(r=c),s}},m?(O===i&&p.initialize(),p.invoke(d)):(O!==i&&p.destroy(),p.initialize())}),r!==i?r:this},e.fn.popup.settings={name:"Popup",debug:!1,verbose:!0,performance:!0,namespace:"popup",onCreate:function(){},onRemove:function(){},onShow:function(){},onVisible:function(){},onHide:function(){},onHidden:function(){},variation:"",content:!1,html:!1,title:!1,on:"hover",closable:!0,hideOnScroll:"auto",context:"body",position:"top left",prefer:"opposite",lastResort:!1,delay:{show:30,hide:0},setFluidWidth:!0,target:!1,popup:!1,inline:!1,preserve:!0,hoverable:!1,duration:200,easing:"easeOutQuint",transition:"scale",distanceAway:0,offset:0,maxSearchDepth:20,error:{invalidPosition:"The position you specified is not a valid position",cannotPlace:"No visible position could be found for the popup",method:"The method you called is not defined."},metadata:{content:"content",html:"html",offset:"offset",position:"position",title:"title",variation:"variation"},className:{active:"active",animating:"animating",dropdown:"dropdown",fluid:"fluid",loading:"loading",popup:"ui popup",position:"top left center bottom right",visible:"visible"},selector:{popup:".ui.popup"},templates:{escape:function(e){var t=/[&<>"'`]/g,n=/[&<>"'`]/,i={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},o=function(e){return i[e]};return n.test(e)?e.replace(t,o):e},popup:function(t){var n="",o=e.fn.popup.settings.templates.escape;return typeof t!==i&&(typeof t.title!==i&&t.title&&(t.title=o(t.title),n+='<div class="header">'+t.title+"</div>"),typeof t.content!==i&&t.content&&(t.content=o(t.content),n+='<div class="content">'+t.content+"</div>")),n}}},e.extend(e.easing,{easeOutQuad:function(e,t,n,i,o){return-i*(t/=o)*(t-2)+n}})}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.progress=function(t){var n,o=e(this),r=o.selector||"",a=(new Date).getTime(),s=[],c=arguments[0],l="string"==typeof c,u=[].slice.call(arguments,1);return o.each(function(){var o,d=e.isPlainObject(t)?e.extend(!0,{},e.fn.progress.settings,t):e.extend({},e.fn.progress.settings),m=d.className,f=d.metadata,p=d.namespace,g=d.selector,b=d.error,v="module-"+p,h=e(this),y=e(this).find(g.bar),x=e(this).find(g.progress),w=e(this).find(g.label),C=this,T=h.data(v);o={initialize:function(){o.debug("Initializing progress",d),o.read.metadata(),o.set.initials(),o.instantiate()},instantiate:function(){o.verbose("Storing instance of progress",o),T=o,h.data(v,o)},destroy:function(){o.verbose("Destroying previous progress for",h),o.remove.state(),h.removeData(v),T=i},reset:function(){o.set.percent(0)},complete:function(){(o.percent===i||o.percent<100)&&o.set.percent(100)},read:{metadata:function(){h.data(f.percent)&&(o.verbose("Current percent value set from metadata"),o.percent=h.data(f.percent)),h.data(f.total)&&(o.verbose("Total value set from metadata"),o.total=h.data(f.total)),h.data(f.value)&&(o.verbose("Current value set from metadata"),o.value=h.data(f.value))},currentValue:function(){return o.value!==i?o.value:!1}},increment:function(e){var t,n,i,r=o.total||!1;r?(n=o.value||0,e=e||1,i=n+e,t=o.total,o.debug("Incrementing value by",e,n,t),i>t&&(o.debug("Value cannot increment above total",t),i=t),o.set.progress(i)):(n=o.percent||0,e=e||o.get.randomValue(),i=n+e,t=100,o.debug("Incrementing percentage by",e,n),i>t&&(o.debug("Value cannot increment above 100 percent"),i=t),o.set.progress(i))},decrement:function(e){var t,n,i=o.total||!1,r=0;i?(t=o.value||0,e=e||1,n=t-e,o.debug("Decrementing value by",e,t)):(t=o.percent||0,e=e||o.get.randomValue(),n=t-e,o.debug("Decrementing percentage by",e,t)),r>n&&(o.debug("Value cannot decrement below 0"),n=0),o.set.progress(n)},get:{text:function(e){var t=o.value||0,n=o.total||0,i=o.percent||0;return e=e||"",e=e.replace("{value}",t).replace("{total}",n).replace("{percent}",i),o.debug("Adding variables to progress bar text",e),e},randomValue:function(){return o.debug("Generating random increment percentage"),Math.floor(Math.random()*d.random.max+d.random.min)},percent:function(){return o.percent||0},value:function(){return o.value||!1},total:function(){return o.total||!1}},is:{success:function(){return h.hasClass(m.success)},warning:function(){return h.hasClass(m.warning)},error:function(){return h.hasClass(m.error)}},remove:{state:function(){o.verbose("Removing stored state"),delete o.total,delete o.percent,delete o.value},active:function(){o.verbose("Removing active state"),h.removeClass(m.active)},success:function(){o.verbose("Removing success state"),h.removeClass(m.success)},warning:function(){o.verbose("Removing warning state"),h.removeClass(m.warning)},error:function(){o.verbose("Removing error state"),h.removeClass(m.error)}},set:{barWidth:function(e){e>100?o.error(b.tooHigh,e):0>e?o.error(b.tooLow,e):y.css("width",e+"%")},initials:function(){d.total!==!1&&(o.verbose("Current total set in settings",d.total),o.total=d.total),d.value!==!1&&(o.verbose("Current value set in settings",d.value),o.value=d.value),d.percent!==!1&&(o.verbose("Current percent set in settings",d.percent),o.percent=d.percent),o.percent!==i?o.set.percent(o.percent):o.value!==i&&o.set.progress(o.value)},percent:function(t){t="string"==typeof t?+t.replace("%",""):t,t>0&&1>t&&(o.verbose("Module percentage passed as decimal, converting"),t=100*t),t=Math.round(0===d.precision?t:10*t*d.precision/(10*d.precision)),o.percent=t,o.total&&(o.value=Math.round(t/100*o.total)),d.limitValues&&(o.value=o.value>100?100:o.value<0?0:o.value),o.set.barWidth(t),o.set.barLabel(),100===t?!d.autoSuccess||o.is.warning()||o.is.error()?o.remove.active():(o.set.success(),o.debug("Automatically triggering success at 100%")):t>0&&o.set.active(),e.proxy(d.onChange,C)(t,o.value,o.total)},label:function(e){e=e||"",e&&(e=o.get.text(e),o.debug("Setting label to text",e),w.text(e))},barLabel:function(e){e!==i?x.text(o.get.text(e)):"ratio"==d.label&&o.total?(o.debug("Adding ratio to bar label"),x.text(o.get.text(d.text.ratio))):"percent"==d.label&&(o.debug("Adding percentage to bar label"),x.text(o.get.text(d.text.percent)))},active:function(t){t=t||d.text.active,o.debug("Setting active state"),d.showActivity&&h.addClass(m.active),o.remove.warning(),o.remove.error(),o.remove.success(),t&&o.set.label(t),e.proxy(d.onActive,C)(o.value,o.total)},success:function(t){t=t||d.text.success,o.debug("Setting success state"),h.addClass(m.success),o.remove.active(),o.remove.warning(),o.remove.error(),o.complete(),t&&o.set.label(t),e.proxy(d.onSuccess,C)(o.total)},warning:function(t){t=t||d.text.warning,o.debug("Setting warning state"),h.addClass(m.warning),o.remove.active(),o.remove.success(),o.remove.error(),o.complete(),t&&o.set.label(t),e.proxy(d.onWarning,C)(o.value,o.total)},error:function(t){t=t||d.text.error,o.debug("Setting error state"),h.addClass(m.error),o.remove.active(),o.remove.success(),o.remove.warning(),o.complete(),t&&o.set.label(t),e.proxy(d.onError,C)(o.value,o.total)},total:function(e){o.total=e},progress:function(e){var t,n="string"==typeof e?""!==e.replace(/[^\d.]/g,"")?+e.replace(/[^\d.]/g,""):!1:e;n===!1&&o.error(b.nonNumeric,e),o.total?(o.value=n,t=n/o.total*100,o.debug("Calculating percent complete from total",t),o.set.percent(t)):(t=n,o.debug("Setting value to exact percentage value",t),o.set.percent(t))}},setting:function(t,n){if(o.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,d,t);else{if(n===i)return d[t];d[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,o,t);else{if(n===i)return o[t];o[t]=n}},debug:function(){d.debug&&(d.performance?o.performance.log(arguments):(o.debug=Function.prototype.bind.call(console.info,console,d.name+":"),o.debug.apply(console,arguments)))},verbose:function(){d.verbose&&d.debug&&(d.performance?o.performance.log(arguments):(o.verbose=Function.prototype.bind.call(console.info,console,d.name+":"),o.verbose.apply(console,arguments)))},error:function(){o.error=Function.prototype.bind.call(console.error,console,d.name+":"),o.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;d.performance&&(t=(new Date).getTime(),i=a||t,n=t-i,a=t,s.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:C,"Execution Time":n})),clearTimeout(o.performance.timer),o.performance.timer=setTimeout(o.performance.display,100)},display:function(){var t=d.name+":",n=0;a=!1,clearTimeout(o.performance.timer),e.each(s,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",r&&(t+=" '"+r+"'"),(console.group!==i||console.table!==i)&&s.length>0&&(console.groupCollapsed(t),console.table?console.table(s):e.each(s,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),s=[]}},invoke:function(t,r,a){var s,c,l,d=T;return r=r||u,a=C||a,"string"==typeof t&&d!==i&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(n,r){var a=n!=s?r+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(d[a])&&n!=s)d=d[a];else{if(d[a]!==i)return c=d[a],!1;if(!e.isPlainObject(d[r])||n==s)return d[r]!==i?(c=d[r],!1):(o.error(b.method,t),!1);d=d[r]}})),e.isFunction(c)?l=c.apply(a,r):c!==i&&(l=c),e.isArray(n)?n.push(l):n!==i?n=[n,l]:l!==i&&(n=l),c}},l?(T===i&&o.initialize(),o.invoke(c)):(T!==i&&o.destroy(),o.initialize())}),n!==i?n:this},e.fn.progress.settings={name:"Progress",namespace:"progress",debug:!1,verbose:!0,performance:!0,random:{min:2,max:5},autoSuccess:!0,showActivity:!0,limitValues:!0,label:"percent",precision:1,percent:!1,total:!1,value:!1,onChange:function(){},onSuccess:function(){},onActive:function(){},onError:function(){},onWarning:function(){},error:{method:"The method you called is not defined.",nonNumeric:"Progress value is non numeric",tooHigh:"Value specified is above 100%",tooLow:"Value specified is below 0%"},regExp:{variable:/\{\$*[A-z0-9]+\}/g},metadata:{percent:"percent",total:"total",value:"value"},selector:{bar:"> .bar",label:"> .label",progress:".bar > .progress"},text:{active:!1,error:!1,success:!1,warning:!1,percent:"{percent}%",ratio:"{value} of {total}"},className:{active:"active",error:"error",success:"success",warning:"warning"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.rating=function(t){var n,o=e(this),r=o.selector||"",a=(new Date).getTime(),s=[],c=arguments[0],l="string"==typeof c,u=[].slice.call(arguments,1);return o.each(function(){var d,m=e.isPlainObject(t)?e.extend(!0,{},e.fn.rating.settings,t):e.extend({},e.fn.rating.settings),f=m.namespace,p=m.className,g=m.metadata,b=m.selector,v=(m.error,"."+f),h="module-"+f,y=this,x=e(this).data(h),w=e(this),C=w.find(b.icon);d={initialize:function(){d.verbose("Initializing rating module",m),0===C.size()&&d.setup.layout(),m.interactive?d.enable():d.disable(),m.initialRating&&(d.debug("Setting initial rating"),d.setRating(m.initialRating)),w.data(g.rating)&&(d.debug("Rating found in metadata"),d.setRating(w.data(g.rating))),d.instantiate()},instantiate:function(){d.verbose("Instantiating module",m),x=d,w.data(h,d)},destroy:function(){d.verbose("Destroying previous instance",x),w.removeData(h),C.off(v)},refresh:function(){C=w.find(b.icon)},setup:{layout:function(){var t=w.data(g.maxRating)||m.maxRating;d.debug("Generating icon html dynamically"),w.html(e.fn.rating.settings.templates.icon(t)),d.refresh()}},event:{mouseenter:function(){var t=e(this);t.nextAll().removeClass(p.selected),w.addClass(p.selected),t.addClass(p.selected).prevAll().addClass(p.selected)},mouseleave:function(){w.removeClass(p.selected),C.removeClass(p.selected)},click:function(){var t=e(this),n=d.getRating(),i=C.index(t)+1,o="auto"==m.clearable?1===C.size():m.clearable;o&&n==i?d.clearRating():d.setRating(i)}},clearRating:function(){d.debug("Clearing current rating"),d.setRating(0)},getRating:function(){var e=C.filter("."+p.active).size();return d.verbose("Current rating retrieved",e),e},enable:function(){d.debug("Setting rating to interactive mode"),C.on("mouseenter"+v,d.event.mouseenter).on("mouseleave"+v,d.event.mouseleave).on("click"+v,d.event.click),w.removeClass(p.disabled)},disable:function(){d.debug("Setting rating to read-only mode"),C.off(v),w.addClass(p.disabled)},setRating:function(t){var n=t-1>=0?t-1:0,i=C.eq(n);w.removeClass(p.selected),C.removeClass(p.selected).removeClass(p.active),t>0&&(d.verbose("Setting current rating to",t),i.prevAll().andSelf().addClass(p.active)),e.proxy(m.onRate,y)(t)},setting:function(t,n){if(d.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,m,t);else{if(n===i)return m[t];m[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,d,t);else{if(n===i)return d[t];d[t]=n}},debug:function(){m.debug&&(m.performance?d.performance.log(arguments):(d.debug=Function.prototype.bind.call(console.info,console,m.name+":"),d.debug.apply(console,arguments)))},verbose:function(){m.verbose&&m.debug&&(m.performance?d.performance.log(arguments):(d.verbose=Function.prototype.bind.call(console.info,console,m.name+":"),d.verbose.apply(console,arguments)))},error:function(){d.error=Function.prototype.bind.call(console.error,console,m.name+":"),d.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;m.performance&&(t=(new Date).getTime(),i=a||t,n=t-i,a=t,s.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:y,"Execution Time":n})),clearTimeout(d.performance.timer),d.performance.timer=setTimeout(d.performance.display,100)},display:function(){var t=m.name+":",n=0;a=!1,clearTimeout(d.performance.timer),e.each(s,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",r&&(t+=" '"+r+"'"),o.size()>1&&(t+=" ("+o.size()+")"),(console.group!==i||console.table!==i)&&s.length>0&&(console.groupCollapsed(t),console.table?console.table(s):e.each(s,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),s=[]}},invoke:function(t,o,r){var a,s,c,l=x;return o=o||u,r=y||r,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(r,o):s!==i&&(c=s),e.isArray(n)?n.push(c):n!==i?n=[n,c]:c!==i&&(n=c),s}},l?(x===i&&d.initialize(),d.invoke(c)):(x!==i&&d.destroy(),d.initialize())}),n!==i?n:this},e.fn.rating.settings={name:"Rating",namespace:"rating",debug:!1,verbose:!0,performance:!0,initialRating:0,interactive:!0,maxRating:4,clearable:"auto",onRate:function(){},error:{method:"The method you called is not defined",noMaximum:"No maximum rating specified. Cannot generate HTML automatically"},metadata:{rating:"rating",maxRating:"maxRating"},className:{active:"active",disabled:"disabled",selected:"selected",loading:"loading"},selector:{icon:".icon"},templates:{icon:function(e){for(var t=1,n="";e>=t;)n+='<i class="icon"></i>',t++;return n}}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.search=function(n){var o,r=e(this),a=r.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return e(this).each(function(){var m,f=e.extend(!0,{},e.fn.search.settings,n),p=f.className,g=f.selector,b=f.error,v=f.namespace,h="."+v,y=v+"-module",x=e(this),w=x.find(g.prompt),C=x.find(g.searchButton),T=x.find(g.results),k=(x.find(g.result),x.find(g.category),this),S=x.data(y);m={initialize:function(){m.verbose("Initializing module");var e=w[0],t=e!==i&&e.oninput!==i?"input":e!==i&&e.onpropertychange!==i?"propertychange":"keyup";f.automatic&&w.on(t+h,m.search.throttle),w.on("focus"+h,m.event.focus).on("blur"+h,m.event.blur).on("keydown"+h,m.handleKeyboard),C.on("click"+h,m.search.query),T.on("mousedown"+h,m.event.mousedown).on("mouseup"+h,m.event.mouseup).on("click"+h,g.result,m.results.select),m.instantiate()},instantiate:function(){m.verbose("Storing instance of module",m),S=m,x.data(y,m)},destroy:function(){m.verbose("Destroying instance"),x.removeData(y),w.off(h),C.off(h),T.off(h)},event:{focus:function(){x.addClass(p.focus),clearTimeout(m.timer),m.search.throttle(),m.has.minimum()&&m.results.show()},mousedown:function(){m.resultsClicked=!0},mouseup:function(){m.resultsClicked=!1},blur:function(){m.search.cancel(),x.removeClass(p.focus),m.resultsClicked||(m.timer=setTimeout(m.results.hide,f.hideDelay))}},handleKeyboard:function(t){var n,i=x.find(g.result),o=x.find(g.category),r=t.which,a={backspace:8,enter:13,escape:27,upArrow:38,downArrow:40},s=p.active,c=i.index(i.filter("."+s)),l=i.size();if(r==a.escape&&(m.verbose("Escape key pressed, blurring search field"),w.trigger("blur")),T.filter(":visible").size()>0)if(r==a.enter){if(m.verbose("Enter key pressed, selecting active result"),i.filter("."+s).size()>0)return e.proxy(m.results.select,i.filter("."+s))(t),t.preventDefault(),!1}else r==a.upArrow?(m.verbose("Up key pressed, changing active result"),n=0>c-1?c:c-1,o.removeClass(s),i.removeClass(s).eq(n).addClass(s).closest(o).addClass(s),t.preventDefault()):r==a.downArrow&&(m.verbose("Down key pressed, changing active result"),n=c+1>=l?c:c+1,o.removeClass(s),i.removeClass(s).eq(n).addClass(s).closest(o).addClass(s),t.preventDefault());else r==a.enter&&(m.verbose("Enter key pressed, executing query"),m.search.query(),C.addClass(p.down),w.one("keyup",function(){C.removeClass(p.down)}))},has:{minimum:function(){var e=w.val(),t=e.length;return t>=f.minCharacters}},search:{cancel:function(){var e=x.data("xhr")||!1;e&&"resolved"!=e.state()&&(m.debug("Cancelling last search"),e.abort())},throttle:function(){clearTimeout(m.timer),m.has.minimum()?m.timer=setTimeout(m.search.query,f.searchDelay):m.results.hide()},query:function(){var t=w.val(),n=m.search.cache.read(t);
-n?(m.debug("Reading result for '"+t+"' from cache"),m.results.add(n)):(m.debug("Querying for '"+t+"'"),e.isPlainObject(f.source)||e.isArray(f.source)?m.search.local(t):f.apiSettings?m.search.remote(t):e.fn.api!==i&&e.api.settings.api.search!==i?(m.debug("Searching with default search API endpoint"),f.apiSettings={action:"search"},m.search.remote(t)):m.error(b.source),e.proxy(f.onSearchQuery,x)(t))},local:function(t){var n,i=[],o=[],r=e.isArray(f.searchFields)?f.searchFields:[f.searchFields],a=new RegExp("(?:s|^)"+t,"i"),s=new RegExp(t,"i");x.addClass(p.loading),e.each(r,function(t,n){e.each(f.source,function(t,r){var c="string"==typeof r[n],l=-1==e.inArray(r,i)&&-1==e.inArray(r,o);c&&l&&(a.test(r[n])?i.push(r):f.searchFullText&&s.test(r[n])&&o.push(r))})}),n=m.results.generate({results:e.merge(i,o)}),x.removeClass(p.loading),m.search.cache.write(t,n),m.results.add(n)},remote:function(t){var n,i={stateContext:x,urlData:{query:t},onSuccess:function(e){n=m.results.generate(e),m.search.cache.write(t,n),m.results.add(n)},onFailure:m.error};m.search.cancel(),m.debug("Executing search"),e.extend(!0,i,f.apiSettings),e.api(i)},cache:{read:function(e){var t=x.data("cache");return f.cache&&"object"==typeof t&&t[e]!==i?t[e]:!1},write:function(e,t){var n=x.data("cache")!==i?x.data("cache"):{};n[e]=t,x.data("cache",n)}}},results:{generate:function(t){m.debug("Generating html from response",t);var n=f.templates[f.type],i="";return e.isPlainObject(t.results)&&!e.isEmptyObject(t.results)||e.isArray(t.results)&&t.results.length>0?(f.maxResults>0&&(t.results=e.isArray(t.results)?t.results.slice(0,f.maxResults):t.results),e.isFunction(n)?i=n(t):m.error(b.noTemplate,!1)):i=m.message(b.noResults,"empty"),e.proxy(f.onResults,x)(t),i},add:function(t){("default"==f.onResultsAdd||"default"==e.proxy(f.onResultsAdd,T)(t))&&T.html(t),m.results.show()},show:function(){0===T.filter(":visible").size()&&w.filter(":focus").size()>0&&""!==T.html()&&(f.transition&&e.fn.transition!==i&&x.transition("is supported")&&!T.transition("is inward")?(m.debug("Showing results with css animations"),T.transition({animation:f.transition+" in",duration:f.duration,queue:!0})):(m.debug("Showing results with javascript"),T.stop().fadeIn(f.duration,f.easing)),e.proxy(f.onResultsOpen,T)())},hide:function(){T.filter(":visible").size()>0&&(f.transition&&e.fn.transition!==i&&x.transition("is supported")&&!T.transition("is outward")?(m.debug("Hiding results with css animations"),T.transition({animation:f.transition+" out",duration:f.duration,queue:!0})):(m.debug("Hiding results with javascript"),T.stop().fadeIn(f.duration,f.easing)),e.proxy(f.onResultsClose,T)())},select:function(n){m.debug("Search result selected");{var i=e(this),o=i.find(".title");o.html()}if("default"==f.onSelect||"default"==e.proxy(f.onSelect,this)(n)){var r=i.find("a[href]").eq(0),o=i.find(g.title).eq(0),a=r.attr("href")||!1,s=r.attr("target")||!1,c=o.size()>0?o.text():!1;m.results.hide(),c&&w.val(c),a&&("_blank"==s||n.ctrlKey?t.open(a):t.location.href=a)}}},message:function(e,t){return t=t||"standard",m.results.add(f.templates.message(e,t)),f.templates.message(e,t)},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,m,t);else{if(n===i)return m[t];m[t]=n}},debug:function(){f.debug&&(f.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,f.name+":"),m.debug.apply(console,arguments)))},verbose:function(){f.verbose&&f.debug&&(f.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,f.name+":"),m.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;f.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:k,"Execution Time":n})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,100)},display:function(){var t=f.name+":",n=0;s=!1,clearTimeout(m.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",a&&(t+=" '"+a+"'"),r.size()>1&&(t+=" ("+r.size()+")"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,r){var a,s,c,l=S;return n=n||d,r=k||r,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(r,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},u?(S===i&&m.initialize(),m.invoke(l)):(S!==i&&m.destroy(),m.initialize())}),o!==i?o:this},e.fn.search.settings={name:"Search Module",namespace:"search",debug:!1,verbose:!0,performance:!0,apiSettings:!1,type:"standard",minCharacters:1,source:!1,searchFields:["title","description"],searchFullText:!0,automatic:"true",hideDelay:0,searchDelay:300,maxResults:7,cache:!0,transition:"scale",duration:300,easing:"easeOutExpo",onSelect:"default",onResultsAdd:"default",onSearchQuery:function(){},onResults:function(){},onResultsOpen:function(){},onResultsClose:function(){},className:{active:"active",down:"down",focus:"focus",empty:"empty",loading:"loading"},error:{source:"Cannot search. No source used, and Semantic API module was not included",noResults:"Your search returned no results",logging:"Error in debug logging, exiting.",noTemplate:"A valid template name was not specified.",serverError:"There was an issue with querying the server.",method:"The method you called is not defined."},selector:{prompt:".prompt",searchButton:".search.button",results:".results",category:".category",result:".result",title:".title, .name"},templates:{escape:function(e){var t=/[&<>"'`]/g,n=/[&<>"'`]/,i={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},o=function(e){return i[e]};return n.test(e)?e.replace(t,o):e},message:function(e,t){var n="";return e!==i&&t!==i&&(n+='<div class="message '+t+'">',n+="empty"==t?'<div class="header">No Results</div class="header"><div class="description">'+e+'</div class="description">':' <div class="description">'+e+"</div>",n+="</div>"),n},category:function(t){var n="",o=e.fn.search.settings.templates.escape;return t.results!==i?(e.each(t.results,function(t,r){r.results!==i&&r.results.length>0&&(n+='<div class="category"><div class="name">'+r.name+"</div>",e.each(r.results,function(e,t){n+='<div class="result">',t.url&&(n+='<a href="'+t.url+'"></a>'),t.image!==i&&(t.image=o(t.image),n+='<div class="image"> <img src="'+t.image+'" alt=""></div>'),n+='<div class="content">',t.price!==i&&(t.price=o(t.price),n+='<div class="price">'+t.price+"</div>"),t.title!==i&&(t.title=o(t.title),n+='<div class="title">'+t.title+"</div>"),t.description!==i&&(n+='<div class="description">'+t.description+"</div>"),n+="</div></div>"}),n+="</div>")}),t.action&&(n+='<a href="'+t.action.url+'" class="action">'+t.action.text+"</a>"),n):!1},standard:function(t){var n="";return t.results!==i?(e.each(t.results,function(e,t){n+=t.url?'<a class="result" href="'+t.url+'">':'<a class="result">',t.image!==i&&(n+='<div class="image"> <img src="'+t.image+'"></div>'),n+='<div class="content">',t.price!==i&&(n+='<div class="price">'+t.price+"</div>"),t.title!==i&&(n+='<div class="title">'+t.title+"</div>"),t.description!==i&&(n+='<div class="description">'+t.description+"</div>"),n+="</div>",n+="</a>"}),t.action&&(n+='<a href="'+t.action.url+'" class="action">'+t.action.text+"</a>"),n):!1}}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.shape=function(o){var r,a=e(this),s=(e("body"),(new Date).getTime()),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1),m=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)};return a.each(function(){var t,f,p,g=a.selector||"",b=e.extend(!0,{},e.fn.shape.settings,o),v=b.namespace,h=b.selector,y=b.error,x=b.className,w="."+v,C="module-"+v,T=e(this),k=T.find(h.sides),S=T.find(h.side),z=!1,A=this,E=T.data(C);p={initialize:function(){p.verbose("Initializing module for",A),p.set.defaultSide(),p.instantiate()},instantiate:function(){p.verbose("Storing instance of module",p),E=p,T.data(C,E)},destroy:function(){p.verbose("Destroying previous module for",A),T.removeData(C).off(w)},refresh:function(){p.verbose("Refreshing selector cache for",A),T=e(A),k=e(this).find(h.shape),S=e(this).find(h.side)},repaint:function(){p.verbose("Forcing repaint event");{var e=k.get(0)||n.createElement("div");e.offsetWidth}},animate:function(n,o){p.verbose("Animating box with properties",n),o=o||function(e){p.verbose("Executing animation callback"),e!==i&&e.stopPropagation(),p.reset(),p.set.active()},e.proxy(b.beforeChange,f[0])(),p.get.transitionEvent()?(p.verbose("Starting CSS animation"),T.addClass(x.animating),k.css(n).one(p.get.transitionEvent(),o),p.set.duration(b.duration),m(function(){T.addClass(x.animating),t.addClass(x.hidden)})):o()},queue:function(e){p.debug("Queueing animation of",e),k.one(p.get.transitionEvent(),function(){p.debug("Executing queued animation"),setTimeout(function(){T.shape(e)},0)})},reset:function(){p.verbose("Animating states reset"),T.removeClass(x.animating).attr("style","").removeAttr("style"),k.attr("style","").removeAttr("style"),S.attr("style","").removeAttr("style").removeClass(x.hidden),f.removeClass(x.animating).attr("style","").removeAttr("style")},is:{complete:function(){return S.filter("."+x.active)[0]==f[0]},animating:function(){return T.hasClass(x.animating)}},set:{defaultSide:function(){t=T.find("."+b.className.active),f=t.next(h.side).size()>0?t.next(h.side):T.find(h.side).first(),z=!1,p.verbose("Active side set to",t),p.verbose("Next side set to",f)},duration:function(e){e=e||b.duration,e="number"==typeof e?e+"ms":e,p.verbose("Setting animation duration",e),k.add(S).css({"-webkit-transition-duration":e,"-moz-transition-duration":e,"-ms-transition-duration":e,"-o-transition-duration":e,"transition-duration":e})},stageSize:function(){var e=T.clone().addClass(x.loading),t=e.find("."+b.className.active),n=z?e.find(h.side).eq(z):t.next(h.side).size()>0?t.next(h.side):e.find(h.side).first(),i={};t.removeClass(x.active),n.addClass(x.active),e.insertAfter(T),i={width:n.outerWidth(),height:n.outerHeight()},e.remove(),T.css(i),p.verbose("Resizing stage to fit new content",i)},nextSide:function(e){z=e,f=S.filter(e),z=S.index(f),0===f.size()&&(p.set.defaultSide(),p.error(y.side)),p.verbose("Next side manually set to",f)},active:function(){p.verbose("Setting new side to active",f),S.removeClass(x.active),f.addClass(x.active),e.proxy(b.onChange,f[0])(),p.set.defaultSide()}},flip:{up:function(){return!p.is.complete()||p.is.animating()||b.allowRepeats?void(p.is.animating()?p.queue("flip up"):(p.debug("Flipping up",f),p.set.stageSize(),p.stage.above(),p.animate(p.get.transform.up()))):void p.debug("Side already visible",f)},down:function(){return!p.is.complete()||p.is.animating()||b.allowRepeats?void(p.is.animating()?p.queue("flip down"):(p.debug("Flipping down",f),p.set.stageSize(),p.stage.below(),p.animate(p.get.transform.down()))):void p.debug("Side already visible",f)},left:function(){return!p.is.complete()||p.is.animating()||b.allowRepeats?void(p.is.animating()?p.queue("flip left"):(p.debug("Flipping left",f),p.set.stageSize(),p.stage.left(),p.animate(p.get.transform.left()))):void p.debug("Side already visible",f)},right:function(){return!p.is.complete()||p.is.animating()||b.allowRepeats?void(p.is.animating()?p.queue("flip right"):(p.debug("Flipping right",f),p.set.stageSize(),p.stage.right(),p.animate(p.get.transform.right()))):void p.debug("Side already visible",f)},over:function(){return!p.is.complete()||p.is.animating()||b.allowRepeats?void(p.is.animating()?p.queue("flip over"):(p.debug("Flipping over",f),p.set.stageSize(),p.stage.behind(),p.animate(p.get.transform.over()))):void p.debug("Side already visible",f)},back:function(){return!p.is.complete()||p.is.animating()||b.allowRepeats?void(p.is.animating()?p.queue("flip back"):(p.debug("Flipping back",f),p.set.stageSize(),p.stage.behind(),p.animate(p.get.transform.back()))):void p.debug("Side already visible",f)}},get:{transform:{up:function(){var e={y:-((t.outerHeight()-f.outerHeight())/2),z:-(t.outerHeight()/2)};return{transform:"translateY("+e.y+"px) translateZ("+e.z+"px) rotateX(-90deg)"}},down:function(){var e={y:-((t.outerHeight()-f.outerHeight())/2),z:-(t.outerHeight()/2)};return{transform:"translateY("+e.y+"px) translateZ("+e.z+"px) rotateX(90deg)"}},left:function(){var e={x:-((t.outerWidth()-f.outerWidth())/2),z:-(t.outerWidth()/2)};return{transform:"translateX("+e.x+"px) translateZ("+e.z+"px) rotateY(90deg)"}},right:function(){var e={x:-((t.outerWidth()-f.outerWidth())/2),z:-(t.outerWidth()/2)};return{transform:"translateX("+e.x+"px) translateZ("+e.z+"px) rotateY(-90deg)"}},over:function(){var e={x:-((t.outerWidth()-f.outerWidth())/2)};return{transform:"translateX("+e.x+"px) rotateY(180deg)"}},back:function(){var e={x:-((t.outerWidth()-f.outerWidth())/2)};return{transform:"translateX("+e.x+"px) rotateY(-180deg)"}}},transitionEvent:function(){var e,t=n.createElement("element"),o={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in o)if(t.style[e]!==i)return o[e]},nextSide:function(){return t.next(h.side).size()>0?t.next(h.side):T.find(h.side).first()}},stage:{above:function(){var e={origin:(t.outerHeight()-f.outerHeight())/2,depth:{active:f.outerHeight()/2,next:t.outerHeight()/2}};p.verbose("Setting the initial animation position as above",f,e),t.css({transform:"rotateY(0deg) translateZ("+e.depth.active+"px)"}),f.addClass(x.animating).css({display:"block",top:e.origin+"px",transform:"rotateX(90deg) translateZ("+e.depth.next+"px)"})},below:function(){var e={origin:(t.outerHeight()-f.outerHeight())/2,depth:{active:f.outerHeight()/2,next:t.outerHeight()/2}};p.verbose("Setting the initial animation position as below",f,e),t.css({transform:"rotateY(0deg) translateZ("+e.depth.active+"px)"}),f.addClass(x.animating).css({display:"block",top:e.origin+"px",transform:"rotateX(-90deg) translateZ("+e.depth.next+"px)"})},left:function(){var e={origin:(t.outerWidth()-f.outerWidth())/2,depth:{active:f.outerWidth()/2,next:t.outerWidth()/2}};p.verbose("Setting the initial animation position as left",f,e),t.css({transform:"rotateY(0deg) translateZ("+e.depth.active+"px)"}),f.addClass(x.animating).css({display:"block",left:e.origin+"px",transform:"rotateY(-90deg) translateZ("+e.depth.next+"px)"})},right:function(){var e={origin:(t.outerWidth()-f.outerWidth())/2,depth:{active:f.outerWidth()/2,next:t.outerWidth()/2}};p.verbose("Setting the initial animation position as left",f,e),t.css({transform:"rotateY(0deg) translateZ("+e.depth.active+"px)"}),f.addClass(x.animating).css({display:"block",left:e.origin+"px",transform:"rotateY(90deg) translateZ("+e.depth.next+"px)"})},behind:function(){var e={origin:(t.outerWidth()-f.outerWidth())/2,depth:{active:f.outerWidth()/2,next:t.outerWidth()/2}};p.verbose("Setting the initial animation position as behind",f,e),t.css({transform:"rotateY(0deg)"}),f.addClass(x.animating).css({display:"block",left:e.origin+"px",transform:"rotateY(-180deg)"})}},setting:function(t,n){if(p.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,b,t);else{if(n===i)return b[t];b[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,p,t);else{if(n===i)return p[t];p[t]=n}},debug:function(){b.debug&&(b.performance?p.performance.log(arguments):(p.debug=Function.prototype.bind.call(console.info,console,b.name+":"),p.debug.apply(console,arguments)))},verbose:function(){b.verbose&&b.debug&&(b.performance?p.performance.log(arguments):(p.verbose=Function.prototype.bind.call(console.info,console,b.name+":"),p.verbose.apply(console,arguments)))},error:function(){p.error=Function.prototype.bind.call(console.error,console,b.name+":"),p.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;b.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:A,"Execution Time":n})),clearTimeout(p.performance.timer),p.performance.timer=setTimeout(p.performance.display,100)},display:function(){var t=b.name+":",n=0;s=!1,clearTimeout(p.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",g&&(t+=" '"+g+"'"),a.size()>1&&(t+=" ("+a.size()+")"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,o){var a,s,c,l=E;return n=n||d,o=A||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(r)?r.push(c):r!==i?r=[r,c]:c!==i&&(r=c),s}},u?(E===i&&p.initialize(),p.invoke(l)):(E!==i&&p.destroy(),p.initialize())}),r!==i?r:this},e.fn.shape.settings={name:"Shape",debug:!1,verbose:!0,performance:!0,namespace:"shape",beforeChange:function(){},onChange:function(){},allowRepeats:!1,duration:700,error:{side:"You tried to switch to a side that does not exist.",method:"The method you called is not defined"},className:{animating:"animating",hidden:"hidden",loading:"loading",active:"active"},selector:{sides:".sides",side:".side"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.sidebar=function(o){var r,a=e(this),s=e(t),c=e(n),l=e("head"),u=a.selector||"",d=(new Date).getTime(),m=[],f=arguments[0],p="string"==typeof f,g=[].slice.call(arguments,1),b=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)};return a.each(function(){var a,v,h,y,x,w,C=e.isPlainObject(o)?e.extend(!0,{},e.fn.sidebar.settings,o):e.extend({},e.fn.sidebar.settings),T=C.selector,k=C.className,S=C.namespace,z=C.error,A="."+S,E="module-"+S,F=e(this),D=e(C.context),O=F.children(T.sidebar),P=D.children(T.pusher),R=this,j=F.data(E);w={initialize:function(){w.debug("Initializing sidebar",o),x=w.get.transitionEvent(),(w.is.legacy()||C.legacy)&&(C.transition="overlay",C.useLegacy=!0),h=w.get.uniqueID(),v="."+h,b(w.setup.layout),w.instantiate()},instantiate:function(){w.verbose("Storing instance of module",w),j=w,F.data(E,w)},destroy:function(){w.verbose("Destroying previous module for",F),w.remove.direction(),F.off(A).removeData(E),D.off(v),s.off(v),c.off(v)},event:{clickaway:function(t){0===e(t.target).closest(T.sidebar).size()&&(w.verbose("User clicked on dimmed page"),w.hide())},touch:function(){},containScroll:function(){R.scrollTop<=0&&(R.scrollTop=1),R.scrollTop+R.offsetHeight>=R.scrollHeight&&(R.scrollTop=R.scrollHeight-R.offsetHeight-1)},scroll:function(t){0===e(t.target).closest(T.sidebar).size()&&t.preventDefault()}},bind:{clickaway:function(){w.verbose("Adding clickaway events to context",D),C.closable&&D.on("click"+v,w.event.clickaway).on("touchend"+v,w.event.clickaway)},scrollLock:function(){C.scrollLock&&(w.debug("Disabling page scroll"),s.on("DOMMouseScroll"+v,w.event.scroll)),w.verbose("Adding events to contain sidebar scroll"),c.on("touchmove"+v,w.event.touch),F.on("scroll"+A,w.event.containScroll)}},unbind:{clickaway:function(){w.verbose("Removing clickaway events from context",D),D.off(v)},scrollLock:function(){w.verbose("Removing scroll lock from page"),c.off(v),s.off(v),F.off("scroll"+A)}},add:{bodyCSS:function(){var t,n=F.outerWidth(),i=F.outerHeight();t='<style title="'+S+'"> .ui.visible.left.sidebar ~ .fixed, .ui.visible.left.sidebar ~ .pusher { -webkit-transform: translate3d('+n+"px, 0, 0); transform: translate3d("+n+"px, 0, 0); } .ui.visible.right.sidebar ~ .fixed, .ui.visible.right.sidebar ~ .pusher { -webkit-transform: translate3d(-"+n+"px, 0, 0); transform: translate3d(-"+n+"px, 0, 0); } .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .fixed, .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher, .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .fixed, .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher { -webkit-transform: translate3d(0px, 0, 0); transform: translate3d(0px, 0, 0); } .ui.visible.top.sidebar ~ .fixed, .ui.visible.top.sidebar ~ .pusher { -webkit-transform: translate3d(0, "+i+"px, 0); transform: translate3d(0, "+i+"px, 0); } .ui.visible.bottom.sidebar ~ .fixed, .ui.visible.bottom.sidebar ~ .pusher { -webkit-transform: translate3d(0, -"+i+"px, 0); transform: translate3d(0, -"+i+"px, 0); }",w.is.ie()&&(t+=" .ui.visible.left.sidebar ~ .pusher:after { -webkit-transform: translate3d("+n+"px, 0, 0); transform: translate3d("+n+"px, 0, 0); } .ui.visible.right.sidebar ~ .pusher:after { -webkit-transform: translate3d(-"+n+"px, 0, 0); transform: translate3d(-"+n+"px, 0, 0); } .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher:after, .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher:after { -webkit-transform: translate3d(0px, 0, 0); transform: translate3d(0px, 0, 0); } .ui.visible.top.sidebar ~ .pusher:after { -webkit-transform: translate3d(0, "+i+"px, 0); transform: translate3d(0, "+i+"px, 0); } .ui.visible.bottom.sidebar ~ .pusher:after { -webkit-transform: translate3d(0, -"+i+"px, 0); transform: translate3d(0, -"+i+"px, 0); }"),t+="</style>",l.append(t),a=e("style[title="+S+"]"),w.debug("Adding sizing css to head",a)}},refresh:function(){w.verbose("Refreshing selector cache"),D=e(C.context),O=D.children(T.sidebar),P=D.children(T.pusher)},refreshSidebars:function(){w.verbose("Refreshing other sidebars"),O=D.children(T.sidebar)},repaint:function(){w.verbose("Forcing repaint event"),R.style.display="none",R.offsetHeight,R.scrollTop=R.scrollTop,R.style.display=""},setup:{layout:function(){0===D.children(T.pusher).size()&&(w.debug("Adding wrapper element for sidebar"),w.error(z.pusher),P=e('<div class="pusher" />'),D.children().not(T.omitted).not(O).wrapAll(P),w.refresh()),(0===F.nextAll(T.pusher).size()||F.nextAll(T.pusher)[0]!==P[0])&&(w.debug("Moved sidebar to correct parent element"),w.error(z.movedSidebar,R),F.detach().prependTo(D),w.refresh()),w.set.pushable(),w.set.direction()}},attachEvents:function(t,n){var i=e(t);n=e.isFunction(w[n])?w[n]:w.toggle,i.size()>0?(w.debug("Attaching sidebar events to element",t,n),i.on("click"+A,n)):w.error(z.notFound,t)},show:function(t){var n=C.useLegacy?w.legacyPushPage:w.pushPage;t=e.isFunction(t)?t:function(){},w.is.hidden()?(w.refreshSidebars(),C.overlay&&(w.error(z.overlay),C.transition="overlay"),w.refresh(),w.othersVisible()&&"overlay"!=w.get.transition()&&(w.debug("Other sidebars currently open"),C.exclusive&&w.hideOthers()),n(function(){e.proxy(t,R)(),e.proxy(C.onShow,R)()}),e.proxy(C.onChange,R)(),e.proxy(C.onVisible,R)()):w.debug("Sidebar is already visible")},hide:function(t){var n=C.useLegacy?w.legacyPullPage:w.pullPage;t=e.isFunction(t)?t:function(){},(w.is.visible()||w.is.animating())&&(w.debug("Hiding sidebar",t),w.refreshSidebars(),n(function(){e.proxy(t,R)(),e.proxy(C.onHidden,R)()}),e.proxy(C.onChange,R)(),e.proxy(C.onHide,R)())},othersVisible:function(){return O.not(F).filter("."+k.visible).size()>0},hideOthers:function(e){var t=O.not(F).filter("."+k.visible),e=e||function(){},n=t.size(),i=0;t.sidebar("hide",function(){i++,i==n&&e()})},toggle:function(){w.verbose("Determining toggled direction"),w.is.hidden()?w.show():w.hide()},pushPage:function(t){var n,i,o=w.get.transition(),r="safe"==o?D:"overlay"==o||w.othersVisible()?F:P;t=e.isFunction(t)?t:function(){},("scale down"==C.transition||w.is.mobile()&&"overlay"!==o)&&w.scrollToTop(),w.set.transition(),w.repaint(),n=function(){w.bind.clickaway(),w.add.bodyCSS(),w.set.animating(),w.set.visible(),w.othersVisible()||C.dimPage&&P.addClass(k.dimmed)},i=function(n){n.target==r[0]&&(r.off(x+v,i),w.remove.animating(),w.bind.scrollLock(),e.proxy(t,R)())},r.off(x+v),r.on(x+v,i),b(n)},pullPage:function(t){var n,i,o=w.get.transition(),r="safe"==o?D:"overlay"==o||w.othersVisible()?F:P;t=e.isFunction(t)?t:function(){},w.verbose("Removing context push state",w.get.direction()),w.unbind.clickaway(),w.unbind.scrollLock(),n=function(){w.set.animating(),w.remove.visible(),C.dimPage&&!w.othersVisible()&&P.removeClass(k.dimmed)},i=function(n){n.target==r[0]&&(r.off(x+v,i),w.remove.animating(),w.remove.transition(),w.remove.bodyCSS(),("scale down"==o||C.returnScroll&&w.is.mobile())&&w.scrollBack(),e.proxy(t,R)())},r.off(x+v),r.on(x+v,i),b(n)},legacyPushPage:function(t){var n=F.width(),i=w.get.direction(),o={};n=n||F.width(),t=e.isFunction(t)?t:function(){},o[i]=n,w.debug("Using javascript to push context",o),w.set.visible(),w.set.transition(),w.set.animating(),C.dimPage&&P.addClass(k.dimmed),D.css("position","relative").animate(o,C.duration,C.easing,function(){w.remove.animating(),w.bind.clickaway(),e.proxy(t,w)()})},legacyPullPage:function(t){var n=0,i=w.get.direction(),o={};n=n||F.width(),t=e.isFunction(t)?t:function(){},o[i]="0px",w.debug("Using javascript to pull context",o),w.unbind.clickaway(),w.set.animating(),w.remove.visible(),C.dimPage&&!w.othersVisible()&&P.removeClass(k.dimmed),D.css("position","relative").animate(o,C.duration,C.easing,function(){w.remove.animating(),e.proxy(t,w)()})},scrollToTop:function(){w.verbose("Scrolling to top of page to avoid animation issues"),y=e(t).scrollTop(),F.scrollTop(0),t.scrollTo(0,0)},scrollBack:function(){w.verbose("Scrolling back to original page position"),t.scrollTo(0,y)},set:{pushed:function(){D.addClass(k.pushed)},pushable:function(){D.addClass(k.pushable)},active:function(){F.addClass(k.active)},animating:function(){F.addClass(k.animating)},transition:function(e){e=e||w.get.transition(),F.addClass(e)},direction:function(e){e=e||w.get.direction(),F.addClass(k[e])},visible:function(){F.addClass(k.visible)},overlay:function(){F.addClass(k.overlay)}},remove:{bodyCSS:function(){w.debug("Removing body css styles",a),a.size()>0&&a.remove()},pushed:function(){D.removeClass(k.pushed)},pushable:function(){D.removeClass(k.pushable)},active:function(){F.removeClass(k.active)},animating:function(){F.removeClass(k.animating)},transition:function(e){e=e||w.get.transition(),F.removeClass(e)},direction:function(e){e=e||w.get.direction(),F.removeClass(k[e])},visible:function(){F.removeClass(k.visible)},overlay:function(){F.removeClass(k.overlay)}},get:{direction:function(){return F.hasClass(k.top)?k.top:F.hasClass(k.right)?k.right:F.hasClass(k.bottom)?k.bottom:k.left},transition:function(){var e=w.get.direction();return w.is.mobile()?"auto"==C.mobileTransition?C.defaultTransition.mobile[e]:C.mobileTransition:"auto"==C.transition?C.defaultTransition.computer[e]:C.transition},transitionEvent:function(){var e,t=n.createElement("element"),o={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in o)if(t.style[e]!==i)return o[e]},uniqueID:function(){return(Math.random().toString(16)+"000000000").substr(2,8)}},is:{ie:function(){var e=!t.ActiveXObject&&"ActiveXObject"in t,n="ActiveXObject"in t;return e||n},legacy:function(){var e,o=n.createElement("div"),r={webkitTransform:"-webkit-transform",OTransform:"-o-transform",msTransform:"-ms-transform",MozTransform:"-moz-transform",transform:"transform"};n.body.insertBefore(o,null);for(var a in r)o.style[a]!==i&&(o.style[a]="translate3d(1px,1px,1px)",e=t.getComputedStyle(o).getPropertyValue(r[a]));return n.body.removeChild(o),!(e!==i&&e.length>0&&"none"!==e)},mobile:function(){var e=navigator.userAgent,t=/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/,n=t.test(e);return n?(w.verbose("Browser was found to be mobile",e),!0):(w.verbose("Browser is not mobile, using regular transition",e),!1)},hidden:function(){return!w.is.visible()},visible:function(){return F.hasClass(k.visible)},open:function(){return w.is.visible()},closed:function(){return w.is.hidden()},vertical:function(){return F.hasClass(k.top)},animating:function(){return D.hasClass(k.animating)}},setting:function(t,n){if(w.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,C,t);else{if(n===i)return C[t];C[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,w,t);else{if(n===i)return w[t];w[t]=n}},debug:function(){C.debug&&(C.performance?w.performance.log(arguments):(w.debug=Function.prototype.bind.call(console.info,console,C.name+":"),w.debug.apply(console,arguments)))},verbose:function(){C.verbose&&C.debug&&(C.performance?w.performance.log(arguments):(w.verbose=Function.prototype.bind.call(console.info,console,C.name+":"),w.verbose.apply(console,arguments)))},error:function(){w.error=Function.prototype.bind.call(console.error,console,C.name+":"),w.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;C.performance&&(t=(new Date).getTime(),i=d||t,n=t-i,d=t,m.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:R,"Execution Time":n})),clearTimeout(w.performance.timer),w.performance.timer=setTimeout(w.performance.display,100)},display:function(){var t=C.name+":",n=0;d=!1,clearTimeout(w.performance.timer),e.each(m,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",u&&(t+=" '"+u+"'"),(console.group!==i||console.table!==i)&&m.length>0&&(console.groupCollapsed(t),console.table?console.table(m):e.each(m,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),m=[]}},invoke:function(t,n,o){var a,s,c,l=j;return n=n||g,o=R||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):(w.error(z.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(r)?r.push(c):r!==i?r=[r,c]:c!==i&&(r=c),s}},p?(j===i&&w.initialize(),w.invoke(f)):(j!==i&&w.invoke("destroy"),w.initialize())}),r!==i?r:this},e.fn.sidebar.settings={name:"Sidebar",namespace:"sidebar",debug:!1,verbose:!0,performance:!0,transition:"auto",mobileTransition:"auto",defaultTransition:{computer:{left:"uncover",right:"uncover",top:"overlay",bottom:"overlay"},mobile:{left:"uncover",right:"uncover",top:"overlay",bottom:"overlay"}},context:"body",exclusive:!1,closable:!0,dimPage:!0,scrollLock:!1,returnScroll:!1,useLegacy:!1,duration:500,easing:"easeInOutQuint",onChange:function(){},onShow:function(){},onHide:function(){},onHidden:function(){},onVisible:function(){},className:{active:"active",animating:"animating",dimmed:"dimmed",pushable:"pushable",pushed:"pushed",right:"right",top:"top",left:"left",bottom:"bottom",visible:"visible"},selector:{fixed:".fixed",omitted:"script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed",pusher:".pusher",sidebar:".ui.sidebar"},error:{method:"The method you called is not defined.",pusher:"Had to add pusher element. For optimal performance make sure body content is inside a pusher element",movedSidebar:"Had to move sidebar. For optimal performance make sure sidebar and pusher are direct children of your body tag",overlay:"The overlay setting is no longer supported, use animation: overlay",notFound:"There were no elements that matched the specified selector"}},e.extend(e.easing,{easeInOutQuint:function(e,t,n,i,o){return(t/=o/2)<1?i/2*t*t*t*t*t+n:i/2*((t-=2)*t*t*t*t+2)+n
-}})}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.sticky=function(n){var o,r=e(this),a=r.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return r.each(function(){var r,m,f,p=e.extend(!0,{},e.fn.sticky.settings,n),g=p.className,b=p.namespace,v=p.error,h="."+b,y="module-"+b,x=e(this),w=e(t),C=x.offsetParent(),T=e(p.scrollContext),k=(x.selector||"",x.data(y)),S=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)},z=this;f={initialize:function(){return r=p.context?e(p.context):C,0===r.size()?void f.error(v.invalidContext,p.context,x):(f.verbose("Initializing sticky",p,C),f.save.positions(),f.is.hidden()&&f.error(v.visible,x),f.cache.element.height>f.cache.context.height?(f.reset(),void f.error(v.elementSize,x)):(w.on("resize"+h,f.event.resize),T.on("scroll"+h,f.event.scroll),f.observeChanges(),void f.instantiate()))},instantiate:function(){f.verbose("Storing instance of module",f),k=f,x.data(y,f)},destroy:function(){f.verbose("Destroying previous module"),f.reset(),w.off("resize"+h,f.event.resize),T.off("scroll"+h,f.event.scroll),x.removeData(y)},observeChanges:function(){var e=r[0];"MutationObserver"in t&&(m=new MutationObserver(function(){clearTimeout(f.timer),f.timer=setTimeout(function(){f.verbose("DOM tree modified, updating sticky menu"),f.refresh()},200)}),m.observe(z,{childList:!0,subtree:!0}),m.observe(e,{childList:!0,subtree:!0}),f.debug("Setting up mutation observer",m))},event:{resize:function(){S(function(){f.refresh(),f.stick()})},scroll:function(){S(function(){f.stick(),e.proxy(p.onScroll,z)()})}},refresh:function(t){f.reset(),t&&(C=x.offsetParent()),f.save.positions(),f.stick(),e.proxy(p.onReposition,z)()},supports:{sticky:function(){{var t=e("<div/>");t.get()}return t.addClass(g.supported),t.css("position").match("sticky")}},save:{scroll:function(e){f.lastScroll=e},positions:function(){var e={height:w.height()},t={margin:{top:parseInt(x.css("margin-top"),10),bottom:parseInt(x.css("margin-bottom"),10)},offset:x.offset(),width:x.outerWidth(),height:x.outerHeight()},n={offset:r.offset(),height:r.outerHeight()};f.cache={fits:t.height<e.height,window:{height:e.height},element:{margin:t.margin,top:t.offset.top-t.margin.top,left:t.offset.left,width:t.width,height:t.height,bottom:t.offset.top+t.height},context:{top:n.offset.top,height:n.height,bottom:n.offset.top+n.height}},f.set.containerSize(),f.set.size(),f.stick(),f.debug("Caching element positions",f.cache)}},get:{direction:function(e){var t="down";return e=e||T.scrollTop(),f.lastScroll!==i&&(f.lastScroll<e?t="down":f.lastScroll>e&&(t="up")),t},scrollChange:function(e){return e=e||T.scrollTop(),f.lastScroll?e-f.lastScroll:0},currentElementScroll:function(){return f.is.top()?Math.abs(parseInt(x.css("top"),10))||0:Math.abs(parseInt(x.css("bottom"),10))||0},elementScroll:function(e){e=e||T.scrollTop();var t,n=f.cache.element,i=f.cache.window,o=f.get.scrollChange(e),r=n.height-i.height+p.offset,a=f.get.currentElementScroll(),s=a+o;return t=f.cache.fits||0>s?0:s>r?r:s}},remove:{offset:function(){x.css("margin-top","")}},set:{offset:function(){f.verbose("Setting offset on element",p.offset),x.css("margin-top",p.offset)},containerSize:function(){var e=C.get(0).tagName;"HTML"===e||"body"==e?C=x.offsetParent():(f.debug("Settings container size",f.cache.context.height),C.height(f.cache.context.height))},scroll:function(e){f.debug("Setting scroll on element",e),f.is.top()&&x.css("bottom","").css("top",-e),f.is.bottom()&&x.css("top","").css("bottom",e)},size:function(){0!==f.cache.element.height&&0!==f.cache.element.width&&x.css({width:f.cache.element.width,height:f.cache.element.height})}},is:{top:function(){return x.hasClass(g.top)},bottom:function(){return x.hasClass(g.bottom)},initialPosition:function(){return!f.is.fixed()&&!f.is.bound()},hidden:function(){return!x.is(":visible")},bound:function(){return x.hasClass(g.bound)},fixed:function(){return x.hasClass(g.fixed)}},stick:function(){var e=f.cache,t=e.fits,n=e.element,i=e.window,o=e.context,r=f.is.bottom()&&p.pushing?p.bottomOffset:p.offset,a={top:T.scrollTop()+r,bottom:T.scrollTop()+r+i.height},s=(f.get.direction(a.top),f.get.elementScroll(a.top)),c=!t,l=0!==n.height;f.save.scroll(a.top),l&&(f.is.initialPosition()?a.top>=n.top&&(f.debug("Element passed, fixing element to page"),f.fixTop()):f.is.fixed()?f.is.top()?a.top<n.top?(f.debug("Fixed element reached top of container"),f.setInitialPosition()):n.height+a.top-s>o.bottom?(f.debug("Fixed element reached bottom of container"),f.bindBottom()):c&&f.set.scroll(s):f.is.bottom()&&(a.bottom-n.height<n.top?(f.debug("Bottom fixed rail has reached top of container"),f.setInitialPosition()):a.bottom>o.bottom?(f.debug("Bottom fixed rail has reached bottom of container"),f.bindBottom()):c&&f.set.scroll(s)):f.is.bottom()&&(p.pushing?f.is.bound()&&a.bottom<o.bottom&&(f.debug("Fixing bottom attached element to bottom of browser."),f.fixBottom()):f.is.bound()&&a.top<o.bottom-n.height&&(f.debug("Fixing bottom attached element to top of browser."),f.fixTop())))},bindTop:function(){f.debug("Binding element to top of parent container"),f.remove.offset(),x.css("left","").css("top","").css("bottom","").removeClass(g.fixed).removeClass(g.bottom).addClass(g.bound).addClass(g.top),e.proxy(p.onTop,z)(),e.proxy(p.onUnstick,z)()},bindBottom:function(){f.debug("Binding element to bottom of parent container"),f.remove.offset(),x.css("left","").css("top","").css("bottom","").removeClass(g.fixed).removeClass(g.top).addClass(g.bound).addClass(g.bottom),e.proxy(p.onBottom,z)(),e.proxy(p.onUnstick,z)()},setInitialPosition:function(){f.unfix(),f.unbind()},fixTop:function(){f.debug("Fixing element to top of page"),f.set.offset(),x.css("left",f.cache.element.left).removeClass(g.bound).removeClass(g.bottom).addClass(g.fixed).addClass(g.top),e.proxy(p.onStick,z)()},fixBottom:function(){f.debug("Sticking element to bottom of page"),f.set.offset(),x.css("left",f.cache.element.left).removeClass(g.bound).removeClass(g.top).addClass(g.fixed).addClass(g.bottom),e.proxy(p.onStick,z)()},unbind:function(){f.debug("Removing absolute position on element"),f.remove.offset(),x.removeClass(g.bound).removeClass(g.top).removeClass(g.bottom)},unfix:function(){f.debug("Removing fixed position on element"),f.remove.offset(),x.removeClass(g.fixed).removeClass(g.top).removeClass(g.bottom),e.proxy(p.onUnstick,this)()},reset:function(){f.debug("Reseting elements position"),f.unbind(),f.unfix(),f.resetCSS()},resetCSS:function(){x.css({top:"",bottom:"",width:"",height:""}),C.css({height:""})},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,p,t);else{if(n===i)return p[t];p[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},debug:function(){p.debug&&(p.performance?f.performance.log(arguments):(f.debug=Function.prototype.bind.call(console.info,console,p.name+":"),f.debug.apply(console,arguments)))},verbose:function(){p.verbose&&p.debug&&(p.performance?f.performance.log(arguments):(f.verbose=Function.prototype.bind.call(console.info,console,p.name+":"),f.verbose.apply(console,arguments)))},error:function(){f.error=Function.prototype.bind.call(console.error,console,p.name+":"),f.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;p.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:z,"Execution Time":n})),clearTimeout(f.performance.timer),f.performance.timer=setTimeout(f.performance.display,0)},display:function(){var t=p.name+":",n=0;s=!1,clearTimeout(f.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",a&&(t+=" '"+a+"'"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,r){var a,s,c,l=k;return n=n||d,r=z||r,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(r,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},u?(k===i&&f.initialize(),f.invoke(l)):(k!==i&&f.destroy(),f.initialize())}),o!==i?o:this},e.fn.sticky.settings={name:"Sticky",namespace:"sticky",debug:!1,verbose:!1,performance:!1,pushing:!1,context:!1,scrollContext:t,offset:0,bottomOffset:0,onReposition:function(){},onScroll:function(){},onStick:function(){},onUnstick:function(){},onTop:function(){},onBottom:function(){},error:{container:"Sticky element must be inside a relative container",visible:"Element is hidden, you must call refresh after element becomes visible",method:"The method you called is not defined.",invalidContext:"Context specified does not exist",elementSize:"Sticky element is larger than its container, cannot create sticky."},className:{bound:"bound",fixed:"fixed",supported:"native",top:"top",bottom:"bottom"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.tab=e.fn.tab=function(n){var o,r,a=e(e.isFunction(this)?t:this),s=e.isPlainObject(n)?e.extend(!0,{},e.fn.tab.settings,n):e.extend({},e.fn.tab.settings),c=a.selector||"",l=(new Date).getTime(),u=[],d=arguments[0],m="string"==typeof d,f=[].slice.call(arguments,1);return a.each(function(){var n,p,g,b,v,h=s.className,y=s.metadata,x=s.selector,w=s.error,C="."+s.namespace,T="module-"+s.namespace,k=e(this),S={},z=!0,A=0,E=this,F=k.data(T);o={initialize:function(){o.debug("Initializing tab menu item",k),o.determineTabs(),o.debug("Determining tabs",s.context,p),s.auto&&(o.verbose("Setting up automatic tab retrieval from server"),s.apiSettings={url:s.path+"/{$tab}"}),e.isWindow(E)||(o.debug("Attaching tab activation events to element",k),k.on("click"+C,o.event.click)),o.instantiate()},determineTabs:function(){var t;"parent"===s.context?(k.closest(x.ui).size()>0?(t=k.closest(x.ui),o.verbose("Using closest UI element for determining parent",t)):t=k,n=t.parent(),o.verbose("Determined parent element for creating context",n)):s.context?(n=e(s.context),o.verbose("Using selector for tab context",s.context,n)):n=e("body"),s.childrenOnly?(p=n.children(x.tabs),o.debug("Searching tab context children for tabs",n,p)):(p=n.find(x.tabs),o.debug("Searching tab context for tabs",n,p))},initializeHistory:function(){if(s.history){if(o.debug("Initializing page state"),e.address===i)return o.error(w.state),!1;if("state"==s.historyType){if(o.debug("Using HTML5 to manage state"),s.path===!1)return o.error(w.path),!1;e.address.history(!0).state(s.path)}e.address.bind("change",o.event.history.change)}},instantiate:function(){o.verbose("Storing instance of module",o),k.data(T,o)},destroy:function(){o.debug("Destroying tabs",k),k.removeData(T).off(C)},event:{click:function(t){var n=e(this).data(y.tab);n!==i?(s.history?(o.verbose("Updating page state",t),e.address.value(n)):(o.verbose("Changing tab",t),o.changeTab(n)),t.preventDefault()):o.debug("No tab specified")},history:{change:function(t){var n=t.pathNames.join("/")||o.get.initialPath(),r=s.templates.determineTitle(n)||!1;o.performance.display(),o.debug("History change event",n,t),v=t,n!==i&&o.changeTab(n),r&&e.address.title(r)}}},refresh:function(){g&&(o.debug("Refreshing tab",g),o.changeTab(g))},cache:{read:function(e){return e!==i?S[e]:!1},add:function(e,t){e=e||g,o.debug("Adding cached content for",e),S[e]=t},remove:function(e){e=e||g,o.debug("Removing cached content for",e),delete S[e]}},set:{state:function(t){e.address.value(t)}},changeTab:function(i){var r=t.history&&t.history.pushState,a=r&&s.ignoreFirstLoad&&z,c=s.auto||e.isPlainObject(s.apiSettings),l=c&&!a?o.utilities.pathToArray(i):o.get.defaultPathArray(i);i=o.utilities.arrayToPath(l),e.each(l,function(t,r){var u,d,m,f,p=l.slice(0,t+1),h=o.utilities.arrayToPath(p),y=o.is.tab(h),x=t+1==l.length,C=o.get.tabElement(h);if(o.verbose("Looking for tab",r),y){if(o.verbose("Tab was found",r),g=h,b=o.utilities.filterArray(l,p),x?f=!0:(d=l.slice(0,t+2),m=o.utilities.arrayToPath(d),f=!o.is.tab(m),f&&o.verbose("Tab parameters found",d)),f&&c)return a?(o.debug("Ignoring remote content on first tab load",h),z=!1,o.cache.add(i,C.html()),o.activate.all(h),e.proxy(s.onTabInit,C)(h,b,v),e.proxy(s.onTabLoad,C)(h,b,v)):(o.activate.navigation(h),o.content.fetch(h,i)),!1;o.debug("Opened local tab",h),o.activate.all(h),o.cache.read(h)||(o.cache.add(h,!0),o.debug("First time tab loaded calling tab init"),e.proxy(s.onTabInit,C)(h,b,v)),e.proxy(s.onTabLoad,C)(h,b,v)}else{if(-1!=i.search("/"))return o.error(w.missingTab,k,n,h),!1;if(u=e("#"+i+', a[name="'+i+'"]'),h=u.closest("[data-tab]").data("tab"),C=o.get.tabElement(h),u&&u.size()>0&&h)return o.debug("No tab found, but deep anchor link present, opening parent tab"),o.activate.all(h),o.cache.read(h)||(o.cache.add(h,!0),o.debug("First time tab loaded calling tab init"),e.proxy(s.onTabInit,C)(h,b,v)),!1}})},content:{fetch:function(t,n){var r,a,c=o.get.tabElement(t),l={dataType:"html",stateContext:c,onSuccess:function(i){o.cache.add(n,i),o.content.update(t,i),t==g?(o.debug("Content loaded",t),o.activate.tab(t)):o.debug("Content loaded in background",t),e.proxy(s.onTabInit,c)(t,b,v),e.proxy(s.onTabLoad,c)(t,b,v)},urlData:{tab:n}},u=c.data(y.promise)||!1,d=u&&"pending"===u.state();n=n||t,a=o.cache.read(n),s.cache&&a?(o.debug("Showing existing content",n),o.content.update(t,a),o.activate.tab(t),e.proxy(s.onTabLoad,c)(t,b,v)):d?(o.debug("Content is already loading",n),c.addClass(h.loading)):e.api!==i?(r=e.extend(!0,{headers:{"X-Remote":!0}},s.apiSettings,l),o.debug("Retrieving remote content",n,r),e.api(r)):o.error(w.api)},update:function(e,t){o.debug("Updating html for",e);var n=o.get.tabElement(e);n.html(t)}},activate:{all:function(e){o.activate.tab(e),o.activate.navigation(e)},tab:function(e){var t=o.get.tabElement(e);o.verbose("Showing tab content for",t),t.addClass(h.active).siblings(p).removeClass(h.active+" "+h.loading)},navigation:function(e){var t=o.get.navElement(e);o.verbose("Activating tab navigation for",t,e),t.addClass(h.active).siblings(a).removeClass(h.active+" "+h.loading)}},deactivate:{all:function(){o.deactivate.navigation(),o.deactivate.tabs()},navigation:function(){a.removeClass(h.active)},tabs:function(){p.removeClass(h.active+" "+h.loading)}},is:{tab:function(e){return e!==i?o.get.tabElement(e).size()>0:!1}},get:{initialPath:function(){return a.eq(0).data(y.tab)||p.eq(0).data(y.tab)},path:function(){return e.address.value()},defaultPathArray:function(e){return o.utilities.pathToArray(o.get.defaultPath(e))},defaultPath:function(e){var t=a.filter("[data-"+y.tab+'^="'+e+'/"]').eq(0),n=t.data(y.tab)||!1;if(n){if(o.debug("Found default tab",n),A<s.maxDepth)return A++,o.get.defaultPath(n);o.error(w.recursion)}else o.debug("No default tabs found for",e,p);return A=0,e},navElement:function(e){return e=e||g,a.filter("[data-"+y.tab+'="'+e+'"]')},tabElement:function(e){var t,n,i,r;return e=e||g,i=o.utilities.pathToArray(e),r=o.utilities.last(i),t=p.filter("[data-"+y.tab+'="'+r+'"]'),n=p.filter("[data-"+y.tab+'="'+e+'"]'),t.size()>0?t:n},tab:function(){return g}},utilities:{filterArray:function(t,n){return e.grep(t,function(t){return-1==e.inArray(t,n)})},last:function(t){return e.isArray(t)?t[t.length-1]:!1},pathToArray:function(e){return e===i&&(e=g),"string"==typeof e?e.split("/"):[e]},arrayToPath:function(t){return e.isArray(t)?t.join("/"):!1}},setting:function(t,n){if(o.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,s,t);else{if(n===i)return s[t];s[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,o,t);else{if(n===i)return o[t];o[t]=n}},debug:function(){s.debug&&(s.performance?o.performance.log(arguments):(o.debug=Function.prototype.bind.call(console.info,console,s.name+":"),o.debug.apply(console,arguments)))},verbose:function(){s.verbose&&s.debug&&(s.performance?o.performance.log(arguments):(o.verbose=Function.prototype.bind.call(console.info,console,s.name+":"),o.verbose.apply(console,arguments)))},error:function(){o.error=Function.prototype.bind.call(console.error,console,s.name+":"),o.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;s.performance&&(t=(new Date).getTime(),i=l||t,n=t-i,l=t,u.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:E,"Execution Time":n})),clearTimeout(o.performance.timer),o.performance.timer=setTimeout(o.performance.display,100)},display:function(){var t=s.name+":",n=0;l=!1,clearTimeout(o.performance.timer),e.each(u,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",c&&(t+=" '"+c+"'"),(console.group!==i||console.table!==i)&&u.length>0&&(console.groupCollapsed(t),console.table?console.table(u):e.each(u,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),u=[]}},invoke:function(t,n,a){var s,c,l,u=F;return n=n||f,a=E||a,"string"==typeof t&&u!==i&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(n,r){var a=n!=s?r+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(u[a])&&n!=s)u=u[a];else{if(u[a]!==i)return c=u[a],!1;if(!e.isPlainObject(u[r])||n==s)return u[r]!==i?(c=u[r],!1):(o.error(w.method,t),!1);u=u[r]}})),e.isFunction(c)?l=c.apply(a,n):c!==i&&(l=c),e.isArray(r)?r.push(l):r!==i?r=[r,l]:l!==i&&(r=l),c}},m?(F===i&&o.initialize(),o.invoke(d)):(F!==i&&o.destroy(),o.initialize())}),o&&!m&&o.initializeHistory(),r!==i?r:this},e.tab=function(n){e(t).tab(n)},e.fn.tab.settings={name:"Tab",namespace:"tab",debug:!1,verbose:!0,performance:!0,auto:!1,history:!1,historyType:"hash",path:!1,context:!1,childrenOnly:!1,maxDepth:25,ignoreFirstLoad:!1,alwaysRefresh:!1,cache:!0,apiSettings:!1,onTabInit:function(){},onTabLoad:function(){},templates:{determineTitle:function(){}},error:{api:"You attempted to load content without API module",method:"The method you called is not defined",missingTab:"Activated tab cannot be found for this context.",noContent:"The tab you specified is missing a content url.",path:"History enabled, but no path was specified",recursion:"Max recursive depth reached",state:"History requires Asual's Address library <https://github.com/asual/jquery-address>"},metadata:{tab:"tab",loaded:"loaded",promise:"promise"},className:{loading:"loading",active:"active"},selector:{tabs:".ui.tab",ui:".ui"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.transition=function(){{var o,r=e(this),a=r.selector||"",s=(new Date).getTime(),c=[],l=arguments,u=l[0],d=[].slice.call(arguments,1),m="string"==typeof u;t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)}}return r.each(function(){var t,f,p,g,b,v,h,y,x,w,C,T,k=e(this),S=this;T={initialize:function(){w="module-"+x,t=T.get.settings.apply(S,l),g=t.className,b=t.metadata,v=T.get.animationStartEvent(),h=T.get.animationEndEvent(),y=T.get.animationName(),p=t.error,x=t.namespace,C="."+t.namespace,f=k.data(w)||T,m&&(m=T.invoke(u)),m===!1&&(T.verbose("Converted arguments into settings object",t),T.animate(),T.instantiate())},instantiate:function(){T.verbose("Storing instance of module",T),k.data(w,f)},destroy:function(){T.verbose("Destroying previous module for",S),k.removeData(w)},refresh:function(){T.verbose("Refreshing display type on next animation"),delete T.displayType},forceRepaint:function(){T.verbose("Forcing element repaint");var e=k.parent(),t=k.next();0===t.size()?k.detach().appendTo(e):k.detach().insertBefore(t)},repaint:function(){T.verbose("Repainting element");S.offsetWidth},animate:function(e){return t=e||t,T.is.supported()?(T.debug("Preparing animation",t.animation),T.is.animating()&&t.queue?(!t.allowRepeats&&T.has.direction()&&T.is.occuring()&&T.queuing!==!0?T.error(p.repeated,t.animation,k):T.queue(t.animation),!1):void(T.can.animate()?T.set.animating(t.animation):T.error(p.noAnimation,t.animation))):(T.error(p.support),!1)},reset:function(){T.debug("Resetting animation to beginning conditions"),T.remove.animationEndCallback(),T.restore.conditions(),T.remove.animating()},queue:function(e){T.debug("Queueing animation of",e),T.queuing=!0,k.one(h+C,function(){T.queuing=!1,T.repaint(),T.animate.apply(this,t)})},complete:function(){T.verbose("CSS animation complete",t.animation),T.remove.animationEndCallback(),T.remove.failSafe(),T.is.looping()||(T.is.outward()?(T.verbose("Animation is outward, hiding element"),T.restore.conditions(),T.hide(),e.proxy(t.onHide,this)()):T.is.inward()?(T.verbose("Animation is outward, showing element"),T.restore.conditions(),T.show(),T.set.display(),e.proxy(t.onShow,this)()):T.restore.conditions(),T.remove.animation(),T.remove.animating()),e.proxy(t.onComplete,this)()},has:{direction:function(e){return e=e||t.animation,-1!==e.search(g.inward)||-1!==e.search(g.outward)?(T.debug("Direction already set in animation"),!0):!1},inlineDisplay:function(){var t=k.attr("style")||"";return e.isArray(t.match(/display.*?;/,""))}},set:{animating:function(n){n=n||t.animation,T.is.animating()||T.save.conditions(),T.remove.direction(),T.remove.animationEndCallback(),T.can.transition()&&!T.has.direction()&&T.set.direction(),T.remove.hidden(),T.set.display(),k.addClass(g.animating).addClass(g.transition).addClass(n).one(h+".complete"+C,T.complete),t.useFailSafe&&T.add.failSafe(),T.set.duration(t.duration),e.proxy(t.onStart,this)(),T.debug("Starting tween",n,k.attr("class"))},duration:function(e,n){n=n||t.duration,n="number"==typeof n?n+"ms":n,T.verbose("Setting animation duration",n),k.css({"-webkit-animation-duration":n,"-moz-animation-duration":n,"-ms-animation-duration":n,"-o-animation-duration":n,"animation-duration":n})},display:function(){var e=T.get.style(),t=T.get.displayType(),n=e+"display: "+t+" !important;";k.css("display",""),T.refresh(),k.css("display")!==t&&(T.verbose("Setting inline visibility to",t),k.attr("style",n))},direction:function(){k.is(":visible")&&!T.is.hidden()?(T.debug("Automatically determining the direction of animation","Outward"),k.removeClass(g.inward).addClass(g.outward)):(T.debug("Automatically determining the direction of animation","Inward"),k.removeClass(g.outward).addClass(g.inward))},looping:function(){T.debug("Transition set to loop"),k.addClass(g.looping)},hidden:function(){T.is.hidden()||(k.addClass(g.transition).addClass(g.hidden),"none"!==k.css("display")&&(T.verbose("Overriding default display to hide element"),k.css("display","none")))},visible:function(){k.addClass(g.transition).addClass(g.visible)}},save:{displayType:function(e){k.data(b.displayType,e)},transitionExists:function(t,n){e.fn.transition.exists[t]=n,T.verbose("Saving existence of transition",t,n)},conditions:function(){k.attr("class")||!1,k.attr("style")||"";k.removeClass(t.animation),T.remove.direction(),T.cache={className:k.attr("class"),style:T.get.style()},T.verbose("Saving original attributes",T.cache)}},restore:{conditions:function(){return T.cache===i?!1:(T.cache.className?k.attr("class",T.cache.className):k.removeAttr("class"),T.cache.style&&(T.verbose("Restoring original style attribute",T.cache.style),k.attr("style",T.cache.style)),T.is.looping()&&T.remove.looping(),void T.verbose("Restoring original attributes",T.cache))}},add:{failSafe:function(){var e=T.get.duration();T.timer=setTimeout(T.complete,e+100),T.verbose("Adding fail safe timer",T.timer)}},remove:{animating:function(){k.removeClass(g.animating)},animation:function(){k.css({"-webkit-animation":"","-moz-animation":"","-ms-animation":"","-o-animation":"",animation:""})},animationEndCallback:function(){k.off(".complete")},display:function(){k.css("display","")},direction:function(){k.removeClass(g.inward).removeClass(g.outward)},failSafe:function(){T.verbose("Removing fail safe timer",T.timer),T.timer&&clearTimeout(T.timer)},hidden:function(){k.removeClass(g.hidden)},visible:function(){k.removeClass(g.visible)},looping:function(){T.debug("Transitions are no longer looping"),k.removeClass(g.looping),T.forceRepaint()},transition:function(){k.removeClass(g.visible).removeClass(g.hidden)}},get:{settings:function(t,n,i){return"object"==typeof t?e.extend(!0,{},e.fn.transition.settings,t):"function"==typeof i?e.extend({},e.fn.transition.settings,{animation:t,onComplete:i,duration:n}):"string"==typeof n||"number"==typeof n?e.extend({},e.fn.transition.settings,{animation:t,duration:n}):"object"==typeof n?e.extend({},e.fn.transition.settings,n,{animation:t}):"function"==typeof n?e.extend({},e.fn.transition.settings,{animation:t,onComplete:n}):e.extend({},e.fn.transition.settings,{animation:t})},duration:function(e){return e=e||t.duration,"string"==typeof t.duration?e.indexOf("ms")>-1?parseFloat(e):1e3*parseFloat(e):e},displayType:function(){return t.displayType?t.displayType:(k.data(b.displayType)===i&&T.can.transition(!0),k.data(b.displayType))},style:function(){var e=k.attr("style")||"";return e.replace(/display.*?;/,"")},transitionExists:function(t){return e.fn.transition.exists[t]},animationName:function(){var e,t=n.createElement("div"),o={animation:"animationName",OAnimation:"oAnimationName",MozAnimation:"mozAnimationName",WebkitAnimation:"webkitAnimationName"};for(e in o)if(t.style[e]!==i)return o[e];return!1},animationStartEvent:function(){var e,t=n.createElement("div"),o={animation:"animationstart",OAnimation:"oAnimationStart",MozAnimation:"mozAnimationStart",WebkitAnimation:"webkitAnimationStart"};for(e in o)if(t.style[e]!==i)return o[e];return!1},animationEndEvent:function(){var e,t=n.createElement("div"),o={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"mozAnimationEnd",WebkitAnimation:"webkitAnimationEnd"};for(e in o)if(t.style[e]!==i)return o[e];return!1}},can:{transition:function(n){var o,r,a,s,c,l=k.attr("class"),u=k.prop("tagName"),d=t.animation,m=T.get.transitionExists(d);if(m===i||n){if(T.verbose("Determining whether animation exists"),o=e("<"+u+" />").addClass(l).insertAfter(k),r=o.addClass(d).removeClass(g.inward).removeClass(g.outward).addClass(g.animating).addClass(g.transition).css(y),a=o.addClass(g.inward).css(y),c=o.attr("class",l).removeAttr("style").removeClass(g.hidden).removeClass(g.visible).show().css("display"),T.verbose("Determining final display state",c),o.remove(),r!=a)T.debug("Direction exists for animation",d),s=!0;else{if("none"==r||!r)return void T.debug("No animation defined in css",d);T.debug("Static animation found",d,c),s=!1}T.save.displayType(c),T.save.transitionExists(d,s)}return m!==i?m:s},animate:function(){return T.can.transition()!==i}},is:{animating:function(){return k.hasClass(g.animating)},inward:function(){return k.hasClass(g.inward)},outward:function(){return k.hasClass(g.outward)},looping:function(){return k.hasClass(g.looping)},occuring:function(e){return e=e||t.animation,e=e.replace(" ","."),k.filter(e).size()>0},visible:function(){return k.is(":visible")},hidden:function(){return"hidden"===k.css("visibility")},supported:function(){return y!==!1&&h!==!1}},hide:function(){T.verbose("Hiding element"),T.is.animating()&&T.reset(),T.remove.display(),T.remove.visible(),T.set.hidden(),T.repaint()},show:function(e){T.verbose("Showing element",e),T.remove.hidden(),T.set.visible(),T.repaint()},start:function(){T.verbose("Starting animation"),k.removeClass(g.disabled)},stop:function(){T.debug("Stopping animation"),k.addClass(g.disabled)},toggle:function(){T.debug("Toggling play status"),k.toggleClass(g.disabled)},setting:function(n,o){if(T.debug("Changing setting",n,o),e.isPlainObject(n))e.extend(!0,t,n);else{if(o===i)return t[n];t[n]=o}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,T,t);else{if(n===i)return T[t];T[t]=n}},debug:function(){t.debug&&(t.performance?T.performance.log(arguments):(T.debug=Function.prototype.bind.call(console.info,console,t.name+":"),T.debug.apply(console,arguments)))},verbose:function(){t.verbose&&t.debug&&(t.performance?T.performance.log(arguments):(T.verbose=Function.prototype.bind.call(console.info,console,t.name+":"),T.verbose.apply(console,arguments)))},error:function(){T.error=Function.prototype.bind.call(console.error,console,t.name+":"),T.error.apply(console,arguments)},performance:{log:function(e){var n,i,o;t.performance&&(n=(new Date).getTime(),o=s||n,i=n-o,s=n,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:S,"Execution Time":i})),clearTimeout(T.performance.timer),T.performance.timer=setTimeout(T.performance.display,600)},display:function(){var n=t.name+":",o=0;s=!1,clearTimeout(T.performance.timer),e.each(c,function(e,t){o+=t["Execution Time"]}),n+=" "+o+"ms",a&&(n+=" '"+a+"'"),r.size()>1&&(n+=" ("+r.size()+")"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(n),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,r){var a,s,c,l=f;return n=n||d,r=S||r,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(r,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s!==i?s:!1}},T.initialize()}),o!==i?o:this},e.fn.transition.exists={},e.fn.transition.settings={name:"Transition",debug:!1,verbose:!0,performance:!0,namespace:"transition",onStart:function(){},onComplete:function(){},onShow:function(){},onHide:function(){},useFailSafe:!1,allowRepeats:!1,displayType:!1,animation:"fade",duration:"500ms",queue:!0,metadata:{displayType:"display"},className:{animating:"animating",disabled:"disabled",hidden:"hidden",inward:"in",loading:"loading",looping:"looping",outward:"out",transition:"transition",visible:"visible"},error:{noAnimation:"There is no css animation matching the one you specified.",repeated:"That animation is already occurring, cancelling repeated animation",method:"The method you called is not defined",support:"This browser does not support CSS animations"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.video=function(n){{var o,r=e(this),a=r.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)}}return r.each(function(){var m,f=e.isPlainObject(n)?e.extend(!0,{},e.fn.video.settings,n):e.extend({},e.fn.video.settings),p=f.selector,g=f.className,b=f.error,v=f.metadata,h=f.namespace,y=f.templates,x="."+h,w="module-"+h,C=(e(t),e(this)),T=C.find(p.placeholder),k=C.find(p.playButton),S=C.find(p.embed),z=this,A=C.data(w);m={initialize:function(){m.debug("Initializing video"),m.create(),T.on("click"+x,m.play),k.on("click"+x,m.play),m.instantiate()},instantiate:function(){m.verbose("Storing instance of module",m),A=m,C.data(w,m)},create:function(){var e=C.data(v.image),t=y.video(e);C.html(t),m.refresh(),e||m.play(),m.debug("Creating html for video element",t)},destroy:function(){m.verbose("Destroying previous instance of video"),m.reset(),C.removeData(w).off(x),T.off(x),k.off(x)},refresh:function(){m.verbose("Refreshing selector cache"),T=C.find(p.placeholder),k=C.find(p.playButton),S=C.find(p.embed)},change:function(e,t,n){m.debug("Changing video to ",e,t,n),C.data(v.source,e).data(v.id,t).data(v.url,n),f.onChange()},reset:function(){m.debug("Clearing video embed and showing placeholder"),C.removeClass(g.active),S.html(" "),T.show(),f.onReset()},play:function(){m.debug("Playing video");var e=C.data(v.source)||!1,t=C.data(v.url)||!1,n=C.data(v.id)||!1;S.html(m.generate.html(e,n,t)),C.addClass(g.active),f.onPlay()},get:{source:function(e){return"string"!=typeof e?!1:-1!==e.search("youtube.com")?"youtube":-1!==e.search("vimeo.com")?"vimeo":!1
-},id:function(e){return f.regExp.youtube.test(e)?e.match(f.regExp.youtube)[1]:f.regExp.vimeo.test(e)?e.match(f.regExp.vimeo)[2]:!1}},generate:{html:function(e,t,n){m.debug("Generating embed html");var i;return e=e||f.source,t=t||f.id,e&&t||n?(e&&t||(e=m.get.source(n),t=m.get.id(n)),"vimeo"==e?i='<iframe src="http://player.vimeo.com/video/'+t+"?="+m.generate.url(e)+'" width="100%" height="100%" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>':"youtube"==e&&(i='<iframe src="http://www.youtube.com/embed/'+t+"?="+m.generate.url(e)+'" width="100%" height="100%" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>')):m.error(b.noVideo),i},url:function(e){var t=f.api?1:0,n="auto"===f.autoplay?C.data("image")!==i:f.autoplay,o=f.hd?1:0,r=f.showUI?1:0,a=f.showUI?0:1,s="";return"vimeo"==e&&(s="api="+t+"&amp;title="+r+"&amp;byline="+r+"&amp;portrait="+r+"&amp;autoplay="+n,f.color&&(s+="&amp;color="+f.color)),"ustream"==e?(s="autoplay="+n,f.color&&(s+="&amp;color="+f.color)):"youtube"==e&&(s="enablejsapi="+t+"&amp;autoplay="+n+"&amp;autohide="+a+"&amp;hq="+o+"&amp;modestbranding=1",f.color&&(s+="&amp;color="+f.color)),s}},setting:function(t,n){if(m.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,m,t);else{if(n===i)return m[t];m[t]=n}},debug:function(){f.debug&&(f.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,f.name+":"),m.debug.apply(console,arguments)))},verbose:function(){f.verbose&&f.debug&&(f.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,f.name+":"),m.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;f.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:z,"Execution Time":n})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,100)},display:function(){var t=f.name+":",n=0;s=!1,clearTimeout(m.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",a&&(t+=" '"+a+"'"),r.size()>1&&(t+=" ("+r.size()+")"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,r){var a,s,c,l=A;return n=n||d,r=z||r,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(r,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},u?(A===i&&m.initialize(),m.invoke(l)):(A!==i&&m.destroy(),m.initialize())}),o!==i?o:this},e.fn.video.settings={name:"Video",namespace:"video",debug:!1,verbose:!0,performance:!0,metadata:{id:"id",image:"image",source:"source",url:"url"},source:!1,url:!1,id:!1,aspectRatio:16/9,onPlay:function(){},onReset:function(){},onChange:function(){},onPause:function(){},onStop:function(){},width:"auto",height:"auto",autoplay:"auto",color:"#442359",hd:!0,showUI:!1,api:!0,regExp:{youtube:/^(?:https?:\/\/)?(?:www\.)?(?:youtu\.be\/|youtube\.com\/(?:embed\/|v\/|watch\?v=|watch\?.+&v=))((\w|-){11})(?:\S+)?$/,vimeo:/http:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/},error:{noVideo:"No video specified",method:"The method you called is not defined"},className:{active:"active"},selector:{embed:".embed",placeholder:".placeholder",playButton:".play"}},e.fn.video.settings.templates={video:function(e){var t="";return e&&(t+='<i class="video play icon"></i><img class="placeholder" src="'+e+'">'),t+='<div class="embed"></div>'}}}(jQuery,window,document),function(e,t,n,i){e.api=e.fn.api=function(n){var o,r=e(e.isFunction(this)?t:this),a=r.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return r.each(function(){var t,r,m,f,p,g=e.isPlainObject(n)?e.extend(!0,{},e.fn.api.settings,n):e.extend({},e.fn.api.settings),b=g.namespace,v=(g.metadata,g.selector),h=g.error,y=g.className,x="."+b,w="module-"+b,C=e(this),T=C.closest(v.form),k=g.stateContext?e(g.stateContext):C,S=this,z=k.get(),A=C.data(w);p={initialize:function(){var e=p.get.event();u||(e?(p.debug("Attaching API events to element",e),C.on(e+x,p.event.trigger)):p.query()),p.instantiate()},instantiate:function(){p.verbose("Storing instance of module",p),A=p,C.data(w,A)},destroy:function(){p.verbose("Destroying previous module for",S),C.removeData(w).off(x)},query:function(){if(p.is.disabled())return void p.debug("Element is disabled API request aborted");if(p.is.loading()&&0===g.throttle)return void p.debug("Cancelling request, previous request is still pending");if(g.defaultData&&e.extend(!0,g.urlData,p.get.defaultData()),(g.serializeForm!==!1||k.is("form"))&&("json"==g.serializeForm?e.extend(!0,g.data,p.get.formData()):g.data=p.get.formData()),r=p.get.settings(),r===!1)return void p.error(h.beforeSend);if(g.url?(p.debug("Using specified url",m),m=p.add.urlData(g.url)):(m=p.add.urlData(p.get.templateURL()),p.debug("Added URL Data to url",m)),!m){if(!C.is("form"))return void p.error(h.missingURL,g.action);p.debug("No url or action specified, defaulting to form action"),m=C.attr("action")}p.set.loading(),t=e.extend(!0,{},g,{type:g.method||g.type,data:f,url:g.base+m,beforeSend:g.beforeXHR,success:function(){},failure:function(){},complete:function(){}}),p.verbose("Creating AJAX request with settings",t),p.is.loading()?p.timer=setTimeout(function(){p.request=p.create.request(),p.xhr=p.create.xhr()},g.throttle):(p.request=p.create.request(),p.xhr=p.create.xhr())},is:{disabled:function(){return C.filter(g.filter).size()>0},loading:function(){return p.request&&"pending"==p.request.state()}},was:{succesful:function(){return p.request&&"resolved"==p.request.state()},failure:function(){return p.request&&"rejected"==p.request.state()},complete:function(){return p.request&&("resolved"==p.request.state()||"rejected"==p.request.state())}},add:{urlData:function(t,n){var o,r;return t&&(o=t.match(g.regExp.required),r=t.match(g.regExp.optional),n=n||g.urlData,o&&(p.debug("Looking for required URL variables",o),e.each(o,function(o,r){var a=-1!==r.indexOf("$")?r.substr(2,r.length-3):r.substr(1,r.length-2),s=e.isPlainObject(n)&&n[a]!==i?n[a]:C.data(a)!==i?C.data(a):k.data(a)!==i?k.data(a):n[a];return s===i?(p.error(h.requiredParameter,a,t),t=!1,!1):(p.verbose("Found required variable",a,s),void(t=t.replace(r,s)))})),r&&(p.debug("Looking for optional URL variables",o),e.each(r,function(o,r){var a=-1!==r.indexOf("$")?r.substr(3,r.length-4):r.substr(2,r.length-3),s=e.isPlainObject(n)&&n[a]!==i?n[a]:C.data(a)!==i?C.data(a):k.data(a)!==i?k.data(a):n[a];s!==i?(p.verbose("Optional variable Found",a,s),t=t.replace(r,s)):(p.verbose("Optional variable not found",a),t=-1!==t.indexOf("/"+r)?t.replace("/"+r,""):t.replace(r,""))}))),t}},event:{trigger:function(e){p.query(),("submit"==e.type||"click"==e.type)&&e.preventDefault()},xhr:{always:function(){},done:function(e){var t=this,n=(new Date).getTime()-s,i=g.loadingDuration-n;i=i>0?i:0,setTimeout(function(){p.request.resolveWith(t,[e])},i)},fail:function(e,t,n){var i=this,o=(new Date).getTime()-s,r=g.loadingDuration-o;r=r>0?r:0,setTimeout(function(){"abort"!==t?p.request.rejectWith(i,[e,t,n]):p.reset()},r)}},request:{complete:function(t){p.remove.loading(),e.proxy(g.onComplete,z)(t,C)},done:function(t){p.debug("API Response Received",t),"json"==g.dataType&&e.isFunction(g.successTest)?(p.debug("Checking JSON returned success",g.successTest,t),g.successTest(t)?e.proxy(g.onSuccess,z)(t,C):(p.debug("JSON test specified by user and response failed",t),e.proxy(g.onFailure,z)(t,C))):e.proxy(g.onSuccess,z)(t,C)},error:function(t,n,o){var r,a=g.error[n]!==i?g.error[n]:o;if(t!==i)if(t.readyState!==i&&4==t.readyState){if(200!=t.status&&o!==i&&""!==o)p.error(h.statusMessage+o);else if("error"==n&&"json"==g.dataType)try{r=e.parseJSON(t.responseText),r&&r.error!==i&&(a=r.error)}catch(s){p.error(h.JSONParse)}p.remove.loading(),p.set.error(),g.errorDuration&&setTimeout(p.remove.error,g.errorDuration),p.debug("API Request error:",a),e.proxy(g.onError,z)(a,z)}else e.proxy(g.onAbort,z)(a,z),p.debug("Request Aborted (Most likely caused by page change or CORS Policy)",n,o)}}},create:{request:function(){return e.Deferred().always(p.event.request.complete).done(p.event.request.done).fail(p.event.request.error)},xhr:function(){e.ajax(t).always(p.event.xhr.always).done(p.event.xhr.done).fail(p.event.xhr.fail)}},set:{error:function(){p.verbose("Adding error state to element",k),k.addClass(y.error)},loading:function(){p.verbose("Adding loading state to element",k),k.addClass(y.loading)}},remove:{error:function(){p.verbose("Removing error state from element",k),k.removeClass(y.error)},loading:function(){p.verbose("Removing loading state from element",k),k.removeClass(y.loading)}},get:{request:function(){return p.request||!1},xhr:function(){return p.xhr||!1},settings:function(){var t;return t=e.proxy(g.beforeSend,C)(g),t&&(t.success!==i&&(p.debug("Legacy success callback detected",t),p.error(h.legacyParameters,t.success),t.onSuccess=t.success),t.failure!==i&&(p.debug("Legacy failure callback detected",t),p.error(h.legacyParameters,t.failure),t.onFailure=t.failure),t.complete!==i&&(p.debug("Legacy complete callback detected",t),p.error(h.legacyParameters,t.complete),t.onComplete=t.complete)),t===i&&p.error(h.noReturnedValue),t!==i?t:g},defaultData:function(){var t={};return e.isWindow(S)||(C.is("input")?t.value=C.val():C.is("form")||(t.text=C.text())),t},event:function(){return e.isWindow(S)||"now"==g.on?(p.debug("API called without element, no events attached"),!1):"auto"==g.on?C.is("input")?S.oninput!==i?"input":S.onpropertychange!==i?"propertychange":"keyup":C.is("form")?"submit":"click":g.on},formData:function(){var t;return e(this).serializeObject()!==i?t=T.serializeObject():(p.error(h.missingSerialize),t=T.serialize()),p.debug("Retrieved form data",t),t},templateURL:function(e){var t;return e=e||C.data(g.metadata.action)||g.action||!1,e&&(p.debug("Looking up url for action",e,g.api),g.api[e]!==i?(t=g.api[e],p.debug("Found template url",t)):p.error(h.missingAction,g.action,g.api)),t}},reset:function(){p.remove.error(),p.remove.loading()},setting:function(t,n){if(p.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,g,t);else{if(n===i)return g[t];g[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,p,t);else{if(n===i)return p[t];p[t]=n}},debug:function(){g.debug&&(g.performance?p.performance.log(arguments):(p.debug=Function.prototype.bind.call(console.info,console,g.name+":"),p.debug.apply(console,arguments)))},verbose:function(){g.verbose&&g.debug&&(g.performance?p.performance.log(arguments):(p.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),p.verbose.apply(console,arguments)))},error:function(){p.error=Function.prototype.bind.call(console.error,console,g.name+":"),p.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;g.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"","Execution Time":n})),clearTimeout(p.performance.timer),p.performance.timer=setTimeout(p.performance.display,100)},display:function(){var t=g.name+":",n=0;s=!1,clearTimeout(p.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",a&&(t+=" '"+a+"'"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,r){var a,s,c,l=A;return n=n||d,r=S||r,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):(p.error(h.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(r,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},u?(A===i&&p.initialize(),p.invoke(l)):(A!==i&&p.destroy(),p.initialize())}),o!==i?o:this},e.api.settings={name:"API",namespace:"api",debug:!1,verbose:!0,performance:!0,on:"auto",filter:".disabled",stateContext:!1,loadingDuration:0,errorDuration:2e3,action:!1,url:!1,base:"",urlData:{},defaultData:!0,serializeForm:!1,throttle:0,method:"get",data:{},dataType:"json",beforeSend:function(e){return e},beforeXHR:function(){},onSuccess:function(){},onComplete:function(){},onFailure:function(){},onError:function(){},onAbort:function(){},successTest:!1,error:{beforeSend:"The before send function has aborted the request",error:"There was an error with your request",exitConditions:"API Request Aborted. Exit conditions met",JSONParse:"JSON could not be parsed during error handling",legacyParameters:"You are using legacy API success callback names",missingAction:"API action used but no url was defined",missingSerialize:"Required dependency jquery-serialize-object missing, using basic serialize",missingURL:"No URL specified for api event",noReturnedValue:"The beforeSend callback must return a settings object, beforeSend ignored.",parseError:"There was an error parsing your request",requiredParameter:"Missing a required URL parameter: ",statusMessage:"Server gave an error: ",timeout:"Your request timed out"},regExp:{required:/\{\$*[A-z0-9]+\}/g,optional:/\{\/\$*[A-z0-9]+\}/g},className:{loading:"loading",error:"error"},selector:{form:"form"},metadata:{action:"action",request:"request",xhr:"xhr"}},e.api.settings.api={}}(jQuery,window,document),function(e,t,n,i){e.fn.form=function(t,o){var r,a=e(this),s=e.extend(!0,{},e.fn.form.settings,o),c=e.extend({},e.fn.form.settings.defaults,t),l=s.namespace,u=s.metadata,d=s.selector,m=s.className,f=(s.error,"."+l),p="module-"+l,g=a.selector||"",b=(new Date).getTime(),v=[],h=arguments[0],y="string"==typeof h,x=[].slice.call(arguments,1);return a.each(function(){var t,o=e(this),l=e(this).find(d.field),w=e(this).find(d.group),C=e(this).find(d.message),T=(e(this).find(d.prompt),e(this).find(d.submit)),k=[],S=this,z=o.data(p);t={initialize:function(){t.verbose("Initializing form validation",o,c,s),t.bindEvents(),t.instantiate()},instantiate:function(){t.verbose("Storing instance of module",t),z=t,o.data(p,t)},destroy:function(){t.verbose("Destroying previous module",z),t.removeEvents(),o.removeData(p)},refresh:function(){t.verbose("Refreshing selector cache"),l=o.find(d.field)},submit:function(){t.verbose("Submitting form",o),o.submit()},attachEvents:function(n,i){i=i||"submit",e(n).on("click",function(e){t[i](),e.preventDefault()})},bindEvents:function(){s.keyboardShortcuts&&l.on("keydown"+f,t.event.field.keydown),o.on("submit"+f,t.validate.form),l.on("blur"+f,t.event.field.blur),t.attachEvents(T,"submit"),l.each(function(){var n=e(this).prop("type"),i=t.get.changeEvent(n);e(this).on(i+f,t.event.field.change)})},removeEvents:function(){o.off(f),l.off(f),T.off(f),l.off(f)},event:{field:{keydown:function(n){var i=e(this),o=n.which,r={enter:13,escape:27};o==r.escape&&(t.verbose("Escape key pressed blurring field"),i.blur()),!n.ctrlKey&&o==r.enter&&i.is(d.input)&&i.not(d.checkbox).size()>0&&(t.debug("Enter key pressed, submitting form"),T.addClass(m.down),i.one("keyup"+f,t.event.field.keyup))},keyup:function(){t.verbose("Doing keyboard shortcut form submit"),T.removeClass(m.down),t.submit()},blur:function(){var n=e(this),i=n.closest(w);i.hasClass(m.error)?(t.debug("Revalidating field",n,t.get.validation(n)),t.validate.field(t.get.validation(n))):("blur"==s.on||"change"==s.on)&&t.validate.field(t.get.validation(n))},change:function(){var n=e(this),i=n.closest(w);("change"==s.on||i.hasClass(m.error)&&s.revalidate)&&(clearTimeout(t.timer),t.timer=setTimeout(function(){t.debug("Revalidating field",n,t.get.validation(n)),t.validate.field(t.get.validation(n))},s.delay))}}},get:{changeEvent:function(e){return"checkbox"==e||"radio"==e||"hidden"==e?"change":n.createElement("input").oninput!==i?"input":n.createElement("input").onpropertychange!==i?"propertychange":"keyup"},field:function(n){return t.verbose("Finding field with identifier",n),l.filter("#"+n).size()>0?l.filter("#"+n):l.filter('[name="'+n+'"]').size()>0?l.filter('[name="'+n+'"]'):l.filter("[data-"+u.validate+'="'+n+'"]').size()>0?l.filter("[data-"+u.validate+'="'+n+'"]'):e("<input/>")},validation:function(n){var i;return e.each(c,function(e,o){t.get.field(o.identifier).get(0)==n.get(0)&&(i=o)}),i||!1}},has:{field:function(e){return t.verbose("Checking for existence of a field with identifier",e),l.filter("#"+e).size()>0?!0:l.filter('[name="'+e+'"]').size()>0?!0:l.filter("[data-"+u.validate+'="'+e+'"]').size()>0?!0:!1}},add:{prompt:function(n,r){var a=t.get.field(n),c=a.closest(w),l=c.find(d.prompt),u=0!==l.size();r="string"==typeof r?[r]:r,t.verbose("Adding field error state",n),c.addClass(m.error),s.inline&&(u||(l=s.templates.prompt(r),l.appendTo(c)),l.html(r[0]),u?t.verbose("Inline errors are disabled, no inline error added",n):s.transition&&e.fn.transition!==i&&o.transition("is supported")?(t.verbose("Displaying error with css transition",s.transition),l.transition(s.transition+" in",s.duration)):(t.verbose("Displaying error with fallback javascript animation"),l.fadeIn(s.duration)))},errors:function(e){t.debug("Adding form error messages",e),C.html(s.templates.error(e))}},remove:{prompt:function(n){var r=t.get.field(n.identifier),a=r.closest(w),c=a.find(d.prompt);a.removeClass(m.error),s.inline&&c.is(":visible")&&(t.verbose("Removing prompt for field",n),s.transition&&e.fn.transition!==i&&o.transition("is supported")?c.transition(s.transition+" out",s.duration,function(){c.remove()}):c.fadeOut(s.duration,function(){c.remove()}))}},set:{success:function(){o.removeClass(m.error).addClass(m.success)},error:function(){o.removeClass(m.success).addClass(m.error)}},validate:{form:function(n){var r=!0;return k=[],e.each(c,function(e,n){t.validate.field(n)||(r=!1)}),r?(t.debug("Form has no validation errors, submitting"),t.set.success(),e.proxy(s.onSuccess,this)(n)):(t.debug("Form has errors"),t.set.error(),s.inline||t.add.errors(k),o.data("moduleApi")!==i&&n.stopImmediatePropagation(),e.proxy(s.onFailure,this)(k))},field:function(n){var o=t.get.field(n.identifier),r=!0,a=[];return n.optional&&""===e.trim(o.val())?(t.debug("Field is optional and empty. Skipping",n.identifier),r=!0):n.rules!==i&&e.each(n.rules,function(e,i){t.has.field(n.identifier)&&!t.validate.rule(n,i)&&(t.debug("Field is invalid",n.identifier,i.type),a.push(i.prompt),r=!1)}),r?(t.remove.prompt(n,a),e.proxy(s.onValid,o)(),!0):(k=k.concat(a),t.add.prompt(n.identifier,a),e.proxy(s.onInvalid,o)(a),!1)},rule:function(n,r){var a,c,l=t.get.field(n.identifier),u=r.type,d=e.trim(l.val()+""),m=/\[(.*)\]/i,f=m.exec(u),p=!0;return f!==i&&null!==f?(a=""+f[1],c=u.replace(f[0],""),p=e.proxy(s.rules[c],o)(d,a)):p=e.proxy(s.rules[u],l)(d),p}},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,s,t);else{if(n===i)return s[t];s[t]=n}},internal:function(n,o){if(e.isPlainObject(n))e.extend(!0,t,n);else{if(o===i)return t[n];t[n]=o}},debug:function(){s.debug&&(s.performance?t.performance.log(arguments):(t.debug=Function.prototype.bind.call(console.info,console,s.name+":"),t.debug.apply(console,arguments)))},verbose:function(){s.verbose&&s.debug&&(s.performance?t.performance.log(arguments):(t.verbose=Function.prototype.bind.call(console.info,console,s.name+":"),t.verbose.apply(console,arguments)))},error:function(){t.error=Function.prototype.bind.call(console.error,console,s.name+":"),t.error.apply(console,arguments)},performance:{log:function(e){var n,i,o;s.performance&&(n=(new Date).getTime(),o=b||n,i=n-o,b=n,v.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:S,"Execution Time":i})),clearTimeout(t.performance.timer),t.performance.timer=setTimeout(t.performance.display,100)},display:function(){var n=s.name+":",o=0;b=!1,clearTimeout(t.performance.timer),e.each(v,function(e,t){o+=t["Execution Time"]}),n+=" "+o+"ms",g&&(n+=" '"+g+"'"),a.size()>1&&(n+=" ("+a.size()+")"),(console.group!==i||console.table!==i)&&v.length>0&&(console.groupCollapsed(n),console.table?console.table(v):e.each(v,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),v=[]}},invoke:function(t,n,o){var a,s,c,l=z;return n=n||x,o=S||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),a=t.length-1,e.each(t,function(n,o){var r=n!=a?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[r])&&n!=a)l=l[r];else{if(l[r]!==i)return s=l[r],!1;if(!e.isPlainObject(l[o])||n==a)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(r)?r.push(c):r!==i?r=[r,c]:c!==i&&(r=c),s}},y?(z===i&&t.initialize(),t.invoke(h)):(z!==i&&t.destroy(),t.initialize())}),r!==i?r:this},e.fn.form.settings={name:"Form",namespace:"form",debug:!1,verbose:!0,performance:!0,keyboardShortcuts:!0,on:"submit",inline:!1,delay:200,revalidate:!0,transition:"scale",duration:200,onValid:function(){},onInvalid:function(){},onSuccess:function(){return!0},onFailure:function(){return!1},metadata:{validate:"validate"},selector:{message:".error.message",field:"input, textarea, select",group:".field",checkbox:'input[type="checkbox"], input[type="radio"]',input:"input",prompt:".prompt",submit:".submit"},className:{error:"error",success:"success",down:"down",label:"ui prompt label"},error:{method:"The method you called is not defined."},templates:{error:function(t){var n='<ul class="list">';return e.each(t,function(e,t){n+="<li>"+t+"</li>"}),n+="</ul>",e(n)},prompt:function(t){return e("<div/>").addClass("ui red pointing prompt label").html(t[0])}},rules:{checked:function(){return e(this).filter(":checked").size()>0},contains:function(e,t){return t=t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),-1!==e.search(t)},email:function(e){var t=new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?","i");return t.test(e)},empty:function(e){return!(e===i||""===e)},integer:function(e,t){var n,o,r,a=/^\-?\d+$/;return t===i||""===t||".."===t||(-1==t.indexOf("..")?a.test(t)&&(n=o=t-0):(r=t.split("..",2),a.test(r[0])&&(n=r[0]-0),a.test(r[1])&&(o=r[1]-0))),a.test(e)&&(n===i||e>=n)&&(o===i||o>=e)},is:function(e,t){return e==t},length:function(e,t){return e!==i?e.length>=t:!1},match:function(t,n){var o,r=e(this);return r.find("#"+n).size()>0?o=r.find("#"+n).val():r.find('[name="'+n+'"]').size()>0?o=r.find('[name="'+n+'"]').val():r.find('[data-validate="'+n+'"]').size()>0&&(o=r.find('[data-validate="'+n+'"]').val()),o!==i?t.toString()==o.toString():!1},maxLength:function(e,t){return e!==i?e.length<=t:!1},not:function(e,t){return e!=t},url:function(e){var t=/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;return t.test(e)}}}}(jQuery,window,document); \ No newline at end of file
+!function(e,t,n,i){e.site=e.fn.site=function(o){var a,r,s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1),m=e.isPlainObject(o)?e.extend(!0,{},e.site.settings,o):e.extend({},e.site.settings),f=m.namespace,g=m.error,p="module-"+f,v=e(n),h=v,b=this,y=h.data(p);return a={initialize:function(){a.instantiate()},instantiate:function(){a.verbose("Storing instance of site",a),y=a,h.data(p,a)},normalize:function(){a.fix.console(),a.fix.requestAnimationFrame()},fix:{console:function(){a.debug("Normalizing window.console"),(console===i||console.log===i)&&(a.verbose("Console not available, normalizing events"),a.disable.console()),("undefined"==typeof console.group||"undefined"==typeof console.groupEnd||"undefined"==typeof console.groupCollapsed)&&(a.verbose("Console group not available, normalizing events"),t.console.group=function(){},t.console.groupEnd=function(){},t.console.groupCollapsed=function(){}),"undefined"==typeof console.markTimeline&&(a.verbose("Mark timeline not available, normalizing events"),t.console.markTimeline=function(){})},consoleClear:function(){a.debug("Disabling programmatic console clearing"),t.console.clear=function(){}},requestAnimationFrame:function(){a.debug("Normalizing requestAnimationFrame"),t.requestAnimationFrame===i&&(a.debug("RequestAnimationFrame not available, normalizing event"),t.requestAnimationFrame=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)})}},moduleExists:function(t){return e.fn[t]!==i&&e.fn[t].settings!==i},enabled:{modules:function(t){var n=[];return t=t||m.modules,e.each(t,function(e,t){a.moduleExists(t)&&n.push(t)}),n}},disabled:{modules:function(t){var n=[];return t=t||m.modules,e.each(t,function(e,t){a.moduleExists(t)||n.push(t)}),n}},change:{setting:function(t,n,o,r){o="string"==typeof o?"all"===o?m.modules:[o]:o||m.modules,r=r!==i?r:!0,e.each(o,function(i,o){var s,c=a.moduleExists(o)?e.fn[o].settings.namespace||!1:!0;a.moduleExists(o)&&(a.verbose("Changing default setting",t,n,o),e.fn[o].settings[t]=n,r&&c&&(s=e(":data(module-"+c+")"),s.length>0&&(a.verbose("Modifying existing settings",s),s[o]("setting",t,n))))})},settings:function(t,n,o){n="string"==typeof n?[n]:n||m.modules,o=o!==i?o:!0,e.each(n,function(n,i){var r;a.moduleExists(i)&&(a.verbose("Changing default setting",t,i),e.extend(!0,e.fn[i].settings,t),o&&f&&(r=e(":data(module-"+f+")"),r.length>0&&(a.verbose("Modifying existing settings",r),r[i]("setting",t))))})}},enable:{console:function(){a.console(!0)},debug:function(e,t){e=e||m.modules,a.debug("Enabling debug for modules",e),a.change.setting("debug",!0,e,t)},verbose:function(e,t){e=e||m.modules,a.debug("Enabling verbose debug for modules",e),a.change.setting("verbose",!0,e,t)}},disable:{console:function(){a.console(!1)},debug:function(e,t){e=e||m.modules,a.debug("Disabling debug for modules",e),a.change.setting("debug",!1,e,t)},verbose:function(e,t){e=e||m.modules,a.debug("Disabling verbose debug for modules",e),a.change.setting("verbose",!1,e,t)}},console:function(e){if(e){if(y.cache.console===i)return void a.error(g.console);a.debug("Restoring console function"),t.console=y.cache.console}else a.debug("Disabling console function"),y.cache.console=t.console,t.console={clear:function(){},error:function(){},group:function(){},groupCollapsed:function(){},groupEnd:function(){},info:function(){},log:function(){},markTimeline:function(){},warn:function(){}}},destroy:function(){a.verbose("Destroying previous site for",h),h.removeData(p)},cache:{},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,m,t);else{if(n===i)return m[t];m[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,a,t);else{if(n===i)return a[t];a[t]=n}},debug:function(){m.debug&&(m.performance?a.performance.log(arguments):(a.debug=Function.prototype.bind.call(console.info,console,m.name+":"),a.debug.apply(console,arguments)))},verbose:function(){m.verbose&&m.debug&&(m.performance?a.performance.log(arguments):(a.verbose=Function.prototype.bind.call(console.info,console,m.name+":"),a.verbose.apply(console,arguments)))},error:function(){a.error=Function.prototype.bind.call(console.error,console,m.name+":"),a.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;m.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Element:b,Name:e[0],Arguments:[].slice.call(e,1)||"","Execution Time":n})),clearTimeout(a.performance.timer),a.performance.timer=setTimeout(a.performance.display,500)},display:function(){var t=m.name+":",n=0;s=!1,clearTimeout(a.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,o){var s,c,l,u=y;return n=n||d,o=b||o,"string"==typeof t&&u!==i&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(n,o){var r=n!=s?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(u[r])&&n!=s)u=u[r];else{if(u[r]!==i)return c=u[r],!1;if(!e.isPlainObject(u[o])||n==s)return u[o]!==i?(c=u[o],!1):(a.error(g.method,t),!1);u=u[o]}})),e.isFunction(c)?l=c.apply(o,n):c!==i&&(l=c),e.isArray(r)?r.push(l):r!==i?r=[r,l]:l!==i&&(r=l),c}},u?(y===i&&a.initialize(),a.invoke(l)):(y!==i&&a.destroy(),a.initialize()),r!==i?r:this},e.site.settings={name:"Site",namespace:"site",error:{console:"Console cannot be restored, most likely it was overwritten outside of module",method:"The method you called is not defined."},debug:!1,verbose:!1,performance:!0,modules:["accordion","api","checkbox","dimmer","dropdown","embed","form","modal","nag","popup","rating","shape","sidebar","state","sticky","tab","transition","visit","visibility"],siteNamespace:"site",namespaceStub:{cache:{},config:{},sections:{},section:{},utilities:{}}},e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(n){return!!e.data(n,t)}}):function(t,n,i){return!!e.data(t,i[3])}})}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.form=function(t){var o,a=e(this),r=a.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u=arguments[1],d="string"==typeof l,m=[].slice.call(arguments,1);return a.each(function(){var f,g,p,v,h,b,y,x,C,w,k,S,T,A,R,E,P,F,D=e(this),O=this,q=[],j=!1;F={initialize:function(){F.get.settings(),d?(P===i&&F.instantiate(),F.invoke(l)):(F.verbose("Initializing form validation",D,x),F.bindEvents(),F.set.defaults(),F.instantiate())},instantiate:function(){F.verbose("Storing instance of module",F),P=F,D.data(R,F)},destroy:function(){F.verbose("Destroying previous module",P),F.removeEvents(),D.removeData(R)},refresh:function(){F.verbose("Refreshing selector cache"),f=D.find(k.field),g=D.find(k.group),p=D.find(k.message),v=D.find(k.prompt),h=D.find(k.submit),b=D.find(k.clear),y=D.find(k.reset)},submit:function(){F.verbose("Submitting form",D),D.submit()},attachEvents:function(t,n){n=n||"submit",e(t).on("click"+E,function(e){F[n](),e.preventDefault()})},bindEvents:function(){F.verbose("Attaching form events"),D.on("submit"+E,F.validate.form).on("blur"+E,k.field,F.event.field.blur).on("click"+E,k.submit,F.submit).on("click"+E,k.reset,F.reset).on("click"+E,k.clear,F.clear),x.keyboardShortcuts&&D.on("keydown"+E,k.field,F.event.field.keydown),f.each(function(){var t=e(this),n=t.prop("type"),i=F.get.changeEvent(n,t);e(this).on(i+E,F.event.field.change)})},clear:function(){f.each(function(){var t=e(this),n=t.parent(),i=t.closest(g),o=i.find(k.prompt),a=t.data(w.defaultValue)||"",r=n.is(k.uiCheckbox),s=n.is(k.uiDropdown),c=i.hasClass(S.error);c&&(F.verbose("Resetting error on field",i),i.removeClass(S.error),o.remove()),s?(F.verbose("Resetting dropdown value",n,a),n.dropdown("clear")):r?t.prop("checked",!1):(F.verbose("Resetting field value",t,a),t.val(""))})},reset:function(){f.each(function(){var t=e(this),n=t.parent(),o=t.closest(g),a=o.find(k.prompt),r=t.data(w.defaultValue),s=n.is(k.uiCheckbox),c=n.is(k.uiDropdown),l=o.hasClass(S.error);r!==i&&(l&&(F.verbose("Resetting error on field",o),o.removeClass(S.error),a.remove()),c?(F.verbose("Resetting dropdown value",n,r),n.dropdown("restore defaults")):s?(F.verbose("Resetting checkbox value",n,r),t.prop("checked",r)):(F.verbose("Resetting field value",t,r),t.val(r)))})},is:{bracketedRule:function(e){return e.type&&e.type.match(x.regExp.bracket)},valid:function(){var t=!0;return F.verbose("Checking if form is valid"),e.each(C,function(e,n){F.validate.field(n,e)||(t=!1)}),t}},removeEvents:function(){D.off(E),f.off(E),h.off(E),f.off(E)},event:{field:{keydown:function(t){var n=e(this),i=t.which,o={enter:13,escape:27};i==o.escape&&(F.verbose("Escape key pressed blurring field"),n.blur()),!t.ctrlKey&&i==o.enter&&n.is(k.input)&&n.not(k.checkbox).length>0&&(j||(n.one("keyup"+E,F.event.field.keyup),F.submit(),F.debug("Enter pressed on input submitting form")),j=!0)},keyup:function(){j=!1},blur:function(t){var n=e(this),i=n.closest(g),o=F.get.validation(n);i.hasClass(S.error)?(F.debug("Revalidating field",n,o),F.validate.form.call(F,t,!0)):("blur"==x.on||"change"==x.on)&&o&&F.validate.field(o)},change:function(t){var n=e(this),i=n.closest(g);("change"==x.on||i.hasClass(S.error)&&x.revalidate)&&(clearTimeout(F.timer),F.timer=setTimeout(function(){F.debug("Revalidating field",n,F.get.validation(n)),F.validate.form.call(F,t,!0)},x.delay))}}},get:{ancillaryValue:function(e){return e.type&&F.is.bracketedRule(e)?e.type.match(x.regExp.bracket)[1]+"":!1},ruleName:function(e){return F.is.bracketedRule(e)?e.type.replace(e.type.match(x.regExp.bracket)[0],""):e.type},changeEvent:function(e,t){return"checkbox"==e||"radio"==e||"hidden"==e||t.is("select")?"change":F.get.inputEvent()},inputEvent:function(){return n.createElement("input").oninput!==i?"input":n.createElement("input").onpropertychange!==i?"propertychange":"keyup"},prompt:function(e,t){var n,i,o,a=F.get.ruleName(e),r=F.get.ancillaryValue(e),s=e.prompt||x.prompt[a]||x.text.unspecifiedRule,c=-1!==s.search("{value}"),l=-1!==s.search("{name}");return(l||c)&&(i=F.get.field(t.identifier)),c&&(s=s.replace("{value}",i.val())),l&&(n=i.closest(k.group).find("label").eq(0),o=1==n.size()?n.text():i.prop("placeholder")||x.text.unspecifiedField,s=s.replace("{name}",o)),s=s.replace("{identifier}",t.identifier),s=s.replace("{ruleValue}",r),e.prompt||F.verbose("Using default validation prompt for type",s,a),s},settings:function(){if(e.isPlainObject(t)){var n,o=Object.keys(t),a=o.length>0?t[o[0]].identifier!==i&&t[o[0]].rules!==i:!1;a?(x=e.extend(!0,{},e.fn.form.settings,u),C=e.extend({},e.fn.form.settings.defaults,t),F.error(x.error.oldSyntax,O),F.verbose("Extending settings from legacy parameters",C,x)):(t.fields&&(n=Object.keys(t.fields),("string"==typeof t.fields[n[0]]||e.isArray(t.fields[n[0]]))&&e.each(t.fields,function(n,i){"string"==typeof i&&(i=[i]),t.fields[n]={rules:[]},e.each(i,function(e,i){t.fields[n].rules.push({type:i})})})),x=e.extend(!0,{},e.fn.form.settings,t),C=e.extend({},e.fn.form.settings.defaults,x.fields),F.verbose("Extending settings",C,x))}else x=e.fn.form.settings,C=e.fn.form.settings.defaults,F.verbose("Using default form validation",C,x);A=x.namespace,w=x.metadata,k=x.selector,S=x.className,T=x.error,R="module-"+A,E="."+A,P=D.data(R),F.refresh()},field:function(t){return F.verbose("Finding field with identifier",t),f.filter("#"+t).length>0?f.filter("#"+t):f.filter('[name="'+t+'"]').length>0?f.filter('[name="'+t+'"]'):f.filter('[name="'+t+'[]"]').length>0?f.filter('[name="'+t+'[]"]'):f.filter("[data-"+w.validate+'="'+t+'"]').length>0?f.filter("[data-"+w.validate+'="'+t+'"]'):e("<input/>")},fields:function(t){var n=e();return e.each(t,function(e,t){n=n.add(F.get.field(t))}),n},validation:function(t){var n,i;return C?(e.each(C,function(e,o){i=o.identifier||e,F.get.field(i)[0]==t[0]&&(o.identifier=i,n=o)}),n||!1):!1},value:function(e){var t,n=[];return n.push(e),t=F.get.values.call(O,n),t[e]},values:function(t){var n=e.isArray(t)?F.get.fields(t):f,i={};return n.each(function(t,n){var o=e(n),a=(o.prop("type"),o.prop("name")),r=o.val(),s=o.is(k.checkbox),c=o.is(k.radio),l=-1!==a.indexOf("[]"),u=s?o.is(":checked"):!1;a&&(l?(a=a.replace("[]",""),i[a]||(i[a]=[]),s?u?i[a].push(r||!0):i[a].push(!1):i[a].push(r)):c?u&&(i[a]=r):s?u?i[a]=r||!0:i[a]=!1:i[a]=r)}),i}},has:{field:function(e){return F.verbose("Checking for existence of a field with identifier",e),"string"!=typeof e&&F.error(T.identifier,e),f.filter("#"+e).length>0?!0:f.filter('[name="'+e+'"]').length>0?!0:f.filter("[data-"+w.validate+'="'+e+'"]').length>0?!0:!1}},add:{prompt:function(t,n){var o=F.get.field(t),a=o.closest(g),r=a.children(k.prompt),s=0!==r.length;n="string"==typeof n?[n]:n,F.verbose("Adding field error state",t),a.addClass(S.error),x.inline&&(s||(r=x.templates.prompt(n),r.appendTo(a)),r.html(n[0]),s?F.verbose("Inline errors are disabled, no inline error added",t):x.transition&&e.fn.transition!==i&&D.transition("is supported")?(F.verbose("Displaying error with css transition",x.transition),r.transition(x.transition+" in",x.duration)):(F.verbose("Displaying error with fallback javascript animation"),r.fadeIn(x.duration)))},errors:function(e){F.debug("Adding form error messages",e),F.set.error(),p.html(x.templates.error(e))}},remove:{prompt:function(t){var n=F.get.field(t),o=n.closest(g),a=o.children(k.prompt);o.removeClass(S.error),x.inline&&a.is(":visible")&&(F.verbose("Removing prompt for field",t),x.transition&&e.fn.transition!==i&&D.transition("is supported")?a.transition(x.transition+" out",x.duration,function(){a.remove()}):a.fadeOut(x.duration,function(){a.remove()}))}},set:{success:function(){D.removeClass(S.error).addClass(S.success)},defaults:function(){f.each(function(){var t=e(this),n=t.filter(k.checkbox).length>0,i=n?t.is(":checked"):t.val();t.data(w.defaultValue,i)})},error:function(){D.removeClass(S.success).addClass(S.error)},value:function(e,t){var n={};return n[e]=t,F.set.values.call(O,n)},values:function(t){e.isEmptyObject(t)||e.each(t,function(t,n){var i,o=F.get.field(t),a=o.parent(),r=e.isArray(n),s=a.is(k.uiCheckbox),c=a.is(k.uiDropdown),l=o.is(k.radio)&&s,u=o.length>0;u&&(r&&s?(F.verbose("Selecting multiple",n,o),a.checkbox("uncheck"),e.each(n,function(e,t){i=o.filter('[value="'+t+'"]'),a=i.parent(),i.length>0&&a.checkbox("check")})):l?(F.verbose("Selecting radio value",n,o),o.filter('[value="'+n+'"]').parent(k.uiCheckbox).checkbox("check")):s?(F.verbose("Setting checkbox value",n,a),n===!0?a.checkbox("check"):a.checkbox("uncheck")):c?(F.verbose("Setting dropdown value",n,a),a.dropdown("set selected",n)):(F.verbose("Setting field value",n,o),o.val(n)))})}},validate:{form:function(e,t){var n=F.get.values();if(j)return!1;if(q=[],F.is.valid()){if(F.debug("Form has no validation errors, submitting"),F.set.success(),t!==!0)return x.onSuccess.call(O,e,n)}else if(F.debug("Form has errors"),F.set.error(),x.inline||F.add.errors(q),D.data("moduleApi")!==i&&e.stopImmediatePropagation(),t!==!0)return x.onFailure.call(O,q,n)},field:function(t,n){var o=t.identifier||n,a=F.get.field(o),r=!0,s=[];return t.identifier||(F.debug("Using field name as identifier",o),t.identifier=o),a.prop("disabled")?(F.debug("Field is disabled. Skipping",o),r=!0):t.optional&&""===e.trim(a.val())?(F.debug("Field is optional and empty. Skipping",o),r=!0):t.rules!==i&&e.each(t.rules,function(e,n){F.has.field(o)&&!F.validate.rule(t,n)&&(F.debug("Field is invalid",o,n.type),s.push(F.get.prompt(n,t)),r=!1)}),r?(F.remove.prompt(o,s),x.onValid.call(a),!0):(q=q.concat(s),F.add.prompt(o,s),x.onInvalid.call(a,s),!1)},rule:function(t,n){var o=F.get.field(t.identifier),a=(n.type,o.val()),r=F.get.ancillaryValue(n),s=F.get.ruleName(n),c=x.rules[s];return e.isFunction(c)?(a=a===i||""===a||null===a?"":e.trim(a+""),c.call(o,a,r)):void F.error(T.noRule,s)}},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,x,t);else{if(n===i)return x[t];x[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,F,t);else{if(n===i)return F[t];F[t]=n}},debug:function(){x.debug&&(x.performance?F.performance.log(arguments):(F.debug=Function.prototype.bind.call(console.info,console,x.name+":"),F.debug.apply(console,arguments)))},verbose:function(){x.verbose&&x.debug&&(x.performance?F.performance.log(arguments):(F.verbose=Function.prototype.bind.call(console.info,console,x.name+":"),F.verbose.apply(console,arguments)))},error:function(){F.error=Function.prototype.bind.call(console.error,console,x.name+":"),F.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;x.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:O,"Execution Time":n})),clearTimeout(F.performance.timer),F.performance.timer=setTimeout(F.performance.display,500)},display:function(){var t=x.name+":",n=0;s=!1,clearTimeout(F.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",r&&(t+=" '"+r+"'"),a.length>1&&(t+=" ("+a.length+")"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,a){var r,s,c,l=P;return n=n||m,a=O||a,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(a,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},F.initialize()}),o!==i?o:this},e.fn.form.settings={name:"Form",namespace:"form",debug:!1,verbose:!1,performance:!0,fields:!1,keyboardShortcuts:!0,on:"submit",inline:!1,delay:200,revalidate:!0,transition:"scale",duration:200,onValid:function(){},onInvalid:function(){},onSuccess:function(){return!0},onFailure:function(){return!1},metadata:{defaultValue:"default",validate:"validate"},regExp:{bracket:/\[(.*)\]/i,decimal:/^\d*(\.)\d+/,email:"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?",escape:/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,flags:/^\/(.*)\/(.*)?/,integer:/^\-?\d+$/,number:/^\-?\d*(\.\d+)?$/,url:/(https?:\/\/(?:www\.|(?!www))[^\s\.]+\.[^\s]{2,}|www\.[^\s]+\.[^\s]{2,})/i},text:{unspecifiedRule:"Please enter a valid value",unspecifiedField:"This field"},prompt:{empty:"{name} must have a value",checked:"{name} must be checked",email:"{name} must be a valid e-mail",url:"{name} must be a valid url",regExp:"{name} is not formatted correctly",integer:"{name} must be an integer",decimal:"{name} must be a decimal number",number:"{name} must be set to a number",is:'{name} must be "{ruleValue}"',isExactly:'{name} must be exactly "{ruleValue}"',not:'{name} cannot be set to "{ruleValue}"',notExactly:'{name} cannot be set to exactly "{ruleValue}"',contain:'{name} cannot contain "{ruleValue}"',containExactly:'{name} cannot contain exactly "{ruleValue}"',doesntContain:'{name} must contain "{ruleValue}"',doesntContainExactly:'{name} must contain exactly "{ruleValue}"',minLength:"{name} must be at least {ruleValue} characters",length:"{name} must be at least {ruleValue} characters",exactLength:"{name} must be exactly {ruleValue} characters",maxLength:"{name} cannot be longer than {ruleValue} characters",match:"{name} must match {ruleValue} field",different:"{name} must have a different value than {ruleValue} field",creditCard:"{name} must be a valid credit card number",minCount:"{name} must have at least {ruleValue} choices",exactCount:"{name} must have exactly {ruleValue} choices",maxCount:"{name} must have {ruleValue} or less choices"},selector:{checkbox:'input[type="checkbox"], input[type="radio"]',clear:".clear",field:"input, textarea, select",group:".field",input:"input",message:".error.message",prompt:".prompt.label",radio:'input[type="radio"]',reset:'.reset:not([type="reset"])',submit:'.submit:not([type="submit"])',uiCheckbox:".ui.checkbox",uiDropdown:".ui.dropdown"},className:{error:"error",label:"ui prompt label",pressed:"down",success:"success"},error:{identifier:"You must specify a string identifier for each field",method:"The method you called is not defined.",noRule:"There is no rule matching the one you specified",oldSyntax:"Starting in 2.0 forms now only take a single settings object. Validation settings converted to new syntax automatically."},templates:{error:function(t){var n='<ul class="list">';return e.each(t,function(e,t){n+="<li>"+t+"</li>"}),n+="</ul>",e(n)},prompt:function(t){return e("<div/>").addClass("ui basic red pointing prompt label").html(t[0])}},rules:{empty:function(t){return!(t===i||""===t||e.isArray(t)&&0===t.length)},checked:function(){return e(this).filter(":checked").length>0},email:function(t){var n=new RegExp(e.fn.form.settings.regExp.email,"i");return n.test(t)},url:function(t){return e.fn.form.settings.regExp.url.test(t)},regExp:function(t,n){var i,o=n.match(e.fn.form.settings.regExp.flags);return o&&(n=o.length>=2?o[1]:n,i=o.length>=3?o[2]:""),t.match(new RegExp(n,i))},integer:function(t,n){var o,a,r,s=e.fn.form.settings.regExp.integer;return n&&-1===["",".."].indexOf(n)&&(-1==n.indexOf("..")?s.test(n)&&(o=a=n-0):(r=n.split("..",2),s.test(r[0])&&(o=r[0]-0),s.test(r[1])&&(a=r[1]-0))),s.test(t)&&(o===i||t>=o)&&(a===i||a>=t)},decimal:function(t){return e.fn.form.settings.regExp.decimal.test(t)},number:function(t){return e.fn.form.settings.regExp.number.test(t)},is:function(e,t){return t="string"==typeof t?t.toLowerCase():t,e="string"==typeof e?e.toLowerCase():e,e==t},isExactly:function(e,t){return e==t},not:function(e,t){return e="string"==typeof e?e.toLowerCase():e,t="string"==typeof t?t.toLowerCase():t,e!=t},notExactly:function(e,t){return e!=t},contains:function(t,n){return n=n.replace(e.fn.form.settings.regExp.escape,"\\$&"),-1!==t.search(new RegExp(n,"i"))},containsExactly:function(t,n){return n=n.replace(e.fn.form.settings.regExp.escape,"\\$&"),-1!==t.search(new RegExp(n))},doesntContain:function(t,n){return n=n.replace(e.fn.form.settings.regExp.escape,"\\$&"),-1===t.search(new RegExp(n,"i"))},doesntContainExactly:function(t,n){return n=n.replace(e.fn.form.settings.regExp.escape,"\\$&"),-1===t.search(new RegExp(n))},minLength:function(e,t){return e!==i?e.length>=t:!1},length:function(e,t){return e!==i?e.length>=t:!1},exactLength:function(e,t){return e!==i?e.length==t:!1},maxLength:function(e,t){return e!==i?e.length<=t:!1},match:function(t,n){var o;e(this);return e('[data-validate="'+n+'"]').length>0?o=e('[data-validate="'+n+'"]').val():e("#"+n).length>0?o=e("#"+n).val():e('[name="'+n+'"]').length>0?o=e('[name="'+n+'"]').val():e('[name="'+n+'[]"]').length>0&&(o=e('[name="'+n+'[]"]')),o!==i?t.toString()==o.toString():!1},different:function(t,n){var o;e(this);return e('[data-validate="'+n+'"]').length>0?o=e('[data-validate="'+n+'"]').val():e("#"+n).length>0?o=e("#"+n).val():e('[name="'+n+'"]').length>0?o=e('[name="'+n+'"]').val():e('[name="'+n+'[]"]').length>0&&(o=e('[name="'+n+'[]"]')),o!==i?t.toString()!==o.toString():!1},creditCard:function(t,n){var i,o,a={visa:{pattern:/^4/,length:[16]},amex:{pattern:/^3[47]/,length:[15]},mastercard:{pattern:/^5[1-5]/,length:[16]},discover:{pattern:/^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/,length:[16]},unionPay:{pattern:/^(62|88)/,length:[16,17,18,19]},jcb:{pattern:/^35(2[89]|[3-8][0-9])/,length:[16]},maestro:{pattern:/^(5018|5020|5038|6304|6759|676[1-3])/,length:[12,13,14,15,16,17,18,19]},dinersClub:{pattern:/^(30[0-5]|^36)/,length:[14]},laser:{pattern:/^(6304|670[69]|6771)/,length:[16,17,18,19]},visaElectron:{pattern:/^(4026|417500|4508|4844|491(3|7))/,length:[16]}},r={},s=!1,c="string"==typeof n?n.split(","):!1;if("string"==typeof t&&0!==t.length){if(c&&(e.each(c,function(n,i){o=a[i],o&&(r={length:-1!==e.inArray(t.length,o.length),pattern:-1!==t.search(o.pattern)},r.length&&r.pattern&&(s=!0))}),!s))return!1;if(i={number:-1!==e.inArray(t.length,a.unionPay.length),pattern:-1!==t.search(a.unionPay.pattern)},i.number&&i.pattern)return!0;for(var l=t.length,u=0,d=[[0,1,2,3,4,5,6,7,8,9],[0,2,4,6,8,1,3,5,7,9]],m=0;l--;)m+=d[u][parseInt(t.charAt(l),10)],u^=1;return m%10===0&&m>0}},minCount:function(e,t){return 0==t?!0:1==t?""!==e:e.split(",").length>=t},exactCount:function(e,t){return 0==t?""===e:1==t?""!==e&&-1===e.search(","):e.split(",").length==t},maxCount:function(e,t){return 0==t?!1:1==t?-1===e.search(","):e.split(",").length<=t}}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.accordion=function(n){var o,a=e(this),r=(new Date).getTime(),s=[],c=arguments[0],l="string"==typeof c,u=[].slice.call(arguments,1);t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)};return a.each(function(){var d,m,f=e.isPlainObject(n)?e.extend(!0,{},e.fn.accordion.settings,n):e.extend({},e.fn.accordion.settings),g=f.className,p=f.namespace,v=f.selector,h=f.error,b="."+p,y="module-"+p,x=a.selector||"",C=e(this),w=C.find(v.title),k=C.find(v.content),S=this,T=C.data(y);m={initialize:function(){m.debug("Initializing",C),m.bind.events(),f.observeChanges&&m.observeChanges(),m.instantiate()},instantiate:function(){T=m,C.data(y,m)},destroy:function(){m.debug("Destroying previous instance",C),C.off(b).removeData(y)},refresh:function(){w=C.find(v.title),k=C.find(v.content)},observeChanges:function(){"MutationObserver"in t&&(d=new MutationObserver(function(e){m.debug("DOM tree modified, updating selector cache"),m.refresh()}),d.observe(S,{childList:!0,subtree:!0}),m.debug("Setting up mutation observer",d))},bind:{events:function(){m.debug("Binding delegated events"),C.on(f.on+b,v.trigger,m.event.click)}},event:{click:function(){m.toggle.call(this)}},toggle:function(t){var n=t!==i?"number"==typeof t?w.eq(t):e(t).closest(v.title):e(this).closest(v.title),o=n.next(k),a=o.hasClass(g.animating),r=o.hasClass(g.active),s=r&&!a,c=!r&&a;m.debug("Toggling visibility of content",n),s||c?f.collapsible?m.close.call(n):m.debug("Cannot close accordion content collapsing is disabled"):m.open.call(n)},open:function(t){var n=t!==i?"number"==typeof t?w.eq(t):e(t).closest(v.title):e(this).closest(v.title),o=n.next(k),a=o.hasClass(g.animating),r=o.hasClass(g.active),s=r||a;return s?void m.debug("Accordion already open, skipping",o):(m.debug("Opening accordion content",n),f.onOpening.call(o),f.exclusive&&m.closeOthers.call(n),n.addClass(g.active),o.stop(!0,!0).addClass(g.animating),f.animateChildren&&(e.fn.transition!==i&&C.transition("is supported")?o.children().transition({animation:"fade in",queue:!1,useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):o.children().stop(!0,!0).animate({opacity:1},f.duration,m.resetOpacity)),void o.slideDown(f.duration,f.easing,function(){o.removeClass(g.animating).addClass(g.active),m.reset.display.call(this),f.onOpen.call(this),f.onChange.call(this)}))},close:function(t){var n=t!==i?"number"==typeof t?w.eq(t):e(t).closest(v.title):e(this).closest(v.title),o=n.next(k),a=o.hasClass(g.animating),r=o.hasClass(g.active),s=!r&&a,c=r&&a;!r&&!s||c||(m.debug("Closing accordion content",o),f.onClosing.call(o),n.removeClass(g.active),o.stop(!0,!0).addClass(g.animating),f.animateChildren&&(e.fn.transition!==i&&C.transition("is supported")?o.children().transition({animation:"fade out",queue:!1,useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):o.children().stop(!0,!0).animate({opacity:0},f.duration,m.resetOpacity)),o.slideUp(f.duration,f.easing,function(){o.removeClass(g.animating).removeClass(g.active),m.reset.display.call(this),f.onClose.call(this),f.onChange.call(this)}))},closeOthers:function(t){var n,o,a,r=t!==i?w.eq(t):e(this).closest(v.title),s=r.parents(v.content).prev(v.title),c=r.closest(v.accordion),l=v.title+"."+g.active+":visible",u=v.content+"."+g.active+":visible";f.closeNested?(n=c.find(l).not(s),a=n.next(k)):(n=c.find(l).not(s),o=c.find(u).find(l).not(s),n=n.not(o),a=n.next(k)),n.length>0&&(m.debug("Exclusive enabled, closing other content",n),n.removeClass(g.active),a.removeClass(g.animating).stop(!0,!0),f.animateChildren&&(e.fn.transition!==i&&C.transition("is supported")?a.children().transition({animation:"fade out",useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):a.children().stop(!0,!0).animate({opacity:0},f.duration,m.resetOpacity)),a.slideUp(f.duration,f.easing,function(){e(this).removeClass(g.active),m.reset.display.call(this)}))},reset:{display:function(){m.verbose("Removing inline display from element",this),e(this).css("display",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")},opacity:function(){m.verbose("Removing inline opacity from element",this),e(this).css("opacity",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")}},setting:function(t,n){if(m.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},internal:function(t,n){return m.debug("Changing internal",t,n),n===i?m[t]:void(e.isPlainObject(t)?e.extend(!0,m,t):m[t]=n)},debug:function(){f.debug&&(f.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,f.name+":"),m.debug.apply(console,arguments)))},verbose:function(){f.verbose&&f.debug&&(f.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,f.name+":"),m.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;f.performance&&(t=(new Date).getTime(),i=r||t,n=t-i,r=t,s.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:S,"Execution Time":n})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,500)},display:function(){var t=f.name+":",n=0;r=!1,clearTimeout(m.performance.timer),e.each(s,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",x&&(t+=" '"+x+"'"),(console.group!==i||console.table!==i)&&s.length>0&&(console.groupCollapsed(t),console.table?console.table(s):e.each(s,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),s=[]}},invoke:function(t,n,a){var r,s,c,l=T;return n=n||u,a=S||a,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):(m.error(h.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(a,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},l?(T===i&&m.initialize(),m.invoke(c)):(T!==i&&T.invoke("destroy"),m.initialize())}),o!==i?o:this},e.fn.accordion.settings={name:"Accordion",namespace:"accordion",debug:!1,verbose:!1,performance:!0,on:"click",observeChanges:!0,exclusive:!0,collapsible:!0,closeNested:!1,animateChildren:!0,duration:350,easing:"easeOutQuad",onOpening:function(){},onOpen:function(){},onClosing:function(){},onClose:function(){},onChange:function(){},error:{method:"The method you called is not defined"},className:{active:"active",animating:"animating"},selector:{accordion:".accordion",title:".title",trigger:".title",content:".content"}},e.extend(e.easing,{easeOutQuad:function(e,t,n,i,o){return-i*(t/=o)*(t-2)+n}})}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.checkbox=function(o){var a,r=e(this),s=r.selector||"",c=(new Date).getTime(),l=[],u=arguments[0],d="string"==typeof u,m=[].slice.call(arguments,1);return r.each(function(){var r,f,g=e.extend(!0,{},e.fn.checkbox.settings,o),p=g.className,v=g.namespace,h=g.selector,b=g.error,y="."+v,x="module-"+v,C=e(this),w=e(this).children(h.label),k=e(this).children(h.input),S=k[0],T=!1,A=!1,R=C.data(x),E=this;
+f={initialize:function(){f.verbose("Initializing checkbox",g),f.create.label(),f.bind.events(),f.set.tabbable(),f.hide.input(),f.observeChanges(),f.instantiate(),f.setup()},instantiate:function(){f.verbose("Storing instance of module",f),R=f,C.data(x,f)},destroy:function(){f.verbose("Destroying module"),f.unbind.events(),f.show.input(),C.removeData(x)},fix:{reference:function(){C.is(h.input)&&(f.debug("Behavior called on <input> adjusting invoked element"),C=C.closest(h.checkbox),f.refresh())}},setup:function(){f.set.initialLoad(),f.is.indeterminate()?(f.debug("Initial value is indeterminate"),f.indeterminate()):f.is.checked()?(f.debug("Initial value is checked"),f.check()):(f.debug("Initial value is unchecked"),f.uncheck()),f.remove.initialLoad()},refresh:function(){w=C.children(h.label),k=C.children(h.input),S=k[0]},hide:{input:function(){f.verbose("Modfying <input> z-index to be unselectable"),k.addClass(p.hidden)}},show:{input:function(){f.verbose("Modfying <input> z-index to be selectable"),k.removeClass(p.hidden)}},observeChanges:function(){"MutationObserver"in t&&(r=new MutationObserver(function(e){f.debug("DOM tree modified, updating selector cache"),f.refresh()}),r.observe(E,{childList:!0,subtree:!0}),f.debug("Setting up mutation observer",r))},attachEvents:function(t,n){var i=e(t);n=e.isFunction(f[n])?f[n]:f.toggle,i.length>0?(f.debug("Attaching checkbox events to element",t,n),i.on("click"+y,n)):f.error(b.notFound)},event:{click:function(t){var n=e(t.target);return n.is(h.input)?void f.verbose("Using default check action on initialized checkbox"):n.is(h.link)?void f.debug("Clicking link inside checkbox, skipping toggle"):(f.toggle(),k.focus(),void t.preventDefault())},keydown:function(e){var t=e.which,n={enter:13,space:32,escape:27};t==n.escape?(f.verbose("Escape key pressed blurring field"),k.blur(),A=!0):e.ctrlKey||t!=n.space&&t!=n.enter?A=!1:(f.verbose("Enter/space key pressed, toggling checkbox"),f.toggle(),A=!0)},keyup:function(e){A&&e.preventDefault()}},check:function(){f.should.allowCheck()&&(f.debug("Checking checkbox",k),f.set.checked(),f.should.ignoreCallbacks()||(g.onChecked.call(S),g.onChange.call(S)))},uncheck:function(){f.should.allowUncheck()&&(f.debug("Unchecking checkbox"),f.set.unchecked(),f.should.ignoreCallbacks()||(g.onUnchecked.call(S),g.onChange.call(S)))},indeterminate:function(){return f.should.allowIndeterminate()?void f.debug("Checkbox is already indeterminate"):(f.debug("Making checkbox indeterminate"),f.set.indeterminate(),void(f.should.ignoreCallbacks()||(g.onIndeterminate.call(S),g.onChange.call(S))))},determinate:function(){return f.should.allowDeterminate()?void f.debug("Checkbox is already determinate"):(f.debug("Making checkbox determinate"),f.set.determinate(),void(f.should.ignoreCallbacks()||(g.onDeterminate.call(S),g.onChange.call(S))))},enable:function(){return f.is.enabled()?void f.debug("Checkbox is already enabled"):(f.debug("Enabling checkbox"),f.set.enabled(),void g.onEnable.call(S))},disable:function(){return f.is.disabled()?void f.debug("Checkbox is already disabled"):(f.debug("Disabling checkbox"),f.set.disabled(),void g.onDisable.call(S))},get:{radios:function(){var t=f.get.name();return e('input[name="'+t+'"]').closest(h.checkbox)},otherRadios:function(){return f.get.radios().not(C)},name:function(){return k.attr("name")}},is:{initialLoad:function(){return T},radio:function(){return k.hasClass(p.radio)||"radio"==k.attr("type")},indeterminate:function(){return k.prop("indeterminate")!==i&&k.prop("indeterminate")},checked:function(){return k.prop("checked")!==i&&k.prop("checked")},disabled:function(){return k.prop("disabled")!==i&&k.prop("disabled")},enabled:function(){return!f.is.disabled()},determinate:function(){return!f.is.indeterminate()},unchecked:function(){return!f.is.checked()}},should:{allowCheck:function(){return f.is.determinate()&&f.is.checked()&&!f.should.forceCallbacks()?(f.debug("Should not allow check, checkbox is already checked"),!1):g.beforeChecked.apply(S)===!1?(f.debug("Should not allow check, beforeChecked cancelled"),!1):!0},allowUncheck:function(){return f.is.determinate()&&f.is.unchecked()&&!f.should.forceCallbacks()?(f.debug("Should not allow uncheck, checkbox is already unchecked"),!1):g.beforeUnchecked.apply(S)===!1?(f.debug("Should not allow uncheck, beforeUnchecked cancelled"),!1):!0},allowIndeterminate:function(){return f.is.indeterminate()&&!f.should.forceCallbacks()?(f.debug("Should not allow indeterminate, checkbox is already indeterminate"),!1):g.beforeIndeterminate.apply(S)===!1?(f.debug("Should not allow indeterminate, beforeIndeterminate cancelled"),!1):!0},allowDeterminate:function(){return f.is.determinate()&&!f.should.forceCallbacks()?(f.debug("Should not allow determinate, checkbox is already determinate"),!1):g.beforeDeterminate.apply(S)===!1?(f.debug("Should not allow determinate, beforeDeterminate cancelled"),!1):!0},forceCallbacks:function(){return f.is.initialLoad()&&g.fireOnInit},ignoreCallbacks:function(){return T&&!g.fireOnInit}},can:{change:function(){return!(C.hasClass(p.disabled)||C.hasClass(p.readOnly)||k.prop("disabled")||k.prop("readonly"))},uncheck:function(){return"boolean"==typeof g.uncheckable?g.uncheckable:!f.is.radio()}},set:{initialLoad:function(){T=!0},checked:function(){return f.verbose("Setting class to checked"),C.removeClass(p.indeterminate).addClass(p.checked),f.is.radio()&&f.uncheckOthers(),!f.is.indeterminate()&&f.is.checked()?void f.debug("Input is already checked, skipping input property change"):(f.verbose("Setting state to checked",S),k.prop("indeterminate",!1).prop("checked",!0),void f.trigger.change())},unchecked:function(){return f.verbose("Removing checked class"),C.removeClass(p.indeterminate).removeClass(p.checked),!f.is.indeterminate()&&f.is.unchecked()?void f.debug("Input is already unchecked"):(f.debug("Setting state to unchecked"),k.prop("indeterminate",!1).prop("checked",!1),void f.trigger.change())},indeterminate:function(){return f.verbose("Setting class to indeterminate"),C.addClass(p.indeterminate),f.is.indeterminate()?void f.debug("Input is already indeterminate, skipping input property change"):(f.debug("Setting state to indeterminate"),k.prop("indeterminate",!0),void f.trigger.change())},determinate:function(){return f.verbose("Removing indeterminate class"),C.removeClass(p.indeterminate),f.is.determinate()?void f.debug("Input is already determinate, skipping input property change"):(f.debug("Setting state to determinate"),void k.prop("indeterminate",!1))},disabled:function(){return f.verbose("Setting class to disabled"),C.addClass(p.disabled),f.is.disabled()?void f.debug("Input is already disabled, skipping input property change"):(f.debug("Setting state to disabled"),k.prop("disabled","disabled"),void f.trigger.change())},enabled:function(){return f.verbose("Removing disabled class"),C.removeClass(p.disabled),f.is.enabled()?void f.debug("Input is already enabled, skipping input property change"):(f.debug("Setting state to enabled"),k.prop("disabled",!1),void f.trigger.change())},tabbable:function(){f.verbose("Adding tabindex to checkbox"),k.attr("tabindex")===i&&k.attr("tabindex",0)}},remove:{initialLoad:function(){T=!1}},trigger:{change:function(){var e=n.createEvent("HTMLEvents"),t=k[0];t&&(f.verbose("Triggering native change event"),e.initEvent("change",!0,!1),t.dispatchEvent(e))}},create:{label:function(){k.prevAll(h.label).length>0?(k.prev(h.label).detach().insertAfter(k),f.debug("Moving existing label",w)):f.has.label()||(w=e("<label>").insertAfter(k),f.debug("Creating label",w))}},has:{label:function(){return w.length>0}},bind:{events:function(){f.verbose("Attaching checkbox events"),C.on("click"+y,f.event.click).on("keydown"+y,h.input,f.event.keydown).on("keyup"+y,h.input,f.event.keyup)}},unbind:{events:function(){f.debug("Removing events"),C.off(y)}},uncheckOthers:function(){var e=f.get.otherRadios();f.debug("Unchecking other radios",e),e.removeClass(p.checked)},toggle:function(){return f.can.change()?void(f.is.indeterminate()||f.is.unchecked()?(f.debug("Currently unchecked"),f.check()):f.is.checked()&&f.can.uncheck()&&(f.debug("Currently checked"),f.uncheck())):void(f.is.radio()||f.debug("Checkbox is read-only or disabled, ignoring toggle"))},setting:function(t,n){if(f.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,g,t);else{if(n===i)return g[t];g[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},debug:function(){g.debug&&(g.performance?f.performance.log(arguments):(f.debug=Function.prototype.bind.call(console.info,console,g.name+":"),f.debug.apply(console,arguments)))},verbose:function(){g.verbose&&g.debug&&(g.performance?f.performance.log(arguments):(f.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),f.verbose.apply(console,arguments)))},error:function(){f.error=Function.prototype.bind.call(console.error,console,g.name+":"),f.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;g.performance&&(t=(new Date).getTime(),i=c||t,n=t-i,c=t,l.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:E,"Execution Time":n})),clearTimeout(f.performance.timer),f.performance.timer=setTimeout(f.performance.display,500)},display:function(){var t=g.name+":",n=0;c=!1,clearTimeout(f.performance.timer),e.each(l,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",s&&(t+=" '"+s+"'"),(console.group!==i||console.table!==i)&&l.length>0&&(console.groupCollapsed(t),console.table?console.table(l):e.each(l,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),l=[]}},invoke:function(t,n,o){var r,s,c,l=R;return n=n||m,o=E||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):(f.error(b.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(a)?a.push(c):a!==i?a=[a,c]:c!==i&&(a=c),s}},d?(R===i&&f.initialize(),f.invoke(u)):(R!==i&&R.invoke("destroy"),f.initialize())}),a!==i?a:this},e.fn.checkbox.settings={name:"Checkbox",namespace:"checkbox",debug:!1,verbose:!0,performance:!0,uncheckable:"auto",fireOnInit:!1,onChange:function(){},beforeChecked:function(){},beforeUnchecked:function(){},beforeDeterminate:function(){},beforeIndeterminate:function(){},onChecked:function(){},onUnchecked:function(){},onDeterminate:function(){},onIndeterminate:function(){},onEnabled:function(){},onDisabled:function(){},className:{checked:"checked",indeterminate:"indeterminate",disabled:"disabled",hidden:"hidden",radio:"radio",readOnly:"read-only"},error:{method:"The method you called is not defined"},selector:{checkbox:".ui.checkbox",label:"label, .box",input:'input[type="checkbox"], input[type="radio"]',link:"a[href]"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.dimmer=function(t){var o,a=e(this),r=(new Date).getTime(),s=[],c=arguments[0],l="string"==typeof c,u=[].slice.call(arguments,1);return a.each(function(){var d,m,f,g=e.isPlainObject(t)?e.extend(!0,{},e.fn.dimmer.settings,t):e.extend({},e.fn.dimmer.settings),p=g.selector,v=g.namespace,h=g.className,b=g.error,y="."+v,x="module-"+v,C=a.selector||"",w="ontouchstart"in n.documentElement?"touchstart":"click",k=e(this),S=this,T=k.data(x);f={preinitialize:function(){f.is.dimmer()?(m=k.parent(),d=k):(m=k,d=f.has.dimmer()?g.dimmerName?m.find(p.dimmer).filter("."+g.dimmerName):m.find(p.dimmer):f.create())},initialize:function(){f.debug("Initializing dimmer",g),f.bind.events(),f.set.dimmable(),f.instantiate()},instantiate:function(){f.verbose("Storing instance of module",f),T=f,k.data(x,T)},destroy:function(){f.verbose("Destroying previous module",d),f.unbind.events(),f.remove.variation(),m.off(y)},bind:{events:function(){"hover"==g.on?m.on("mouseenter"+y,f.show).on("mouseleave"+y,f.hide):"click"==g.on&&m.on(w+y,f.toggle),f.is.page()&&(f.debug("Setting as a page dimmer",m),f.set.pageDimmer()),f.is.closable()&&(f.verbose("Adding dimmer close event",d),m.on(w+y,p.dimmer,f.event.click))}},unbind:{events:function(){k.removeData(x)}},event:{click:function(t){f.verbose("Determining if event occured on dimmer",t),(0===d.find(t.target).length||e(t.target).is(p.content))&&(f.hide(),t.stopImmediatePropagation())}},addContent:function(t){var n=e(t);f.debug("Add content to dimmer",n),n.parent()[0]!==d[0]&&n.detach().appendTo(d)},create:function(){var t=e(g.template.dimmer());return g.variation&&(f.debug("Creating dimmer with variation",g.variation),t.addClass(g.variation)),g.dimmerName&&(f.debug("Creating named dimmer",g.dimmerName),t.addClass(g.dimmerName)),t.appendTo(m),t},show:function(t){t=e.isFunction(t)?t:function(){},f.debug("Showing dimmer",d,g),f.is.dimmed()&&!f.is.animating()||!f.is.enabled()?f.debug("Dimmer is already shown or disabled"):(f.animate.show(t),g.onShow.call(S),g.onChange.call(S))},hide:function(t){t=e.isFunction(t)?t:function(){},f.is.dimmed()||f.is.animating()?(f.debug("Hiding dimmer",d),f.animate.hide(t),g.onHide.call(S),g.onChange.call(S)):f.debug("Dimmer is not visible")},toggle:function(){f.verbose("Toggling dimmer visibility",d),f.is.dimmed()?f.hide():f.show()},animate:{show:function(t){t=e.isFunction(t)?t:function(){},g.useCSS&&e.fn.transition!==i&&d.transition("is supported")?("auto"!==g.opacity&&f.set.opacity(),d.transition({animation:g.transition+" in",queue:!1,duration:f.get.duration(),useFailSafe:!0,onStart:function(){f.set.dimmed()},onComplete:function(){f.set.active(),t()}})):(f.verbose("Showing dimmer animation with javascript"),f.set.dimmed(),"auto"==g.opacity&&(g.opacity=.8),d.stop().css({opacity:0,width:"100%",height:"100%"}).fadeTo(f.get.duration(),g.opacity,function(){d.removeAttr("style"),f.set.active(),t()}))},hide:function(t){t=e.isFunction(t)?t:function(){},g.useCSS&&e.fn.transition!==i&&d.transition("is supported")?(f.verbose("Hiding dimmer with css"),d.transition({animation:g.transition+" out",queue:!1,duration:f.get.duration(),useFailSafe:!0,onStart:function(){f.remove.dimmed()},onComplete:function(){f.remove.active(),t()}})):(f.verbose("Hiding dimmer with javascript"),f.remove.dimmed(),d.stop().fadeOut(f.get.duration(),function(){f.remove.active(),d.removeAttr("style"),t()}))}},get:{dimmer:function(){return d},duration:function(){return"object"==typeof g.duration?f.is.active()?g.duration.hide:g.duration.show:g.duration}},has:{dimmer:function(){return g.dimmerName?k.find(p.dimmer).filter("."+g.dimmerName).length>0:k.find(p.dimmer).length>0}},is:{active:function(){return d.hasClass(h.active)},animating:function(){return d.is(":animated")||d.hasClass(h.animating)},closable:function(){return"auto"==g.closable?"hover"==g.on?!1:!0:g.closable},dimmer:function(){return k.hasClass(h.dimmer)},dimmable:function(){return k.hasClass(h.dimmable)},dimmed:function(){return m.hasClass(h.dimmed)},disabled:function(){return m.hasClass(h.disabled)},enabled:function(){return!f.is.disabled()},page:function(){return m.is("body")},pageDimmer:function(){return d.hasClass(h.pageDimmer)}},can:{show:function(){return!d.hasClass(h.disabled)}},set:{opacity:function(e){var t=d.css("background-color"),n=t.split(","),i=n&&4==n.length;e=0===g.opacity?0:g.opacity||e,i?(n[3]=e+")",t=n.join(",")):t="rgba(0, 0, 0, "+e+")",f.debug("Setting opacity to",e),d.css("background-color",t)},active:function(){d.addClass(h.active)},dimmable:function(){m.addClass(h.dimmable)},dimmed:function(){m.addClass(h.dimmed)},pageDimmer:function(){d.addClass(h.pageDimmer)},disabled:function(){d.addClass(h.disabled)},variation:function(e){e=e||g.variation,e&&d.addClass(e)}},remove:{active:function(){d.removeClass(h.active)},dimmed:function(){m.removeClass(h.dimmed)},disabled:function(){d.removeClass(h.disabled)},variation:function(e){e=e||g.variation,e&&d.removeClass(e)}},setting:function(t,n){if(f.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,g,t);else{if(n===i)return g[t];g[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},debug:function(){g.debug&&(g.performance?f.performance.log(arguments):(f.debug=Function.prototype.bind.call(console.info,console,g.name+":"),f.debug.apply(console,arguments)))},verbose:function(){g.verbose&&g.debug&&(g.performance?f.performance.log(arguments):(f.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),f.verbose.apply(console,arguments)))},error:function(){f.error=Function.prototype.bind.call(console.error,console,g.name+":"),f.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;g.performance&&(t=(new Date).getTime(),i=r||t,n=t-i,r=t,s.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:S,"Execution Time":n})),clearTimeout(f.performance.timer),f.performance.timer=setTimeout(f.performance.display,500)},display:function(){var t=g.name+":",n=0;r=!1,clearTimeout(f.performance.timer),e.each(s,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",C&&(t+=" '"+C+"'"),a.length>1&&(t+=" ("+a.length+")"),(console.group!==i||console.table!==i)&&s.length>0&&(console.groupCollapsed(t),console.table?console.table(s):e.each(s,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),s=[]}},invoke:function(t,n,a){var r,s,c,l=T;return n=n||u,a=S||a,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):(f.error(b.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(a,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},f.preinitialize(),l?(T===i&&f.initialize(),f.invoke(c)):(T!==i&&T.invoke("destroy"),f.initialize())}),o!==i?o:this},e.fn.dimmer.settings={name:"Dimmer",namespace:"dimmer",debug:!1,verbose:!1,performance:!0,dimmerName:!1,variation:!1,closable:"auto",useCSS:!0,transition:"fade",on:!1,opacity:"auto",duration:{show:500,hide:500},onChange:function(){},onShow:function(){},onHide:function(){},error:{method:"The method you called is not defined."},className:{active:"active",animating:"animating",dimmable:"dimmable",dimmed:"dimmed",dimmer:"dimmer",disabled:"disabled",hide:"hide",pageDimmer:"page",show:"show"},selector:{dimmer:"> .ui.dimmer",content:".ui.dimmer > .content, .ui.dimmer > .content > .center"},template:{dimmer:function(){return e("<div />").attr("class","ui dimmer")}}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.dropdown=function(o){var a,r=e(this),s=e(n),c=r.selector||"",l="ontouchstart"in n.documentElement,u=(new Date).getTime(),d=[],m=arguments[0],f="string"==typeof m,g=[].slice.call(arguments,1);return r.each(function(p){var v,h,b,y,x,C,w,k=e.isPlainObject(o)?e.extend(!0,{},e.fn.dropdown.settings,o):e.extend({},e.fn.dropdown.settings),S=k.className,T=k.message,A=k.fields,R=k.keys,E=k.metadata,P=k.namespace,F=k.regExp,D=k.selector,O=k.error,q=k.templates,j="."+P,z="module-"+P,I=e(this),L=e(k.context),N=I.find(D.text),V=I.find(D.search),H=I.find(D.input),M=I.find(D.icon),U=I.prev().find(D.text).length>0?I.prev().find(D.text):I.prev(),W=I.children(D.menu),B=W.find(D.item),Q=!1,X=!1,$=!1,Y=this,Z=I.data(z);w={initialize:function(){w.debug("Initializing dropdown",k),w.is.alreadySetup()?w.setup.reference():(w.setup.layout(),w.refreshData(),w.save.defaults(),w.restore.selected(),w.create.id(),w.bind.events(),w.observeChanges(),w.instantiate())},instantiate:function(){w.verbose("Storing instance of dropdown",w),Z=w,I.data(z,w)},destroy:function(){w.verbose("Destroying previous dropdown",I),w.remove.tabbable(),I.off(j).removeData(z),W.off(j),s.off(b),x&&x.disconnect(),C&&C.disconnect()},observeChanges:function(){"MutationObserver"in t&&(x=new MutationObserver(function(e){w.debug("<select> modified, recreating menu"),w.setup.select()}),C=new MutationObserver(function(e){w.debug("Menu modified, updating selector cache"),w.refresh()}),w.has.input()&&x.observe(H[0],{childList:!0,subtree:!0}),w.has.menu()&&C.observe(W[0],{childList:!0,subtree:!0}),w.debug("Setting up mutation observer",x,C))},create:{id:function(){y=(Math.random().toString(16)+"000000000").substr(2,8),b="."+y,w.verbose("Creating unique id for element",y)},userChoice:function(t){var n,o,a;return(t=t||w.get.userValues())?(t=e.isArray(t)?t:[t],e.each(t,function(t,r){w.get.item(r)===!1&&(a=k.templates.addition(w.add.variables(T.addResult,r)),o=e("<div />").html(a).attr("data-"+E.value,r).attr("data-"+E.text,r).addClass(S.addition).addClass(S.item),n=n===i?o:n.add(o),w.verbose("Creating user choices for value",r,o))}),n):!1},userLabels:function(t){var n=w.get.userValues();n&&(w.debug("Adding user labels",n),e.each(n,function(e,t){w.verbose("Adding custom user value"),w.add.label(t,t)}))},menu:function(){W=e("<div />").addClass(S.menu).appendTo(I)}},search:function(e){e=e!==i?e:w.get.query(),w.verbose("Searching for query",e),w.filter(e)},select:{firstUnfiltered:function(){w.verbose("Selecting first non-filtered element"),w.remove.selectedItem(),B.not(D.unselectable).eq(0).addClass(S.selected)},nextAvailable:function(e){e=e.eq(0);var t=e.nextAll(D.item).not(D.unselectable).eq(0),n=e.prevAll(D.item).not(D.unselectable).eq(0),i=t.length>0;i?(w.verbose("Moving selection to",t),t.addClass(S.selected)):(w.verbose("Moving selection to",n),n.addClass(S.selected))}},setup:{api:function(){var e={debug:k.debug,on:!1};w.verbose("First request, initializing API"),I.api(e)},layout:function(){I.is("select")&&(w.setup.select(),w.setup.returnedObject()),w.has.menu()||w.create.menu(),w.is.search()&&!w.has.search()&&(w.verbose("Adding search input"),V=e("<input />").addClass(S.search).prop("autocomplete","off").insertBefore(N)),k.allowTab&&w.set.tabbable()},select:function(){var t=w.get.selectValues();w.debug("Dropdown initialized on a select",t),I.is("select")&&(H=I),H.parent(D.dropdown).length>0?(w.debug("UI dropdown already exists. Creating dropdown menu only"),I=H.closest(D.dropdown),w.has.menu()||w.create.menu(),W=I.children(D.menu),w.setup.menu(t)):(w.debug("Creating entire dropdown from select"),I=e("<div />").attr("class",H.attr("class")).addClass(S.selection).addClass(S.dropdown).html(q.dropdown(t)).insertBefore(H),H.hasClass(S.multiple)&&H.prop("multiple")===!1&&(w.error(O.missingMultiple),H.prop("multiple",!0)),H.is("[multiple]")&&w.set.multiple(),H.prop("disabled")&&(w.debug("Disabling dropdown"),I.addClass(S.disabled)),H.removeAttr("class").detach().prependTo(I)),w.refresh()},menu:function(e){W.html(q.menu(e,A)),B=W.find(D.item)},reference:function(){w.debug("Dropdown behavior was called on select, replacing with closest dropdown"),I=I.parent(D.dropdown),w.refresh(),w.setup.returnedObject(),f&&(Z=w,w.invoke(m))},returnedObject:function(){var e=r.slice(0,p),t=r.slice(p+1);r=e.add(I).add(t)}},refresh:function(){w.refreshSelectors(),w.refreshData()},refreshSelectors:function(){w.verbose("Refreshing selector cache"),N=I.find(D.text),V=I.find(D.search),H=I.find(D.input),M=I.find(D.icon),U=I.prev().find(D.text).length>0?I.prev().find(D.text):I.prev(),W=I.children(D.menu),B=W.find(D.item)},refreshData:function(){w.verbose("Refreshing cached metadata"),B.removeData(E.text).removeData(E.value),I.removeData(E.defaultText).removeData(E.defaultValue).removeData(E.placeholderText)},toggle:function(){w.verbose("Toggling menu visibility"),w.is.active()?w.hide():w.show()},show:function(t){if(t=e.isFunction(t)?t:function(){},w.can.show()&&!w.is.active()){if(w.debug("Showing dropdown"),w.is.multiple()&&!w.has.search()&&w.is.allFiltered())return!0;!w.has.message()||w.has.maxSelections()||w.has.allResultsFiltered()||w.remove.message(),k.onShow.call(Y)!==!1&&w.animate.show(function(){w.can.click()&&w.bind.intent(),w.set.visible(),t.call(Y)})}},hide:function(t){t=e.isFunction(t)?t:function(){},w.is.active()&&(w.debug("Hiding dropdown"),k.onHide.call(Y)!==!1&&w.animate.hide(function(){w.remove.visible(),t.call(Y)}))},hideOthers:function(){w.verbose("Finding other dropdowns to hide"),r.not(I).has(D.menu+"."+S.visible).dropdown("hide")},hideMenu:function(){w.verbose("Hiding menu instantaneously"),w.remove.active(),w.remove.visible(),W.transition("hide")},hideSubMenus:function(){var e=W.children(D.item).find(D.menu);w.verbose("Hiding sub menus",e),e.transition("hide")},bind:{events:function(){l&&w.bind.touchEvents(),w.bind.keyboardEvents(),w.bind.inputEvents(),w.bind.mouseEvents()},touchEvents:function(){w.debug("Touch device detected binding additional touch events"),w.is.searchSelection()||w.is.single()&&I.on("touchstart"+j,w.event.test.toggle),W.on("touchstart"+j,D.item,w.event.item.mouseenter)},keyboardEvents:function(){w.verbose("Binding keyboard events"),I.on("keydown"+j,w.event.keydown),w.has.search()&&I.on(w.get.inputEvent()+j,D.search,w.event.input),w.is.multiple()&&s.on("keydown"+b,w.event.document.keydown)},inputEvents:function(){w.verbose("Binding input change events"),I.on("change"+j,D.input,w.event.change)},mouseEvents:function(){w.verbose("Binding mouse events"),w.is.multiple()&&I.on("click"+j,D.label,w.event.label.click).on("click"+j,D.remove,w.event.remove.click),w.is.searchSelection()?(I.on("mousedown"+j,D.menu,w.event.menu.mousedown).on("mouseup"+j,D.menu,w.event.menu.mouseup).on("click"+j,D.icon,w.event.icon.click).on("click"+j,D.search,w.show).on("focus"+j,D.search,w.event.search.focus).on("blur"+j,D.search,w.event.search.blur).on("click"+j,D.text,w.event.text.focus),w.is.multiple()&&I.on("click"+j,w.event.click)):("click"==k.on?I.on("click"+j,D.icon,w.event.icon.click).on("click"+j,w.event.test.toggle):"hover"==k.on?I.on("mouseenter"+j,w.delay.show).on("mouseleave"+j,w.delay.hide):I.on(k.on+j,w.toggle),I.on("mousedown"+j,w.event.mousedown).on("mouseup"+j,w.event.mouseup).on("focus"+j,w.event.focus).on("blur"+j,w.event.blur)),W.on("mouseenter"+j,D.item,w.event.item.mouseenter).on("mouseleave"+j,D.item,w.event.item.mouseleave).on("click"+j,D.item,w.event.item.click)},intent:function(){w.verbose("Binding hide intent event to document"),l&&s.on("touchstart"+b,w.event.test.touch).on("touchmove"+b,w.event.test.touch),s.on("click"+b,w.event.test.hide)}},unbind:{intent:function(){w.verbose("Removing hide intent event from document"),l&&s.off("touchstart"+b).off("touchmove"+b),s.off("click"+b)}},filter:function(e){var t=e!==i?e:w.get.query(),n=function(){w.is.multiple()&&w.filterActive(),w.select.firstUnfiltered(),w.has.allResultsFiltered()?k.onNoResults.call(Y,t)?k.allowAdditions||(w.verbose("All items filtered, showing message",t),w.add.message(T.noResults)):(w.verbose("All items filtered, hiding dropdown",t),w.hideMenu()):w.remove.message(),k.allowAdditions&&w.add.userSuggestion(e),w.is.searchSelection()&&w.can.show()&&w.is.focusedOnSearch()&&w.show()};k.useLabels&&w.has.maxSelections()||(k.apiSettings?w.can.useAPI()?w.queryRemote(t,function(){n()}):w.error(O.noAPI):(w.filterItems(t),n()))},queryRemote:function(t,n){var i={errorDuration:!1,throttle:k.throttle,urlData:{query:t},onError:function(){w.add.message(T.serverError),n()},onFailure:function(){w.add.message(T.serverError),n()},onSuccess:function(e){w.remove.message(),w.setup.menu({values:e[A.remoteValues]}),n()}};I.api("get request")||w.setup.api(),i=e.extend(!0,{},i,k.apiSettings),I.api("setting",i).api("query")},filterItems:function(t){var n=t!==i?t:w.get.query(),o=null,a=w.escape.regExp(n),r=new RegExp("^"+a,"igm");w.has.query()&&(o=[],w.verbose("Searching for matching values",n),B.each(function(){var t,i,a=e(this);if("both"==k.match||"text"==k.match){if(t=String(w.get.choiceText(a,!1)),-1!==t.search(r))return o.push(this),!0;if(k.fullTextSearch&&w.fuzzySearch(n,t))return o.push(this),!0}if("both"==k.match||"value"==k.match){if(i=String(w.get.choiceValue(a,t)),-1!==i.search(r))return o.push(this),!0;if(k.fullTextSearch&&w.fuzzySearch(n,i))return o.push(this),!0}})),w.debug("Showing only matched items",n),w.remove.filteredItem(),o&&B.not(o).addClass(S.filtered)},fuzzySearch:function(e,t){var n=t.length,i=e.length;if(e=e.toLowerCase(),t=t.toLowerCase(),i>n)return!1;if(i===n)return e===t;e:for(var o=0,a=0;i>o;o++){for(var r=e.charCodeAt(o);n>a;)if(t.charCodeAt(a++)===r)continue e;return!1}return!0},filterActive:function(){k.useLabels&&B.filter("."+S.active).addClass(S.filtered)},focusSearch:function(){w.is.search()&&!w.is.focusedOnSearch()&&V[0].focus()},forceSelection:function(){var e=B.not(S.filtered).filter("."+S.selected).eq(0),t=B.not(S.filtered).filter("."+S.active).eq(0),n=e.length>0?e:t,i=n.size()>0;if(w.has.query()){if(i)return w.debug("Forcing partial selection to selected item",n),void w.event.item.click.call(n);w.remove.searchTerm()}w.hide()},event:{change:function(){$||(w.debug("Input changed, updating selection"),w.set.selected())},focus:function(){k.showOnFocus&&!Q&&w.is.hidden()&&!h&&w.show()},click:function(t){var n=e(t.target);n.is(I)&&!w.is.focusedOnSearch()&&w.focusSearch()},blur:function(e){h=n.activeElement===this,Q||h||(w.remove.activeLabel(),w.hide())},mousedown:function(){Q=!0},mouseup:function(){Q=!1},search:{focus:function(){Q=!0,w.is.multiple()&&w.remove.activeLabel(),k.showOnFocus&&(w.search(),w.show())},blur:function(e){h=n.activeElement===this,X||h?h&&k.forceSelection&&w.forceSelection():w.is.multiple()?(w.remove.activeLabel(),w.hide()):k.forceSelection?w.forceSelection():w.hide()}},icon:{click:function(e){w.toggle(),e.stopPropagation()}},text:{focus:function(e){Q=!0,w.focusSearch()}},input:function(e){(w.is.multiple()||w.is.searchSelection())&&w.set.filtered(),clearTimeout(w.timer),w.timer=setTimeout(w.search,k.delay.search)},label:{click:function(t){var n=e(this),i=I.find(D.label),o=i.filter("."+S.active),a=n.nextAll("."+S.active),r=n.prevAll("."+S.active),s=a.length>0?n.nextUntil(a).add(o).add(n):n.prevUntil(r).add(o).add(n);t.shiftKey?(o.removeClass(S.active),s.addClass(S.active)):t.ctrlKey?n.toggleClass(S.active):(o.removeClass(S.active),n.addClass(S.active)),k.onLabelSelect.apply(this,i.filter("."+S.active))}},remove:{click:function(){var t=e(this).parent();t.hasClass(S.active)?w.remove.activeLabels():w.remove.activeLabels(t)}},test:{toggle:function(e){var t=w.is.multiple()?w.show:w.toggle;w.determine.eventOnElement(e,t)&&e.preventDefault()},touch:function(e){w.determine.eventOnElement(e,function(){"touchstart"==e.type?w.timer=setTimeout(function(){w.hide()},k.delay.touch):"touchmove"==e.type&&clearTimeout(w.timer)}),e.stopPropagation()},hide:function(e){w.determine.eventInModule(e,w.hide)}},menu:{mousedown:function(){X=!0},mouseup:function(){X=!1}},item:{mouseenter:function(t){var n=e(this).children(D.menu),i=e(this).siblings(D.item).children(D.menu);n.length>0&&(clearTimeout(w.itemTimer),w.itemTimer=setTimeout(function(){w.verbose("Showing sub-menu",n),e.each(i,function(){w.animate.hide(!1,e(this))}),w.animate.show(!1,n)},k.delay.show),t.preventDefault())},mouseleave:function(t){var n=e(this).children(D.menu);n.length>0&&(clearTimeout(w.itemTimer),w.itemTimer=setTimeout(function(){w.verbose("Hiding sub-menu",n),w.animate.hide(!1,n)},k.delay.hide))},touchend:function(){},click:function(t){var n=e(this),i=e(t?t.target:""),o=n.find(D.menu),a=w.get.choiceText(n),r=w.get.choiceValue(n,a),s=o.length>0,c=o.find(i).length>0;c||s&&!k.allowCategorySelection||(k.useLabels||(w.remove.filteredItem(),w.remove.searchTerm(),w.set.scrollPosition(n)),w.determine.selectAction.call(this,a,r))}},document:{keydown:function(e){var t=e.which,n=w.is.inObject(t,R);if(n){var i=I.find(D.label),o=i.filter("."+S.active),a=(o.data(E.value),i.index(o)),r=i.length,s=o.length>0,c=o.length>1,l=0===a,u=a+1==r,d=w.is.searchSelection(),m=w.is.focusedOnSearch(),f=w.is.focused(),g=m&&0===w.get.caretPosition();if(d&&!s&&!m)return;t==R.leftArrow?!f&&!g||s?s&&(e.shiftKey?w.verbose("Adding previous label to selection"):(w.verbose("Selecting previous label"),i.removeClass(S.active)),l&&!c?o.addClass(S.active):o.prev(D.siblingLabel).addClass(S.active).end(),
+e.preventDefault()):(w.verbose("Selecting previous label"),i.last().addClass(S.active)):t==R.rightArrow?(f&&!s&&i.first().addClass(S.active),s&&(e.shiftKey?w.verbose("Adding next label to selection"):(w.verbose("Selecting next label"),i.removeClass(S.active)),u?d?m?i.removeClass(S.active):w.focusSearch():c?o.next(D.siblingLabel).addClass(S.active):o.addClass(S.active):o.next(D.siblingLabel).addClass(S.active),e.preventDefault())):t==R.deleteKey||t==R.backspace?s?(w.verbose("Removing active labels"),u&&d&&!m&&w.focusSearch(),o.last().next(D.siblingLabel).addClass(S.active),w.remove.activeLabels(o),e.preventDefault()):g&&!s&&t==R.backspace&&(w.verbose("Removing last label on input backspace"),o=i.last().addClass(S.active),w.remove.activeLabels(o)):o.removeClass(S.active)}}},keydown:function(e){var t=e.which,n=w.is.inObject(t,R);if(n){var i,o,a=B.not(D.unselectable).filter("."+S.selected).eq(0),r=W.children("."+S.active).eq(0),s=a.length>0?a:r,c=s.length>0?s.siblings(":not(."+S.filtered+")").andSelf():W.children(":not(."+S.filtered+")"),l=s.children(D.menu),u=s.closest(D.menu),d=u.hasClass(S.visible)||u.hasClass(S.animating)||u.parent(D.menu).length>0,m=l.length>0,f=s.length>0,g=s.not(D.unselectable).length>0,p=t==R.delimiter&&k.allowAdditions&&w.is.multiple();if(w.is.visible()){if((t==R.enter||p)&&(t==R.enter&&f&&m&&!k.allowCategorySelection?(w.verbose("Pressed enter on unselectable category, opening sub menu"),t=R.rightArrow):g&&(w.verbose("Selecting item from keyboard shortcut",s),w.event.item.click.call(s,e),w.is.searchSelection()&&w.remove.searchTerm()),e.preventDefault()),t==R.leftArrow&&(o=u[0]!==W[0],o&&(w.verbose("Left key pressed, closing sub-menu"),w.animate.hide(!1,u),s.removeClass(S.selected),u.closest(D.item).addClass(S.selected),e.preventDefault())),t==R.rightArrow&&m&&(w.verbose("Right key pressed, opening sub-menu"),w.animate.show(!1,l),s.removeClass(S.selected),l.find(D.item).eq(0).addClass(S.selected),e.preventDefault()),t==R.upArrow){if(i=f&&d?s.prevAll(D.item+":not("+D.unselectable+")").eq(0):B.eq(0),c.index(i)<0)return w.verbose("Up key pressed but reached top of current menu"),void e.preventDefault();w.verbose("Up key pressed, changing active item"),s.removeClass(S.selected),i.addClass(S.selected),w.set.scrollPosition(i),e.preventDefault()}if(t==R.downArrow){if(i=f&&d?i=s.nextAll(D.item+":not("+D.unselectable+")").eq(0):B.eq(0),0===i.length)return w.verbose("Down key pressed but reached bottom of current menu"),void e.preventDefault();w.verbose("Down key pressed, changing active item"),B.removeClass(S.selected),i.addClass(S.selected),w.set.scrollPosition(i),e.preventDefault()}t==R.pageUp&&(w.scrollPage("up"),e.preventDefault()),t==R.pageDown&&(w.scrollPage("down"),e.preventDefault()),t==R.escape&&(w.verbose("Escape key pressed, closing dropdown"),w.hide())}else p&&e.preventDefault(),t==R.downArrow&&(w.verbose("Down key pressed, showing dropdown"),w.show(),e.preventDefault())}else w.is.selection()&&!w.is.search()&&w.set.selectedLetter(String.fromCharCode(t))}},trigger:{change:function(){var e=n.createEvent("HTMLEvents"),t=H[0];t&&(w.verbose("Triggering native change event"),e.initEvent("change",!0,!1),t.dispatchEvent(e))}},determine:{selectAction:function(t,n){w.verbose("Determining action",k.action),e.isFunction(w.action[k.action])?(w.verbose("Triggering preset action",k.action,t,n),w.action[k.action].call(this,t,n)):e.isFunction(k.action)?(w.verbose("Triggering user action",k.action,t,n),k.action.call(this,t,n)):w.error(O.action,k.action)},eventInModule:function(t,i){var o=e(t.target),a=o.closest(n.documentElement).length>0,r=o.closest(I).length>0;return i=e.isFunction(i)?i:function(){},a&&!r?(w.verbose("Triggering event",i),i(),!0):(w.verbose("Event occurred in dropdown, canceling callback"),!1)},eventOnElement:function(t,n){var i=e(t.target),o=i.closest(D.siblingLabel),a=0===I.find(o).length,r=0===i.closest(W).length;return n=e.isFunction(n)?n:function(){},a&&r?(w.verbose("Triggering event",n),n(),!0):(w.verbose("Event occurred in dropdown menu, canceling callback"),!1)}},action:{nothing:function(){},activate:function(t,n){if(n=n!==i?n:t,w.can.activate(e(this))){if(w.set.selected(n,e(this)),w.is.multiple()&&!w.is.allFiltered())return;w.hideAndClear()}},select:function(e,t){w.action.activate.call(this)},combo:function(t,n){n=n!==i?n:t,w.set.selected(n,e(this)),w.hideAndClear()},hide:function(e,t){w.set.value(t),w.hideAndClear()}},get:{id:function(){return y},defaultText:function(){return I.data(E.defaultText)},defaultValue:function(){return I.data(E.defaultValue)},placeholderText:function(){return I.data(E.placeholderText)||""},text:function(){return N.text()},query:function(){return e.trim(V.val())},searchWidth:function(e){return e*k.glyphWidth+"em"},selectionCount:function(){var t,n=w.get.values();return t=w.is.multiple()?e.isArray(n)?n.length:0:""!==w.get.value()?1:0},transition:function(e){return"auto"==k.transition?w.is.upward(e)?"slide up":"slide down":k.transition},userValues:function(){var t=w.get.values();return t?(t=e.isArray(t)?t:[t],e.grep(t,function(e){return w.get.item(e)===!1})):!1},uniqueArray:function(t){return e.grep(t,function(n,i){return e.inArray(n,t)===i})},caretPosition:function(){var e,t,i=V.get(0);return"selectionStart"in i?i.selectionStart:n.selection?(i.focus(),e=n.selection.createRange(),t=e.text.length,e.moveStart("character",-i.value.length),e.text.length-t):void 0},value:function(){var t=H.length>0?H.val():I.data(E.value);return e.isArray(t)&&1===t.length&&""===t[0]?"":t},values:function(){var e=w.get.value();return""===e?"":!w.has.selectInput()&&w.is.multiple()?"string"==typeof e?e.split(k.delimiter):"":e},remoteValues:function(){var t=w.get.values(),n=!1;return t&&("string"==typeof t&&(t=[t]),n={},e.each(t,function(e,t){var i=w.read.remoteData(t);w.verbose("Restoring value from session data",i,t),n[t]=i?i:t})),n},choiceText:function(t,n){return n=n!==i?n:k.preserveHTML,t?(t.find(D.menu).length>0&&(w.verbose("Retreiving text of element with sub-menu"),t=t.clone(),t.find(D.menu).remove(),t.find(D.menuIcon).remove()),t.data(E.text)!==i?t.data(E.text):n?e.trim(t.html()):e.trim(t.text())):void 0},choiceValue:function(t,n){return n=n||w.get.choiceText(t),t?t.data(E.value)!==i?String(t.data(E.value)):"string"==typeof n?e.trim(n.toLowerCase()):String(n):!1},inputEvent:function(){var e=V[0];return e?e.oninput!==i?"input":e.onpropertychange!==i?"propertychange":"keyup":!1},selectValues:function(){var t={};return t.values=[],I.find("option").each(function(){var n=e(this),o=n.html(),a=n.attr("disabled"),r=n.attr("value")!==i?n.attr("value"):o;"auto"===k.placeholder&&""===r?t.placeholder=o:t.values.push({name:o,value:r,disabled:a})}),k.placeholder&&"auto"!==k.placeholder&&(w.debug("Setting placeholder value to",k.placeholder),t.placeholder=k.placeholder),k.sortSelect?(t.values.sort(function(e,t){return e.name>t.name?1:-1}),w.debug("Retrieved and sorted values from select",t)):w.debug("Retreived values from select",t),t},activeItem:function(){return B.filter("."+S.active)},selectedItem:function(){var e=B.not(D.unselectable).filter("."+S.selected);return e.length>0?e:B.eq(0)},itemWithAdditions:function(e){var t=w.get.item(e),n=w.create.userChoice(e),i=n&&n.length>0;return i&&(t=t.length>0?t.add(n):n),t},item:function(t,n){var o,a,r=!1;return t=t!==i?t:w.get.values()!==i?w.get.values():w.get.text(),o=a?t.length>0:t!==i&&null!==t,a=w.is.multiple()&&e.isArray(t),n=""===t||0===t?!0:n||!1,o&&B.each(function(){var o=e(this),s=w.get.choiceText(o),c=w.get.choiceValue(o,s);if(null!==c&&c!==i)if(a)(-1!==e.inArray(String(c),t)||-1!==e.inArray(s,t))&&(r=r?r.add(o):o);else if(n){if(w.verbose("Ambiguous dropdown value using strict type check",o,t),c===t||s===t)return r=o,!0}else if(String(c)==String(t)||s==t)return w.verbose("Found select item by value",c,t),r=o,!0}),r}},check:{maxSelections:function(e){return k.maxSelections?(e=e!==i?e:w.get.selectionCount(),e>=k.maxSelections?(w.debug("Maximum selection count reached"),k.useLabels&&(B.addClass(S.filtered),w.add.message(T.maxSelections)),!0):(w.verbose("No longer at maximum selection count"),w.remove.message(),w.remove.filteredItem(),w.is.searchSelection()&&w.filterItems(),!1)):!0}},restore:{defaults:function(){w.clear(),w.restore.defaultText(),w.restore.defaultValue()},defaultText:function(){var e=w.get.defaultText(),t=w.get.placeholderText;e===t?(w.debug("Restoring default placeholder text",e),w.set.placeholderText(e)):(w.debug("Restoring default text",e),w.set.text(e))},defaultValue:function(){var e=w.get.defaultValue();e!==i&&(w.debug("Restoring default value",e),""!==e?(w.set.value(e),w.set.selected()):(w.remove.activeItem(),w.remove.selectedItem()))},labels:function(){k.allowAdditions&&(k.useLabels||(w.error(O.labels),k.useLabels=!0),w.debug("Restoring selected values"),w.create.userLabels()),w.check.maxSelections()},selected:function(){w.restore.values(),w.is.multiple()?(w.debug("Restoring previously selected values and labels"),w.restore.labels()):w.debug("Restoring previously selected values")},values:function(){w.set.initialLoad(),k.apiSettings?k.saveRemoteData?w.restore.remoteValues():w.clearValue():w.set.selected(),w.remove.initialLoad()},remoteValues:function(){var t=w.get.remoteValues();w.debug("Recreating selected from session data",t),t&&(w.is.single()?e.each(t,function(e,t){w.set.text(t)}):e.each(t,function(e,t){w.add.label(e,t)}))}},read:{remoteData:function(e){var n;return t.Storage===i?void w.error(O.noStorage):(n=sessionStorage.getItem(e),n!==i?n:!1)}},save:{defaults:function(){w.save.defaultText(),w.save.placeholderText(),w.save.defaultValue()},defaultValue:function(){var e=w.get.value();w.verbose("Saving default value as",e),I.data(E.defaultValue,e)},defaultText:function(){var e=w.get.text();w.verbose("Saving default text as",e),I.data(E.defaultText,e)},placeholderText:function(){var e;k.placeholder!==!1&&N.hasClass(S.placeholder)&&(e=w.get.text(),w.verbose("Saving placeholder text as",e),I.data(E.placeholderText,e))},remoteData:function(e,n){return t.Storage===i?void w.error(O.noStorage):(w.verbose("Saving remote data to session storage",n,e),void sessionStorage.setItem(n,e))}},clear:function(){w.is.multiple()?w.remove.labels():(w.remove.activeItem(),w.remove.selectedItem()),w.set.placeholderText(),w.clearValue()},clearValue:function(){w.set.value("")},scrollPage:function(e,t){var n,i,o,a=t||w.get.selectedItem(),r=a.closest(D.menu),s=r.outerHeight(),c=r.scrollTop(),l=B.eq(0).outerHeight(),u=Math.floor(s/l),d=(r.prop("scrollHeight"),"up"==e?c-l*u:c+l*u),m=B.not(D.unselectable);o="up"==e?m.index(a)-u:m.index(a)+u,n="up"==e?o>=0:o<m.length,i=n?m.eq(o):"up"==e?m.first():m.last(),i.length>0&&(w.debug("Scrolling page",e,i),a.removeClass(S.selected),i.addClass(S.selected),r.scrollTop(d))},set:{filtered:function(){var e=w.is.multiple(),t=w.is.searchSelection(),n=e&&t,i=t?w.get.query():"",o="string"==typeof i&&i.length>0,a=w.get.searchWidth(i.length),r=""!==i;e&&o&&(w.verbose("Adjusting input width",a,k.glyphWidth),V.css("width",a)),o||n&&r?(w.verbose("Hiding placeholder text"),N.addClass(S.filtered)):(!e||n&&!r)&&(w.verbose("Showing placeholder text"),N.removeClass(S.filtered))},loading:function(){I.addClass(S.loading)},placeholderText:function(e){e=e||w.get.placeholderText(),w.debug("Setting placeholder text",e),w.set.text(e),N.addClass(S.placeholder)},tabbable:function(){w.has.search()?(w.debug("Added tabindex to searchable dropdown"),V.val("").attr("tabindex",0),W.attr("tabindex",-1)):(w.debug("Added tabindex to dropdown"),I.attr("tabindex")===i&&(I.attr("tabindex",0),W.attr("tabindex",-1)))},initialLoad:function(){w.verbose("Setting initial load"),v=!0},activeItem:function(e){k.allowAdditions&&e.filter(D.addition).length>0?e.addClass(S.filtered):e.addClass(S.active)},scrollPosition:function(e,t){var n,o,a,r,s,c,l,u,d,m=5;e=e||w.get.selectedItem(),n=e.closest(D.menu),o=e&&e.length>0,t=t!==i?t:!1,e&&n.length>0&&o&&(r=e.position().top,n.addClass(S.loading),c=n.scrollTop(),s=n.offset().top,r=e.offset().top,a=c-s+r,t||(l=n.height(),d=a+m>c+l,u=c>a-m),w.debug("Scrolling to active item",a),(t||u||d)&&n.scrollTop(a),n.removeClass(S.loading))},text:function(e){"select"!==k.action&&("combo"==k.action?(w.debug("Changing combo button text",e,U),k.preserveHTML?U.html(e):U.text(e)):(e!==w.get.placeholderText()&&N.removeClass(S.placeholder),w.debug("Changing text",e,N),N.removeClass(S.filtered),k.preserveHTML?N.html(e):N.text(e)))},selectedLetter:function(t){var n,i=B.filter("."+S.selected),o=i.length>0&&w.has.firstLetter(i,t),a=!1;o&&(n=i.nextAll(B).eq(0),w.has.firstLetter(n,t)&&(a=n)),a||B.each(function(){return w.has.firstLetter(e(this),t)?(a=e(this),!1):void 0}),a&&(w.verbose("Scrolling to next value with letter",t),w.set.scrollPosition(a),i.removeClass(S.selected),a.addClass(S.selected))},direction:function(e){"auto"==k.direction?w.is.onScreen(e)?w.remove.upward(e):w.set.upward(e):"upward"==k.direction&&w.set.upward(e)},upward:function(e){var t=e||I;t.addClass(S.upward)},value:function(e,t,n){var o=H.length>0,a=(!w.has.value(e),w.get.values()),r=e!==i?String(e):e;if(o){if(r==a&&(w.verbose("Skipping value update already same value",e,a),!w.is.initialLoad()))return;w.is.single()&&w.has.selectInput()&&w.can.extendSelect()&&(w.debug("Adding user option",e),w.add.optionValue(e)),w.debug("Updating input value",e,a),$=!0,H.val(e),k.fireOnInit===!1&&w.is.initialLoad()?w.debug("Input native change event ignored on initial load"):w.trigger.change(),$=!1}else w.verbose("Storing value in metadata",e,H),e!==a&&I.data(E.value,r);k.fireOnInit===!1&&w.is.initialLoad()?w.verbose("No callback on initial load",k.onChange):k.onChange.call(Y,e,t,n)},active:function(){I.addClass(S.active)},multiple:function(){I.addClass(S.multiple)},visible:function(){I.addClass(S.visible)},exactly:function(e,t){w.debug("Setting selected to exact values"),w.clear(),w.set.selected(e,t)},selected:function(t,n){var i=w.is.multiple();n=k.allowAdditions?n||w.get.itemWithAdditions(t):n||w.get.item(t),n&&(w.debug("Setting selected menu item to",n),w.is.single()?(w.remove.activeItem(),w.remove.selectedItem()):k.useLabels&&w.remove.selectedItem(),n.each(function(){var t=e(this),o=w.get.choiceText(t),a=w.get.choiceValue(t,o),r=t.hasClass(S.filtered),s=t.hasClass(S.active),c=t.hasClass(S.addition),l=i&&1==n.length;i?!s||c?(k.apiSettings&&k.saveRemoteData&&w.save.remoteData(o,a),k.useLabels?(w.add.value(a,o,t),w.add.label(a,o,l),w.set.activeItem(t),w.filterActive(),w.select.nextAvailable(n)):(w.add.value(a,o,t),w.set.text(w.add.variables(T.count)),w.set.activeItem(t))):r||(w.debug("Selected active value, removing label"),w.remove.selected(a)):(k.apiSettings&&k.saveRemoteData&&w.save.remoteData(o,a),w.set.text(o),w.set.value(a,o,t),t.addClass(S.active).addClass(S.selected))}))}},add:{label:function(t,n,i){var o,a=w.is.searchSelection()?V:N;return o=e("<a />").addClass(S.label).attr("data-value",t).html(q.label(t,n)),o=k.onLabelCreate.call(o,t,n),w.has.label(t)?void w.debug("Label already exists, skipping",t):(k.label.variation&&o.addClass(k.label.variation),void(i===!0?(w.debug("Animating in label",o),o.addClass(S.hidden).insertBefore(a).transition(k.label.transition,k.label.duration)):(w.debug("Adding selection label",o),o.insertBefore(a))))},message:function(t){var n=W.children(D.message),i=k.templates.message(w.add.variables(t));n.length>0?n.html(i):n=e("<div/>").html(i).addClass(S.message).appendTo(W)},optionValue:function(t){var n=H.find('option[value="'+t+'"]'),i=n.length>0;i||(x&&(x.disconnect(),w.verbose("Temporarily disconnecting mutation observer",t)),w.is.single()&&(w.verbose("Removing previous user addition"),H.find("option."+S.addition).remove()),e("<option/>").prop("value",t).addClass(S.addition).html(t).appendTo(H),w.verbose("Adding user addition as an <option>",t),x&&x.observe(H[0],{childList:!0,subtree:!0}))},userSuggestion:function(e){var t,n=W.children(D.addition),i=w.get.item(e),o=i&&i.not(D.addition).length,a=n.length>0;if(!k.useLabels||!w.has.maxSelections()){if(""===e||o)return void n.remove();B.removeClass(S.selected),a?(t=k.templates.addition(w.add.variables(T.addResult,e)),n.html(t).attr("data-"+E.value,e).attr("data-"+E.text,e).removeClass(S.filtered).addClass(S.selected),w.verbose("Replacing user suggestion with new value",n)):(n=w.create.userChoice(e),n.prependTo(W).addClass(S.selected),w.verbose("Adding item choice to menu corresponding with user choice addition",n))}},variables:function(e,t){var n,i,o=-1!==e.search("{count}"),a=-1!==e.search("{maxCount}"),r=-1!==e.search("{term}");return w.verbose("Adding templated variables to message",e),o&&(n=w.get.selectionCount(),e=e.replace("{count}",n)),a&&(n=w.get.selectionCount(),e=e.replace("{maxCount}",k.maxSelections)),r&&(i=t||w.get.query(),e=e.replace("{term}",i)),e},value:function(t,n,i){var o,a=w.get.values();return""===t?void w.debug("Cannot select blank values from multiselect"):(e.isArray(a)?(o=a.concat([t]),o=w.get.uniqueArray(o)):o=[t],w.has.selectInput()?w.can.extendSelect()&&(w.debug("Adding value to select",t,o,H),w.add.optionValue(t)):(o=o.join(k.delimiter),w.debug("Setting hidden input to delimited value",o,H)),k.fireOnInit===!1&&w.is.initialLoad()?w.verbose("Skipping onadd callback on initial load",k.onAdd):k.onAdd.call(Y,t,n,i),w.set.value(o,t,n,i),void w.check.maxSelections())}},remove:{active:function(){I.removeClass(S.active)},activeLabel:function(){I.find(D.label).removeClass(S.active)},loading:function(){I.removeClass(S.loading)},initialLoad:function(){v=!1},upward:function(e){var t=e||I;t.removeClass(S.upward)},visible:function(){I.removeClass(S.visible)},activeItem:function(){B.removeClass(S.active)},filteredItem:function(){k.useLabels&&w.has.maxSelections()||(k.useLabels&&w.is.multiple()?B.not("."+S.active).removeClass(S.filtered):B.removeClass(S.filtered))},optionValue:function(e){var t=H.find('option[value="'+e+'"]'),n=t.length>0;n&&t.hasClass(S.addition)&&(x&&(x.disconnect(),w.verbose("Temporarily disconnecting mutation observer",e)),t.remove(),w.verbose("Removing user addition as an <option>",e),x&&x.observe(H[0],{childList:!0,subtree:!0}))},message:function(){W.children(D.message).remove()},searchTerm:function(){w.verbose("Cleared search term"),V.val(""),w.set.filtered()},selected:function(t,n){return(n=k.allowAdditions?n||w.get.itemWithAdditions(t):n||w.get.item(t))?void n.each(function(){var t=e(this),n=w.get.choiceText(t),i=w.get.choiceValue(t,n);w.is.multiple()?k.useLabels?(w.remove.value(i,n,t),w.remove.label(i)):(w.remove.value(i,n,t),0===w.get.selectionCount()?w.set.placeholderText():w.set.text(w.add.variables(T.count))):w.remove.value(i,n,t),t.removeClass(S.filtered).removeClass(S.active),k.useLabels&&t.removeClass(S.selected)}):!1},selectedItem:function(){B.removeClass(S.selected)},value:function(e,t,n){var i,o=w.get.values();w.has.selectInput()?(w.verbose("Input is <select> removing selected option",e),i=w.remove.arrayValue(e,o),w.remove.optionValue(e)):(w.verbose("Removing from delimited values",e),i=w.remove.arrayValue(e,o),i=i.join(k.delimiter)),k.fireOnInit===!1&&w.is.initialLoad()?w.verbose("No callback on initial load",k.onRemove):k.onRemove.call(Y,e,t,n),w.set.value(i,t,n),w.check.maxSelections()},arrayValue:function(t,n){return e.isArray(n)||(n=[n]),n=e.grep(n,function(e){return t!=e}),w.verbose("Removed value from delimited string",t,n),n},label:function(e,t){var n=I.find(D.label),i=n.filter('[data-value="'+e+'"]');w.verbose("Removing label",i),i.remove()},activeLabels:function(e){e=e||I.find(D.label).filter("."+S.active),w.verbose("Removing active label selections",e),w.remove.labels(e)},labels:function(t){t=t||I.find(D.label),w.verbose("Removing labels",t),t.each(function(){var t=e(this),n=t.data(E.value),o=n!==i?String(n):n,a=w.is.userValue(o);return k.onLabelRemove.call(t,n)===!1?void w.debug("Label remove callback cancelled removal"):void(a?(w.remove.value(o),w.remove.label(o)):w.remove.selected(o))})},tabbable:function(){w.has.search()?(w.debug("Searchable dropdown initialized"),V.removeAttr("tabindex"),W.removeAttr("tabindex")):(w.debug("Simple selection dropdown initialized"),I.removeAttr("tabindex"),W.removeAttr("tabindex"))}},has:{search:function(){return V.length>0},selectInput:function(){return H.is("select")},firstLetter:function(e,t){var n,i;return e&&0!==e.length&&"string"==typeof t?(n=w.get.choiceText(e,!1),t=t.toLowerCase(),i=String(n).charAt(0).toLowerCase(),t==i):!1},input:function(){return H.length>0},items:function(){return B.length>0},menu:function(){return W.length>0},message:function(){return 0!==W.children(D.message).length},label:function(e){var t=I.find(D.label);return t.filter('[data-value="'+e+'"]').length>0},maxSelections:function(){return k.maxSelections&&w.get.selectionCount()>=k.maxSelections},allResultsFiltered:function(){return B.filter(D.unselectable).length===B.length},query:function(){return""!==w.get.query()},value:function(t){var n=w.get.values(),i=e.isArray(n)?n&&-1!==e.inArray(t,n):n==t;return i?!0:!1}},is:{active:function(){return I.hasClass(S.active)},alreadySetup:function(){return I.is("select")&&I.parent(D.dropdown).length>0&&0===I.prev().length},animating:function(e){return e?e.transition&&e.transition("is animating"):W.transition&&W.transition("is animating")},disabled:function(){return I.hasClass(S.disabled)},focused:function(){return n.activeElement===I[0]},focusedOnSearch:function(){return n.activeElement===V[0]},allFiltered:function(){return(w.is.multiple()||w.has.search())&&!w.has.message()&&w.has.allResultsFiltered()},hidden:function(e){return!w.is.visible(e)},initialLoad:function(){return v},onScreen:function(e){var t,n=e||W,i=!0,o={};return n.addClass(S.loading),t={context:{scrollTop:L.scrollTop(),height:L.outerHeight()},menu:{offset:n.offset(),height:n.outerHeight()}},o={above:t.context.scrollTop<=t.menu.offset.top-t.menu.height,below:t.context.scrollTop+t.context.height>=t.menu.offset.top+t.menu.height},o.below?(w.verbose("Dropdown can fit in context downward",o),i=!0):o.below||o.above?(w.verbose("Dropdown cannot fit below, opening upward",o),i=!1):(w.verbose("Dropdown cannot fit in either direction, favoring downward",o),i=!0),n.removeClass(S.loading),i},inObject:function(t,n){var i=!1;return e.each(n,function(e,n){return n==t?(i=!0,!0):void 0}),i},multiple:function(){return I.hasClass(S.multiple)},single:function(){return!w.is.multiple()},selectMutation:function(t){var n=!1;return e.each(t,function(t,i){return i.target&&e(i.target).is("select")?(n=!0,!0):void 0}),n},search:function(){return I.hasClass(S.search)},searchSelection:function(){return w.has.search()&&1===V.parent(D.dropdown).length},selection:function(){return I.hasClass(S.selection)},userValue:function(t){return-1!==e.inArray(t,w.get.userValues())},upward:function(e){var t=e||I;return t.hasClass(S.upward)},visible:function(e){return e?e.hasClass(S.visible):W.hasClass(S.visible)}},can:{activate:function(e){return k.useLabels?!0:w.has.maxSelections()?w.has.maxSelections()&&e.hasClass(S.active)?!0:!1:!0},click:function(){return l||"click"==k.on},extendSelect:function(){return k.allowAdditions||k.apiSettings},show:function(){return!w.is.disabled()&&(w.has.items()||w.has.message())},useAPI:function(){return e.fn.api!==i}},animate:{show:function(t,n){var o,a=n||W,r=n?function(){}:function(){w.hideSubMenus(),w.hideOthers(),w.set.active()};t=e.isFunction(t)?t:function(){},w.verbose("Doing menu show animation",a),w.set.direction(n),o=w.get.transition(n),w.is.selection()&&w.set.scrollPosition(w.get.selectedItem(),!0),(w.is.hidden(a)||w.is.animating(a))&&("none"==o?(r(),a.transition("show"),t.call(Y)):e.fn.transition!==i&&I.transition("is supported")?a.transition({animation:o+" in",debug:k.debug,verbose:k.verbose,duration:k.duration,queue:!0,onStart:r,onComplete:function(){t.call(Y)}}):w.error(O.noTransition,o))},hide:function(t,n){var o=n||W,a=(n?.9*k.duration:k.duration,n?function(){}:function(){w.can.click()&&w.unbind.intent(),w.remove.active()}),r=w.get.transition(n);t=e.isFunction(t)?t:function(){},(w.is.visible(o)||w.is.animating(o))&&(w.verbose("Doing menu hide animation",o),"none"==r?(a(),o.transition("hide"),t.call(Y)):e.fn.transition!==i&&I.transition("is supported")?o.transition({animation:r+" out",duration:k.duration,debug:k.debug,verbose:k.verbose,queue:!0,onStart:a,onComplete:function(){"auto"==k.direction&&w.remove.upward(n),t.call(Y)}}):w.error(O.transition))}},hideAndClear:function(){w.remove.searchTerm(),w.has.maxSelections()||(w.has.search()?w.hide(function(){w.remove.filteredItem()}):w.hide())},delay:{show:function(){w.verbose("Delaying show event to ensure user intent"),clearTimeout(w.timer),w.timer=setTimeout(w.show,k.delay.show)},hide:function(){w.verbose("Delaying hide event to ensure user intent"),clearTimeout(w.timer),w.timer=setTimeout(w.hide,k.delay.hide)}},escape:{regExp:function(e){return e=String(e),e.replace(F.escape,"\\$&")}},setting:function(t,n){if(w.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,k,t);else{if(n===i)return k[t];k[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,w,t);else{if(n===i)return w[t];w[t]=n}},debug:function(){k.debug&&(k.performance?w.performance.log(arguments):(w.debug=Function.prototype.bind.call(console.info,console,k.name+":"),w.debug.apply(console,arguments)))},verbose:function(){k.verbose&&k.debug&&(k.performance?w.performance.log(arguments):(w.verbose=Function.prototype.bind.call(console.info,console,k.name+":"),w.verbose.apply(console,arguments)))},error:function(){w.error=Function.prototype.bind.call(console.error,console,k.name+":"),w.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;k.performance&&(t=(new Date).getTime(),i=u||t,n=t-i,u=t,d.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:Y,"Execution Time":n})),clearTimeout(w.performance.timer),w.performance.timer=setTimeout(w.performance.display,500)},display:function(){var t=k.name+":",n=0;u=!1,clearTimeout(w.performance.timer),e.each(d,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",c&&(t+=" '"+c+"'"),(console.group!==i||console.table!==i)&&d.length>0&&(console.groupCollapsed(t),console.table?console.table(d):e.each(d,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),d=[]}},invoke:function(t,n,o){var r,s,c,l=Z;return n=n||g,o=Y||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):(w.error(O.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(a)?a.push(c):a!==i?a=[a,c]:c!==i&&(a=c),s}},f?(Z===i&&w.initialize(),w.invoke(m)):(Z!==i&&Z.invoke("destroy"),w.initialize())}),a!==i?a:r},e.fn.dropdown.settings={debug:!1,verbose:!1,performance:!0,on:"click",action:"activate",apiSettings:!1,saveRemoteData:!0,throttle:200,context:t,direction:"auto",keepOnScreen:!0,match:"both",fullTextSearch:!1,placeholder:"auto",preserveHTML:!0,sortSelect:!1,forceSelection:!0,allowAdditions:!1,maxSelections:!1,useLabels:!0,delimiter:",",showOnFocus:!0,allowTab:!0,allowCategorySelection:!1,fireOnInit:!1,transition:"auto",duration:200,glyphWidth:1.0714,label:{transition:"scale",duration:200,variation:!1},delay:{hide:300,show:200,search:20,touch:50},onChange:function(e,t,n){},onAdd:function(e,t,n){},onRemove:function(e,t,n){},onLabelSelect:function(e){},onLabelCreate:function(t,n){return e(this)},onLabelRemove:function(e){return!0},onNoResults:function(e){return!0},onShow:function(){},onHide:function(){},name:"Dropdown",namespace:"dropdown",message:{addResult:"Add <b>{term}</b>",count:"{count} selected",maxSelections:"Max {maxCount} selections",noResults:"No results found.",serverError:"There was an error contacting the server"},error:{action:"You called a dropdown action that was not defined",alreadySetup:"Once a select has been initialized behaviors must be called on the created ui dropdown",labels:"Allowing user additions currently requires the use of labels.",missingMultiple:"<select> requires multiple property to be set to correctly preserve multiple values",method:"The method you called is not defined.",noAPI:"The API module is required to load resources remotely",noStorage:"Saving remote data requires session storage",noTransition:"This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>"},regExp:{escape:/[-[\]{}()*+?.,\\^$|#\s]/g},metadata:{defaultText:"defaultText",defaultValue:"defaultValue",placeholderText:"placeholder",text:"text",value:"value"},fields:{remoteValues:"results",values:"values",name:"name",value:"value"},keys:{backspace:8,delimiter:188,deleteKey:46,enter:13,escape:27,pageUp:33,pageDown:34,leftArrow:37,upArrow:38,rightArrow:39,downArrow:40},selector:{addition:".addition",dropdown:".ui.dropdown",icon:"> .dropdown.icon",input:'> input[type="hidden"], > select',item:".item",label:"> .label",remove:"> .label > .delete.icon",siblingLabel:".label",menu:".menu",message:".message",menuIcon:".dropdown.icon",search:"input.search, .menu > .search > input",text:"> .text:not(.icon)",unselectable:".disabled, .filtered"},className:{active:"active",addition:"addition",animating:"animating",disabled:"disabled",dropdown:"ui dropdown",filtered:"filtered",hidden:"hidden transition",item:"item",label:"ui label",loading:"loading",menu:"menu",message:"message",multiple:"multiple",placeholder:"default",search:"search",selected:"selected",selection:"selection",upward:"upward",visible:"visible"}},e.fn.dropdown.settings.templates={dropdown:function(t){var n=t.placeholder||!1,i=(t.values||{},"");return i+='<i class="dropdown icon"></i>',i+=t.placeholder?'<div class="default text">'+n+"</div>":'<div class="text"></div>',i+='<div class="menu">',e.each(t.values,function(e,t){i+=t.disabled?'<div class="disabled item" data-value="'+t.value+'">'+t.name+"</div>":'<div class="item" data-value="'+t.value+'">'+t.name+"</div>"}),i+="</div>"},menu:function(t,n){var i=t[n.values]||{},o="";return e.each(i,function(e,t){o+='<div class="item" data-value="'+t[n.value]+'">'+t[n.name]+"</div>"}),o},label:function(e,t){return t+'<i class="delete icon"></i>'},message:function(e){return e},addition:function(e){return e}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.embed=function(n){var o,a=e(this),r=a.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return a.each(function(){var m,f=e.isPlainObject(n)?e.extend(!0,{},e.fn.embed.settings,n):e.extend({},e.fn.embed.settings),g=f.selector,p=f.className,v=f.sources,h=f.error,b=f.metadata,y=f.namespace,x=f.templates,C="."+y,w="module-"+y,k=(e(t),e(this)),S=k.find(g.placeholder),T=k.find(g.icon),A=k.find(g.embed),R=this,E=k.data(w);m={initialize:function(){m.debug("Initializing embed"),m.determine.autoplay(),m.create(),m.bind.events(),m.instantiate()},instantiate:function(){m.verbose("Storing instance of module",m),E=m,k.data(w,m)},destroy:function(){m.verbose("Destroying previous instance of embed"),m.reset(),k.removeData(w).off(C)},refresh:function(){m.verbose("Refreshing selector cache"),S=k.find(g.placeholder),T=k.find(g.icon),A=k.find(g.embed)},bind:{events:function(){m.has.placeholder()&&(m.debug("Adding placeholder events"),k.on("click"+C,g.placeholder,m.createAndShow).on("click"+C,g.icon,m.createAndShow))}},create:function(){var e=m.get.placeholder();e?m.createPlaceholder():m.createAndShow()},createPlaceholder:function(e){var t=m.get.icon(),n=m.get.url();m.generate.embed(n);e=e||m.get.placeholder(),k.html(x.placeholder(e,t)),m.debug("Creating placeholder for embed",e,t)},createEmbed:function(t){m.refresh(),t=t||m.get.url(),A=e("<div/>").addClass(p.embed).html(m.generate.embed(t)).appendTo(k),f.onCreate.call(R,t),m.debug("Creating embed object",A)},createAndShow:function(){m.createEmbed(),m.show()},change:function(e,t,n){m.debug("Changing video to ",e,t,n),
+k.data(b.source,e).data(b.id,t).data(b.url,n),m.create()},reset:function(){m.debug("Clearing embed and showing placeholder"),m.remove.active(),m.remove.embed(),m.showPlaceholder(),f.onReset.call(R)},show:function(){m.debug("Showing embed"),m.set.active(),f.onDisplay.call(R)},hide:function(){m.debug("Hiding embed"),m.showPlaceholder()},showPlaceholder:function(){m.debug("Showing placeholder image"),m.remove.active(),f.onPlaceholderDisplay.call(R)},get:{id:function(){return f.id||k.data(b.id)},placeholder:function(){return f.placeholder||k.data(b.placeholder)},icon:function(){return f.icon?f.icon:k.data(b.icon)!==i?k.data(b.icon):m.determine.icon()},source:function(e){return f.source?f.source:k.data(b.source)!==i?k.data(b.source):m.determine.source()},type:function(){var e=m.get.source();return v[e]!==i?v[e].type:!1},url:function(){return f.url?f.url:k.data(b.url)!==i?k.data(b.url):m.determine.url()}},determine:{autoplay:function(){m.should.autoplay()&&(f.autoplay=!0)},source:function(t){var n=!1;return t=t||m.get.url(),t&&e.each(v,function(e,i){return-1!==t.search(i.domain)?(n=e,!1):void 0}),n},icon:function(){var e=m.get.source();return v[e]!==i?v[e].icon:!1},url:function(){var e,t=f.id||k.data(b.id),n=f.source||k.data(b.source);return e=v[n]!==i?v[n].url.replace("{id}",t):!1,e&&k.data(b.url,e),e}},set:{active:function(){k.addClass(p.active)}},remove:{active:function(){k.removeClass(p.active)},embed:function(){A.empty()}},encode:{parameters:function(e){var t,n=[];for(t in e)n.push(encodeURIComponent(t)+"="+encodeURIComponent(e[t]));return n.join("&amp;")}},generate:{embed:function(e){m.debug("Generating embed html");var t,n,i=m.get.source();return e=m.get.url(e),e?(n=m.generate.parameters(i),t=x.iframe(e,n)):m.error(h.noURL,k),t},parameters:function(t,n){var o=v[t]&&v[t].parameters!==i?v[t].parameters(f):{};return n=n||f.parameters,n&&(o=e.extend({},o,n)),o=f.onEmbed(o),m.encode.parameters(o)}},has:{placeholder:function(){return f.placeholder||k.data(b.placeholder)}},should:{autoplay:function(){return"auto"===f.autoplay?f.placeholder||k.data(b.placeholder)!==i:f.autoplay}},is:{video:function(){return"video"==m.get.type()}},setting:function(t,n){if(m.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,m,t);else{if(n===i)return m[t];m[t]=n}},debug:function(){f.debug&&(f.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,f.name+":"),m.debug.apply(console,arguments)))},verbose:function(){f.verbose&&f.debug&&(f.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,f.name+":"),m.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;f.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:R,"Execution Time":n})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,500)},display:function(){var t=f.name+":",n=0;s=!1,clearTimeout(m.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",r&&(t+=" '"+r+"'"),a.length>1&&(t+=" ("+a.length+")"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,a){var r,s,c,l=E;return n=n||d,a=R||a,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):(m.error(h.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(a,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},u?(E===i&&m.initialize(),m.invoke(l)):(E!==i&&E.invoke("destroy"),m.initialize())}),o!==i?o:this},e.fn.embed.settings={name:"Embed",namespace:"embed",debug:!1,verbose:!1,performance:!0,icon:!1,source:!1,url:!1,id:!1,autoplay:"auto",color:"#444444",hd:!0,brandedUI:!1,parameters:!1,onDisplay:function(){},onPlaceholderDisplay:function(){},onReset:function(){},onCreate:function(e){},onEmbed:function(e){return e},metadata:{id:"id",icon:"icon",placeholder:"placeholder",source:"source",url:"url"},error:{noURL:"No URL specified",method:"The method you called is not defined"},className:{active:"active",embed:"embed"},selector:{embed:".embed",placeholder:".placeholder",icon:".icon"},sources:{youtube:{name:"youtube",type:"video",icon:"video play",domain:"youtube.com",url:"//www.youtube.com/embed/{id}",parameters:function(e){return{autohide:!e.brandedUI,autoplay:e.autoplay,color:e.colors||i,hq:e.hd,jsapi:e.api,modestbranding:!e.brandedUI}}},vimeo:{name:"vimeo",type:"video",icon:"video play",domain:"vimeo.com",url:"//player.vimeo.com/video/{id}",parameters:function(e){return{api:e.api,autoplay:e.autoplay,byline:e.brandedUI,color:e.colors||i,portrait:e.brandedUI,title:e.brandedUI}}}},templates:{iframe:function(e,t){return'<iframe src="'+e+"?"+t+'" width="100%" height="100%" frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>'},placeholder:function(e,t){var n="";return t&&(n+='<i class="'+t+' icon"></i>'),e&&(n+='<img class="placeholder" src="'+e+'">'),n}},api:!0,onPause:function(){},onPlay:function(){},onStop:function(){}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.modal=function(o){var a,r=e(this),s=e(t),c=e(n),l=e("body"),u=r.selector||"",d=(new Date).getTime(),m=[],f=arguments[0],g="string"==typeof f,p=[].slice.call(arguments,1),v=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)};return r.each(function(){var r,h,b,y,x,C,w,k,S,T=e.isPlainObject(o)?e.extend(!0,{},e.fn.modal.settings,o):e.extend({},e.fn.modal.settings),A=T.selector,R=T.className,E=T.namespace,P=T.error,F="."+E,D="module-"+E,O=e(this),q=e(T.context),j=O.find(A.close),z=this,I=O.data(D);S={initialize:function(){S.verbose("Initializing dimmer",q),S.create.id(),S.create.dimmer(),S.refreshModals(),S.bind.events(),T.observeChanges&&S.observeChanges(),S.instantiate()},instantiate:function(){S.verbose("Storing instance of modal"),I=S,O.data(D,I)},create:{dimmer:function(){var t={debug:T.debug,dimmerName:"modals",duration:{show:T.duration,hide:T.duration}},n=e.extend(!0,t,T.dimmerSettings);return T.inverted&&(n.variation=n.variation!==i?n.variation+" inverted":"inverted"),e.fn.dimmer===i?void S.error(P.dimmer):(S.debug("Creating dimmer with settings",n),y=q.dimmer(n),T.detachable?(S.verbose("Modal is detachable, moving content into dimmer"),y.dimmer("add content",O)):S.set.undetached(),T.blurring&&y.addClass(R.blurring),void(x=y.dimmer("get dimmer")))},id:function(){w=(Math.random().toString(16)+"000000000").substr(2,8),C="."+w,S.verbose("Creating unique id for element",w)}},destroy:function(){S.verbose("Destroying previous modal"),O.removeData(D).off(F),s.off(C),j.off(F),q.dimmer("destroy")},observeChanges:function(){"MutationObserver"in t&&(k=new MutationObserver(function(e){S.debug("DOM tree modified, refreshing"),S.refresh()}),k.observe(z,{childList:!0,subtree:!0}),S.debug("Setting up mutation observer",k))},refresh:function(){S.remove.scrolling(),S.cacheSizes(),S.set.screenHeight(),S.set.type(),S.set.position()},refreshModals:function(){h=O.siblings(A.modal),r=h.add(O)},attachEvents:function(t,n){var i=e(t);n=e.isFunction(S[n])?S[n]:S.toggle,i.length>0?(S.debug("Attaching modal events to element",t,n),i.off(F).on("click"+F,n)):S.error(P.notFound,t)},bind:{events:function(){S.verbose("Attaching events"),O.on("click"+F,A.close,S.event.close).on("click"+F,A.approve,S.event.approve).on("click"+F,A.deny,S.event.deny),s.on("resize"+C,S.event.resize)}},get:{id:function(){return(Math.random().toString(16)+"000000000").substr(2,8)}},event:{approve:function(){return T.onApprove.call(z,e(this))===!1?void S.verbose("Approve callback returned false cancelling hide"):void S.hide()},deny:function(){return T.onDeny.call(z,e(this))===!1?void S.verbose("Deny callback returned false cancelling hide"):void S.hide()},close:function(){S.hide()},click:function(t){var i=e(t.target),o=i.closest(A.modal).length>0,a=e.contains(n.documentElement,t.target);!o&&a&&(S.debug("Dimmer clicked, hiding all modals"),S.is.active()&&(S.remove.clickaway(),T.allowMultiple?S.hide():S.hideAll()))},debounce:function(e,t){clearTimeout(S.timer),S.timer=setTimeout(e,t)},keyboard:function(e){var t=e.which,n=27;t==n&&(T.closable?(S.debug("Escape key pressed hiding modal"),S.hide()):S.debug("Escape key pressed, but closable is set to false"),e.preventDefault())},resize:function(){y.dimmer("is active")&&v(S.refresh)}},toggle:function(){S.is.active()||S.is.animating()?S.hide():S.show()},show:function(t){t=e.isFunction(t)?t:function(){},S.refreshModals(),S.showModal(t)},hide:function(t){t=e.isFunction(t)?t:function(){},S.refreshModals(),S.hideModal(t)},showModal:function(t){t=e.isFunction(t)?t:function(){},S.is.animating()||!S.is.active()?(S.showDimmer(),S.cacheSizes(),S.set.position(),S.set.screenHeight(),S.set.type(),S.set.clickaway(),!T.allowMultiple&&S.others.active()?S.hideOthers(S.showModal):(T.onShow.call(z),T.transition&&e.fn.transition!==i&&O.transition("is supported")?(S.debug("Showing modal with css animations"),O.transition({debug:T.debug,animation:T.transition+" in",queue:T.queue,duration:T.duration,useFailSafe:!0,onComplete:function(){T.onVisible.apply(z),S.add.keyboardShortcuts(),S.save.focus(),S.set.active(),T.autofocus&&S.set.autofocus(),t()}})):S.error(P.noTransition))):S.debug("Modal is already visible")},hideModal:function(t,n){return t=e.isFunction(t)?t:function(){},S.debug("Hiding modal"),T.onHide.call(z,e(this))===!1?void S.verbose("Hide callback returned false cancelling hide"):void((S.is.animating()||S.is.active())&&(T.transition&&e.fn.transition!==i&&O.transition("is supported")?(S.remove.active(),O.transition({debug:T.debug,animation:T.transition+" out",queue:T.queue,duration:T.duration,useFailSafe:!0,onStart:function(){S.others.active()||n||S.hideDimmer(),S.remove.keyboardShortcuts()},onComplete:function(){T.onHidden.call(z),S.restore.focus(),t()}})):S.error(P.noTransition)))},showDimmer:function(){y.dimmer("is animating")||!y.dimmer("is active")?(S.debug("Showing dimmer"),y.dimmer("show")):S.debug("Dimmer already visible")},hideDimmer:function(){return y.dimmer("is animating")||y.dimmer("is active")?void y.dimmer("hide",function(){S.remove.clickaway(),S.remove.screenHeight()}):void S.debug("Dimmer is not visible cannot hide")},hideAll:function(t){var n=r.filter("."+R.active+", ."+R.animating);t=e.isFunction(t)?t:function(){},n.length>0&&(S.debug("Hiding all visible modals"),S.hideDimmer(),n.modal("hide modal",t))},hideOthers:function(t){var n=h.filter("."+R.active+", ."+R.animating);t=e.isFunction(t)?t:function(){},n.length>0&&(S.debug("Hiding other modals",h),n.modal("hide modal",t,!0))},others:{active:function(){return h.filter("."+R.active).length>0},animating:function(){return h.filter("."+R.animating).length>0}},add:{keyboardShortcuts:function(){S.verbose("Adding keyboard shortcuts"),c.on("keyup"+F,S.event.keyboard)}},save:{focus:function(){b=e(n.activeElement).blur()}},restore:{focus:function(){b&&b.length>0&&b.focus()}},remove:{active:function(){O.removeClass(R.active)},clickaway:function(){T.closable&&x.off("click"+C)},bodyStyle:function(){""===l.attr("style")&&(S.verbose("Removing style attribute"),l.removeAttr("style"))},screenHeight:function(){S.debug("Removing page height"),l.css("height","")},keyboardShortcuts:function(){S.verbose("Removing keyboard shortcuts"),c.off("keyup"+F)},scrolling:function(){y.removeClass(R.scrolling),O.removeClass(R.scrolling)}},cacheSizes:function(){var o=O.outerHeight();(S.cache===i||0!==o)&&(S.cache={pageHeight:e(n).outerHeight(),height:o+T.offset,contextHeight:"body"==T.context?e(t).height():y.height()}),S.debug("Caching modal and container sizes",S.cache)},can:{fit:function(){return S.cache.height+2*T.padding<S.cache.contextHeight}},is:{active:function(){return O.hasClass(R.active)},animating:function(){return O.transition("is supported")?O.transition("is animating"):O.is(":visible")},scrolling:function(){return y.hasClass(R.scrolling)},modernBrowser:function(){return!(t.ActiveXObject||"ActiveXObject"in t)}},set:{autofocus:function(){var e=O.find(":input").filter(":visible"),t=e.filter("[autofocus]"),n=t.length>0?t.first():e.first();n.length>0&&n.focus()},clickaway:function(){T.closable&&x.on("click"+C,S.event.click)},screenHeight:function(){S.can.fit()?l.css("height",""):(S.debug("Modal is taller than page content, resizing page height"),l.css("height",S.cache.height+2*T.padding))},active:function(){O.addClass(R.active)},scrolling:function(){y.addClass(R.scrolling),O.addClass(R.scrolling)},type:function(){S.can.fit()?(S.verbose("Modal fits on screen"),S.others.active()||S.others.animating()||S.remove.scrolling()):(S.verbose("Modal cannot fit on screen setting to scrolling"),S.set.scrolling())},position:function(){S.verbose("Centering modal on page",S.cache),S.can.fit()?O.css({top:"",marginTop:-(S.cache.height/2)}):O.css({marginTop:"",top:c.scrollTop()})},undetached:function(){y.addClass(R.undetached)}},setting:function(t,n){if(S.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,T,t);else{if(n===i)return T[t];T[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,S,t);else{if(n===i)return S[t];S[t]=n}},debug:function(){T.debug&&(T.performance?S.performance.log(arguments):(S.debug=Function.prototype.bind.call(console.info,console,T.name+":"),S.debug.apply(console,arguments)))},verbose:function(){T.verbose&&T.debug&&(T.performance?S.performance.log(arguments):(S.verbose=Function.prototype.bind.call(console.info,console,T.name+":"),S.verbose.apply(console,arguments)))},error:function(){S.error=Function.prototype.bind.call(console.error,console,T.name+":"),S.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;T.performance&&(t=(new Date).getTime(),i=d||t,n=t-i,d=t,m.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:z,"Execution Time":n})),clearTimeout(S.performance.timer),S.performance.timer=setTimeout(S.performance.display,500)},display:function(){var t=T.name+":",n=0;d=!1,clearTimeout(S.performance.timer),e.each(m,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",u&&(t+=" '"+u+"'"),(console.group!==i||console.table!==i)&&m.length>0&&(console.groupCollapsed(t),console.table?console.table(m):e.each(m,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),m=[]}},invoke:function(t,n,o){var r,s,c,l=I;return n=n||p,o=z||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(a)?a.push(c):a!==i?a=[a,c]:c!==i&&(a=c),s}},g?(I===i&&S.initialize(),S.invoke(f)):(I!==i&&I.invoke("destroy"),S.initialize())}),a!==i?a:this},e.fn.modal.settings={name:"Modal",namespace:"modal",debug:!1,verbose:!1,performance:!0,observeChanges:!1,allowMultiple:!1,detachable:!0,closable:!0,autofocus:!0,inverted:!1,blurring:!1,dimmerSettings:{closable:!1,useCSS:!0},context:"body",queue:!1,duration:500,offset:0,transition:"scale",padding:50,onShow:function(){},onVisible:function(){},onHide:function(){return!0},onHidden:function(){},onApprove:function(){return!0},onDeny:function(){return!0},selector:{close:"> .close",approve:".actions .positive, .actions .approve, .actions .ok",deny:".actions .negative, .actions .deny, .actions .cancel",modal:".ui.modal"},error:{dimmer:"UI Dimmer, a required component is not included in this page",method:"The method you called is not defined.",notFound:"The element you specified could not be found"},className:{active:"active",animating:"animating",blurring:"blurring",scrolling:"scrolling",undetached:"undetached"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.nag=function(n){var o,a=e(this),r=a.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return a.each(function(){var a,m=e.isPlainObject(n)?e.extend(!0,{},e.fn.nag.settings,n):e.extend({},e.fn.nag.settings),f=(m.className,m.selector),g=m.error,p=m.namespace,v="."+p,h=p+"-module",b=e(this),y=(b.find(f.close),e(m.context?m.context:"body")),x=this,C=b.data(h);t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)};a={initialize:function(){a.verbose("Initializing element"),b.on("click"+v,f.close,a.dismiss).data(h,a),m.detachable&&b.parent()[0]!==y[0]&&b.detach().prependTo(y),m.displayTime>0&&setTimeout(a.hide,m.displayTime),a.show()},destroy:function(){a.verbose("Destroying instance"),b.removeData(h).off(v)},show:function(){a.should.show()&&!b.is(":visible")&&(a.debug("Showing nag",m.animation.show),"fade"==m.animation.show?b.fadeIn(m.duration,m.easing):b.slideDown(m.duration,m.easing))},hide:function(){a.debug("Showing nag",m.animation.hide),"fade"==m.animation.show?b.fadeIn(m.duration,m.easing):b.slideUp(m.duration,m.easing)},onHide:function(){a.debug("Removing nag",m.animation.hide),b.remove(),m.onHide&&m.onHide()},dismiss:function(e){m.storageMethod&&a.storage.set(m.key,m.value),a.hide(),e.stopImmediatePropagation(),e.preventDefault()},should:{show:function(){return m.persist?(a.debug("Persistent nag is set, can show nag"),!0):a.storage.get(m.key)!=m.value.toString()?(a.debug("Stored value is not set, can show nag",a.storage.get(m.key)),!0):(a.debug("Stored value is set, cannot show nag",a.storage.get(m.key)),!1)}},get:{storageOptions:function(){var e={};return m.expires&&(e.expires=m.expires),m.domain&&(e.domain=m.domain),m.path&&(e.path=m.path),e}},clear:function(){a.storage.remove(m.key)},storage:{set:function(n,o){var r=a.get.storageOptions();if("localstorage"==m.storageMethod&&t.localStorage!==i)t.localStorage.setItem(n,o),a.debug("Value stored using local storage",n,o);else if("sessionstorage"==m.storageMethod&&t.sessionStorage!==i)t.sessionStorage.setItem(n,o),a.debug("Value stored using session storage",n,o);else{if(e.cookie===i)return void a.error(g.noCookieStorage);e.cookie(n,o,r),a.debug("Value stored using cookie",n,o,r)}},get:function(n,o){var r;return"localstorage"==m.storageMethod&&t.localStorage!==i?r=t.localStorage.getItem(n):"sessionstorage"==m.storageMethod&&t.sessionStorage!==i?r=t.sessionStorage.getItem(n):e.cookie!==i?r=e.cookie(n):a.error(g.noCookieStorage),("undefined"==r||"null"==r||r===i||null===r)&&(r=i),r},remove:function(n){var o=a.get.storageOptions();"localstorage"==m.storageMethod&&t.localStorage!==i?t.localStorage.removeItem(n):"sessionstorage"==m.storageMethod&&t.sessionStorage!==i?t.sessionStorage.removeItem(n):e.cookie!==i?e.removeCookie(n,o):a.error(g.noStorage)}},setting:function(t,n){if(a.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,m,t);else{if(n===i)return m[t];m[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,a,t);else{if(n===i)return a[t];a[t]=n}},debug:function(){m.debug&&(m.performance?a.performance.log(arguments):(a.debug=Function.prototype.bind.call(console.info,console,m.name+":"),a.debug.apply(console,arguments)))},verbose:function(){m.verbose&&m.debug&&(m.performance?a.performance.log(arguments):(a.verbose=Function.prototype.bind.call(console.info,console,m.name+":"),a.verbose.apply(console,arguments)))},error:function(){a.error=Function.prototype.bind.call(console.error,console,m.name+":"),a.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;m.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:x,"Execution Time":n})),clearTimeout(a.performance.timer),a.performance.timer=setTimeout(a.performance.display,500)},display:function(){var t=m.name+":",n=0;s=!1,clearTimeout(a.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",r&&(t+=" '"+r+"'"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,r){var s,c,l,u=C;return n=n||d,r=x||r,"string"==typeof t&&u!==i&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(n,o){var r=n!=s?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(u[r])&&n!=s)u=u[r];else{if(u[r]!==i)return c=u[r],!1;if(!e.isPlainObject(u[o])||n==s)return u[o]!==i?(c=u[o],!1):(a.error(g.method,t),!1);u=u[o]}})),e.isFunction(c)?l=c.apply(r,n):c!==i&&(l=c),e.isArray(o)?o.push(l):o!==i?o=[o,l]:l!==i&&(o=l),c}},u?(C===i&&a.initialize(),a.invoke(l)):(C!==i&&C.invoke("destroy"),a.initialize())}),o!==i?o:this},e.fn.nag.settings={name:"Nag",debug:!1,verbose:!1,performance:!0,namespace:"Nag",persist:!1,displayTime:0,animation:{show:"slide",hide:"slide"},context:!1,detachable:!1,expires:30,domain:!1,path:"/",storageMethod:"cookie",key:"nag",value:"dismiss",error:{noCookieStorage:"$.cookie is not included. A storage solution is required.",noStorage:"Neither $.cookie or store is defined. A storage solution is required for storing state",method:"The method you called is not defined."},className:{bottom:"bottom",fixed:"fixed"},selector:{close:".close.icon"},speed:500,easing:"easeOutQuad",onHide:function(){}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.popup=function(o){var a,r=e(this),s=e(n),c=e(t),l=e("body"),u=r.selector||"",d=!0,m=(new Date).getTime(),f=[],g=arguments[0],p="string"==typeof g,v=[].slice.call(arguments,1);return r.each(function(){var n,r,h,b,y,x=e.isPlainObject(o)?e.extend(!0,{},e.fn.popup.settings,o):e.extend({},e.fn.popup.settings),C=x.selector,w=x.className,k=x.error,S=x.metadata,T=x.namespace,A="."+x.namespace,R="module-"+T,E=e(this),P=e(x.context),F=x.target?e(x.target):E,D=0,O=!1,q=!1,j=this,z=E.data(R);y={initialize:function(){y.debug("Initializing",E),y.createID(),y.bind.events(),!y.exists()&&x.preserve&&y.create(),y.instantiate()},instantiate:function(){y.verbose("Storing instance",y),z=y,E.data(R,z)},refresh:function(){x.popup?n=e(x.popup).eq(0):x.inline&&(n=F.nextAll(C.popup).eq(0),x.popup=n),x.popup?(n.addClass(w.loading),r=y.get.offsetParent(),n.removeClass(w.loading),x.movePopup&&y.has.popup()&&y.get.offsetParent(n)[0]!==r[0]&&(y.debug("Moving popup to the same offset parent as activating element"),n.detach().appendTo(r))):r=x.inline?y.get.offsetParent(F):y.has.popup()?y.get.offsetParent(n):l,r.is("html")&&r[0]!==l[0]&&(y.debug("Setting page as offset parent"),r=l),y.get.variation()&&y.set.variation()},reposition:function(){y.refresh(),y.set.position()},destroy:function(){y.debug("Destroying previous module"),n&&!x.preserve&&y.removePopup(),clearTimeout(y.hideTimer),clearTimeout(y.showTimer),c.off(h),E.off(A).removeData(R)},event:{start:function(t){var n=e.isPlainObject(x.delay)?x.delay.show:x.delay;clearTimeout(y.hideTimer),q||(y.showTimer=setTimeout(y.show,n))},end:function(){var t=e.isPlainObject(x.delay)?x.delay.hide:x.delay;clearTimeout(y.showTimer),y.hideTimer=setTimeout(y.hide,t)},touchstart:function(e){q=!0,y.show()},resize:function(){y.is.visible()&&y.set.position()},hideGracefully:function(t){t&&0===e(t.target).closest(C.popup).length?(y.debug("Click occurred outside popup hiding popup"),y.hide()):y.debug("Click was inside popup, keeping popup open")}},create:function(){var t=y.get.html(),i=y.get.title(),o=y.get.content();t||o||i?(y.debug("Creating pop-up html"),t||(t=x.templates.popup({title:i,content:o})),n=e("<div/>").addClass(w.popup).data(S.activator,E).html(t),x.inline?(y.verbose("Inserting popup element inline",n),n.insertAfter(E)):(y.verbose("Appending popup element to body",n),n.appendTo(P)),y.refresh(),y.set.variation(),x.hoverable&&y.bind.popup(),x.onCreate.call(n,j)):0!==F.next(C.popup).length?(y.verbose("Pre-existing popup found"),x.inline=!0,x.popups=F.next(C.popup).data(S.activator,E),y.refresh(),x.hoverable&&y.bind.popup()):x.popup?(e(x.popup).data(S.activator,E),y.verbose("Used popup specified in settings"),y.refresh(),x.hoverable&&y.bind.popup()):y.debug("No content specified skipping display",j)},createID:function(){b=(Math.random().toString(16)+"000000000").substr(2,8),h="."+b,y.verbose("Creating unique id for element",b)},toggle:function(){y.debug("Toggling pop-up"),y.is.hidden()?(y.debug("Popup is hidden, showing pop-up"),y.unbind.close(),y.show()):(y.debug("Popup is visible, hiding pop-up"),y.hide())},show:function(e){if(e=e||function(){},y.debug("Showing pop-up",x.transition),y.is.hidden()&&(!y.is.active()||!y.is.dropdown())){if(y.exists()||y.create(),x.onShow.call(n,j)===!1)return void y.debug("onShow callback returned false, cancelling popup animation");x.preserve||x.popup||y.refresh(),n&&y.set.position()&&(y.save.conditions(),x.exclusive&&y.hideAll(),y.animate.show(e))}},hide:function(e){if(e=e||function(){},y.is.visible()||y.is.animating()){if(x.onHide.call(n,j)===!1)return void y.debug("onHide callback returned false, cancelling popup animation");y.remove.visible(),y.unbind.close(),y.restore.conditions(),y.animate.hide(e)}},hideAll:function(){e(C.popup).filter("."+w.visible).each(function(){e(this).data(S.activator).popup("hide")})},exists:function(){return n?x.inline||x.popup?y.has.popup():n.closest(P).length>=1?!0:!1:!1},removePopup:function(){y.has.popup()&&!x.popup&&(y.debug("Removing popup",n),n.remove(),n=i,x.onRemove.call(n,j))},save:{conditions:function(){y.cache={title:E.attr("title")},y.cache.title&&E.removeAttr("title"),y.verbose("Saving original attributes",y.cache.title)}},restore:{conditions:function(){return y.cache&&y.cache.title&&(E.attr("title",y.cache.title),y.verbose("Restoring original attributes",y.cache.title)),!0}},animate:{show:function(t){t=e.isFunction(t)?t:function(){},x.transition&&e.fn.transition!==i&&E.transition("is supported")?(y.set.visible(),n.transition({animation:x.transition+" in",queue:!1,debug:x.debug,verbose:x.verbose,duration:x.duration,onComplete:function(){y.bind.close(),t.call(n,j),x.onVisible.call(n,j)}})):y.error(k.noTransition)},hide:function(t){return t=e.isFunction(t)?t:function(){},y.debug("Hiding pop-up"),x.onHide.call(n,j)===!1?void y.debug("onHide callback returned false, cancelling popup animation"):void(x.transition&&e.fn.transition!==i&&E.transition("is supported")?n.transition({animation:x.transition+" out",queue:!1,duration:x.duration,debug:x.debug,verbose:x.verbose,onComplete:function(){y.reset(),t.call(n,j),x.onHidden.call(n,j)}}):y.error(k.noTransition))}},change:{content:function(e){n.html(e)}},get:{html:function(){return E.removeData(S.html),E.data(S.html)||x.html},title:function(){return E.removeData(S.title),E.data(S.title)||x.title},content:function(){return E.removeData(S.content),E.data(S.content)||E.attr("title")||x.content},variation:function(){return E.removeData(S.variation),E.data(S.variation)||x.variation},popup:function(){return n},popupOffset:function(){return n.offset()},calculations:function(){var e,i=F[0],o=x.inline||x.popup&&x.movePopup?F.position():F.offset(),a={};return a={target:{element:F[0],width:F.outerWidth(),height:F.outerHeight(),top:o.top,left:o.left,margin:{}},popup:{width:n.outerWidth(),height:n.outerHeight()},parent:{width:r.outerWidth(),height:r.outerHeight()},screen:{scroll:{top:c.scrollTop(),left:c.scrollLeft()},width:c.width(),height:c.height()}},x.setFluidWidth&&y.is.fluid()&&(a.container={width:n.parent().outerWidth()},a.popup.width=a.container.width),a.target.margin.top=x.inline?parseInt(t.getComputedStyle(i).getPropertyValue("margin-top"),10):0,a.target.margin.left=x.inline?y.is.rtl()?parseInt(t.getComputedStyle(i).getPropertyValue("margin-right"),10):parseInt(t.getComputedStyle(i).getPropertyValue("margin-left"),10):0,e=a.screen,a.boundary={top:e.scroll.top,bottom:e.scroll.top+e.height,left:e.scroll.left,right:e.scroll.left+e.width},a},id:function(){return b},startEvent:function(){return"hover"==x.on?"mouseenter":"focus"==x.on?"focus":!1},scrollEvent:function(){return"scroll"},endEvent:function(){return"hover"==x.on?"mouseleave":"focus"==x.on?"blur":!1},distanceFromBoundary:function(e,t){var n,i,o={};return e=e||y.get.offset(),t=t||y.get.calculations(),n=t.popup,i=t.boundary,e&&(o={top:e.top-i.top,left:e.left-i.left,right:i.right-(e.left+n.width),bottom:i.bottom-(e.top+n.height)},y.verbose("Distance from boundaries determined",e,o)),o},offsetParent:function(t){var n=t!==i?t[0]:E[0],o=n.parentNode,a=e(o);if(o)for(var r="none"===a.css("transform"),s="static"===a.css("position"),c=a.is("html");o&&!c&&s&&r;)o=o.parentNode,a=e(o),r="none"===a.css("transform"),s="static"===a.css("position"),c=a.is("html");return a&&a.length>0?a:e()},positions:function(){return{"top left":!1,"top center":!1,"top right":!1,"bottom left":!1,"bottom center":!1,"bottom right":!1,"left center":!1,"right center":!1}},nextPosition:function(e){var t=e.split(" "),n=t[0],i=t[1],o={top:"bottom",bottom:"top",left:"right",right:"left"},a={left:"center",center:"right",right:"left"},r={"top left":"top center","top center":"top right","top right":"right center","right center":"bottom right","bottom right":"bottom center","bottom center":"bottom left","bottom left":"left center","left center":"top left"},s="top"==n||"bottom"==n,c=!1,l=!1,u=!1;return O||(y.verbose("All available positions available"),O=y.get.positions()),y.debug("Recording last position tried",e),O[e]=!0,"opposite"===x.prefer&&(u=[o[n],i],u=u.join(" "),c=O[u]===!0,y.debug("Trying opposite strategy",u)),"adjacent"===x.prefer&&s&&(u=[n,a[i]],u=u.join(" "),l=O[u]===!0,y.debug("Trying adjacent strategy",u)),(l||c)&&(y.debug("Using backup position",u),u=r[e]),u}},set:{position:function(e,t){if(0===F.length||0===n.length)return void y.error(k.notFound);var o,a,r,s,c,l,u,d;if(t=t||y.get.calculations(),e=e||E.data(S.position)||x.position,o=E.data(S.offset)||x.offset,a=x.distanceAway,r=t.target,s=t.popup,c=t.parent,0===r.width&&0===r.height&&!(r.element instanceof SVGGraphicsElement))return y.debug("Popup target is hidden, no action taken"),!1;switch(x.inline&&(y.debug("Adding margin to calculation",r.margin),"left center"==e||"right center"==e?(o+=r.margin.top,a+=-r.margin.left):"top left"==e||"top center"==e||"top right"==e?(o+=r.margin.left,a-=r.margin.top):(o+=r.margin.left,a+=r.margin.top)),y.debug("Determining popup position from calculations",e,t),y.is.rtl()&&(e=e.replace(/left|right/g,function(e){return"left"==e?"right":"left"}),y.debug("RTL: Popup position updated",e)),D==x.maxSearchDepth&&"string"==typeof x.lastResort&&(e=x.lastResort),e){case"top left":l={top:"auto",bottom:c.height-r.top+a,left:r.left+o,right:"auto"};break;case"top center":l={bottom:c.height-r.top+a,left:r.left+r.width/2-s.width/2+o,top:"auto",right:"auto"};break;case"top right":l={bottom:c.height-r.top+a,right:c.width-r.left-r.width-o,top:"auto",left:"auto"};break;case"left center":l={top:r.top+r.height/2-s.height/2+o,right:c.width-r.left+a,left:"auto",bottom:"auto"};break;case"right center":l={top:r.top+r.height/2-s.height/2+o,left:r.left+r.width+a,bottom:"auto",right:"auto"};break;case"bottom left":l={top:r.top+r.height+a,left:r.left+o,bottom:"auto",right:"auto"};break;case"bottom center":l={top:r.top+r.height+a,left:r.left+r.width/2-s.width/2+o,bottom:"auto",right:"auto"};break;case"bottom right":l={top:r.top+r.height+a,right:c.width-r.left-r.width-o,left:"auto",bottom:"auto"}}if(l===i&&y.error(k.invalidPosition,e),y.debug("Calculated popup positioning values",l),n.css(l).removeClass(w.position).addClass(e).addClass(w.loading),
+u=y.get.popupOffset(),d=y.get.distanceFromBoundary(u,t),y.is.offstage(d,e)){if(y.debug("Position is outside viewport",e),D<x.maxSearchDepth)return D++,e=y.get.nextPosition(e),y.debug("Trying new position",e),n?y.set.position(e,t):!1;if(!x.lastResort)return y.debug("Popup could not find a position to display",n),y.error(k.cannotPlace,j),y.remove.attempts(),y.remove.loading(),y.reset(),!1;y.debug("No position found, showing with last position")}return y.debug("Position is on stage",e),y.remove.attempts(),y.remove.loading(),x.setFluidWidth&&y.is.fluid()&&y.set.fluidWidth(t),!0},fluidWidth:function(e){e=e||y.get.calculations(),y.debug("Automatically setting element width to parent width",e.parent.width),n.css("width",e.container.width)},variation:function(e){e=e||y.get.variation(),e&&y.has.popup()&&(y.verbose("Adding variation to popup",e),n.addClass(e))},visible:function(){E.addClass(w.visible)}},remove:{loading:function(){n.removeClass(w.loading)},variation:function(e){e=e||y.get.variation(),e&&(y.verbose("Removing variation",e),n.removeClass(e))},visible:function(){E.removeClass(w.visible)},attempts:function(){y.verbose("Resetting all searched positions"),D=0,O=!1}},bind:{events:function(){y.debug("Binding popup events to module"),"click"==x.on&&E.on("click"+A,y.toggle),"hover"==x.on&&d&&E.on("touchstart"+A,y.event.touchstart),y.get.startEvent()&&E.on(y.get.startEvent()+A,y.event.start).on(y.get.endEvent()+A,y.event.end),x.target&&y.debug("Target set to element",F),c.on("resize"+h,y.event.resize)},popup:function(){y.verbose("Allowing hover events on popup to prevent closing"),n&&y.has.popup()&&n.on("mouseenter"+A,y.event.start).on("mouseleave"+A,y.event.end)},close:function(){(x.hideOnScroll===!0||"auto"==x.hideOnScroll&&"click"!=x.on)&&(s.one(y.get.scrollEvent()+h,y.event.hideGracefully),P.one(y.get.scrollEvent()+h,y.event.hideGracefully)),"hover"==x.on&&q&&(y.verbose("Binding popup close event to document"),s.on("touchstart"+h,function(e){y.verbose("Touched away from popup"),y.event.hideGracefully.call(j,e)})),"click"==x.on&&x.closable&&(y.verbose("Binding popup close event to document"),s.on("click"+h,function(e){y.verbose("Clicked away from popup"),y.event.hideGracefully.call(j,e)}))}},unbind:{close:function(){(x.hideOnScroll===!0||"auto"==x.hideOnScroll&&"click"!=x.on)&&(s.off("scroll"+h,y.hide),P.off("scroll"+h,y.hide)),"hover"==x.on&&q&&(s.off("touchstart"+h),q=!1),"click"==x.on&&x.closable&&(y.verbose("Removing close event from document"),s.off("click"+h))}},has:{popup:function(){return n&&n.length>0}},is:{offstage:function(t,n){var i=[];return e.each(t,function(e,t){t<-x.jitter&&(y.debug("Position exceeds allowable distance from edge",e,t,n),i.push(e))}),i.length>0?!0:!1},active:function(){return E.hasClass(w.active)},animating:function(){return n&&n.hasClass(w.animating)},fluid:function(){return n&&n.hasClass(w.fluid)},visible:function(){return n&&n.hasClass(w.visible)},dropdown:function(){return E.hasClass(w.dropdown)},hidden:function(){return!y.is.visible()},rtl:function(){return"rtl"==E.css("direction")}},reset:function(){y.remove.visible(),x.preserve?e.fn.transition!==i&&n.transition("remove transition"):y.removePopup()},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,x,t);else{if(n===i)return x[t];x[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,y,t);else{if(n===i)return y[t];y[t]=n}},debug:function(){x.debug&&(x.performance?y.performance.log(arguments):(y.debug=Function.prototype.bind.call(console.info,console,x.name+":"),y.debug.apply(console,arguments)))},verbose:function(){x.verbose&&x.debug&&(x.performance?y.performance.log(arguments):(y.verbose=Function.prototype.bind.call(console.info,console,x.name+":"),y.verbose.apply(console,arguments)))},error:function(){y.error=Function.prototype.bind.call(console.error,console,x.name+":"),y.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;x.performance&&(t=(new Date).getTime(),i=m||t,n=t-i,m=t,f.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:j,"Execution Time":n})),clearTimeout(y.performance.timer),y.performance.timer=setTimeout(y.performance.display,500)},display:function(){var t=x.name+":",n=0;m=!1,clearTimeout(y.performance.timer),e.each(f,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",u&&(t+=" '"+u+"'"),(console.group!==i||console.table!==i)&&f.length>0&&(console.groupCollapsed(t),console.table?console.table(f):e.each(f,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),f=[]}},invoke:function(t,n,o){var r,s,c,l=z;return n=n||v,o=j||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(a)?a.push(c):a!==i?a=[a,c]:c!==i&&(a=c),s}},p?(z===i&&y.initialize(),y.invoke(g)):(z!==i&&z.invoke("destroy"),y.initialize())}),a!==i?a:this},e.fn.popup.settings={name:"Popup",debug:!1,verbose:!1,performance:!0,namespace:"popup",onCreate:function(){},onRemove:function(){},onShow:function(){},onVisible:function(){},onHide:function(){},onHidden:function(){},on:"hover",addTouchEvents:!0,position:"top left",variation:"",movePopup:!0,target:!1,popup:!1,inline:!1,preserve:!1,hoverable:!1,content:!1,html:!1,title:!1,closable:!0,hideOnScroll:"auto",exclusive:!1,context:"body",prefer:"opposite",lastResort:!1,delay:{show:50,hide:70},setFluidWidth:!0,duration:200,transition:"scale",distanceAway:0,jitter:2,offset:0,maxSearchDepth:15,error:{invalidPosition:"The position you specified is not a valid position",cannotPlace:"Popup does not fit within the boundaries of the viewport",method:"The method you called is not defined.",noTransition:"This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>",notFound:"The target or popup you specified does not exist on the page"},metadata:{activator:"activator",content:"content",html:"html",offset:"offset",position:"position",title:"title",variation:"variation"},className:{active:"active",animating:"animating",dropdown:"dropdown",fluid:"fluid",loading:"loading",popup:"ui popup",position:"top left center bottom right",visible:"visible"},selector:{popup:".ui.popup"},templates:{escape:function(e){var t=/[&<>"'`]/g,n=/[&<>"'`]/,i={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},o=function(e){return i[e]};return n.test(e)?e.replace(t,o):e},popup:function(t){var n="",o=e.fn.popup.settings.templates.escape;return typeof t!==i&&(typeof t.title!==i&&t.title&&(t.title=o(t.title),n+='<div class="header">'+t.title+"</div>"),typeof t.content!==i&&t.content&&(t.content=o(t.content),n+='<div class="content">'+t.content+"</div>")),n}}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.progress=function(t){var o,a=e(this),r=a.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return a.each(function(){var a,m,f=e.isPlainObject(t)?e.extend(!0,{},e.fn.progress.settings,t):e.extend({},e.fn.progress.settings),g=f.className,p=f.metadata,v=f.namespace,h=f.selector,b=f.error,y="."+v,x="module-"+v,C=e(this),w=e(this).find(h.bar),k=e(this).find(h.progress),S=e(this).find(h.label),T=this,A=C.data(x),R=!1;m={initialize:function(){m.debug("Initializing progress bar",f),m.set.duration(),m.set.transitionEvent(),m.read.metadata(),m.read.settings(),m.instantiate()},instantiate:function(){m.verbose("Storing instance of progress",m),A=m,C.data(x,m)},destroy:function(){m.verbose("Destroying previous progress for",C),clearInterval(A.interval),m.remove.state(),C.removeData(x),A=i},reset:function(){m.set.percent(0),m.set.value(0)},complete:function(){(m.percent===i||m.percent<100)&&m.set.percent(100)},read:{metadata:function(){var e={percent:C.data(p.percent),total:C.data(p.total),value:C.data(p.value)};e.percent&&(m.debug("Current percent value set from metadata",e.percent),m.set.percent(e.percent)),e.total&&(m.debug("Total value set from metadata",e.total),m.set.total(e.total)),e.value&&(m.debug("Current value set from metadata",e.value),m.set.value(e.value),m.set.progress(e.value))},settings:function(){f.total!==!1&&(m.debug("Current total set in settings",f.total),m.set.total(f.total)),f.value!==!1&&(m.debug("Current value set in settings",f.value),m.set.value(f.value),m.set.progress(m.value)),f.percent!==!1&&(m.debug("Current percent set in settings",f.percent),m.set.percent(f.percent))}},increment:function(e){var t,n,i;m.has.total()?(n=m.get.value(),e=e||1,i=n+e,t=m.get.total(),m.debug("Incrementing value",n,i,t),i>t&&(m.debug("Value cannot increment above total",t),i=t)):(n=m.get.percent(),e=e||m.get.randomValue(),i=n+e,t=100,m.debug("Incrementing percentage by",n,i),i>t&&(m.debug("Value cannot increment above 100 percent"),i=t)),m.set.progress(i)},decrement:function(e){var t,n,i=m.get.total();i?(t=m.get.value(),e=e||1,n=t-e,m.debug("Decrementing value by",e,t)):(t=m.get.percent(),e=e||m.get.randomValue(),n=t-e,m.debug("Decrementing percentage by",e,t)),0>n&&(m.debug("Value cannot decrement below 0"),n=0),m.set.progress(n)},has:{total:function(){return m.get.total()!==!1}},get:{text:function(e){var t=m.value||0,n=m.total||0,i=R?m.get.displayPercent():m.percent||0,o=m.total>0?n-t:100-i;return e=e||"",e=e.replace("{value}",t).replace("{total}",n).replace("{left}",o).replace("{percent}",i),m.debug("Adding variables to progress bar text",e),e},randomValue:function(){return m.debug("Generating random increment percentage"),Math.floor(Math.random()*f.random.max+f.random.min)},numericValue:function(e){return"string"==typeof e?""!==e.replace(/[^\d.]/g,"")?+e.replace(/[^\d.]/g,""):!1:e},transitionEnd:function(){var e,t=n.createElement("element"),o={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in o)if(t.style[e]!==i)return o[e]},displayPercent:function(){var e=w.width(),t=C.width(),n=parseInt(w.css("min-width"),10),i=e>n?e/t*100:m.percent;return f.precision>0?Math.round(i*(10*f.precision))/(10*f.precision):Math.round(i)},percent:function(){return m.percent||0},value:function(){return m.value||0},total:function(){return m.total||!1}},is:{success:function(){return C.hasClass(g.success)},warning:function(){return C.hasClass(g.warning)},error:function(){return C.hasClass(g.error)},active:function(){return C.hasClass(g.active)},visible:function(){return C.is(":visible")}},remove:{state:function(){m.verbose("Removing stored state"),delete m.total,delete m.percent,delete m.value},active:function(){m.verbose("Removing active state"),C.removeClass(g.active)},success:function(){m.verbose("Removing success state"),C.removeClass(g.success)},warning:function(){m.verbose("Removing warning state"),C.removeClass(g.warning)},error:function(){m.verbose("Removing error state"),C.removeClass(g.error)}},set:{barWidth:function(e){e>100?m.error(b.tooHigh,e):0>e?m.error(b.tooLow,e):(w.css("width",e+"%"),C.attr("data-percent",parseInt(e,10)))},duration:function(e){e=e||f.duration,e="number"==typeof e?e+"ms":e,m.verbose("Setting progress bar transition duration",e),w.css({"transition-duration":e})},percent:function(e){e="string"==typeof e?+e.replace("%",""):e,e=f.precision>0?Math.round(e*(10*f.precision))/(10*f.precision):Math.round(e),m.percent=e,m.has.total()||(m.value=f.precision>0?Math.round(e/100*m.total*(10*f.precision))/(10*f.precision):Math.round(e/100*m.total*10)/10,f.limitValues&&(m.value=m.value>100?100:m.value<0?0:m.value)),m.set.barWidth(e),m.set.labelInterval(),m.set.labels(),f.onChange.call(T,e,m.value,m.total)},labelInterval:function(){var e=function(){m.verbose("Bar finished animating, removing continuous label updates"),clearInterval(m.interval),R=!1,m.set.labels()};clearInterval(m.interval),w.one(a+y,e),m.timer=setTimeout(e,f.duration+100),R=!0,m.interval=setInterval(m.set.labels,f.framerate)},labels:function(){m.verbose("Setting both bar progress and outer label text"),m.set.barLabel(),m.set.state()},label:function(e){e=e||"",e&&(e=m.get.text(e),m.debug("Setting label to text",e),S.text(e))},state:function(e){e=e!==i?e:m.percent,100===e?!f.autoSuccess||m.is.warning()||m.is.error()?(m.verbose("Reached 100% removing active state"),m.remove.active()):(m.set.success(),m.debug("Automatically triggering success at 100%")):e>0?(m.verbose("Adjusting active progress bar label",e),m.set.active()):(m.remove.active(),m.set.label(f.text.active))},barLabel:function(e){e!==i?k.text(m.get.text(e)):"ratio"==f.label&&m.total?(m.debug("Adding ratio to bar label"),k.text(m.get.text(f.text.ratio))):"percent"==f.label&&(m.debug("Adding percentage to bar label"),k.text(m.get.text(f.text.percent)))},active:function(e){e=e||f.text.active,m.debug("Setting active state"),f.showActivity&&!m.is.active()&&C.addClass(g.active),m.remove.warning(),m.remove.error(),m.remove.success(),e&&m.set.label(e),f.onActive.call(T,m.value,m.total)},success:function(e){e=e||f.text.success,m.debug("Setting success state"),C.addClass(g.success),m.remove.active(),m.remove.warning(),m.remove.error(),m.complete(),e&&m.set.label(e),f.onSuccess.call(T,m.total)},warning:function(e){e=e||f.text.warning,m.debug("Setting warning state"),C.addClass(g.warning),m.remove.active(),m.remove.success(),m.remove.error(),m.complete(),e&&m.set.label(e),f.onWarning.call(T,m.value,m.total)},error:function(e){e=e||f.text.error,m.debug("Setting error state"),C.addClass(g.error),m.remove.active(),m.remove.success(),m.remove.warning(),m.complete(),e&&m.set.label(e),f.onError.call(T,m.value,m.total)},transitionEvent:function(){a=m.get.transitionEnd()},total:function(e){m.total=e},value:function(e){m.value=e},progress:function(e){var t,n=m.get.numericValue(e);n===!1&&m.error(b.nonNumeric,e),m.has.total()?(m.set.value(n),t=n/m.total*100,m.debug("Calculating percent complete from total",t),m.set.percent(t)):(t=n,m.debug("Setting value to exact percentage value",t),m.set.percent(t))}},setting:function(t,n){if(m.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,m,t);else{if(n===i)return m[t];m[t]=n}},debug:function(){f.debug&&(f.performance?m.performance.log(arguments):(m.debug=Function.prototype.bind.call(console.info,console,f.name+":"),m.debug.apply(console,arguments)))},verbose:function(){f.verbose&&f.debug&&(f.performance?m.performance.log(arguments):(m.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),m.verbose.apply(console,arguments)))},error:function(){m.error=Function.prototype.bind.call(console.error,console,f.name+":"),m.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;f.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:T,"Execution Time":n})),clearTimeout(m.performance.timer),m.performance.timer=setTimeout(m.performance.display,500)},display:function(){var t=f.name+":",n=0;s=!1,clearTimeout(m.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",r&&(t+=" '"+r+"'"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,a){var r,s,c,l=A;return n=n||d,a=T||a,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):(m.error(b.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(a,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},u?(A===i&&m.initialize(),m.invoke(l)):(A!==i&&A.invoke("destroy"),m.initialize())}),o!==i?o:this},e.fn.progress.settings={name:"Progress",namespace:"progress",debug:!1,verbose:!1,performance:!0,random:{min:2,max:5},duration:300,autoSuccess:!0,showActivity:!0,limitValues:!0,label:"percent",precision:0,framerate:1e3/30,percent:!1,total:!1,value:!1,onChange:function(e,t,n){},onSuccess:function(e){},onActive:function(e,t){},onError:function(e,t){},onWarning:function(e,t){},error:{method:"The method you called is not defined.",nonNumeric:"Progress value is non numeric",tooHigh:"Value specified is above 100%",tooLow:"Value specified is below 0%"},regExp:{variable:/\{\$*[A-z0-9]+\}/g},metadata:{percent:"percent",total:"total",value:"value"},selector:{bar:"> .bar",label:"> .label",progress:".bar > .progress"},text:{active:!1,error:!1,success:!1,warning:!1,percent:"{percent}%",ratio:"{value} of {total}"},className:{active:"active",error:"error",success:"success",warning:"warning"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.rating=function(t){var n,o=e(this),a=o.selector||"",r=(new Date).getTime(),s=[],c=arguments[0],l="string"==typeof c,u=[].slice.call(arguments,1);return o.each(function(){var d,m=e.isPlainObject(t)?e.extend(!0,{},e.fn.rating.settings,t):e.extend({},e.fn.rating.settings),f=m.namespace,g=m.className,p=m.metadata,v=m.selector,h=(m.error,"."+f),b="module-"+f,y=this,x=e(this).data(b),C=e(this),w=C.find(v.icon);d={initialize:function(){d.verbose("Initializing rating module",m),0===w.length&&d.setup.layout(),m.interactive?d.enable():d.disable(),d.set.rating(d.get.initialRating()),d.instantiate()},instantiate:function(){d.verbose("Instantiating module",m),x=d,C.data(b,d)},destroy:function(){d.verbose("Destroying previous instance",x),d.remove.events(),C.removeData(b)},refresh:function(){w=C.find(v.icon)},setup:{layout:function(){var t=d.get.maxRating(),n=e.fn.rating.settings.templates.icon(t);d.debug("Generating icon html dynamically"),C.html(n),d.refresh()}},event:{mouseenter:function(){var t=e(this);t.nextAll().removeClass(g.selected),C.addClass(g.selected),t.addClass(g.selected).prevAll().addClass(g.selected)},mouseleave:function(){C.removeClass(g.selected),w.removeClass(g.selected)},click:function(){var t=e(this),n=d.get.rating(),i=w.index(t)+1,o="auto"==m.clearable?1===w.length:m.clearable;o&&n==i?d.clearRating():d.set.rating(i)}},clearRating:function(){d.debug("Clearing current rating"),d.set.rating(0)},bind:{events:function(){d.verbose("Binding events"),C.on("mouseenter"+h,v.icon,d.event.mouseenter).on("mouseleave"+h,v.icon,d.event.mouseleave).on("click"+h,v.icon,d.event.click)}},remove:{events:function(){d.verbose("Removing events"),C.off(h)}},enable:function(){d.debug("Setting rating to interactive mode"),d.bind.events(),C.removeClass(g.disabled)},disable:function(){d.debug("Setting rating to read-only mode"),d.remove.events(),C.addClass(g.disabled)},get:{initialRating:function(){return C.data(p.rating)!==i?(C.removeData(p.rating),C.data(p.rating)):m.initialRating},maxRating:function(){return C.data(p.maxRating)!==i?(C.removeData(p.maxRating),C.data(p.maxRating)):m.maxRating},rating:function(){var e=w.filter("."+g.active).length;return d.verbose("Current rating retrieved",e),e}},set:{rating:function(e){var t=e-1>=0?e-1:0,n=w.eq(t);C.removeClass(g.selected),w.removeClass(g.selected).removeClass(g.active),e>0&&(d.verbose("Setting current rating to",e),n.prevAll().andSelf().addClass(g.active)),m.onRate.call(y,e)}},setting:function(t,n){if(d.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,m,t);else{if(n===i)return m[t];m[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,d,t);else{if(n===i)return d[t];d[t]=n}},debug:function(){m.debug&&(m.performance?d.performance.log(arguments):(d.debug=Function.prototype.bind.call(console.info,console,m.name+":"),d.debug.apply(console,arguments)))},verbose:function(){m.verbose&&m.debug&&(m.performance?d.performance.log(arguments):(d.verbose=Function.prototype.bind.call(console.info,console,m.name+":"),d.verbose.apply(console,arguments)))},error:function(){d.error=Function.prototype.bind.call(console.error,console,m.name+":"),d.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;m.performance&&(t=(new Date).getTime(),i=r||t,n=t-i,r=t,s.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:y,"Execution Time":n})),clearTimeout(d.performance.timer),d.performance.timer=setTimeout(d.performance.display,500)},display:function(){var t=m.name+":",n=0;r=!1,clearTimeout(d.performance.timer),e.each(s,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",a&&(t+=" '"+a+"'"),o.length>1&&(t+=" ("+o.length+")"),(console.group!==i||console.table!==i)&&s.length>0&&(console.groupCollapsed(t),console.table?console.table(s):e.each(s,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),s=[]}},invoke:function(t,o,a){var r,s,c,l=x;return o=o||u,a=y||a,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(a,o):s!==i&&(c=s),e.isArray(n)?n.push(c):n!==i?n=[n,c]:c!==i&&(n=c),s}},l?(x===i&&d.initialize(),d.invoke(c)):(x!==i&&x.invoke("destroy"),d.initialize())}),n!==i?n:this},e.fn.rating.settings={name:"Rating",namespace:"rating",debug:!1,verbose:!1,performance:!0,initialRating:0,interactive:!0,maxRating:4,clearable:"auto",onRate:function(e){},error:{method:"The method you called is not defined",noMaximum:"No maximum rating specified. Cannot generate HTML automatically"},metadata:{rating:"rating",maxRating:"maxRating"},className:{active:"active",disabled:"disabled",selected:"selected",loading:"loading"},selector:{icon:".icon"},templates:{icon:function(e){for(var t=1,n="";e>=t;)n+='<i class="icon"></i>',t++;return n}}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.search=function(o){var a,r=e(this),s=r.selector||"",c=(new Date).getTime(),l=[],u=arguments[0],d="string"==typeof u,m=[].slice.call(arguments,1);return e(this).each(function(){var f,g=e.isPlainObject(o)?e.extend(!0,{},e.fn.search.settings,o):e.extend({},e.fn.search.settings),p=g.className,v=g.metadata,h=g.regExp,b=g.fields,y=g.selector,x=g.error,C=g.namespace,w="."+C,k=C+"-module",S=e(this),T=S.find(y.prompt),A=S.find(y.searchButton),R=S.find(y.results),E=(S.find(y.result),S.find(y.category),this),P=S.data(k);f={initialize:function(){f.verbose("Initializing module"),f.determine.searchFields(),f.bind.events(),f.set.type(),f.create.results(),f.instantiate()},instantiate:function(){f.verbose("Storing instance of module",f),P=f,S.data(k,f)},destroy:function(){f.verbose("Destroying instance"),S.off(w).removeData(k)},bind:{events:function(){f.verbose("Binding events to search"),g.automatic&&(S.on(f.get.inputEvent()+w,y.prompt,f.event.input),T.attr("autocomplete","off")),S.on("focus"+w,y.prompt,f.event.focus).on("blur"+w,y.prompt,f.event.blur).on("keydown"+w,y.prompt,f.handleKeyboard).on("click"+w,y.searchButton,f.query).on("mousedown"+w,y.results,f.event.result.mousedown).on("mouseup"+w,y.results,f.event.result.mouseup).on("click"+w,y.result,f.event.result.click)}},determine:{searchFields:function(){o&&o.searchFields!==i&&(g.searchFields=o.searchFields)}},event:{input:function(){clearTimeout(f.timer),f.timer=setTimeout(f.query,g.searchDelay)},focus:function(){f.set.focus(),f.has.minimumCharacters()&&(f.query(),f.can.show()&&f.showResults())},blur:function(e){var t=n.activeElement===this;t||f.resultsClicked||(f.cancel.query(),f.remove.focus(),f.timer=setTimeout(f.hideResults,g.hideDelay))},result:{mousedown:function(){f.resultsClicked=!0},mouseup:function(){f.resultsClicked=!1},click:function(n){f.debug("Search result selected");var i=e(this),o=i.find(y.title).eq(0),a=i.find("a[href]").eq(0),r=a.attr("href")||!1,s=a.attr("target")||!1,c=(o.html(),o.length>0?o.text():!1),l=f.get.results(),u=i.data(v.result)||f.get.result(c,l);return e.isFunction(g.onSelect)&&g.onSelect.call(E,u,l)===!1?void f.debug("Custom onSelect callback cancelled default select action"):(f.hideResults(),c&&f.set.value(c),void(r&&(f.verbose("Opening search link found in result",a),"_blank"==s||n.ctrlKey?t.open(r):t.location.href=r)))}}},handleKeyboard:function(e){var t,n=S.find(y.result),i=S.find(y.category),o=n.index(n.filter("."+p.active)),a=n.length,r=e.which,s={backspace:8,enter:13,escape:27,upArrow:38,downArrow:40};if(r==s.escape&&(f.verbose("Escape key pressed, blurring search field"),f.trigger.blur()),f.is.visible())if(r==s.enter){if(f.verbose("Enter key pressed, selecting active result"),n.filter("."+p.active).length>0)return f.event.result.click.call(n.filter("."+p.active),e),e.preventDefault(),!1}else r==s.upArrow?(f.verbose("Up key pressed, changing active result"),t=0>o-1?o:o-1,i.removeClass(p.active),n.removeClass(p.active).eq(t).addClass(p.active).closest(i).addClass(p.active),e.preventDefault()):r==s.downArrow&&(f.verbose("Down key pressed, changing active result"),t=o+1>=a?o:o+1,i.removeClass(p.active),n.removeClass(p.active).eq(t).addClass(p.active).closest(i).addClass(p.active),e.preventDefault());else r==s.enter&&(f.verbose("Enter key pressed, executing query"),f.query(),f.set.buttonPressed(),T.one("keyup",f.remove.buttonFocus))},setup:{api:function(){var e={debug:g.debug,on:!1,cache:"local",action:"search",onError:f.error};f.verbose("First request, initializing API"),S.api(e)}},can:{useAPI:function(){return e.fn.api!==i},show:function(){return f.is.focused()&&!f.is.visible()&&!f.is.empty()},transition:function(){return g.transition&&e.fn.transition!==i&&S.transition("is supported")}},is:{empty:function(){return""===R.html()},visible:function(){return R.filter(":visible").length>0},focused:function(){return T.filter(":focus").length>0}},trigger:{blur:function(){var e=n.createEvent("HTMLEvents"),t=T[0];t&&(f.verbose("Triggering native blur event"),e.initEvent("blur",!1,!1),t.dispatchEvent(e))}},get:{inputEvent:function(){var e=T[0],t=e!==i&&e.oninput!==i?"input":e!==i&&e.onpropertychange!==i?"propertychange":"keyup";return t},value:function(){return T.val()},results:function(){var e=S.data(v.results);return e},result:function(t,n){var o=["title","id"],a=!1;return t=t!==i?t:f.get.value(),n=n!==i?n:f.get.results(),"category"===g.type?(f.debug("Finding result that matches",t),e.each(n,function(n,i){return e.isArray(i.results)&&(a=f.search.object(t,i.results,o)[0])?!1:void 0})):(f.debug("Finding result in results object",t),a=f.search.object(t,n,o)[0]),a||!1}},set:{focus:function(){S.addClass(p.focus)},loading:function(){S.addClass(p.loading)},value:function(e){f.verbose("Setting search input value",e),T.val(e)},type:function(e){e=e||g.type,"category"==g.type&&S.addClass(g.type)},buttonPressed:function(){A.addClass(p.pressed)}},remove:{loading:function(){S.removeClass(p.loading)},focus:function(){S.removeClass(p.focus)},buttonPressed:function(){A.removeClass(p.pressed)}},query:function(){var t=f.get.value(),n=f.read.cache(t);f.has.minimumCharacters()?(n?(f.debug("Reading result from cache",t),f.save.results(n.results),f.addResults(n.html),f.inject.id(n.results)):(f.debug("Querying for",t),e.isPlainObject(g.source)||e.isArray(g.source)?f.search.local(t):f.can.useAPI()?f.search.remote(t):f.error(x.source)),g.onSearchQuery.call(E,t)):f.hideResults()},search:{local:function(e){var t,n=f.search.object(e,g.content);f.set.loading(),f.save.results(n),f.debug("Returned local search results",n),t=f.generateResults({results:n}),f.remove.loading(),f.addResults(t),f.inject.id(n),f.write.cache(e,{html:t,results:n})},remote:function(t){var n={onSuccess:function(e){f.parse.response.call(E,e,t)},onFailure:function(){f.displayMessage(x.serverError)},urlData:{query:t}};S.api("get request")||f.setup.api(),e.extend(!0,n,g.apiSettings),f.debug("Executing search",n),f.cancel.query(),S.api("setting",n).api("query")},object:function(t,n,o){var a=[],r=[],s=t.toString().replace(h.escape,"\\$&"),c=new RegExp(h.beginsWith+s,"i"),l=function(t,n){var i=-1==e.inArray(n,a),o=-1==e.inArray(n,r);i&&o&&t.push(n)};return n=n||g.source,o=o!==i?o:g.searchFields,e.isArray(o)||(o=[o]),n===i||n===!1?(f.error(x.source),[]):(e.each(o,function(i,o){e.each(n,function(e,n){var i="string"==typeof n[o];i&&(-1!==n[o].search(c)?l(a,n):g.searchFullText&&f.fuzzySearch(t,n[o])&&l(r,n))})}),e.merge(a,r))}},fuzzySearch:function(e,t){var n=t.length,i=e.length;if("string"!=typeof e)return!1;if(e=e.toLowerCase(),t=t.toLowerCase(),i>n)return!1;if(i===n)return e===t;e:for(var o=0,a=0;i>o;o++){for(var r=e.charCodeAt(o);n>a;)if(t.charCodeAt(a++)===r)continue e;return!1}return!0},parse:{response:function(e,t){var n=f.generateResults(e);f.verbose("Parsing server response",e),e!==i&&t!==i&&e[b.results]!==i&&(f.addResults(n),f.inject.id(e[b.results]),f.write.cache(t,{html:n,results:e[b.results]}),f.save.results(e[b.results]))}},cancel:{query:function(){f.can.useAPI()&&S.api("abort")}},has:{minimumCharacters:function(){var e=f.get.value(),t=e.length;return t>=g.minCharacters}},clear:{cache:function(e){var t=S.data(v.cache);e?e&&t&&t[e]&&(f.debug("Removing value from cache",e),delete t[e],S.data(v.cache,t)):(f.debug("Clearing cache",e),S.removeData(v.cache))}},read:{cache:function(e){var t=S.data(v.cache);return g.cache?(f.verbose("Checking cache for generated html for query",e),"object"==typeof t&&t[e]!==i?t[e]:!1):!1}},create:{id:function(e,t){var n,o,a=e+1;return t!==i?(n=String.fromCharCode(97+t),o=n+a,f.verbose("Creating category result id",o)):(o=a,f.verbose("Creating result id",o)),o},results:function(){0===R.length&&(R=e("<div />").addClass(p.results).appendTo(S))}},inject:{result:function(e,t,n){f.verbose("Injecting result into results");var o=n!==i?R.children().eq(n).children(y.result).eq(t):R.children(y.result).eq(t);f.verbose("Injecting results metadata",o),o.data(v.result,e)},id:function(t){f.debug("Injecting unique ids into results");var n=0,o=0;return"category"===g.type?e.each(t,function(t,a){o=0,e.each(a.results,function(e,t){var r=a.results[e];r.id===i&&(r.id=f.create.id(o,n)),f.inject.result(r,o,n),o++}),n++}):e.each(t,function(e,n){var a=t[e];a.id===i&&(a.id=f.create.id(o)),f.inject.result(a,o),o++}),t}},save:{results:function(e){f.verbose("Saving current search results to metadata",e),S.data(v.results,e)}},write:{cache:function(e,t){var n=S.data(v.cache)!==i?S.data(v.cache):{};g.cache&&(f.verbose("Writing generated html to cache",e,t),n[e]=t,S.data(v.cache,n))}},addResults:function(t){return e.isFunction(g.onResultsAdd)&&g.onResultsAdd.call(R,t)===!1?(f.debug("onResultsAdd callback cancelled default action"),!1):(R.html(t),void(f.can.show()&&f.showResults()))},showResults:function(){f.is.visible()||(f.can.transition()?(f.debug("Showing results with css animations"),R.transition({animation:g.transition+" in",debug:g.debug,verbose:g.verbose,duration:g.duration,queue:!0})):(f.debug("Showing results with javascript"),R.stop().fadeIn(g.duration,g.easing)),g.onResultsOpen.call(R))},hideResults:function(){f.is.visible()&&(f.can.transition()?(f.debug("Hiding results with css animations"),R.transition({animation:g.transition+" out",debug:g.debug,verbose:g.verbose,duration:g.duration,queue:!0})):(f.debug("Hiding results with javascript"),R.stop().fadeOut(g.duration,g.easing)),g.onResultsClose.call(R))},generateResults:function(t){f.debug("Generating html from response",t);var n=g.templates[g.type],i=e.isPlainObject(t[b.results])&&!e.isEmptyObject(t[b.results]),o=e.isArray(t[b.results])&&t[b.results].length>0,a="";return i||o?(g.maxResults>0&&(i?"standard"==g.type&&f.error(x.maxResults):t[b.results]=t[b.results].slice(0,g.maxResults)),e.isFunction(n)?a=n(t,b):f.error(x.noTemplate,!1)):a=f.displayMessage(x.noResults,"empty"),g.onResults.call(E,t),a},displayMessage:function(e,t){return t=t||"standard",f.debug("Displaying message",e,t),f.addResults(g.templates.message(e,t)),g.templates.message(e,t)},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,g,t);else{
+if(n===i)return g[t];g[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},debug:function(){g.debug&&(g.performance?f.performance.log(arguments):(f.debug=Function.prototype.bind.call(console.info,console,g.name+":"),f.debug.apply(console,arguments)))},verbose:function(){g.verbose&&g.debug&&(g.performance?f.performance.log(arguments):(f.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),f.verbose.apply(console,arguments)))},error:function(){f.error=Function.prototype.bind.call(console.error,console,g.name+":"),f.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;g.performance&&(t=(new Date).getTime(),i=c||t,n=t-i,c=t,l.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:E,"Execution Time":n})),clearTimeout(f.performance.timer),f.performance.timer=setTimeout(f.performance.display,500)},display:function(){var t=g.name+":",n=0;c=!1,clearTimeout(f.performance.timer),e.each(l,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",s&&(t+=" '"+s+"'"),r.length>1&&(t+=" ("+r.length+")"),(console.group!==i||console.table!==i)&&l.length>0&&(console.groupCollapsed(t),console.table?console.table(l):e.each(l,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),l=[]}},invoke:function(t,n,o){var r,s,c,l=P;return n=n||m,o=E||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(a)?a.push(c):a!==i?a=[a,c]:c!==i&&(a=c),s}},d?(P===i&&f.initialize(),f.invoke(u)):(P!==i&&P.invoke("destroy"),f.initialize())}),a!==i?a:this},e.fn.search.settings={name:"Search",namespace:"search",debug:!1,verbose:!1,performance:!0,type:"standard",minCharacters:1,apiSettings:!1,source:!1,searchFields:["title","description"],displayField:"",searchFullText:!0,automatic:!0,hideDelay:0,searchDelay:200,maxResults:7,cache:!0,transition:"scale",duration:200,easing:"easeOutExpo",onSelect:!1,onResultsAdd:!1,onSearchQuery:function(e){},onResults:function(e){},onResultsOpen:function(){},onResultsClose:function(){},className:{active:"active",empty:"empty",focus:"focus",loading:"loading",results:"results",pressed:"down"},error:{source:"Cannot search. No source used, and Semantic API module was not included",noResults:"Your search returned no results",logging:"Error in debug logging, exiting.",noEndpoint:"No search endpoint was specified",noTemplate:"A valid template name was not specified.",serverError:"There was an issue querying the server.",maxResults:"Results must be an array to use maxResults setting",method:"The method you called is not defined."},metadata:{cache:"cache",results:"results",result:"result"},regExp:{escape:/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,beginsWith:"(?:s|^)"},fields:{categories:"results",categoryName:"name",categoryResults:"results",description:"description",image:"image",price:"price",results:"results",title:"title",url:"url",action:"action",actionText:"text",actionURL:"url"},selector:{prompt:".prompt",searchButton:".search.button",results:".results",category:".category",result:".result",title:".title, .name"},templates:{escape:function(e){var t=/[&<>"'`]/g,n=/[&<>"'`]/,i={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},o=function(e){return i[e]};return n.test(e)?e.replace(t,o):e},message:function(e,t){var n="";return e!==i&&t!==i&&(n+='<div class="message '+t+'">',n+="empty"==t?'<div class="header">No Results</div class="header"><div class="description">'+e+'</div class="description">':' <div class="description">'+e+"</div>",n+="</div>"),n},category:function(t,n){var o="";e.fn.search.settings.templates.escape;return t[n.categoryResults]!==i?(e.each(t[n.categoryResults],function(t,a){a[n.results]!==i&&a.results.length>0&&(o+='<div class="category">',a[n.categoryName]!==i&&(o+='<div class="name">'+a[n.categoryName]+"</div>"),e.each(a.results,function(e,t){o+=t[n.url]?'<a class="result" href="'+t[n.url]+'">':'<a class="result">',t[n.image]!==i&&(o+='<div class="image"> <img src="'+t[n.image]+'"></div>'),o+='<div class="content">',t[n.price]!==i&&(o+='<div class="price">'+t[n.price]+"</div>"),t[n.title]!==i&&(o+='<div class="title">'+t[n.title]+"</div>"),t[n.description]!==i&&(o+='<div class="description">'+t[n.description]+"</div>"),o+="</div>",o+="</a>"}),o+="</div>")}),t[n.action]&&(o+='<a href="'+t[n.action][n.actionURL]+'" class="action">'+t[n.action][n.actionText]+"</a>"),o):!1},standard:function(t,n){var o="";return t[n.results]!==i?(e.each(t[n.results],function(e,t){o+=t[n.url]?'<a class="result" href="'+t[n.url]+'">':'<a class="result">',t[n.image]!==i&&(o+='<div class="image"> <img src="'+t[n.image]+'"></div>'),o+='<div class="content">',t[n.price]!==i&&(o+='<div class="price">'+t[n.price]+"</div>"),t[n.title]!==i&&(o+='<div class="title">'+t[n.title]+"</div>"),t[n.description]!==i&&(o+='<div class="description">'+t[n.description]+"</div>"),o+="</div>",o+="</a>"}),t[n.action]&&(o+='<a href="'+t[n.action][n.actionURL]+'" class="action">'+t[n.action][n.actionText]+"</a>"),o):!1}}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.shape=function(o){var a,r=e(this),s=(e("body"),(new Date).getTime()),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1),m=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)};return r.each(function(){var t,f,g,p=r.selector||"",v=e.isPlainObject(o)?e.extend(!0,{},e.fn.shape.settings,o):e.extend({},e.fn.shape.settings),h=v.namespace,b=v.selector,y=v.error,x=v.className,C="."+h,w="module-"+h,k=e(this),S=k.find(b.sides),T=k.find(b.side),A=!1,R=this,E=k.data(w);g={initialize:function(){g.verbose("Initializing module for",R),g.set.defaultSide(),g.instantiate()},instantiate:function(){g.verbose("Storing instance of module",g),E=g,k.data(w,E)},destroy:function(){g.verbose("Destroying previous module for",R),k.removeData(w).off(C)},refresh:function(){g.verbose("Refreshing selector cache for",R),k=e(R),S=e(this).find(b.shape),T=e(this).find(b.side)},repaint:function(){g.verbose("Forcing repaint event");var e=S[0]||n.createElement("div");e.offsetWidth},animate:function(e,n){g.verbose("Animating box with properties",e),n=n||function(e){g.verbose("Executing animation callback"),e!==i&&e.stopPropagation(),g.reset(),g.set.active()},v.beforeChange.call(f[0]),g.get.transitionEvent()?(g.verbose("Starting CSS animation"),k.addClass(x.animating),S.css(e).one(g.get.transitionEvent(),n),g.set.duration(v.duration),m(function(){k.addClass(x.animating),t.addClass(x.hidden)})):n()},queue:function(e){g.debug("Queueing animation of",e),S.one(g.get.transitionEvent(),function(){g.debug("Executing queued animation"),setTimeout(function(){k.shape(e)},0)})},reset:function(){g.verbose("Animating states reset"),k.removeClass(x.animating).attr("style","").removeAttr("style"),S.attr("style","").removeAttr("style"),T.attr("style","").removeAttr("style").removeClass(x.hidden),f.removeClass(x.animating).attr("style","").removeAttr("style")},is:{complete:function(){return T.filter("."+x.active)[0]==f[0]},animating:function(){return k.hasClass(x.animating)}},set:{defaultSide:function(){t=k.find("."+v.className.active),f=t.next(b.side).length>0?t.next(b.side):k.find(b.side).first(),A=!1,g.verbose("Active side set to",t),g.verbose("Next side set to",f)},duration:function(e){e=e||v.duration,e="number"==typeof e?e+"ms":e,g.verbose("Setting animation duration",e),(v.duration||0===v.duration)&&S.add(T).css({"-webkit-transition-duration":e,"-moz-transition-duration":e,"-ms-transition-duration":e,"-o-transition-duration":e,"transition-duration":e})},currentStageSize:function(){var e=k.find("."+v.className.active),t=e.outerWidth(!0),n=e.outerHeight(!0);k.css({width:t,height:n})},stageSize:function(){var e=k.clone().addClass(x.loading),t=e.find("."+v.className.active),n=A?e.find(b.side).eq(A):t.next(b.side).length>0?t.next(b.side):e.find(b.side).first(),i={};g.set.currentStageSize(),t.removeClass(x.active),n.addClass(x.active),e.insertAfter(k),i={width:n.outerWidth(!0),height:n.outerHeight(!0)},e.remove(),k.css(i),g.verbose("Resizing stage to fit new content",i)},nextSide:function(e){A=e,f=T.filter(e),A=T.index(f),0===f.length&&(g.set.defaultSide(),g.error(y.side)),g.verbose("Next side manually set to",f)},active:function(){g.verbose("Setting new side to active",f),T.removeClass(x.active),f.addClass(x.active),v.onChange.call(f[0]),g.set.defaultSide()}},flip:{up:function(){return!g.is.complete()||g.is.animating()||v.allowRepeats?void(g.is.animating()?g.queue("flip up"):(g.debug("Flipping up",f),g.set.stageSize(),g.stage.above(),g.animate(g.get.transform.up()))):void g.debug("Side already visible",f)},down:function(){return!g.is.complete()||g.is.animating()||v.allowRepeats?void(g.is.animating()?g.queue("flip down"):(g.debug("Flipping down",f),g.set.stageSize(),g.stage.below(),g.animate(g.get.transform.down()))):void g.debug("Side already visible",f)},left:function(){return!g.is.complete()||g.is.animating()||v.allowRepeats?void(g.is.animating()?g.queue("flip left"):(g.debug("Flipping left",f),g.set.stageSize(),g.stage.left(),g.animate(g.get.transform.left()))):void g.debug("Side already visible",f)},right:function(){return!g.is.complete()||g.is.animating()||v.allowRepeats?void(g.is.animating()?g.queue("flip right"):(g.debug("Flipping right",f),g.set.stageSize(),g.stage.right(),g.animate(g.get.transform.right()))):void g.debug("Side already visible",f)},over:function(){return!g.is.complete()||g.is.animating()||v.allowRepeats?void(g.is.animating()?g.queue("flip over"):(g.debug("Flipping over",f),g.set.stageSize(),g.stage.behind(),g.animate(g.get.transform.over()))):void g.debug("Side already visible",f)},back:function(){return!g.is.complete()||g.is.animating()||v.allowRepeats?void(g.is.animating()?g.queue("flip back"):(g.debug("Flipping back",f),g.set.stageSize(),g.stage.behind(),g.animate(g.get.transform.back()))):void g.debug("Side already visible",f)}},get:{transform:{up:function(){var e={y:-((t.outerHeight(!0)-f.outerHeight(!0))/2),z:-(t.outerHeight(!0)/2)};return{transform:"translateY("+e.y+"px) translateZ("+e.z+"px) rotateX(-90deg)"}},down:function(){var e={y:-((t.outerHeight(!0)-f.outerHeight(!0))/2),z:-(t.outerHeight(!0)/2)};return{transform:"translateY("+e.y+"px) translateZ("+e.z+"px) rotateX(90deg)"}},left:function(){var e={x:-((t.outerWidth(!0)-f.outerWidth(!0))/2),z:-(t.outerWidth(!0)/2)};return{transform:"translateX("+e.x+"px) translateZ("+e.z+"px) rotateY(90deg)"}},right:function(){var e={x:-((t.outerWidth(!0)-f.outerWidth(!0))/2),z:-(t.outerWidth(!0)/2)};return{transform:"translateX("+e.x+"px) translateZ("+e.z+"px) rotateY(-90deg)"}},over:function(){var e={x:-((t.outerWidth(!0)-f.outerWidth(!0))/2)};return{transform:"translateX("+e.x+"px) rotateY(180deg)"}},back:function(){var e={x:-((t.outerWidth(!0)-f.outerWidth(!0))/2)};return{transform:"translateX("+e.x+"px) rotateY(-180deg)"}}},transitionEvent:function(){var e,t=n.createElement("element"),o={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in o)if(t.style[e]!==i)return o[e]},nextSide:function(){return t.next(b.side).length>0?t.next(b.side):k.find(b.side).first()}},stage:{above:function(){var e={origin:(t.outerHeight(!0)-f.outerHeight(!0))/2,depth:{active:f.outerHeight(!0)/2,next:t.outerHeight(!0)/2}};g.verbose("Setting the initial animation position as above",f,e),S.css({transform:"translateZ(-"+e.depth.active+"px)"}),t.css({transform:"rotateY(0deg) translateZ("+e.depth.active+"px)"}),f.addClass(x.animating).css({top:e.origin+"px",transform:"rotateX(90deg) translateZ("+e.depth.next+"px)"})},below:function(){var e={origin:(t.outerHeight(!0)-f.outerHeight(!0))/2,depth:{active:f.outerHeight(!0)/2,next:t.outerHeight(!0)/2}};g.verbose("Setting the initial animation position as below",f,e),S.css({transform:"translateZ(-"+e.depth.active+"px)"}),t.css({transform:"rotateY(0deg) translateZ("+e.depth.active+"px)"}),f.addClass(x.animating).css({top:e.origin+"px",transform:"rotateX(-90deg) translateZ("+e.depth.next+"px)"})},left:function(){var e={active:t.outerWidth(!0),next:f.outerWidth(!0)},n={origin:(e.active-e.next)/2,depth:{active:e.next/2,next:e.active/2}};g.verbose("Setting the initial animation position as left",f,n),S.css({transform:"translateZ(-"+n.depth.active+"px)"}),t.css({transform:"rotateY(0deg) translateZ("+n.depth.active+"px)"}),f.addClass(x.animating).css({left:n.origin+"px",transform:"rotateY(-90deg) translateZ("+n.depth.next+"px)"})},right:function(){var e={active:t.outerWidth(!0),next:f.outerWidth(!0)},n={origin:(e.active-e.next)/2,depth:{active:e.next/2,next:e.active/2}};g.verbose("Setting the initial animation position as left",f,n),S.css({transform:"translateZ(-"+n.depth.active+"px)"}),t.css({transform:"rotateY(0deg) translateZ("+n.depth.active+"px)"}),f.addClass(x.animating).css({left:n.origin+"px",transform:"rotateY(90deg) translateZ("+n.depth.next+"px)"})},behind:function(){var e={active:t.outerWidth(!0),next:f.outerWidth(!0)},n={origin:(e.active-e.next)/2,depth:{active:e.next/2,next:e.active/2}};g.verbose("Setting the initial animation position as behind",f,n),t.css({transform:"rotateY(0deg)"}),f.addClass(x.animating).css({left:n.origin+"px",transform:"rotateY(-180deg)"})}},setting:function(t,n){if(g.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,v,t);else{if(n===i)return v[t];v[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,g,t);else{if(n===i)return g[t];g[t]=n}},debug:function(){v.debug&&(v.performance?g.performance.log(arguments):(g.debug=Function.prototype.bind.call(console.info,console,v.name+":"),g.debug.apply(console,arguments)))},verbose:function(){v.verbose&&v.debug&&(v.performance?g.performance.log(arguments):(g.verbose=Function.prototype.bind.call(console.info,console,v.name+":"),g.verbose.apply(console,arguments)))},error:function(){g.error=Function.prototype.bind.call(console.error,console,v.name+":"),g.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;v.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:R,"Execution Time":n})),clearTimeout(g.performance.timer),g.performance.timer=setTimeout(g.performance.display,500)},display:function(){var t=v.name+":",n=0;s=!1,clearTimeout(g.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",p&&(t+=" '"+p+"'"),r.length>1&&(t+=" ("+r.length+")"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,o){var r,s,c,l=E;return n=n||d,o=R||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(a)?a.push(c):a!==i?a=[a,c]:c!==i&&(a=c),s}},u?(E===i&&g.initialize(),g.invoke(l)):(E!==i&&E.invoke("destroy"),g.initialize())}),a!==i?a:this},e.fn.shape.settings={name:"Shape",debug:!1,verbose:!1,performance:!0,namespace:"shape",beforeChange:function(){},onChange:function(){},allowRepeats:!1,duration:!1,error:{side:"You tried to switch to a side that does not exist.",method:"The method you called is not defined"},className:{animating:"animating",hidden:"hidden",loading:"loading",active:"active"},selector:{sides:".sides",side:".side"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.sidebar=function(o){var a,r=e(this),s=e(t),c=e(n),l=e("html"),u=e("head"),d=r.selector||"",m=(new Date).getTime(),f=[],g=arguments[0],p="string"==typeof g,v=[].slice.call(arguments,1),h=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)};return r.each(function(){var r,b,y,x,C,w,k=e.isPlainObject(o)?e.extend(!0,{},e.fn.sidebar.settings,o):e.extend({},e.fn.sidebar.settings),S=k.selector,T=k.className,A=k.namespace,R=k.regExp,E=k.error,P="."+A,F="module-"+A,D=e(this),O=e(k.context),q=D.children(S.sidebar),j=O.children(S.fixed),z=O.children(S.pusher),I=this,L=D.data(F);w={initialize:function(){w.debug("Initializing sidebar",o),w.create.id(),C=w.get.transitionEvent(),w.is.ios()&&w.set.ios(),k.delaySetup?h(w.setup.layout):w.setup.layout(),h(function(){w.setup.cache()}),w.instantiate()},instantiate:function(){w.verbose("Storing instance of module",w),L=w,D.data(F,w)},create:{id:function(){y=(Math.random().toString(16)+"000000000").substr(2,8),b="."+y,w.verbose("Creating unique id for element",y)}},destroy:function(){w.verbose("Destroying previous module for",D),D.off(P).removeData(F),w.is.ios()&&w.remove.ios(),O.off(b),s.off(b),c.off(b)},event:{clickaway:function(e){var t=z.find(e.target).length>0||z.is(e.target),n=O.is(e.target);t&&(w.verbose("User clicked on dimmed page"),w.hide()),n&&(w.verbose("User clicked on dimmable context (scaled out page)"),w.hide())},touch:function(e){},containScroll:function(e){I.scrollTop<=0&&(I.scrollTop=1),I.scrollTop+I.offsetHeight>=I.scrollHeight&&(I.scrollTop=I.scrollHeight-I.offsetHeight-1)},scroll:function(t){0===e(t.target).closest(S.sidebar).length&&t.preventDefault()}},bind:{clickaway:function(){w.verbose("Adding clickaway events to context",O),k.closable&&O.on("click"+b,w.event.clickaway).on("touchend"+b,w.event.clickaway)},scrollLock:function(){k.scrollLock&&(w.debug("Disabling page scroll"),s.on("DOMMouseScroll"+b,w.event.scroll)),w.verbose("Adding events to contain sidebar scroll"),c.on("touchmove"+b,w.event.touch),D.on("scroll"+P,w.event.containScroll)}},unbind:{clickaway:function(){w.verbose("Removing clickaway events from context",O),O.off(b)},scrollLock:function(){w.verbose("Removing scroll lock from page"),c.off(b),s.off(b),D.off("scroll"+P)}},add:{inlineCSS:function(){var t,n=w.cache.width||D.outerWidth(),i=w.cache.height||D.outerHeight(),o=w.is.rtl(),a=w.get.direction(),s={left:n,right:-n,top:i,bottom:-i};o&&(w.verbose("RTL detected, flipping widths"),s.left=-n,s.right=n),t="<style>","left"===a||"right"===a?(w.debug("Adding CSS rules for animation distance",n),t+=" .ui.visible."+a+".sidebar ~ .fixed, .ui.visible."+a+".sidebar ~ .pusher { -webkit-transform: translate3d("+s[a]+"px, 0, 0); transform: translate3d("+s[a]+"px, 0, 0); }"):("top"===a||"bottom"==a)&&(t+=" .ui.visible."+a+".sidebar ~ .fixed, .ui.visible."+a+".sidebar ~ .pusher { -webkit-transform: translate3d(0, "+s[a]+"px, 0); transform: translate3d(0, "+s[a]+"px, 0); }"),w.is.ie()&&("left"===a||"right"===a?(w.debug("Adding CSS rules for animation distance",n),t+=" body.pushable > .ui.visible."+a+".sidebar ~ .pusher:after { -webkit-transform: translate3d("+s[a]+"px, 0, 0); transform: translate3d("+s[a]+"px, 0, 0); }"):("top"===a||"bottom"==a)&&(t+=" body.pushable > .ui.visible."+a+".sidebar ~ .pusher:after { -webkit-transform: translate3d(0, "+s[a]+"px, 0); transform: translate3d(0, "+s[a]+"px, 0); }"),t+=" body.pushable > .ui.visible.left.sidebar ~ .ui.visible.right.sidebar ~ .pusher:after, body.pushable > .ui.visible.right.sidebar ~ .ui.visible.left.sidebar ~ .pusher:after { -webkit-transform: translate3d(0px, 0, 0); transform: translate3d(0px, 0, 0); }"),t+="</style>",r=e(t).appendTo(u),w.debug("Adding sizing css to head",r)}},refresh:function(){w.verbose("Refreshing selector cache"),O=e(k.context),q=O.children(S.sidebar),z=O.children(S.pusher),j=O.children(S.fixed),w.clear.cache()},refreshSidebars:function(){w.verbose("Refreshing other sidebars"),q=O.children(S.sidebar)},repaint:function(){w.verbose("Forcing repaint event"),I.style.display="none";I.offsetHeight;I.scrollTop=I.scrollTop,I.style.display=""},setup:{cache:function(){w.cache={width:D.outerWidth(),height:D.outerHeight(),rtl:"rtl"==D.css("direction")}},layout:function(){0===O.children(S.pusher).length&&(w.debug("Adding wrapper element for sidebar"),w.error(E.pusher),z=e('<div class="pusher" />'),O.children().not(S.omitted).not(q).wrapAll(z),w.refresh()),(0===D.nextAll(S.pusher).length||D.nextAll(S.pusher)[0]!==z[0])&&(w.debug("Moved sidebar to correct parent element"),w.error(E.movedSidebar,I),D.detach().prependTo(O),w.refresh()),w.clear.cache(),w.set.pushable(),w.set.direction()}},attachEvents:function(t,n){var i=e(t);n=e.isFunction(w[n])?w[n]:w.toggle,i.length>0?(w.debug("Attaching sidebar events to element",t,n),i.on("click"+P,n)):w.error(E.notFound,t)},show:function(t){if(t=e.isFunction(t)?t:function(){},w.is.hidden()){if(w.refreshSidebars(),k.overlay&&(w.error(E.overlay),k.transition="overlay"),w.refresh(),w.othersActive())if(w.debug("Other sidebars currently visible"),k.exclusive){if("overlay"!=k.transition)return void w.hideOthers(w.show);w.hideOthers()}else k.transition="overlay";w.pushPage(function(){t.call(I),k.onShow.call(I)}),k.onChange.call(I),k.onVisible.call(I)}else w.debug("Sidebar is already visible")},hide:function(t){t=e.isFunction(t)?t:function(){},(w.is.visible()||w.is.animating())&&(w.debug("Hiding sidebar",t),w.refreshSidebars(),w.pullPage(function(){t.call(I),k.onHidden.call(I)}),k.onChange.call(I),k.onHide.call(I))},othersAnimating:function(){return q.not(D).filter("."+T.animating).length>0},othersVisible:function(){return q.not(D).filter("."+T.visible).length>0},othersActive:function(){return w.othersVisible()||w.othersAnimating()},hideOthers:function(e){var t=q.not(D).filter("."+T.visible),n=t.length,i=0;e=e||function(){},t.sidebar("hide",function(){i++,i==n&&e()})},toggle:function(){w.verbose("Determining toggled direction"),w.is.hidden()?w.show():w.hide()},pushPage:function(t){var n,i,o,a=w.get.transition(),r="overlay"===a||w.othersActive()?D:z;t=e.isFunction(t)?t:function(){},"scale down"==k.transition&&w.scrollToTop(),w.set.transition(a),w.repaint(),n=function(){w.bind.clickaway(),w.add.inlineCSS(),w.set.animating(),w.set.visible()},i=function(){w.set.dimmed()},o=function(e){e.target==r[0]&&(r.off(C+b,o),w.remove.animating(),w.bind.scrollLock(),t.call(I))},r.off(C+b),r.on(C+b,o),h(n),k.dimPage&&!w.othersVisible()&&h(i)},pullPage:function(t){var n,i,o=w.get.transition(),a="overlay"==o||w.othersActive()?D:z;t=e.isFunction(t)?t:function(){},w.verbose("Removing context push state",w.get.direction()),w.unbind.clickaway(),w.unbind.scrollLock(),n=function(){w.set.transition(o),w.set.animating(),w.remove.visible(),k.dimPage&&!w.othersVisible()&&z.removeClass(T.dimmed)},i=function(e){e.target==a[0]&&(a.off(C+b,i),w.remove.animating(),w.remove.transition(),w.remove.inlineCSS(),("scale down"==o||k.returnScroll&&w.is.mobile())&&w.scrollBack(),t.call(I))},a.off(C+b),a.on(C+b,i),h(n)},scrollToTop:function(){w.verbose("Scrolling to top of page to avoid animation issues"),x=e(t).scrollTop(),D.scrollTop(0),t.scrollTo(0,0)},scrollBack:function(){w.verbose("Scrolling back to original page position"),t.scrollTo(0,x)},clear:{cache:function(){w.verbose("Clearing cached dimensions"),w.cache={}}},set:{ios:function(){l.addClass(T.ios)},pushed:function(){O.addClass(T.pushed)},pushable:function(){O.addClass(T.pushable)},dimmed:function(){z.addClass(T.dimmed)},active:function(){D.addClass(T.active)},animating:function(){D.addClass(T.animating)},transition:function(e){e=e||w.get.transition(),D.addClass(e)},direction:function(e){e=e||w.get.direction(),D.addClass(T[e])},visible:function(){D.addClass(T.visible)},overlay:function(){D.addClass(T.overlay)}},remove:{inlineCSS:function(){w.debug("Removing inline css styles",r),r&&r.length>0&&r.remove()},ios:function(){l.removeClass(T.ios)},pushed:function(){O.removeClass(T.pushed)},pushable:function(){O.removeClass(T.pushable)},active:function(){D.removeClass(T.active)},animating:function(){D.removeClass(T.animating)},transition:function(e){e=e||w.get.transition(),D.removeClass(e)},direction:function(e){e=e||w.get.direction(),D.removeClass(T[e])},visible:function(){D.removeClass(T.visible)},overlay:function(){D.removeClass(T.overlay)}},get:{direction:function(){return D.hasClass(T.top)?T.top:D.hasClass(T.right)?T.right:D.hasClass(T.bottom)?T.bottom:T.left},transition:function(){var e,t=w.get.direction();return e=w.is.mobile()?"auto"==k.mobileTransition?k.defaultTransition.mobile[t]:k.mobileTransition:"auto"==k.transition?k.defaultTransition.computer[t]:k.transition,w.verbose("Determined transition",e),e},transitionEvent:function(){var e,t=n.createElement("element"),o={transition:"transitionend",OTransition:"oTransitionEnd",MozTransition:"transitionend",WebkitTransition:"webkitTransitionEnd"};for(e in o)if(t.style[e]!==i)return o[e]}},is:{ie:function(){var e=!t.ActiveXObject&&"ActiveXObject"in t,n="ActiveXObject"in t;return e||n},ios:function(){var e=navigator.userAgent,t=e.match(R.ios),n=e.match(R.mobileChrome);return t&&!n?(w.verbose("Browser was found to be iOS",e),!0):!1},mobile:function(){var e=navigator.userAgent,t=e.match(R.mobile);return t?(w.verbose("Browser was found to be mobile",e),!0):(w.verbose("Browser is not mobile, using regular transition",e),!1)},hidden:function(){return!w.is.visible()},visible:function(){return D.hasClass(T.visible)},open:function(){return w.is.visible()},closed:function(){return w.is.hidden()},vertical:function(){return D.hasClass(T.top)},animating:function(){return O.hasClass(T.animating)},rtl:function(){return w.cache.rtl===i&&(w.cache.rtl="rtl"==D.css("direction")),w.cache.rtl}},setting:function(t,n){if(w.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,k,t);else{if(n===i)return k[t];k[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,w,t);else{if(n===i)return w[t];w[t]=n}},debug:function(){k.debug&&(k.performance?w.performance.log(arguments):(w.debug=Function.prototype.bind.call(console.info,console,k.name+":"),w.debug.apply(console,arguments)))},verbose:function(){k.verbose&&k.debug&&(k.performance?w.performance.log(arguments):(w.verbose=Function.prototype.bind.call(console.info,console,k.name+":"),w.verbose.apply(console,arguments)))},error:function(){w.error=Function.prototype.bind.call(console.error,console,k.name+":"),w.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;k.performance&&(t=(new Date).getTime(),i=m||t,n=t-i,m=t,f.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:I,"Execution Time":n})),clearTimeout(w.performance.timer),w.performance.timer=setTimeout(w.performance.display,500)},display:function(){var t=k.name+":",n=0;m=!1,clearTimeout(w.performance.timer),e.each(f,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",d&&(t+=" '"+d+"'"),(console.group!==i||console.table!==i)&&f.length>0&&(console.groupCollapsed(t),console.table?console.table(f):e.each(f,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),f=[]}},invoke:function(t,n,o){var r,s,c,l=L;return n=n||v,o=I||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):(w.error(E.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(a)?a.push(c):a!==i?a=[a,c]:c!==i&&(a=c),s}},p?(L===i&&w.initialize(),w.invoke(g)):(L!==i&&w.invoke("destroy"),w.initialize())}),a!==i?a:this},e.fn.sidebar.settings={name:"Sidebar",namespace:"sidebar",debug:!1,verbose:!1,performance:!0,transition:"auto",mobileTransition:"auto",defaultTransition:{computer:{left:"uncover",right:"uncover",top:"overlay",bottom:"overlay"},mobile:{left:"uncover",right:"uncover",top:"overlay",bottom:"overlay"}},context:"body",exclusive:!1,closable:!0,dimPage:!0,scrollLock:!1,returnScroll:!1,delaySetup:!1,duration:500,onChange:function(){},onShow:function(){},onHide:function(){},onHidden:function(){},onVisible:function(){},className:{active:"active",animating:"animating",dimmed:"dimmed",ios:"ios",pushable:"pushable",pushed:"pushed",right:"right",top:"top",left:"left",bottom:"bottom",visible:"visible"},selector:{fixed:".fixed",omitted:"script, link, style, .ui.modal, .ui.dimmer, .ui.nag, .ui.fixed",pusher:".pusher",sidebar:".ui.sidebar"},regExp:{ios:/(iPad|iPhone|iPod)/g,mobileChrome:/(CriOS)/g,mobile:/Mobile|iP(hone|od|ad)|Android|BlackBerry|IEMobile|Kindle|NetFront|Silk-Accelerated|(hpw|web)OS|Fennec|Minimo|Opera M(obi|ini)|Blazer|Dolfin|Dolphin|Skyfire|Zune/g},error:{method:"The method you called is not defined.",pusher:"Had to add pusher element. For optimal performance make sure body content is inside a pusher element",movedSidebar:"Had to move sidebar. For optimal performance make sure sidebar and pusher are direct children of your body tag",overlay:"The overlay setting is no longer supported, use animation: overlay",notFound:"There were no elements that matched the specified selector"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.sticky=function(n){var o,a=e(this),r=a.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return a.each(function(){var a,m,f,g,p=e.isPlainObject(n)?e.extend(!0,{},e.fn.sticky.settings,n):e.extend({},e.fn.sticky.settings),v=p.className,h=p.namespace,b=p.error,y="."+h,x="module-"+h,C=e(this),w=e(t),k=e(p.scrollContext),S=(C.selector||"",C.data(x)),T=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)},A=this;g={initialize:function(){g.determineContainer(),g.determineContext(),g.verbose("Initializing sticky",p,a),g.save.positions(),g.checkErrors(),g.bind.events(),p.observeChanges&&g.observeChanges(),g.instantiate()},instantiate:function(){g.verbose("Storing instance of module",g),S=g,C.data(x,g)},destroy:function(){g.verbose("Destroying previous instance"),g.reset(),f&&f.disconnect(),w.off("load"+y,g.event.load).off("resize"+y,g.event.resize),k.off("scrollchange"+y,g.event.scrollchange),C.removeData(x)},observeChanges:function(){var e=m[0];"MutationObserver"in t&&(f=new MutationObserver(function(e){clearTimeout(g.timer),g.timer=setTimeout(function(){g.verbose("DOM tree modified, updating sticky menu",e),g.refresh()},100)}),f.observe(A,{childList:!0,subtree:!0}),f.observe(e,{childList:!0,subtree:!0}),g.debug("Setting up mutation observer",f))},determineContainer:function(){a=C.offsetParent()},determineContext:function(){return m=p.context?e(p.context):a,0===m.length?void g.error(b.invalidContext,p.context,C):void 0},checkErrors:function(){return g.is.hidden()&&g.error(b.visible,C),g.cache.element.height>g.cache.context.height?(g.reset(),void g.error(b.elementSize,C)):void 0},bind:{events:function(){w.on("load"+y,g.event.load).on("resize"+y,g.event.resize),k.off("scroll"+y).on("scroll"+y,g.event.scroll).on("scrollchange"+y,g.event.scrollchange)}},event:{load:function(){g.verbose("Page contents finished loading"),T(g.refresh)},resize:function(){g.verbose("Window resized"),T(g.refresh)},scroll:function(){T(function(){k.triggerHandler("scrollchange"+y,k.scrollTop())})},scrollchange:function(e,t){g.stick(t),p.onScroll.call(A)}},refresh:function(e){g.reset(),p.context||g.determineContext(),e&&g.determineContainer(),g.save.positions(),g.stick(),p.onReposition.call(A)},supports:{sticky:function(){var t=e("<div/>");t[0];return t.addClass(v.supported),t.css("position").match("sticky")}},save:{lastScroll:function(e){g.lastScroll=e},elementScroll:function(e){g.elementScroll=e},positions:function(){var e={height:k.height()},t={margin:{top:parseInt(C.css("margin-top"),10),bottom:parseInt(C.css("margin-bottom"),10)
+},offset:C.offset(),width:C.outerWidth(),height:C.outerHeight()},n={offset:m.offset(),height:m.outerHeight()};({height:a.outerHeight()});g.is.standardScroll()||(g.debug("Non-standard scroll. Removing scroll offset from element offset"),e.top=k.scrollTop(),e.left=k.scrollLeft(),t.offset.top+=e.top,n.offset.top+=e.top,t.offset.left+=e.left,n.offset.left+=e.left),g.cache={fits:t.height<e.height,scrollContext:{height:e.height},element:{margin:t.margin,top:t.offset.top-t.margin.top,left:t.offset.left,width:t.width,height:t.height,bottom:t.offset.top+t.height},context:{top:n.offset.top,height:n.height,bottom:n.offset.top+n.height}},g.set.containerSize(),g.set.size(),g.stick(),g.debug("Caching element positions",g.cache)}},get:{direction:function(e){var t="down";return e=e||k.scrollTop(),g.lastScroll!==i&&(g.lastScroll<e?t="down":g.lastScroll>e&&(t="up")),t},scrollChange:function(e){return e=e||k.scrollTop(),g.lastScroll?e-g.lastScroll:0},currentElementScroll:function(){return g.elementScroll?g.elementScroll:g.is.top()?Math.abs(parseInt(C.css("top"),10))||0:Math.abs(parseInt(C.css("bottom"),10))||0},elementScroll:function(e){e=e||k.scrollTop();var t=g.cache.element,n=g.cache.scrollContext,i=g.get.scrollChange(e),o=t.height-n.height+p.offset,a=g.get.currentElementScroll(),r=a+i;return a=g.cache.fits||0>r?0:r>o?o:r}},remove:{lastScroll:function(){delete g.lastScroll},elementScroll:function(e){delete g.elementScroll},offset:function(){C.css("margin-top","")}},set:{offset:function(){g.verbose("Setting offset on element",p.offset),C.css("margin-top",p.offset)},containerSize:function(){var e=a.get(0).tagName;"HTML"===e||"body"==e?g.determineContainer():Math.abs(a.outerHeight()-g.cache.context.height)>p.jitter&&(g.debug("Context has padding, specifying exact height for container",g.cache.context.height),a.css({height:g.cache.context.height}))},minimumSize:function(){var e=g.cache.element;a.css("min-height",e.height)},scroll:function(e){g.debug("Setting scroll on element",e),g.elementScroll!=e&&(g.is.top()&&C.css("bottom","").css("top",-e),g.is.bottom()&&C.css("top","").css("bottom",e))},size:function(){0!==g.cache.element.height&&0!==g.cache.element.width&&(A.style.setProperty("width",g.cache.element.width+"px","important"),A.style.setProperty("height",g.cache.element.height+"px","important"))}},is:{standardScroll:function(){return k[0]==t},top:function(){return C.hasClass(v.top)},bottom:function(){return C.hasClass(v.bottom)},initialPosition:function(){return!g.is.fixed()&&!g.is.bound()},hidden:function(){return!C.is(":visible")},bound:function(){return C.hasClass(v.bound)},fixed:function(){return C.hasClass(v.fixed)}},stick:function(e){var t=e||k.scrollTop(),n=g.cache,i=n.fits,o=n.element,a=n.scrollContext,r=n.context,s=g.is.bottom()&&p.pushing?p.bottomOffset:p.offset,e={top:t+s,bottom:t+s+a.height},c=(g.get.direction(e.top),i?0:g.get.elementScroll(e.top)),l=!i,u=0!==o.height;u&&(g.is.initialPosition()?e.top>=r.bottom?(g.debug("Initial element position is bottom of container"),g.bindBottom()):e.top>o.top&&(o.height+e.top-c>=r.bottom?(g.debug("Initial element position is bottom of container"),g.bindBottom()):(g.debug("Initial element position is fixed"),g.fixTop())):g.is.fixed()?g.is.top()?e.top<=o.top?(g.debug("Fixed element reached top of container"),g.setInitialPosition()):o.height+e.top-c>=r.bottom?(g.debug("Fixed element reached bottom of container"),g.bindBottom()):l&&(g.set.scroll(c),g.save.lastScroll(e.top),g.save.elementScroll(c)):g.is.bottom()&&(e.bottom-o.height<=o.top?(g.debug("Bottom fixed rail has reached top of container"),g.setInitialPosition()):e.bottom>=r.bottom?(g.debug("Bottom fixed rail has reached bottom of container"),g.bindBottom()):l&&(g.set.scroll(c),g.save.lastScroll(e.top),g.save.elementScroll(c))):g.is.bottom()&&(e.top<=o.top?(g.debug("Jumped from bottom fixed to top fixed, most likely used home/end button"),g.setInitialPosition()):p.pushing?g.is.bound()&&e.bottom<=r.bottom&&(g.debug("Fixing bottom attached element to bottom of browser."),g.fixBottom()):g.is.bound()&&e.top<=r.bottom-o.height&&(g.debug("Fixing bottom attached element to top of browser."),g.fixTop())))},bindTop:function(){g.debug("Binding element to top of parent container"),g.remove.offset(),C.css({left:"",top:"",marginBottom:""}).removeClass(v.fixed).removeClass(v.bottom).addClass(v.bound).addClass(v.top),p.onTop.call(A),p.onUnstick.call(A)},bindBottom:function(){g.debug("Binding element to bottom of parent container"),g.remove.offset(),C.css({left:"",top:""}).removeClass(v.fixed).removeClass(v.top).addClass(v.bound).addClass(v.bottom),p.onBottom.call(A),p.onUnstick.call(A)},setInitialPosition:function(){g.debug("Returning to initial position"),g.unfix(),g.unbind()},fixTop:function(){g.debug("Fixing element to top of page"),g.set.minimumSize(),g.set.offset(),C.css({left:g.cache.element.left,bottom:"",marginBottom:""}).removeClass(v.bound).removeClass(v.bottom).addClass(v.fixed).addClass(v.top),p.onStick.call(A)},fixBottom:function(){g.debug("Sticking element to bottom of page"),g.set.minimumSize(),g.set.offset(),C.css({left:g.cache.element.left,bottom:"",marginBottom:""}).removeClass(v.bound).removeClass(v.top).addClass(v.fixed).addClass(v.bottom),p.onStick.call(A)},unbind:function(){g.is.bound()&&(g.debug("Removing container bound position on element"),g.remove.offset(),C.removeClass(v.bound).removeClass(v.top).removeClass(v.bottom))},unfix:function(){g.is.fixed()&&(g.debug("Removing fixed position on element"),g.remove.offset(),C.removeClass(v.fixed).removeClass(v.top).removeClass(v.bottom),p.onUnstick.call(A))},reset:function(){g.debug("Reseting elements position"),g.unbind(),g.unfix(),g.resetCSS(),g.remove.offset(),g.remove.lastScroll()},resetCSS:function(){C.css({width:"",height:""}),a.css({height:""})},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,p,t);else{if(n===i)return p[t];p[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,g,t);else{if(n===i)return g[t];g[t]=n}},debug:function(){p.debug&&(p.performance?g.performance.log(arguments):(g.debug=Function.prototype.bind.call(console.info,console,p.name+":"),g.debug.apply(console,arguments)))},verbose:function(){p.verbose&&p.debug&&(p.performance?g.performance.log(arguments):(g.verbose=Function.prototype.bind.call(console.info,console,p.name+":"),g.verbose.apply(console,arguments)))},error:function(){g.error=Function.prototype.bind.call(console.error,console,p.name+":"),g.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;p.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:A,"Execution Time":n})),clearTimeout(g.performance.timer),g.performance.timer=setTimeout(g.performance.display,0)},display:function(){var t=p.name+":",n=0;s=!1,clearTimeout(g.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",r&&(t+=" '"+r+"'"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,a){var r,s,c,l=S;return n=n||d,a=A||a,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(a,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},u?(S===i&&g.initialize(),g.invoke(l)):(S!==i&&S.invoke("destroy"),g.initialize())}),o!==i?o:this},e.fn.sticky.settings={name:"Sticky",namespace:"sticky",debug:!1,verbose:!0,performance:!0,pushing:!1,context:!1,scrollContext:t,offset:0,bottomOffset:0,jitter:5,observeChanges:!1,onReposition:function(){},onScroll:function(){},onStick:function(){},onUnstick:function(){},onTop:function(){},onBottom:function(){},error:{container:"Sticky element must be inside a relative container",visible:"Element is hidden, you must call refresh after element becomes visible",method:"The method you called is not defined.",invalidContext:"Context specified does not exist",elementSize:"Sticky element is larger than its container, cannot create sticky."},className:{bound:"bound",fixed:"fixed",supported:"native",top:"top",bottom:"bottom"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.tab=function(o){var a,r=e(e.isFunction(this)?t:this),s=r.selector||"",c=(new Date).getTime(),l=[],u=arguments[0],d="string"==typeof u,m=[].slice.call(arguments,1),f=!1;return r.each(function(){var g,p,v,h,b,y,x=e.isPlainObject(o)?e.extend(!0,{},e.fn.tab.settings,o):e.extend({},e.fn.tab.settings),C=x.className,w=x.metadata,k=x.selector,S=x.error,T="."+x.namespace,A="module-"+x.namespace,R=e(this),E={},P=!0,F=0,D=this,O=R.data(A);b={initialize:function(){b.debug("Initializing tab menu item",R),b.fix.callbacks(),b.determineTabs(),b.debug("Determining tabs",x.context,p),x.auto&&b.set.auto(),b.bind.events(),x.history&&!f&&(b.initializeHistory(),f=!0),b.instantiate()},instantiate:function(){b.verbose("Storing instance of module",b),O=b,R.data(A,b)},destroy:function(){b.debug("Destroying tabs",R),R.removeData(A).off(T)},bind:{events:function(){e.isWindow(D)||(b.debug("Attaching tab activation events to element",R),R.on("click"+T,b.event.click))}},determineTabs:function(){var t;"parent"===x.context?(R.closest(k.ui).length>0?(t=R.closest(k.ui),b.verbose("Using closest UI element as parent",t)):t=R,g=t.parent(),b.verbose("Determined parent element for creating context",g)):x.context?(g=e(x.context),b.verbose("Using selector for tab context",x.context,g)):g=e("body"),x.childrenOnly?(p=g.children(k.tabs),b.debug("Searching tab context children for tabs",g,p)):(p=g.find(k.tabs),b.debug("Searching tab context for tabs",g,p))},fix:{callbacks:function(){e.isPlainObject(o)&&(o.onTabLoad||o.onTabInit)&&(o.onTabLoad&&(o.onLoad=o.onTabLoad,delete o.onTabLoad,b.error(S.legacyLoad,o.onLoad)),o.onTabInit&&(o.onFirstLoad=o.onTabInit,delete o.onTabInit,b.error(S.legacyInit,o.onFirstLoad)),x=e.extend(!0,{},e.fn.tab.settings,o))}},initializeHistory:function(){if(b.debug("Initializing page state"),e.address===i)return b.error(S.state),!1;if("state"==x.historyType){if(b.debug("Using HTML5 to manage state"),x.path===!1)return b.error(S.path),!1;e.address.history(!0).state(x.path)}e.address.bind("change",b.event.history.change)},event:{click:function(t){var n=e(this).data(w.tab);n!==i?(x.history?(b.verbose("Updating page state",t),e.address.value(n)):(b.verbose("Changing tab",t),b.changeTab(n)),t.preventDefault()):b.debug("No tab specified")},history:{change:function(t){var n=t.pathNames.join("/")||b.get.initialPath(),o=x.templates.determineTitle(n)||!1;b.performance.display(),b.debug("History change event",n,t),y=t,n!==i&&b.changeTab(n),o&&e.address.title(o)}}},refresh:function(){v&&(b.debug("Refreshing tab",v),b.changeTab(v))},cache:{read:function(e){return e!==i?E[e]:!1},add:function(e,t){e=e||v,b.debug("Adding cached content for",e),E[e]=t},remove:function(e){e=e||v,b.debug("Removing cached content for",e),delete E[e]}},set:{auto:function(){var t="string"==typeof x.path?x.path.replace(/\/$/,"")+"/{$tab}":"/{$tab}";b.verbose("Setting up automatic tab retrieval from server",t),e.isPlainObject(x.apiSettings)?x.apiSettings.url=t:x.apiSettings={url:t}},loading:function(e){var t=b.get.tabElement(e),n=t.hasClass(C.loading);n||(b.verbose("Setting loading state for",t),t.addClass(C.loading).siblings(p).removeClass(C.active+" "+C.loading),t.length>0&&x.onRequest.call(t[0],e))},state:function(t){e.address.value(t)}},changeTab:function(n){var i=t.history&&t.history.pushState,o=i&&x.ignoreFirstLoad&&P,a=x.auto||e.isPlainObject(x.apiSettings),r=a&&!o?b.utilities.pathToArray(n):b.get.defaultPathArray(n);n=b.utilities.arrayToPath(r),e.each(r,function(t,i){var s,c,l,u,d=r.slice(0,t+1),m=b.utilities.arrayToPath(d),f=b.is.tab(m),p=t+1==r.length,k=b.get.tabElement(m);if(b.verbose("Looking for tab",i),f){if(b.verbose("Tab was found",i),v=m,h=b.utilities.filterArray(r,d),p?u=!0:(c=r.slice(0,t+2),l=b.utilities.arrayToPath(c),u=!b.is.tab(l),u&&b.verbose("Tab parameters found",c)),u&&a)return o?(b.debug("Ignoring remote content on first tab load",m),P=!1,b.cache.add(n,k.html()),b.activate.all(m),x.onFirstLoad.call(k[0],m,h,y),x.onLoad.call(k[0],m,h,y)):(b.activate.navigation(m),b.fetch.content(m,n)),!1;b.debug("Opened local tab",m),b.activate.all(m),b.cache.read(m)||(b.cache.add(m,!0),b.debug("First time tab loaded calling tab init"),x.onFirstLoad.call(k[0],m,h,y)),x.onLoad.call(k[0],m,h,y)}else{if(-1!=n.search("/")||""===n)return b.error(S.missingTab,R,g,m),!1;if(s=e("#"+n+', a[name="'+n+'"]'),m=s.closest("[data-tab]").data(w.tab),k=b.get.tabElement(m),s&&s.length>0&&m)return b.debug("Anchor link used, opening parent tab",k,s),k.hasClass(C.active)||setTimeout(function(){b.scrollTo(s)},0),b.activate.all(m),b.cache.read(m)||(b.cache.add(m,!0),b.debug("First time tab loaded calling tab init"),x.onFirstLoad.call(k[0],m,h,y)),x.onLoad.call(k[0],m,h,y),!1}})},scrollTo:function(t){var i=t&&t.length>0?t.offset().top:!1;i!==!1&&(b.debug("Forcing scroll to an in-page link in a hidden tab",i,t),e(n).scrollTop(i))},update:{content:function(e,t,n){var o=b.get.tabElement(e),a=o[0];n=n!==i?n:x.evaluateScripts,n?(b.debug("Updating HTML and evaluating inline scripts",e,t),o.html(t)):(b.debug("Updating HTML",e,t),a.innerHTML=t)}},fetch:{content:function(t,n){var o,a,r=b.get.tabElement(t),s={dataType:"html",encodeParameters:!1,on:"now",cache:x.alwaysRefresh,headers:{"X-Remote":!0},onSuccess:function(e){b.cache.add(n,e),b.update.content(t,e),t==v?(b.debug("Content loaded",t),b.activate.tab(t)):b.debug("Content loaded in background",t),x.onFirstLoad.call(r[0],t,h,y),x.onLoad.call(r[0],t,h,y)},urlData:{tab:n}},c=r.api("get request")||!1,l=c&&"pending"===c.state();n=n||t,a=b.cache.read(n),x.cache&&a?(b.activate.tab(t),b.debug("Adding cached content",n),"once"==x.evaluateScripts?b.update.content(t,a,!1):b.update.content(t,a),x.onLoad.call(r[0],t,h,y)):l?(b.set.loading(t),b.debug("Content is already loading",n)):e.api!==i?(o=e.extend(!0,{},x.apiSettings,s),b.debug("Retrieving remote content",n,o),b.set.loading(t),r.api(o)):b.error(S.api)}},activate:{all:function(e){b.activate.tab(e),b.activate.navigation(e)},tab:function(e){var t=b.get.tabElement(e),n=t.hasClass(C.active);b.verbose("Showing tab content for",t),n||(t.addClass(C.active).siblings(p).removeClass(C.active+" "+C.loading),t.length>0&&x.onVisible.call(t[0],e))},navigation:function(e){var t=b.get.navElement(e),n=t.hasClass(C.active);b.verbose("Activating tab navigation for",t,e),n||t.addClass(C.active).siblings(r).removeClass(C.active+" "+C.loading)}},deactivate:{all:function(){b.deactivate.navigation(),b.deactivate.tabs()},navigation:function(){r.removeClass(C.active)},tabs:function(){p.removeClass(C.active+" "+C.loading)}},is:{tab:function(e){return e!==i?b.get.tabElement(e).length>0:!1}},get:{initialPath:function(){return r.eq(0).data(w.tab)||p.eq(0).data(w.tab)},path:function(){return e.address.value()},defaultPathArray:function(e){return b.utilities.pathToArray(b.get.defaultPath(e))},defaultPath:function(e){var t=r.filter("[data-"+w.tab+'^="'+e+'/"]').eq(0),n=t.data(w.tab)||!1;if(n){if(b.debug("Found default tab",n),F<x.maxDepth)return F++,b.get.defaultPath(n);b.error(S.recursion)}else b.debug("No default tabs found for",e,p);return F=0,e},navElement:function(e){return e=e||v,r.filter("[data-"+w.tab+'="'+e+'"]')},tabElement:function(e){var t,n,i,o;return e=e||v,i=b.utilities.pathToArray(e),o=b.utilities.last(i),t=p.filter("[data-"+w.tab+'="'+e+'"]'),n=p.filter("[data-"+w.tab+'="'+o+'"]'),t.length>0?t:n},tab:function(){return v}},utilities:{filterArray:function(t,n){return e.grep(t,function(t){return-1==e.inArray(t,n)})},last:function(t){return e.isArray(t)?t[t.length-1]:!1},pathToArray:function(e){return e===i&&(e=v),"string"==typeof e?e.split("/"):[e]},arrayToPath:function(t){return e.isArray(t)?t.join("/"):!1}},setting:function(t,n){if(b.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,x,t);else{if(n===i)return x[t];x[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,b,t);else{if(n===i)return b[t];b[t]=n}},debug:function(){x.debug&&(x.performance?b.performance.log(arguments):(b.debug=Function.prototype.bind.call(console.info,console,x.name+":"),b.debug.apply(console,arguments)))},verbose:function(){x.verbose&&x.debug&&(x.performance?b.performance.log(arguments):(b.verbose=Function.prototype.bind.call(console.info,console,x.name+":"),b.verbose.apply(console,arguments)))},error:function(){b.error=Function.prototype.bind.call(console.error,console,x.name+":"),b.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;x.performance&&(t=(new Date).getTime(),i=c||t,n=t-i,c=t,l.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:D,"Execution Time":n})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(b.performance.display,500)},display:function(){var t=x.name+":",n=0;c=!1,clearTimeout(b.performance.timer),e.each(l,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",s&&(t+=" '"+s+"'"),(console.group!==i||console.table!==i)&&l.length>0&&(console.groupCollapsed(t),console.table?console.table(l):e.each(l,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),l=[]}},invoke:function(t,n,o){var r,s,c,l=O;return n=n||m,o=D||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):(b.error(S.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(a)?a.push(c):a!==i?a=[a,c]:c!==i&&(a=c),s}},d?(O===i&&b.initialize(),b.invoke(u)):(O!==i&&O.invoke("destroy"),b.initialize())}),a!==i?a:this},e.tab=function(){e(t).tab.apply(this,arguments)},e.fn.tab.settings={name:"Tab",namespace:"tab",debug:!1,verbose:!1,performance:!0,auto:!1,history:!1,historyType:"hash",path:!1,context:!1,childrenOnly:!1,maxDepth:25,alwaysRefresh:!1,cache:!0,ignoreFirstLoad:!1,apiSettings:!1,evaluateScripts:"once",onFirstLoad:function(e,t,n){},onLoad:function(e,t,n){},onVisible:function(e,t,n){},onRequest:function(e,t,n){},templates:{determineTitle:function(e){}},error:{api:"You attempted to load content without API module",method:"The method you called is not defined",missingTab:"Activated tab cannot be found. Tabs are case-sensitive.",noContent:"The tab you specified is missing a content url.",path:"History enabled, but no path was specified",recursion:"Max recursive depth reached",legacyInit:"onTabInit has been renamed to onFirstLoad in 2.0, please adjust your code.",legacyLoad:"onTabLoad has been renamed to onLoad in 2.0. Please adjust your code",state:"History requires Asual's Address library <https://github.com/asual/jquery-address>"},metadata:{tab:"tab",loaded:"loaded",promise:"promise"},className:{loading:"loading",active:"active"},selector:{tabs:".ui.tab",ui:".ui"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.transition=function(){var o,a=e(this),r=a.selector||"",s=(new Date).getTime(),c=[],l=arguments,u=l[0],d=[].slice.call(arguments,1),m="string"==typeof u;t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)};return a.each(function(t){var f,g,p,v,h,b,y,x,C,w=e(this),k=this;C={initialize:function(){f=C.get.settings.apply(k,l),v=f.className,p=f.error,h=f.metadata,x="."+f.namespace,y="module-"+f.namespace,g=w.data(y)||C,b=C.get.animationEndEvent(),m&&(m=C.invoke(u)),m===!1&&(C.verbose("Converted arguments into settings object",f),f.interval?C.delay(f.animate):C.animate(),C.instantiate())},instantiate:function(){C.verbose("Storing instance of module",C),g=C,w.data(y,g)},destroy:function(){C.verbose("Destroying previous module for",k),w.removeData(y)},refresh:function(){C.verbose("Refreshing display type on next animation"),delete C.displayType},forceRepaint:function(){C.verbose("Forcing element repaint");var e=w.parent(),t=w.next();0===t.length?w.detach().appendTo(e):w.detach().insertBefore(t)},repaint:function(){C.verbose("Repainting element");k.offsetWidth},delay:function(e){var n,o,r=C.get.animationDirection();r||(r=C.can.transition()?C.get.direction():"static"),e=e!==i?e:f.interval,n="auto"==f.reverse&&r==v.outward,o=n||1==f.reverse?(a.length-t)*f.interval:t*f.interval,C.debug("Delaying animation by",o),setTimeout(C.animate,o)},animate:function(e){if(f=e||f,!C.is.supported())return C.error(p.support),!1;if(C.debug("Preparing animation",f.animation),C.is.animating()){if(f.queue)return!f.allowRepeats&&C.has.direction()&&C.is.occurring()&&C.queuing!==!0?C.debug("Animation is currently occurring, preventing queueing same animation",f.animation):C.queue(f.animation),!1;if(!f.allowRepeats&&C.is.occurring())return C.debug("Animation is already occurring, will not execute repeated animation",f.animation),!1;C.debug("New animation started, completing previous early",f.animation),g.complete()}C.can.animate()?C.set.animating(f.animation):C.error(p.noAnimation,f.animation,k)},reset:function(){C.debug("Resetting animation to beginning conditions"),C.remove.animationCallbacks(),C.restore.conditions(),C.remove.animating()},queue:function(e){C.debug("Queueing animation of",e),C.queuing=!0,w.one(b+".queue"+x,function(){C.queuing=!1,C.repaint(),C.animate.apply(this,f)})},complete:function(e){C.debug("Animation complete",f.animation),C.remove.completeCallback(),C.remove.failSafe(),C.is.looping()||(C.is.outward()?(C.verbose("Animation is outward, hiding element"),C.restore.conditions(),C.hide()):C.is.inward()?(C.verbose("Animation is outward, showing element"),C.restore.conditions(),C.show()):(C.verbose("Static animation completed"),C.restore.conditions(),f.onComplete.call(k)))},force:{visible:function(){var e=w.attr("style"),t=C.get.userStyle(),n=C.get.displayType(),o=t+"display: "+n+" !important;",a=w.css("display"),r=e===i||""===e;a!==n?(C.verbose("Overriding default display to show element",n),w.attr("style",o)):r&&w.removeAttr("style")},hidden:function(){var e=w.attr("style"),t=w.css("display"),n=e===i||""===e;"none"===t||C.is.hidden()?n&&w.removeAttr("style"):(C.verbose("Overriding default display to hide element"),w.css("display","none"))}},has:{direction:function(t){var n=!1;return t=t||f.animation,"string"==typeof t&&(t=t.split(" "),e.each(t,function(e,t){(t===v.inward||t===v.outward)&&(n=!0)})),n},inlineDisplay:function(){var t=w.attr("style")||"";return e.isArray(t.match(/display.*?;/,""))}},set:{animating:function(e){var t;C.remove.completeCallback(),e=e||f.animation,t=C.get.animationClass(e),C.save.animation(t),C.force.visible(),C.remove.hidden(),C.remove.direction(),C.start.animation(t)},duration:function(e,t){t=t||f.duration,t="number"==typeof t?t+"ms":t,(t||0===t)&&(C.verbose("Setting animation duration",t),w.css({"animation-duration":t}))},direction:function(e){e=e||C.get.direction(),e==v.inward?C.set.inward():C.set.outward()},looping:function(){C.debug("Transition set to loop"),w.addClass(v.looping)},hidden:function(){w.addClass(v.transition).addClass(v.hidden)},inward:function(){C.debug("Setting direction to inward"),w.removeClass(v.outward).addClass(v.inward)},outward:function(){C.debug("Setting direction to outward"),w.removeClass(v.inward).addClass(v.outward)},visible:function(){w.addClass(v.transition).addClass(v.visible)}},start:{animation:function(e){e=e||C.get.animationClass(),C.debug("Starting tween",e),w.addClass(e).one(b+".complete"+x,C.complete),f.useFailSafe&&C.add.failSafe(),C.set.duration(f.duration),f.onStart.call(k)}},save:{animation:function(e){C.cache||(C.cache={}),C.cache.animation=e},displayType:function(e){"none"!==e&&w.data(h.displayType,e)},transitionExists:function(t,n){e.fn.transition.exists[t]=n,C.verbose("Saving existence of transition",t,n)}},restore:{conditions:function(){var e=C.get.currentAnimation();e&&(w.removeClass(e),C.verbose("Removing animation class",C.cache)),C.remove.duration()}},add:{failSafe:function(){var e=C.get.duration();C.timer=setTimeout(function(){w.triggerHandler(b)},e+f.failSafeDelay),C.verbose("Adding fail safe timer",C.timer)}},remove:{animating:function(){w.removeClass(v.animating)},animationCallbacks:function(){C.remove.queueCallback(),C.remove.completeCallback()},queueCallback:function(){w.off(".queue"+x)},completeCallback:function(){w.off(".complete"+x)},display:function(){w.css("display","")},direction:function(){w.removeClass(v.inward).removeClass(v.outward)},duration:function(){w.css("animation-duration","")},failSafe:function(){C.verbose("Removing fail safe timer",C.timer),C.timer&&clearTimeout(C.timer)},hidden:function(){w.removeClass(v.hidden)},visible:function(){w.removeClass(v.visible)},looping:function(){C.debug("Transitions are no longer looping"),C.is.looping()&&(C.reset(),w.removeClass(v.looping))},transition:function(){w.removeClass(v.visible).removeClass(v.hidden)}},get:{settings:function(t,n,i){return"object"==typeof t?e.extend(!0,{},e.fn.transition.settings,t):"function"==typeof i?e.extend({},e.fn.transition.settings,{animation:t,onComplete:i,duration:n}):"string"==typeof n||"number"==typeof n?e.extend({},e.fn.transition.settings,{animation:t,duration:n}):"object"==typeof n?e.extend({},e.fn.transition.settings,n,{animation:t}):"function"==typeof n?e.extend({},e.fn.transition.settings,{animation:t,onComplete:n}):e.extend({},e.fn.transition.settings,{animation:t})},animationClass:function(e){var t=e||f.animation,n=C.can.transition()&&!C.has.direction()?C.get.direction()+" ":"";return v.animating+" "+v.transition+" "+n+t},currentAnimation:function(){return C.cache&&C.cache.animation!==i?C.cache.animation:!1},currentDirection:function(){return C.is.inward()?v.inward:v.outward},direction:function(){return C.is.hidden()||!C.is.visible()?v.inward:v.outward},animationDirection:function(t){var n;return t=t||f.animation,"string"==typeof t&&(t=t.split(" "),e.each(t,function(e,t){t===v.inward?n=v.inward:t===v.outward&&(n=v.outward)})),n?n:!1},duration:function(e){return e=e||f.duration,e===!1&&(e=w.css("animation-duration")||0),"string"==typeof e?e.indexOf("ms")>-1?parseFloat(e):1e3*parseFloat(e):e},displayType:function(){return f.displayType?f.displayType:(w.data(h.displayType)===i&&C.can.transition(!0),w.data(h.displayType))},userStyle:function(e){return e=e||w.attr("style")||"",e.replace(/display.*?;/,"")},transitionExists:function(t){return true},animationStartEvent:function(){var e,t=n.createElement("div"),o={animation:"animationstart",OAnimation:"oAnimationStart",MozAnimation:"mozAnimationStart",WebkitAnimation:"webkitAnimationStart"};for(e in o)if(t.style[e]!==i)return o[e];return!1},animationEndEvent:function(){var e,t=n.createElement("div"),o={animation:"animationend",OAnimation:"oAnimationEnd",MozAnimation:"mozAnimationEnd",WebkitAnimation:"webkitAnimationEnd"};for(e in o)if(t.style[e]!==i)return o[e];return!1}},can:{transition:function(t){var n,o,a,r,s,c,l,u=f.animation,d=C.get.transitionExists(u);if(d===i||t){if(C.verbose("Determining whether animation exists"),n=w.attr("class"),o=w.prop("tagName"),a=e("<"+o+" />").addClass(n).insertAfter(w),r=a.addClass(u).removeClass(v.inward).removeClass(v.outward).addClass(v.animating).addClass(v.transition).css("animationName"),s=a.addClass(v.inward).css("animationName"),l=a.attr("class",n).removeAttr("style").removeClass(v.hidden).removeClass(v.visible).show().css("display"),C.verbose("Determining final display state",l),C.save.displayType(l),a.remove(),r!=s)C.debug("Direction exists for animation",u),c=!0;else{if("none"==r||!r)return void C.debug("No animation defined in css",u);C.debug("Static animation found",u,l),c=!1}C.save.transitionExists(u,c)}return d!==i?d:c},animate:function(){return C.can.transition()!==i}},is:{animating:function(){return w.hasClass(v.animating)},inward:function(){return w.hasClass(v.inward)},outward:function(){return w.hasClass(v.outward)},looping:function(){return w.hasClass(v.looping)},occurring:function(e){return e=e||f.animation,e="."+e.replace(" ","."),w.filter(e).length>0},visible:function(){return w.is(":visible")},hidden:function(){return"hidden"===w.css("visibility")},supported:function(){return b!==!1}},hide:function(){C.verbose("Hiding element"),C.is.animating()&&C.reset(),k.blur(),C.remove.display(),C.remove.visible(),C.set.hidden(),C.force.hidden(),f.onHide.call(k),f.onComplete.call(k)},show:function(e){C.verbose("Showing element",e),C.remove.hidden(),C.set.visible(),C.force.visible(),f.onShow.call(k),f.onComplete.call(k)},toggle:function(){C.is.visible()?C.hide():C.show()},stop:function(){C.debug("Stopping current animation"),w.triggerHandler(b)},stopAll:function(){C.debug("Stopping all animation"),C.remove.queueCallback(),w.triggerHandler(b)},clear:{queue:function(){C.debug("Clearing animation queue"),C.remove.queueCallback()}},enable:function(){C.verbose("Starting animation"),w.removeClass(v.disabled)},disable:function(){C.debug("Stopping animation"),w.addClass(v.disabled)},setting:function(t,n){if(C.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,C,t);else{if(n===i)return C[t];C[t]=n}},debug:function(){f.debug&&(f.performance?C.performance.log(arguments):(C.debug=Function.prototype.bind.call(console.info,console,f.name+":"),C.debug.apply(console,arguments)))},verbose:function(){f.verbose&&f.debug&&(f.performance?C.performance.log(arguments):(C.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),C.verbose.apply(console,arguments)))},error:function(){C.error=Function.prototype.bind.call(console.error,console,f.name+":"),C.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;f.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:k,"Execution Time":n})),clearTimeout(C.performance.timer),C.performance.timer=setTimeout(C.performance.display,500)},display:function(){var t=f.name+":",n=0;s=!1,clearTimeout(C.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",r&&(t+=" '"+r+"'"),a.length>1&&(t+=" ("+a.length+")"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,a){var r,s,c,l=g;return n=n||d,a=k||a,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(a,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s!==i?s:!1}},C.initialize()}),o!==i?o:this},e.fn.transition.exists={},e.fn.transition.settings={name:"Transition",debug:!1,verbose:!1,performance:!0,namespace:"transition",interval:0,reverse:"auto",onStart:function(){},onComplete:function(){},onShow:function(){},onHide:function(){},useFailSafe:!0,failSafeDelay:100,allowRepeats:!1,displayType:!1,animation:"fade",duration:!1,queue:!0,metadata:{displayType:"display"},className:{animating:"animating",disabled:"disabled",hidden:"hidden",inward:"in",loading:"loading",looping:"looping",outward:"out",transition:"transition",visible:"visible"},error:{noAnimation:"There is no css animation matching the one you specified. Please make sure your css is vendor prefixed, and you have included transition css.",repeated:"That animation is already occurring, cancelling repeated animation",method:"The method you called is not defined",
+support:"This browser does not support CSS animations"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.api=e.fn.api=function(n){var o,a=e(e.isFunction(this)?t:this),r=a.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return a.each(function(){var a,m,f,g,p,v,h=e.isPlainObject(n)?e.extend(!0,{},e.fn.api.settings,n):e.extend({},e.fn.api.settings),b=h.namespace,y=h.metadata,x=h.selector,C=h.error,w=h.className,k="."+b,S="module-"+b,T=e(this),A=T.closest(x.form),R=h.stateContext?e(h.stateContext):T,E=this,P=R[0],F=T.data(S);v={initialize:function(){u||v.bind.events(),v.instantiate()},instantiate:function(){v.verbose("Storing instance of module",v),F=v,T.data(S,F)},destroy:function(){v.verbose("Destroying previous module for",E),T.removeData(S).off(k)},bind:{events:function(){var e=v.get.event();e?(v.verbose("Attaching API events to element",e),T.on(e+k,v.event.trigger)):"now"==h.on&&(v.debug("Querying API endpoint immediately"),v.query())}},decode:{json:function(e){if(e!==i&&"string"==typeof e)try{e=JSON.parse(e)}catch(t){}return e}},read:{cachedResponse:function(e){var n;return t.Storage===i?void v.error(C.noStorage):(n=sessionStorage.getItem(e),v.debug("Using cached response",e,n),n=v.decode.json(n),!1)}},write:{cachedResponse:function(n,o){return o&&""===o?void v.debug("Response empty, not caching",o):t.Storage===i?void v.error(C.noStorage):(e.isPlainObject(o)&&(o=JSON.stringify(o)),sessionStorage.setItem(n,o),void v.verbose("Storing cached response for url",n,o))}},query:function(){if(v.is.disabled())return void v.debug("Element is disabled API request aborted");if(v.is.loading()){if(!h.interruptRequests)return void v.debug("Cancelling request, previous request is still pending");v.debug("Interrupting previous request"),v.abort()}return h.defaultData&&e.extend(!0,h.urlData,v.get.defaultData()),h.serializeForm&&(h.data=v.add.formData(h.data)),m=v.get.settings(),m===!1?(v.cancelled=!0,void v.error(C.beforeSend)):(v.cancelled=!1,f=v.get.templatedURL(),f||v.is.mocked()?(f=v.add.urlData(f),f||v.is.mocked()?(a=e.extend(!0,{},h,{type:h.method||h.type,data:g,url:h.base+f,beforeSend:h.beforeXHR,success:function(){},failure:function(){},complete:function(){}}),v.debug("Querying URL",a.url),v.verbose("Using AJAX settings",a),"local"===h.cache&&v.read.cachedResponse(f)?(v.debug("Response returned from local cache"),v.request=v.create.request(),void v.request.resolveWith(P,[v.read.cachedResponse(f)])):void(h.throttle?h.throttleFirstRequest||v.timer?(v.debug("Throttling request",h.throttle),clearTimeout(v.timer),v.timer=setTimeout(function(){v.timer&&delete v.timer,v.debug("Sending throttled request",g,a.method),v.send.request()},h.throttle)):(v.debug("Sending request",g,a.method),v.send.request(),v.timer=setTimeout(function(){},h.throttle)):(v.debug("Sending request",g,a.method),v.send.request()))):void 0):void v.error(C.missingURL))},should:{removeError:function(){return h.hideError===!0||"auto"===h.hideError&&!v.is.form()}},is:{disabled:function(){return T.filter(x.disabled).length>0},form:function(){return T.is("form")||R.is("form")},mocked:function(){return h.mockResponse||h.mockResponseAsync},input:function(){return T.is("input")},loading:function(){return v.request&&"pending"==v.request.state()},abortedRequest:function(e){return e&&e.readyState!==i&&0===e.readyState?(v.verbose("XHR request determined to be aborted"),!0):(v.verbose("XHR request was not aborted"),!1)},validResponse:function(t){return"json"!==h.dataType&&"jsonp"!==h.dataType||!e.isFunction(h.successTest)?(v.verbose("Response is not JSON, skipping validation",h.successTest,t),!0):(v.debug("Checking JSON returned success",h.successTest,t),h.successTest(t)?(v.debug("Response passed success test",t),!0):(v.debug("Response failed success test",t),!1))}},was:{cancelled:function(){return v.cancelled||!1},succesful:function(){return v.request&&"resolved"==v.request.state()},failure:function(){return v.request&&"rejected"==v.request.state()},complete:function(){return v.request&&("resolved"==v.request.state()||"rejected"==v.request.state())}},add:{urlData:function(t,n){var o,a;return t&&(o=t.match(h.regExp.required),a=t.match(h.regExp.optional),n=n||h.urlData,o&&(v.debug("Looking for required URL variables",o),e.each(o,function(o,a){var r=-1!==a.indexOf("$")?a.substr(2,a.length-3):a.substr(1,a.length-2),s=e.isPlainObject(n)&&n[r]!==i?n[r]:T.data(r)!==i?T.data(r):R.data(r)!==i?R.data(r):n[r];return s===i?(v.error(C.requiredParameter,r,t),t=!1,!1):(v.verbose("Found required variable",r,s),s=h.encodeParameters?v.get.urlEncodedValue(s):s,t=t.replace(a,s),void 0)})),a&&(v.debug("Looking for optional URL variables",o),e.each(a,function(o,a){var r=-1!==a.indexOf("$")?a.substr(3,a.length-4):a.substr(2,a.length-3),s=e.isPlainObject(n)&&n[r]!==i?n[r]:T.data(r)!==i?T.data(r):R.data(r)!==i?R.data(r):n[r];s!==i?(v.verbose("Optional variable Found",r,s),t=t.replace(a,s)):(v.verbose("Optional variable not found",r),t=-1!==t.indexOf("/"+a)?t.replace("/"+a,""):t.replace(a,""))}))),t},formData:function(t){var n,o=e.fn.serializeObject!==i,a=o?A.serializeObject():A.serialize();return t=t||h.data,n=e.isPlainObject(t),n?o?(v.debug("Extending existing data with form data",t,a),t=e.extend(!0,{},t,a)):(v.error(C.missingSerialize),v.debug("Cant extend data. Replacing data with form data",t,a),t=a):(v.debug("Adding form data",a),t=a),t}},send:{request:function(){v.set.loading(),v.request=v.create.request(),v.is.mocked()?v.mockedXHR=v.create.mockedXHR():v.xhr=v.create.xhr(),h.onRequest.call(P,v.request,v.xhr)}},event:{trigger:function(e){v.query(),("submit"==e.type||"click"==e.type)&&e.preventDefault()},xhr:{always:function(){},done:function(t,n,i){var o=this,a=(new Date).getTime()-p,r=h.loadingDuration-a,s=e.isFunction(h.onResponse)?h.onResponse.call(o,e.extend(!0,{},t)):!1;r=r>0?r:0,s&&(v.debug("Modified API response in onResponse callback",h.onResponse,s,t),t=s),r>0&&v.debug("Response completed early delaying state change by",r),setTimeout(function(){v.is.validResponse(t)?v.request.resolveWith(o,[t,i]):v.request.rejectWith(o,[i,"invalid"])},r)},fail:function(e,t,n){var i=this,o=(new Date).getTime()-p,a=h.loadingDuration-o;a=a>0?a:0,a>0&&v.debug("Response completed early delaying state change by",a),setTimeout(function(){v.is.abortedRequest(e)?v.request.rejectWith(i,[e,"aborted",n]):v.request.rejectWith(i,[e,"error",t,n])},a)}},request:{done:function(e,t){v.debug("Successful API Response",e),"local"===h.cache&&f&&(v.write.cachedResponse(f,e),v.debug("Saving server response locally",v.cache)),h.onSuccess.call(P,e,T,t)},complete:function(e,t){var n,i;v.was.succesful()?(i=e,n=t):(n=e,i=v.get.responseFromXHR(n)),v.remove.loading(),h.onComplete.call(P,i,T,n)},fail:function(e,t,n){var o=v.get.responseFromXHR(e),r=v.get.errorFromRequest(o,t,n);"aborted"==t?(v.debug("XHR Aborted (Most likely caused by page navigation or CORS Policy)",t,n),h.onAbort.call(P,t,T,e)):"invalid"==t?v.debug("JSON did not pass success test. A server-side error has most likely occurred",o):"error"==t&&e!==i&&(v.debug("XHR produced a server error",t,n),200!=e.status&&n!==i&&""!==n&&v.error(C.statusMessage+n,a.url),h.onError.call(P,r,T,e)),h.errorDuration&&"aborted"!==t&&(v.debug("Adding error state"),v.set.error(),v.should.removeError()&&setTimeout(v.remove.error,h.errorDuration)),v.debug("API Request failed",r,e),h.onFailure.call(P,o,T,e)}}},create:{request:function(){return e.Deferred().always(v.event.request.complete).done(v.event.request.done).fail(v.event.request.fail)},mockedXHR:function(){var t,n,i,o=!1,a=!1,r=!1;return i=e.Deferred().always(v.event.xhr.complete).done(v.event.xhr.done).fail(v.event.xhr.fail),h.mockResponse?(e.isFunction(h.mockResponse)?(v.debug("Using mocked callback returning response",h.mockResponse),n=h.mockResponse.call(P,h)):(v.debug("Using specified response",h.mockResponse),n=h.mockResponse),i.resolveWith(P,[n,o,{responseText:n}])):e.isFunction(h.mockResponseAsync)&&(t=function(e){v.debug("Async callback returned response",e),e?i.resolveWith(P,[e,o,{responseText:e}]):i.rejectWith(P,[{responseText:e},a,r])},v.debug("Using async mocked response",h.mockResponseAsync),h.mockResponseAsync.call(P,h,t)),i},xhr:function(){var t;return t=e.ajax(a).always(v.event.xhr.always).done(v.event.xhr.done).fail(v.event.xhr.fail),v.verbose("Created server request",t),t}},set:{error:function(){v.verbose("Adding error state to element",R),R.addClass(w.error)},loading:function(){v.verbose("Adding loading state to element",R),R.addClass(w.loading),p=(new Date).getTime()}},remove:{error:function(){v.verbose("Removing error state from element",R),R.removeClass(w.error)},loading:function(){v.verbose("Removing loading state from element",R),R.removeClass(w.loading)}},get:{responseFromXHR:function(t){return e.isPlainObject(t)?"json"==h.dataType||"jsonp"==h.dataType?v.decode.json(t.responseText):t.responseText:!1},errorFromRequest:function(t,n,o){return e.isPlainObject(t)&&t.error!==i?t.error:h.error[n]!==i?h.error[n]:o},request:function(){return v.request||!1},xhr:function(){return v.xhr||!1},settings:function(){var e;return e=h.beforeSend.call(P,h),e&&(e.success!==i&&(v.debug("Legacy success callback detected",e),v.error(C.legacyParameters,e.success),e.onSuccess=e.success),e.failure!==i&&(v.debug("Legacy failure callback detected",e),v.error(C.legacyParameters,e.failure),e.onFailure=e.failure),e.complete!==i&&(v.debug("Legacy complete callback detected",e),v.error(C.legacyParameters,e.complete),e.onComplete=e.complete)),e===i&&v.error(C.noReturnedValue),e!==i?e:h},urlEncodedValue:function(e){var n=t.decodeURIComponent(e),i=t.encodeURIComponent(e),o=n!==e;return o?(v.debug("URL value is already encoded, avoiding double encoding",e),e):(v.verbose("Encoding value using encodeURIComponent",e,i),i)},defaultData:function(){var t={};return e.isWindow(E)||(v.is.input()?t.value=T.val():v.is.form()&&(t.text=T.text())),t},event:function(){return e.isWindow(E)||"now"==h.on?(v.debug("API called without element, no events attached"),!1):"auto"==h.on?T.is("input")?E.oninput!==i?"input":E.onpropertychange!==i?"propertychange":"keyup":T.is("form")?"submit":"click":h.on},templatedURL:function(e){if(e=e||T.data(y.action)||h.action||!1,f=T.data(y.url)||h.url||!1)return v.debug("Using specified url",f),f;if(e){if(v.debug("Looking up url for action",e,h.api),h.api[e]===i&&!v.is.mocked())return void v.error(C.missingAction,h.action,h.api);f=h.api[e]}else v.is.form()&&(f=T.attr("action")||R.attr("action")||!1,v.debug("No url or action specified, defaulting to form action",f));return f}},abort:function(){var e=v.get.xhr();e&&"resolved"!==e.state()&&(v.debug("Cancelling API request"),e.abort())},reset:function(){v.remove.error(),v.remove.loading()},setting:function(t,n){if(v.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,h,t);else{if(n===i)return h[t];h[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,v,t);else{if(n===i)return v[t];v[t]=n}},debug:function(){h.debug&&(h.performance?v.performance.log(arguments):(v.debug=Function.prototype.bind.call(console.info,console,h.name+":"),v.debug.apply(console,arguments)))},verbose:function(){h.verbose&&h.debug&&(h.performance?v.performance.log(arguments):(v.verbose=Function.prototype.bind.call(console.info,console,h.name+":"),v.verbose.apply(console,arguments)))},error:function(){v.error=Function.prototype.bind.call(console.error,console,h.name+":"),v.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;h.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"","Execution Time":n})),clearTimeout(v.performance.timer),v.performance.timer=setTimeout(v.performance.display,500)},display:function(){var t=h.name+":",n=0;s=!1,clearTimeout(v.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",r&&(t+=" '"+r+"'"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,a){var r,s,c,l=F;return n=n||d,a=E||a,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):(v.error(C.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(a,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},u?(F===i&&v.initialize(),v.invoke(l)):(F!==i&&F.invoke("destroy"),v.initialize())}),o!==i?o:this},e.api.settings={name:"API",namespace:"api",debug:!1,verbose:!1,performance:!0,api:{},cache:!0,interruptRequests:!0,on:"auto",stateContext:!1,loadingDuration:0,hideError:"auto",errorDuration:2e3,encodeParameters:!0,action:!1,url:!1,base:"",urlData:{},defaultData:!0,serializeForm:!1,throttle:0,throttleFirstRequest:!0,method:"get",data:{},dataType:"json",mockResponse:!1,mockResponseAsync:!1,beforeSend:function(e){return e},beforeXHR:function(e){},onRequest:function(e,t){},onResponse:!1,onSuccess:function(e,t){},onComplete:function(e,t){},onFailure:function(e,t){},onError:function(e,t){},onAbort:function(e,t){},successTest:!1,error:{beforeSend:"The before send function has aborted the request",error:"There was an error with your request",exitConditions:"API Request Aborted. Exit conditions met",JSONParse:"JSON could not be parsed during error handling",legacyParameters:"You are using legacy API success callback names",method:"The method you called is not defined",missingAction:"API action used but no url was defined",missingSerialize:"jquery-serialize-object is required to add form data to an existing data object",missingURL:"No URL specified for api event",noReturnedValue:"The beforeSend callback must return a settings object, beforeSend ignored.",noStorage:"Caching responses locally requires session storage",parseError:"There was an error parsing your request",requiredParameter:"Missing a required URL parameter: ",statusMessage:"Server gave an error: ",timeout:"Your request timed out"},regExp:{required:/\{\$*[A-z0-9]+\}/g,optional:/\{\/\$*[A-z0-9]+\}/g},className:{loading:"loading",error:"error"},selector:{disabled:".disabled",form:"form"},metadata:{action:"action",url:"url"}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.state=function(t){var o,a=e(this),r=a.selector||"",s=("ontouchstart"in n.documentElement,(new Date).getTime()),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return a.each(function(){var n,m=e.isPlainObject(t)?e.extend(!0,{},e.fn.state.settings,t):e.extend({},e.fn.state.settings),f=m.error,g=m.metadata,p=m.className,v=m.namespace,h=m.states,b=m.text,y="."+v,x=v+"-module",C=e(this),w=this,k=C.data(x);n={initialize:function(){n.verbose("Initializing module"),m.automatic&&n.add.defaults(),m.context&&""!==r?e(m.context).on(r,"mouseenter"+y,n.change.text).on(r,"mouseleave"+y,n.reset.text).on(r,"click"+y,n.toggle.state):C.on("mouseenter"+y,n.change.text).on("mouseleave"+y,n.reset.text).on("click"+y,n.toggle.state),n.instantiate()},instantiate:function(){n.verbose("Storing instance of module",n),k=n,C.data(x,n)},destroy:function(){n.verbose("Destroying previous module",k),C.off(y).removeData(x)},refresh:function(){n.verbose("Refreshing selector cache"),C=e(w)},add:{defaults:function(){var o=t&&e.isPlainObject(t.states)?t.states:{};e.each(m.defaults,function(t,a){n.is[t]!==i&&n.is[t]()&&(n.verbose("Adding default states",t,w),e.extend(m.states,a,o))})}},is:{active:function(){return C.hasClass(p.active)},loading:function(){return C.hasClass(p.loading)},inactive:function(){return!C.hasClass(p.active)},state:function(e){return p[e]===i?!1:C.hasClass(p[e])},enabled:function(){return!C.is(m.filter.active)},disabled:function(){return C.is(m.filter.active)},textEnabled:function(){return!C.is(m.filter.text)},button:function(){return C.is(".button:not(a, .submit)")},input:function(){return C.is("input")},progress:function(){return C.is(".ui.progress")}},allow:function(e){n.debug("Now allowing state",e),h[e]=!0},disallow:function(e){n.debug("No longer allowing",e),h[e]=!1},allows:function(e){return h[e]||!1},enable:function(){C.removeClass(p.disabled)},disable:function(){C.addClass(p.disabled)},setState:function(e){n.allows(e)&&C.addClass(p[e])},removeState:function(e){n.allows(e)&&C.removeClass(p[e])},toggle:{state:function(){var t,o;if(n.allows("active")&&n.is.enabled()){if(n.refresh(),e.fn.api!==i)if(t=C.api("get request"),o=C.api("was cancelled"))n.debug("API Request cancelled by beforesend"),m.activateTest=function(){return!1},m.deactivateTest=function(){return!1};else if(t)return void n.listenTo(t);n.change.state()}}},listenTo:function(t){n.debug("API request detected, waiting for state signal",t),t&&(b.loading&&n.update.text(b.loading),e.when(t).then(function(){"resolved"==t.state()?(n.debug("API request succeeded"),m.activateTest=function(){return!0},m.deactivateTest=function(){return!0}):(n.debug("API request failed"),m.activateTest=function(){return!1},m.deactivateTest=function(){return!1}),n.change.state()}))},change:{state:function(){n.debug("Determining state change direction"),n.is.inactive()?n.activate():n.deactivate(),m.sync&&n.sync(),m.onChange.call(w)},text:function(){n.is.textEnabled()&&(n.is.disabled()?(n.verbose("Changing text to disabled text",b.hover),n.update.text(b.disabled)):n.is.active()?b.hover?(n.verbose("Changing text to hover text",b.hover),n.update.text(b.hover)):b.deactivate&&(n.verbose("Changing text to deactivating text",b.deactivate),n.update.text(b.deactivate)):b.hover?(n.verbose("Changing text to hover text",b.hover),n.update.text(b.hover)):b.activate&&(n.verbose("Changing text to activating text",b.activate),n.update.text(b.activate)))}},activate:function(){m.activateTest.call(w)&&(n.debug("Setting state to active"),C.addClass(p.active),n.update.text(b.active),m.onActivate.call(w))},deactivate:function(){m.deactivateTest.call(w)&&(n.debug("Setting state to inactive"),C.removeClass(p.active),n.update.text(b.inactive),m.onDeactivate.call(w))},sync:function(){n.verbose("Syncing other buttons to current state"),n.is.active()?a.not(C).state("activate"):a.not(C).state("deactivate")},get:{text:function(){return m.selector.text?C.find(m.selector.text).text():C.html()},textFor:function(e){return b[e]||!1}},flash:{text:function(e,t,i){var o=n.get.text();n.debug("Flashing text message",e,t),e=e||m.text.flash,t=t||m.flashDuration,i=i||function(){},n.update.text(e),setTimeout(function(){n.update.text(o),i.call(w)},t)}},reset:{text:function(){var e=b.active||C.data(g.storedText),t=b.inactive||C.data(g.storedText);n.is.textEnabled()&&(n.is.active()&&e?(n.verbose("Resetting active text",e),n.update.text(e)):t&&(n.verbose("Resetting inactive text",e),n.update.text(t)))}},update:{text:function(e){var t=n.get.text();e&&e!==t?(n.debug("Updating text",e),m.selector.text?C.data(g.storedText,e).find(m.selector.text).text(e):C.data(g.storedText,e).html(e)):n.debug("Text is already set, ignoring update",e)}},setting:function(t,o){if(n.debug("Changing setting",t,o),e.isPlainObject(t))e.extend(!0,m,t);else{if(o===i)return m[t];m[t]=o}},internal:function(t,o){if(e.isPlainObject(t))e.extend(!0,n,t);else{if(o===i)return n[t];n[t]=o}},debug:function(){m.debug&&(m.performance?n.performance.log(arguments):(n.debug=Function.prototype.bind.call(console.info,console,m.name+":"),n.debug.apply(console,arguments)))},verbose:function(){m.verbose&&m.debug&&(m.performance?n.performance.log(arguments):(n.verbose=Function.prototype.bind.call(console.info,console,m.name+":"),n.verbose.apply(console,arguments)))},error:function(){n.error=Function.prototype.bind.call(console.error,console,m.name+":"),n.error.apply(console,arguments)},performance:{log:function(e){var t,i,o;m.performance&&(t=(new Date).getTime(),o=s||t,i=t-o,s=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:w,"Execution Time":i})),clearTimeout(n.performance.timer),n.performance.timer=setTimeout(n.performance.display,500)},display:function(){var t=m.name+":",o=0;s=!1,clearTimeout(n.performance.timer),e.each(c,function(e,t){o+=t["Execution Time"]}),t+=" "+o+"ms",r&&(t+=" '"+r+"'"),(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,a,r){var s,c,l,u=k;return a=a||d,r=w||r,"string"==typeof t&&u!==i&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(o,a){var r=o!=s?a+t[o+1].charAt(0).toUpperCase()+t[o+1].slice(1):t;if(e.isPlainObject(u[r])&&o!=s)u=u[r];else{if(u[r]!==i)return c=u[r],!1;if(!e.isPlainObject(u[a])||o==s)return u[a]!==i?(c=u[a],!1):(n.error(f.method,t),!1);u=u[a]}})),e.isFunction(c)?l=c.apply(r,a):c!==i&&(l=c),e.isArray(o)?o.push(l):o!==i?o=[o,l]:l!==i&&(o=l),c}},u?(k===i&&n.initialize(),n.invoke(l)):(k!==i&&k.invoke("destroy"),n.initialize())}),o!==i?o:this},e.fn.state.settings={name:"State",debug:!1,verbose:!1,namespace:"state",performance:!0,onActivate:function(){},onDeactivate:function(){},onChange:function(){},activateTest:function(){return!0},deactivateTest:function(){return!0},automatic:!0,sync:!1,flashDuration:1e3,filter:{text:".loading, .disabled",active:".disabled"},context:!1,error:{beforeSend:"The before send function has cancelled state change",method:"The method you called is not defined."},metadata:{promise:"promise",storedText:"stored-text"},className:{active:"active",disabled:"disabled",error:"error",loading:"loading",success:"success",warning:"warning"},selector:{text:!1},defaults:{input:{disabled:!0,loading:!0,active:!0},button:{disabled:!0,loading:!0,active:!0},progress:{active:!0,success:!0,warning:!0,error:!0}},states:{active:!0,disabled:!0,error:!0,loading:!0,success:!0,warning:!0},text:{disabled:!1,flash:!1,hover:!1,active:!1,inactive:!1,activate:!1,deactivate:!1}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.visibility=function(o){var a,r=e(this),s=r.selector||"",c=(new Date).getTime(),l=[],u=arguments[0],d="string"==typeof u,m=[].slice.call(arguments,1);return r.each(function(){var r,f,g,p=e.isPlainObject(o)?e.extend(!0,{},e.fn.visibility.settings,o):e.extend({},e.fn.visibility.settings),v=p.className,h=p.namespace,b=p.error,y=p.metadata,x="."+h,C="module-"+h,w=e(t),k=e(this),S=e(p.context),T=(k.selector||"",k.data(C)),A=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)},R=this,E=!1;g={initialize:function(){g.debug("Initializing",p),g.setup.cache(),g.should.trackChanges()&&("image"==p.type&&g.setup.image(),"fixed"==p.type&&g.setup.fixed(),p.observeChanges&&g.observeChanges(),g.bind.events()),g.save.position(),g.is.visible()||g.error(b.visible,k),p.initialCheck&&g.checkVisibility(),g.instantiate()},instantiate:function(){g.debug("Storing instance",g),k.data(C,g),T=g},destroy:function(){g.verbose("Destroying previous module"),f&&f.disconnect(),w.off("load"+x,g.event.load).off("resize"+x,g.event.resize),S.off("scrollchange"+x,g.event.scrollchange),k.off(x).removeData(C)},observeChanges:function(){"MutationObserver"in t&&(f=new MutationObserver(function(e){g.verbose("DOM tree modified, updating visibility calculations"),g.timer=setTimeout(function(){g.verbose("DOM tree modified, updating sticky menu"),g.refresh()},100)}),f.observe(R,{childList:!0,subtree:!0}),g.debug("Setting up mutation observer",f))},bind:{events:function(){g.verbose("Binding visibility events to scroll and resize"),p.refreshOnLoad&&w.on("load"+x,g.event.load),w.on("resize"+x,g.event.resize),S.off("scroll"+x).on("scroll"+x,g.event.scroll).on("scrollchange"+x,g.event.scrollchange)}},event:{resize:function(){g.debug("Window resized"),p.refreshOnResize&&A(g.refresh)},load:function(){g.debug("Page finished loading"),A(g.refresh)},scroll:function(){p.throttle?(clearTimeout(g.timer),g.timer=setTimeout(function(){S.triggerHandler("scrollchange"+x,[S.scrollTop()])},p.throttle)):A(function(){S.triggerHandler("scrollchange"+x,[S.scrollTop()])})},scrollchange:function(e,t){g.checkVisibility(t)}},precache:function(t,i){t instanceof Array||(t=[t]);for(var o=t.length,a=0,r=[],s=n.createElement("img"),c=function(){a++,a>=t.length&&e.isFunction(i)&&i()};o--;)s=n.createElement("img"),s.onload=c,s.onerror=c,s.src=t[o],r.push(s)},enableCallbacks:function(){g.debug("Allowing callbacks to occur"),E=!1},disableCallbacks:function(){g.debug("Disabling all callbacks temporarily"),E=!0},should:{trackChanges:function(){return d?(g.debug("One time query, no need to bind events"),!1):(g.debug("Callbacks being attached"),!0)}},setup:{cache:function(){g.cache={occurred:{},screen:{},element:{}}},image:function(){var e=k.data(y.src);e&&(g.verbose("Lazy loading image",e),p.once=!0,p.observeChanges=!1,p.onOnScreen=function(){g.debug("Image on screen",R),g.precache(e,function(){g.set.image(e)})})},fixed:function(){g.debug("Setting up fixed"),p.once=!1,p.observeChanges=!1,p.initialCheck=!0,p.refreshOnLoad=!0,o.transition||(p.transition=!1),g.create.placeholder(),g.debug("Added placeholder",r),p.onTopPassed=function(){g.debug("Element passed, adding fixed position",k),g.show.placeholder(),g.set.fixed(),p.transition&&e.fn.transition!==i&&k.transition(p.transition,p.duration)},p.onTopPassedReverse=function(){g.debug("Element returned to position, removing fixed",k),g.hide.placeholder(),g.remove.fixed()}}},create:{placeholder:function(){g.verbose("Creating fixed position placeholder"),r=k.clone(!1).css("display","none").addClass(v.placeholder).insertAfter(k)}},show:{placeholder:function(){g.verbose("Showing placeholder"),r.css("display","block").css("visibility","hidden")}},hide:{placeholder:function(){g.verbose("Hiding placeholder"),r.css("display","none").css("visibility","")}},set:{fixed:function(){g.verbose("Setting element to fixed position"),k.addClass(v.fixed).css({position:"fixed",top:p.offset+"px",left:"auto",zIndex:"1"})},image:function(t){k.attr("src",t),p.transition?e.fn.transition!==i?k.transition(p.transition,p.duration):k.fadeIn(p.duration):k.show()}},is:{onScreen:function(){var e=g.get.elementCalculations();return e.onScreen},offScreen:function(){var e=g.get.elementCalculations();return e.offScreen},visible:function(){return g.cache&&g.cache.element?!(0===g.cache.element.width&&0===g.cache.element.offset.top):!1}},refresh:function(){g.debug("Refreshing constants (width/height)"),"fixed"==p.type&&(g.remove.fixed(),g.remove.occurred()),g.reset(),g.save.position(),p.checkOnRefresh&&g.checkVisibility(),p.onRefresh.call(R)},reset:function(){g.verbose("Reseting all cached values"),e.isPlainObject(g.cache)&&(g.cache.screen={},g.cache.element={})},checkVisibility:function(e){g.verbose("Checking visibility of element",g.cache.element),!E&&g.is.visible()&&(g.save.scroll(e),g.save.calculations(),g.passed(),g.passingReverse(),g.topVisibleReverse(),g.bottomVisibleReverse(),g.topPassedReverse(),g.bottomPassedReverse(),g.onScreen(),g.offScreen(),g.passing(),g.topVisible(),g.bottomVisible(),g.topPassed(),g.bottomPassed(),p.onUpdate&&p.onUpdate.call(R,g.get.elementCalculations()))},passed:function(t,n){var o=g.get.elementCalculations();if(t&&n)p.onPassed[t]=n;else{if(t!==i)return g.get.pixelsPassed(t)>o.pixelsPassed;o.passing&&e.each(p.onPassed,function(e,t){o.bottomVisible||o.pixelsPassed>g.get.pixelsPassed(e)?g.execute(t,e):p.once||g.remove.occurred(t)})}},onScreen:function(e){var t=g.get.elementCalculations(),n=e||p.onOnScreen,o="onScreen";return e&&(g.debug("Adding callback for onScreen",e),p.onOnScreen=e),t.onScreen?g.execute(n,o):p.once||g.remove.occurred(o),e!==i?t.onOnScreen:void 0},offScreen:function(e){var t=g.get.elementCalculations(),n=e||p.onOffScreen,o="offScreen";return e&&(g.debug("Adding callback for offScreen",e),p.onOffScreen=e),t.offScreen?g.execute(n,o):p.once||g.remove.occurred(o),e!==i?t.onOffScreen:void 0},passing:function(e){var t=g.get.elementCalculations(),n=e||p.onPassing,o="passing";return e&&(g.debug("Adding callback for passing",e),p.onPassing=e),t.passing?g.execute(n,o):p.once||g.remove.occurred(o),e!==i?t.passing:void 0},topVisible:function(e){var t=g.get.elementCalculations(),n=e||p.onTopVisible,o="topVisible";return e&&(g.debug("Adding callback for top visible",e),p.onTopVisible=e),t.topVisible?g.execute(n,o):p.once||g.remove.occurred(o),e===i?t.topVisible:void 0},bottomVisible:function(e){var t=g.get.elementCalculations(),n=e||p.onBottomVisible,o="bottomVisible";return e&&(g.debug("Adding callback for bottom visible",e),p.onBottomVisible=e),t.bottomVisible?g.execute(n,o):p.once||g.remove.occurred(o),e===i?t.bottomVisible:void 0},topPassed:function(e){var t=g.get.elementCalculations(),n=e||p.onTopPassed,o="topPassed";return e&&(g.debug("Adding callback for top passed",e),p.onTopPassed=e),t.topPassed?g.execute(n,o):p.once||g.remove.occurred(o),e===i?t.topPassed:void 0},bottomPassed:function(e){var t=g.get.elementCalculations(),n=e||p.onBottomPassed,o="bottomPassed";return e&&(g.debug("Adding callback for bottom passed",e),p.onBottomPassed=e),t.bottomPassed?g.execute(n,o):p.once||g.remove.occurred(o),e===i?t.bottomPassed:void 0},passingReverse:function(e){var t=g.get.elementCalculations(),n=e||p.onPassingReverse,o="passingReverse";return e&&(g.debug("Adding callback for passing reverse",e),p.onPassingReverse=e),t.passing?p.once||g.remove.occurred(o):g.get.occurred("passing")&&g.execute(n,o),e!==i?!t.passing:void 0},topVisibleReverse:function(e){var t=g.get.elementCalculations(),n=e||p.onTopVisibleReverse,o="topVisibleReverse";return e&&(g.debug("Adding callback for top visible reverse",e),p.onTopVisibleReverse=e),t.topVisible?p.once||g.remove.occurred(o):g.get.occurred("topVisible")&&g.execute(n,o),e===i?!t.topVisible:void 0},bottomVisibleReverse:function(e){var t=g.get.elementCalculations(),n=e||p.onBottomVisibleReverse,o="bottomVisibleReverse";return e&&(g.debug("Adding callback for bottom visible reverse",e),p.onBottomVisibleReverse=e),t.bottomVisible?p.once||g.remove.occurred(o):g.get.occurred("bottomVisible")&&g.execute(n,o),e===i?!t.bottomVisible:void 0},topPassedReverse:function(e){var t=g.get.elementCalculations(),n=e||p.onTopPassedReverse,o="topPassedReverse";return e&&(g.debug("Adding callback for top passed reverse",e),p.onTopPassedReverse=e),t.topPassed?p.once||g.remove.occurred(o):g.get.occurred("topPassed")&&g.execute(n,o),e===i?!t.onTopPassed:void 0},bottomPassedReverse:function(e){var t=g.get.elementCalculations(),n=e||p.onBottomPassedReverse,o="bottomPassedReverse";return e&&(g.debug("Adding callback for bottom passed reverse",e),p.onBottomPassedReverse=e),t.bottomPassed?p.once||g.remove.occurred(o):g.get.occurred("bottomPassed")&&g.execute(n,o),e===i?!t.bottomPassed:void 0},execute:function(e,t){var n=g.get.elementCalculations(),i=g.get.screenCalculations();e=e||!1,e&&(p.continuous?(g.debug("Callback being called continuously",t,n),e.call(R,n,i)):g.get.occurred(t)||(g.debug("Conditions met",t,n),e.call(R,n,i))),g.save.occurred(t)},remove:{fixed:function(){g.debug("Removing fixed position"),k.removeClass(v.fixed).css({position:"",top:"",left:"",zIndex:""})},occurred:function(e){if(e){var t=g.cache.occurred;t[e]!==i&&t[e]===!0&&(g.debug("Callback can now be called again",e),g.cache.occurred[e]=!1)}else g.cache.occurred={}}},save:{calculations:function(){g.verbose("Saving all calculations necessary to determine positioning"),g.save.direction(),g.save.screenCalculations(),g.save.elementCalculations()},occurred:function(e){e&&(g.cache.occurred[e]===i||g.cache.occurred[e]!==!0)&&(g.verbose("Saving callback occurred",e),g.cache.occurred[e]=!0)},scroll:function(e){e=e+p.offset||S.scrollTop()+p.offset,g.cache.scroll=e},direction:function(){var e,t=g.get.scroll(),n=g.get.lastScroll();return e=t>n&&n?"down":n>t&&n?"up":"static",g.cache.direction=e,
+g.cache.direction},elementPosition:function(){var e=g.cache.element,t=g.get.screenSize();return g.verbose("Saving element position"),e.fits=e.height<t.height,e.offset=k.offset(),e.width=k.outerWidth(),e.height=k.outerHeight(),g.cache.element=e,e},elementCalculations:function(){var e=g.get.screenCalculations(),t=g.get.elementPosition();return p.includeMargin?(t.margin={},t.margin.top=parseInt(k.css("margin-top"),10),t.margin.bottom=parseInt(k.css("margin-bottom"),10),t.top=t.offset.top-t.margin.top,t.bottom=t.offset.top+t.height+t.margin.bottom):(t.top=t.offset.top,t.bottom=t.offset.top+t.height),t.topVisible=e.bottom>=t.top,t.topPassed=e.top>=t.top,t.bottomVisible=e.bottom>=t.bottom,t.bottomPassed=e.top>=t.bottom,t.pixelsPassed=0,t.percentagePassed=0,t.onScreen=t.topVisible&&!t.bottomPassed,t.passing=t.topPassed&&!t.bottomPassed,t.offScreen=!t.onScreen,t.passing&&(t.pixelsPassed=e.top-t.top,t.percentagePassed=(e.top-t.top)/t.height),g.cache.element=t,g.verbose("Updated element calculations",t),t},screenCalculations:function(){var e=g.get.scroll();return g.save.direction(),g.cache.screen.top=e,g.cache.screen.bottom=e+g.cache.screen.height,g.cache.screen},screenSize:function(){g.verbose("Saving window position"),g.cache.screen={height:S.height()}},position:function(){g.save.screenSize(),g.save.elementPosition()}},get:{pixelsPassed:function(e){var t=g.get.elementCalculations();return e.search("%")>-1?t.height*(parseInt(e,10)/100):parseInt(e,10)},occurred:function(e){return g.cache.occurred!==i?g.cache.occurred[e]||!1:!1},direction:function(){return g.cache.direction===i&&g.save.direction(),g.cache.direction},elementPosition:function(){return g.cache.element===i&&g.save.elementPosition(),g.cache.element},elementCalculations:function(){return g.cache.element===i&&g.save.elementCalculations(),g.cache.element},screenCalculations:function(){return g.cache.screen===i&&g.save.screenCalculations(),g.cache.screen},screenSize:function(){return g.cache.screen===i&&g.save.screenSize(),g.cache.screen},scroll:function(){return g.cache.scroll===i&&g.save.scroll(),g.cache.scroll},lastScroll:function(){return g.cache.screen===i?(g.debug("First scroll event, no last scroll could be found"),!1):g.cache.screen.top}},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,p,t);else{if(n===i)return p[t];p[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,g,t);else{if(n===i)return g[t];g[t]=n}},debug:function(){p.debug&&(p.performance?g.performance.log(arguments):(g.debug=Function.prototype.bind.call(console.info,console,p.name+":"),g.debug.apply(console,arguments)))},verbose:function(){p.verbose&&p.debug&&(p.performance?g.performance.log(arguments):(g.verbose=Function.prototype.bind.call(console.info,console,p.name+":"),g.verbose.apply(console,arguments)))},error:function(){g.error=Function.prototype.bind.call(console.error,console,p.name+":"),g.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;p.performance&&(t=(new Date).getTime(),i=c||t,n=t-i,c=t,l.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:R,"Execution Time":n})),clearTimeout(g.performance.timer),g.performance.timer=setTimeout(g.performance.display,500)},display:function(){var t=p.name+":",n=0;c=!1,clearTimeout(g.performance.timer),e.each(l,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",s&&(t+=" '"+s+"'"),(console.group!==i||console.table!==i)&&l.length>0&&(console.groupCollapsed(t),console.table?console.table(l):e.each(l,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),l=[]}},invoke:function(t,n,o){var r,s,c,l=T;return n=n||m,o=R||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):(g.error(b.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(a)?a.push(c):a!==i?a=[a,c]:c!==i&&(a=c),s}},d?(T===i&&g.initialize(),T.save.scroll(),T.save.calculations(),g.invoke(u)):(T!==i&&T.invoke("destroy"),g.initialize())}),a!==i?a:this},e.fn.visibility.settings={name:"Visibility",namespace:"visibility",debug:!1,verbose:!1,performance:!0,observeChanges:!0,initialCheck:!0,refreshOnLoad:!0,refreshOnResize:!0,checkOnRefresh:!0,once:!0,continuous:!1,offset:0,includeMargin:!1,context:t,throttle:!1,type:!1,transition:"fade in",duration:1e3,onPassed:{},onOnScreen:!1,onOffScreen:!1,onPassing:!1,onTopVisible:!1,onBottomVisible:!1,onTopPassed:!1,onBottomPassed:!1,onPassingReverse:!1,onTopVisibleReverse:!1,onBottomVisibleReverse:!1,onTopPassedReverse:!1,onBottomPassedReverse:!1,onUpdate:!1,onRefresh:function(){},metadata:{src:"src"},className:{fixed:"fixed",placeholder:"placeholder"},error:{method:"The method you called is not defined.",visible:"Element is hidden, you must call refresh after element becomes visible"}}}(jQuery,window,document);