diff --git a/dist/components/dropdown.js b/dist/components/dropdown.js index ecf9788b6..11c0b6c57 100644 --- a/dist/components/dropdown.js +++ b/dist/components/dropdown.js @@ -689,7 +689,6 @@ $.fn.dropdown = function(parameters) { $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); @@ -819,12 +818,12 @@ $.fn.dropdown = function(parameters) { labelCount = $label.length, hasActiveLabel = ($activeLabel.length > 0), hasMultipleActive = ($activeLabel.length > 1), - isFirstLabel = (labelIndex == 0), + 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), + caretAtStart = (isFocusedOnSearch && module.get.caretPosition() === 0), $nextLabel ; if(settings.allowAdditions && isFocusedOnSearch && (pressedKey == keys.delimiter)) { @@ -840,7 +839,7 @@ $.fn.dropdown = function(parameters) { else if(hasActiveLabel) { if(!event.shiftKey) { module.verbose('Selecting previous label'); - $label.removeClass(className.active) + $label.removeClass(className.active); } else { module.verbose('Adding previous label to selection'); @@ -866,7 +865,7 @@ $.fn.dropdown = function(parameters) { if(hasActiveLabel) { if(!event.shiftKey) { module.verbose('Selecting next label'); - $label.removeClass(className.active) + $label.removeClass(className.active); } else { module.verbose('Adding next label to selection'); @@ -1108,7 +1107,7 @@ $.fn.dropdown = function(parameters) { ? callback : function(){} ; - if($target.closest($menu).length == 0) { + if($target.closest($menu).length === 0) { module.verbose('Triggering event', callback); callback(); return true; @@ -1213,7 +1212,7 @@ $.fn.dropdown = function(parameters) { var value = module.get.value() ; - if(value == '') { + if(value === '') { return ''; } return (!$input.is('select') && module.is.multiple()) @@ -1444,10 +1443,10 @@ $.fn.dropdown = function(parameters) { : '', hasSearchValue = (typeof searchValue === 'string' && searchValue.length > 0), searchWidth = (searchValue.length * settings.glyphWidth) + 'em', - valueIsSet = $input.val() != '' + valueIsSet = $input.val() !== '' ; if(isMultiple && hasSearchValue) { - module.verbose('Adjusting input width', searchWidth, settings.glyphWidth) + module.verbose('Adjusting input width', searchWidth, settings.glyphWidth); $search.css('width', searchWidth); } if(hasSearchValue || (isSearchMultiple && valueIsSet)) { @@ -1649,7 +1648,7 @@ $.fn.dropdown = function(parameters) { } else { module.set.value(selectedValue, selectedText, $selected); - module.set.text(module.add.variables(message.count)) + module.set.text(module.add.variables(message.count)); $selected.addClass(className.active); } } @@ -1685,7 +1684,7 @@ $.fn.dropdown = function(parameters) { if(settings.label.variation) { $label.addClass(settings.label.variation); } - if(shouldAnimate == true) { + if(shouldAnimate === true) { module.debug('Animating in label', $label); $label .addClass(className.hidden) @@ -1792,7 +1791,7 @@ $.fn.dropdown = function(parameters) { module.remove.label(selectedValue); } else { - module.set.text(module.add.variables(message.count)) + module.set.text(module.add.variables(message.count)); } } $selectedItem @@ -1843,7 +1842,7 @@ $.fn.dropdown = function(parameters) { }, labels: function($activeLabels) { $activeLabels = $activeLabels || $module.find(selector.label).filter('.' + className.active); - module.verbose('Removing active labels', $activeLabels); + module.verbose('Removing active label selections', $activeLabels); $activeLabels .each(function(){ module.remove.selected($(this).data('value')); @@ -1946,7 +1945,7 @@ $.fn.dropdown = function(parameters) { return $module.hasClass(className.search); }, searchSelection: function() { - return ( module.has.search() && $search.closest(selector.menu).length == 0 ); + return ( module.has.search() && $search.closest(selector.menu).length === 0 ); }, selection: function() { return $module.hasClass(className.selection); @@ -2364,7 +2363,7 @@ $.fn.dropdown.settings = { /* Callbacks */ onLabelSelect : function($selectedLabels){}, - onNoResults : function(searchTerm) { return true }, + onNoResults : function(searchTerm) { return true; }, onChange : function(value, text, $selected){}, onShow : function(){}, onHide : function(){}, diff --git a/dist/components/dropdown.min.js b/dist/components/dropdown.min.js index 82d67936d..5bba8a4c6 100644 --- a/dist/components/dropdown.min.js +++ b/dist/components/dropdown.min.js @@ -8,4 +8,4 @@ * http://opensource.org/licenses/MIT * */ -!function(e,t,n,i){"use strict";e.fn.dropdown=function(o){var a,s=e(this),r=e(n),l=s.selector||"",c="ontouchstart"in n.documentElement,u=(new Date).getTime(),d=[],v=arguments[0],f="string"==typeof v,m=[].slice.call(arguments,1);return s.each(function(){var h,g,p,b,w,y=e.isPlainObject(o)?e.extend(!0,{},e.fn.dropdown.settings,o):e.extend({},e.fn.dropdown.settings),x=y.className,C=y.message,S=y.metadata,T=y.namespace,k=y.regExp,A=y.selector,D=y.error,E=y.templates,L="."+T,I="module-"+T,O=e(this),q=O.find(A.text),F=O.find(A.search),R=O.find(A.input),z=O.find(A.icon),V=O.prev().find(A.text).length>0?O.prev().find(A.text):O.prev(),M=O.children(A.menu),P=M.find(A.item),j=!1,H=!1,U=this,K=O.data(I);w={initialize:function(){w.debug("Initializing dropdown",y),w.is.alreadySetup()?w.setup.reference():(w.setup.layout(),w.save.defaults(),w.set.selected(),w.create.id(),c&&w.bind.touchEvents(),w.bind.mouseEvents(),w.bind.keyboardEvents(),w.observeChanges(),w.instantiate())},instantiate:function(){w.verbose("Storing instance of dropdown",w),K=w,O.data(I,w)},destroy:function(){w.verbose("Destroying previous dropdown for",O),w.remove.tabbable(),O.off(L).removeData(I),M.off(L),r.off(h),p&&p.disconnect(),b&&b.disconnect()},observeChanges:function(){"MutationObserver"in t&&(p=new MutationObserver(function(){w.debug("").addClass(x.search).insertBefore(q)),y.allowTab&&w.set.tabbable()},select:function(){var t=w.get.selectValues();w.debug("Dropdown initialized on a select",t),O.is("select")&&(R=O),R.parent(A.dropdown).length>0?(w.debug("UI dropdown already exists. Creating dropdown menu only"),O=R.closest(A.dropdown),M=O.children(A.menu),0===M.length&&(M=e("
").addClass(x.menu).appendTo(O)),M.html(E.menu(t))):(w.debug("Creating entire dropdown from select"),O=e("
").attr("class",R.attr("class")).addClass(x.selection).addClass(x.dropdown).html(E.dropdown(t)).insertBefore(R),R.removeAttr("class").detach().prependTo(O)),R.is("[multiple]")&&w.set.multiple(),w.refresh()},reference:function(){var e,t,n=s.index(O);w.debug("Dropdown behavior was called on select, replacing with closest dropdown"),O=O.parent(A.dropdown),w.refresh(),e=s.slice(0,n),t=s.slice(n+1),s=e.add(O).add(t),f&&(K=w,w.invoke(v))}},refresh:function(){w.verbose("Refreshing selector cache"),q=O.find(A.text),F=O.find(A.search),R=O.find(A.input),z=O.find(A.icon),V=O.prev().find(A.text).length>0?O.prev().find(A.text):O.prev(),M=O.children(A.menu),P=M.find(A.item)},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.animate.show(function(){w.can.click()&&w.bind.intent(),w.set.visible(),t.call(U)}),y.onShow.call(U)}},hide:function(t){t=e.isFunction(t)?t:function(){},w.is.active()&&(w.debug("Hiding dropdown"),w.animate.hide(function(){w.remove.visible(),t.call(U)}),y.onHide.call(U))},hideOthers:function(){w.verbose("Finding other dropdowns to hide"),s.not(O).has(A.menu+":visible:not(."+x.animating+")").dropdown("hide")},hideMenu:function(){w.verbose("Hiding menu instantaneously"),w.remove.active(),w.remove.visible(),M.transition("hide")},hideSubMenus:function(){var e=M.children(A.item).find(A.menu);w.verbose("Hiding sub menus",e),e.transition("hide")},bind:{keyboardEvents:function(){w.debug("Binding keyboard events"),O.on("keydown"+L,w.event.keydown),w.has.search()&&O.on(w.get.inputEvent()+L,A.search,w.event.input),w.is.multiple()&&r.on("keydown"+h,w.event.document.keydown)},touchEvents:function(){w.debug("Touch device detected binding additional touch events"),w.is.searchSelection()||O.on("touchstart"+L,w.event.test.toggle),M.on("touchstart"+L,A.item,w.event.item.mouseenter)},mouseEvents:function(){w.verbose("Mouse detected binding mouse events"),w.is.multiple()&&O.on("click"+L,A.label,w.event.label.click).on("click"+L,A.remove,w.event.remove.click),w.is.searchSelection()?(O.on("mousedown"+L,A.menu,w.event.menu.mousedown).on("mouseup"+L,A.menu,w.event.menu.mouseup).on("click"+L,A.search,w.show).on("focus"+L,A.search,w.event.search.focus).on("blur"+L,A.search,w.event.search.blur).on("click"+L,A.text,w.event.text.focus),w.is.multiple()&&O.on("click"+L,w.event.click)):("click"==y.on?O.on("click"+L,w.event.test.toggle):"hover"==y.on?O.on("mouseenter"+L,w.delay.show).on("mouseleave"+L,w.delay.hide):O.on(y.on+L,w.toggle),O.on("mousedown"+L,w.event.mousedown).on("mouseup"+L,w.event.mouseup).on("focus"+L,w.event.focus).on("blur"+L,w.event.blur)),M.on("mouseenter"+L,A.item,w.event.item.mouseenter).on("mouseleave"+L,A.item,w.event.item.mouseleave).on("click"+L,A.item,w.event.item.click)},intent:function(){w.verbose("Binding hide intent event to document"),c&&r.on("touchstart"+h,w.event.test.touch).on("touchmove"+h,w.event.test.touch),r.on("click"+h,w.event.test.hide)}},unbind:{intent:function(){w.verbose("Removing hide intent event from document"),c&&r.off("touchstart"+h).off("touchmove"+h),r.off("click"+h)}},filter:function(t){var n=e(),i=w.escape.regExp(t),o=new RegExp("^"+i,"igm");w.verbose("Searching for matching values"),P.each(function(){var i,a,s=e(this);if("both"==y.match||"text"==y.match){if(i=String(w.get.choiceText(s,!1)),i.match(o))return n=n.add(s),!0;if(y.fullTextSearch&&w.fuzzySearch(t,i))return n=n.add(s),!0}if("both"==y.match||"value"==y.match){if(a=String(w.get.choiceValue(s,i)),a.match(o))return n=n.add(s),!0;if(y.fullTextSearch&&w.fuzzySearch(t,a))return n=n.add(s),!0}}),w.debug("Setting filter",t),w.remove.filteredItem(),P.not(n).addClass(x.filtered),w.is.multiple()&&w.filterActive(),w.select.firstUnfiltered(),w.is.allFiltered()?y.onNoResults.call(U,t)?y.allowAdditions||(w.verbose("All items filtered, showing message",t),w.add.message(C.noResults)):(w.verbose("All items filtered, hiding dropdown",t),w.hideMenu()):w.remove.message()},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 s=e.charCodeAt(o);n>a;)if(t.charCodeAt(a++)===s)continue e;return!1}return!0},filterActive:function(){y.useLabels&&P.filter("."+x.active).addClass(x.filtered)},focusSearch:function(){w.is.search()&&!w.is.focusedOnSearch()&&F[0].focus()},forceSelection:function(){var e=P.not(x.filtered).filter("."+x.selected).eq(0),t=P.not(x.filtered).filter("."+x.active).eq(0),n=e.length>0?e:t,i=n.size()>0;i?(w.debug("Forcing partial selection to selected item",n),w.event.item.click.call(n),w.remove.filteredItem()):w.hide()},event:{focus:function(){y.showOnFocus&&!j&&w.is.hidden()&&w.show()},click:function(t){var n=e(t.target);!n.is(O)&&!n.is(z)||w.is.focusedOnSearch()||F.focus()},blur:function(){var e=n.activeElement===this;j||e||(w.remove.activeLabel(),w.hide())},mousedown:function(){j=!0},mouseup:function(){j=!1},search:{focus:function(){j=!0,w.is.multiple()&&w.remove.activeLabel(),y.showOnFocus&&w.show()},blur:function(){var e=n.activeElement===this;H||e||(w.is.multiple()?w.remove.activeLabel():y.forceSelection?w.forceSelection():w.hide())}},text:{focus:function(){j=!0,F.focus()}},input:function(){(w.is.multiple()||w.is.searchSelection())&&w.set.filtered(),clearTimeout(w.timer),w.timer=setTimeout(w.search,y.delay.search)},label:{click:function(t){var n=e(this),i=O.find(A.label),o=i.filter("."+x.active),a=n.nextAll("."+x.active),s=n.prevAll("."+x.active),r=a.length>0?n.nextUntil(a).add(o).add(n):n.prevUntil(s).add(o).add(n);t.shiftKey?(o.removeClass(x.active),r.addClass(x.active)):t.ctrlKey?n.toggleClass(x.active):(o.removeClass(x.active),n.addClass(x.active)),y.onLabelSelect.apply(this,i.filter("."+x.active))}},remove:{click:function(){var t=e(this).parent();t.hasClass(x.active)?w.remove.labels():w.remove.labels(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(w.hide,y.delay.touch):"touchmove"==e.type&&clearTimeout(w.timer)}),e.stopPropagation()},hide:function(e){w.determine.eventInModule(e,w.hide)}},menu:{mousedown:function(){H=!0},mouseup:function(){H=!1}},item:{mouseenter:function(t){var n=e(this).children(A.menu),i=e(this).siblings(A.item).children(A.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)},y.delay.show),t.preventDefault())},mouseleave:function(){var t=e(this).children(A.menu);t.length>0&&(clearTimeout(w.itemTimer),w.itemTimer=setTimeout(function(){w.verbose("Hiding sub-menu",t),w.animate.hide(!1,t)},y.delay.hide))},click:function(t){var n=e(this),i=e(t?t.target:""),o=n.find(A.menu),a=w.get.choiceText(n),s=w.get.choiceValue(n,a),r=o.length>0,l=o.find(i).length>0;l||r&&!y.allowCategorySelection||w.determine.selectAction.call(this,a,s)}},document:{keydown:function(e){var t=e.which,n=w.get.shortcutKeys(),i=w.is.inObject(t,n);if(i){var o=O.find(A.label),a=o.filter("."+x.active),s=a.data("value"),r=o.index(a),l=o.length,c=a.length>0,u=a.length>1,d=0==r,v=r+1==l,f=w.is.searchSelection(),m=w.is.focusedOnSearch(),h=w.is.focused(),g=m&&0==w.get.caretPosition();y.allowAdditions&&m&&t==n.delimiter?(w.verbose("Delimiter key pressed. Tokenizing"),e.preventDefault()):t==n.leftArrow?!h&&!g||c?c&&(e.shiftKey?w.verbose("Adding previous label to selection"):(w.verbose("Selecting previous label"),o.removeClass(x.active)),d&&!u?a.addClass(x.active):a.prev(A.siblingLabel).addClass(x.active).end(),e.preventDefault()):(w.verbose("Selecting previous label"),o.last().addClass(x.active)):t==n.rightArrow?(h&&!c&&o.first().addClass(x.active),c&&(e.shiftKey?w.verbose("Adding next label to selection"):(w.verbose("Selecting next label"),o.removeClass(x.active)),v?f&&!m?w.focusSearch():u?a.next(A.siblingLabel).addClass(x.active):a.addClass(x.active):a.next(A.siblingLabel).addClass(x.active),e.preventDefault())):t==n.deleteKey||t==n.backspace?c?(w.verbose("Removing active labels"),v&&f&&!m&&w.focusSearch(),a.last().next(A.siblingLabel).addClass(x.active),w.remove.labels(a),e.preventDefault()):g&&!c&&t==n.backspace&&(w.verbose("Removing last label on input backspace"),a=o.last().addClass(x.active),s=a.data("value"),w.remove.selected(s),e.preventDefault()):a.removeClass(x.active)}}},keydown:function(e){var t=e.which,n=w.get.shortcutKeys(),i=w.is.inObject(t,n);if(i){var o,a,s=P.not("."+x.filtered).filter("."+x.selected).eq(0),r=M.children("."+x.active).eq(0),l=s.length>0?s:r,c=l.length>0?l.siblings(":not(."+x.filtered+")").andSelf():M.children(":not(."+x.filtered+")"),u=l.children(A.menu),d=l.closest(A.menu),v=d.hasClass(x.visible)||d.hasClass(x.animating)||d.parent(A.menu).length>0,f=u.length>0,m=l.length>0,h=l.not("."+x.filtered).length>0;if(w.is.visible()){if(t==n.enter&&m&&(f&&!y.allowCategorySelection?(w.verbose("Pressed enter on unselectable category, opening sub menu"),t=n.rightArrow):h&&(w.verbose("Enter key pressed, choosing selected item"),w.event.item.click.call(l,e),y.useLabels||w.remove.searchTerm(),e.stopImmediatePropagation()),e.preventDefault()),t==n.leftArrow&&(a=d[0]!==M[0],a&&(w.verbose("Left key pressed, closing sub-menu"),w.animate.hide(!1,d),l.removeClass(x.selected),d.closest(A.item).addClass(x.selected),e.preventDefault())),t==n.rightArrow&&f&&(w.verbose("Right key pressed, opening sub-menu"),w.animate.show(!1,u),l.removeClass(x.selected),u.find(A.item).eq(0).addClass(x.selected),e.preventDefault()),t==n.upArrow){if(o=m&&v?l.prevAll(A.item+":not(."+x.filtered+")").eq(0):P.eq(0),c.index(o)<0)return w.verbose("Up key pressed but reached top of current menu"),void e.preventDefault();w.verbose("Up key pressed, changing active item"),l.removeClass(x.selected),o.addClass(x.selected),w.set.scrollPosition(o),e.preventDefault()}if(t==n.downArrow){if(o=m&&v?o=l.nextAll(A.item+":not(."+x.filtered+")").eq(0):P.eq(0),0===o.length)return w.verbose("Down key pressed but reached bottom of current menu"),void e.preventDefault();w.verbose("Down key pressed, changing active item"),P.removeClass(x.selected),o.addClass(x.selected),w.set.scrollPosition(o),e.preventDefault()}t==n.escape&&(w.verbose("Escape key pressed, closing dropdown"),w.hide())}else t==n.enter&&(w.verbose("Enter key pressed, showing dropdown"),w.show(),e.preventDefault()),t==n.downArrow&&(w.verbose("Down key pressed, showing dropdown"),w.show(),e.preventDefault())}}},determine:{selectAction:function(t,n){w.verbose("Determining action",y.action),e.isFunction(w.action[y.action])?(w.verbose("Triggering preset action",y.action,t,n),w.action[y.action].call(this,t,n)):e.isFunction(y.action)?(w.verbose("Triggering user action",y.action,t,n),y.action.call(this,t,n)):w.error(D.action,y.action)},eventInModule:function(t,n){return n=e.isFunction(n)?n:function(){},0===e(t.target).closest(O).length?(w.verbose("Triggering event",n),n(),!0):(w.verbose("Event occurred in dropdown, canceling callback"),!1)},eventOnElement:function(t,n){var i=e(t.target);return n=e.isFunction(n)?n:function(){},0==i.closest(M).length?(w.verbose("Triggering event",n),n(),!0):(w.verbose("Event occurred in dropdown menu, canceling callback"),!1)}},action:{nothing:function(){},activate:function(t,n){n=n!==i?n:t,w.set.selected(n,e(this)),(!w.is.multiple()||w.is.allFiltered())&&w.hideAndClear()},select:function(){w.action.activate.call(this)},combo:function(t,n){n=n!==i?n:t,w.set.selected(n,e(this)),w.hideAndClear()},hide:function(){w.hideAndClear()}},get:{id:function(){return g},text:function(){return q.text()},query:function(){return F.val()},uniqueArray:function(t){return e.grep(t,function(n,i){return e.inArray(n,t)===i})},caretPosition:function(){var e,t,i=F.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},shortcutKeys:function(){return{backspace:8,delimiter:188,deleteKey:46,enter:13,escape:27,leftArrow:37,upArrow:38,rightArrow:39,downArrow:40}},value:function(){return R.length>0?R.val():O.data(S.value)},values:function(){var e=w.get.value();return""==e?"":!R.is("select")&&w.is.multiple()?"string"==typeof e?e.split(y.delimiter):"":e},choiceText:function(e,t){return t=t!==i?t:y.preserveHTML,e?(e.find(A.menu).length>0&&(w.verbose("Retreiving text of element with sub-menu"),e=e.clone(),e.find(A.menu).remove(),e.find(A.menuIcon).remove()),e.data(S.text)!==i?e.data(S.text):t?e.html().trim():e.text().trim()):void 0},choiceValue:function(e,t){return t=t||w.get.choiceText(e),e?e.data(S.value)!==i?e.data(S.value):"string"==typeof t?t.toLowerCase().trim():t:!1},inputEvent:function(){var e=F[0];return e?e.oninput!==i?"input":e.onpropertychange!==i?"propertychange":"keyup":!1},selectValues:function(){var t={};return t.values=y.sortSelect?{}:[],O.find("option").each(function(){var n=e(this).html(),o=e(this).attr("value")!==i?e(this).attr("value"):n;"auto"===y.placeholder&&""===o?t.placeholder=n:y.sortSelect?t.values[o]={name:n,value:o}:t.values.push({name:n,value:o})}),y.placeholder&&"auto"!==y.placeholder&&(w.debug("Setting placeholder value to",y.placeholder),t.placeholder=y.placeholder),y.sortSelect?w.debug("Retrieved and sorted values from select",t):w.debug("Retreived values from select",t),t},activeItem:function(){return P.filter("."+x.active)},item:function(t,n){var o,a=!1;return t=t!==i?t:w.get.values()!==i?w.get.values():w.get.text(),o=w.is.multiple()&&e.isArray(t),n=""===t||0===t?!0:n||!1,t!==i&&P.each(function(){var i=e(this),s=w.get.choiceText(i),r=w.get.choiceValue(i,s);if(o)(-1!==e.inArray(r.toString(),t)||-1!==e.inArray(s,t))&&(a=a?a.add(i):i);else if(n){if(w.verbose("Ambiguous dropdown value using strict type check",i,t),r===t||s===t)return a=i,!0}else if(r==t||s==t)return w.verbose("Found select item by value",r,t),a=i,!0}),a}},restore:{defaults:function(){w.restore.defaultText(),w.restore.defaultValue()},defaultText:function(){var e=O.data(S.defaultText);w.debug("Restoring default text",e),w.set.text(e),q.addClass(x.placeholder)},defaultValue:function(){var e=O.data(S.defaultValue);e!==i&&(w.debug("Restoring default value",e),e.length?w.set.selected(e):(w.remove.activeItem(),w.remove.selectedItem()))}},save:{defaults:function(){w.save.defaultText(),w.save.placeholderText(),w.save.defaultValue()},defaultValue:function(){O.data(S.defaultValue,w.get.value())},defaultText:function(){O.data(S.defaultText,q.text())},placeholderText:function(){q.hasClass(x.placeholder)&&O.data(S.placeholderText,q.text())}},clear:function(){w.set.placeholderText(),w.clearValue(),w.remove.activeItem(),w.remove.selectedItem()},clearValue:function(){w.set.value("")},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=i.length*y.glyphWidth+"em",s=""!=R.val();e&&o&&(w.verbose("Adjusting input width",a,y.glyphWidth),F.css("width",a)),o||n&&s?(w.verbose("Hiding placeholder text"),q.addClass(x.filtered)):(!e||n&&!s)&&(w.verbose("Showing placeholder text"),q.removeClass(x.filtered))},placeholderText:function(e){w.debug("Restoring placeholder text"),e=e||O.data(S.placeholderText),w.set.text(e),q.addClass(x.placeholder)},tabbable:function(){w.has.search()?(w.debug("Searchable dropdown initialized"),F.val("").attr("tabindex",0),M.attr("tabindex","-1")):(w.debug("Simple selection dropdown initialized"),O.attr("tabindex")||(O.attr("tabindex",0),M.attr("tabindex","-1")))},scrollPosition:function(e,t){var n,o,a,s,r,l,c,u,d,v,f=5;e=e||w.get.activeItem(),n=e.closest(A.menu),o=e&&e.length>0,t=t!==i?t:!1,e&&o&&(n.hasClass(x.visible)||n.addClass(x.loading),u=n.height(),s=e.height(),c=n.scrollTop(),l=n.offset().top,r=e.offset().top,a=c-l+r,v=a+f>c+u,d=c>a-f,w.debug("Scrolling to active item",a),(d||v||t)&&n.scrollTop(a).removeClass(x.loading))},text:function(e){"select"!==y.action?(w.debug("Changing text",e,q),q.removeClass(x.filtered).removeClass(x.placeholder),y.preserveHTML?q.html(e):q.text(e)):"combo"==y.action&&(w.debug("Changing combo button text",e,V),y.preserveHTML?V.html(e):V.text(e))},value:function(t,n,i){var o=(R.length>0,w.get.values());if(R.length>0){if(w.is.multiple()&&(t=[t],e.isArray(o)&&(t=o.concat(t),t=w.get.uniqueArray(t)),R.is("select")?w.debug("Setting multiple removing selected"),R.find('option[value="'+i+'"]').prop("selected",!1)):(w.verbose("Input is csv removing value"),n=w.remove.delimitedValue(i,n),R.val(n).trigger("change")),w.is.multiple()&&(y.useLabels?w.remove.label(i):w.set.text(w.add.variables(C.count))),t.removeClass(x.filtered).removeClass(x.active),y.useLabels&&t.removeClass(x.selected))},selectedItem:function(){P.removeClass(x.selected)},delimitedValue:function(t,n){return"string"!=typeof n?!1:(n=n.split(y.delimiter),n=e.grep(n,function(e){return t!=e}),n=n.join(y.delimiter),w.verbose("Removed value from delimited string",t,n),n)},label:function(e){var t=O.find(A.label),n=t.filter('[data-value="'+e+'"]'),i=t.length,o=t.index(n)+1==i,a=1==i,s=a||o;s?(w.verbose("Animating and removing label",n),n.transition(y.label.transition,y.label.duration,function(){n.remove()})):(w.verbose("Removing label",n),n.remove())},labels:function(t){t=t||O.find(A.label).filter("."+x.active),w.verbose("Removing active labels",t),t.each(function(){w.remove.selected(e(this).data("value"))})},tabbable:function(){w.has.search()?(w.debug("Searchable dropdown initialized"),F.attr("tabindex","-1"),M.attr("tabindex","-1")):(w.debug("Simple selection dropdown initialized"),O.attr("tabindex","-1"),M.attr("tabindex","-1"))}},has:{search:function(){return F.length>0},input:function(){return R.length>0},menu:function(){return M.length>0}},is:{active:function(){return O.hasClass(x.active)},alreadySetup:function(){return O.is("select")&&O.parent(A.dropdown).length>0},animating:function(e){return e?e.transition&&e.transition("is animating"):M.transition&&M.transition("is animating")},focused:function(){return n.activeElement===O[0]},focusedOnSearch:function(){return n.activeElement===F[0]},allFiltered:function(){return(w.is.multiple()||w.has.search())&&P.filter("."+x.filtered).length===P.length},hidden:function(e){return e?e.is(":hidden"):M.is(":hidden")},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 O.hasClass(x.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 O.hasClass(x.search)},searchSelection:function(){return w.has.search()&&0==F.closest(A.menu).length},selection:function(){return O.hasClass(x.selection)},upward:function(){return O.hasClass(x.upward)},visible:function(e){return e?e.is(":visible"):M.is(":visible")}},can:{click:function(){return c||"click"==y.on},show:function(){return!O.hasClass(x.disabled)}},animate:{show:function(t,n){var o=n||M,a=n?function(){}:function(){w.hideSubMenus(),w.hideOthers(),w.set.active()};t=e.isFunction(t)?t:function(){},w.is.single()&&w.set.scrollPosition(w.get.activeItem(),!0),w.verbose("Doing menu show animation",o),(w.is.hidden(o)||w.is.animating(o))&&("auto"==y.transition&&(y.transition=w.is.upward()?"slide up":"slide down",w.verbose("Automatically determining animation based on animation direction",y.transition)),"none"==y.transition?(a(),o.transition("show"),t.call(U)):e.fn.transition!==i&&O.transition("is supported")?o.transition({animation:y.transition+" in",debug:y.debug,verbose:y.verbose,duration:y.duration,queue:!0,onStart:a,onComplete:function(){t.call(U)}}):w.error(D.noTransition,y.transition))},hide:function(t,n){var o=n||M,a=(n?.9*y.duration:y.duration,n?function(){}:function(){w.can.click()&&w.unbind.intent(),w.focusSearch(),w.remove.active()});t=e.isFunction(t)?t:function(){},(w.is.visible(o)||w.is.animating(o))&&(w.verbose("Doing menu hide animation",o),"auto"==y.transition&&(y.transition=w.is.upward()?"slide up":"slide down"),"none"==y.transition?(a(),o.transition("hide"),t.call(U)):e.fn.transition!==i&&O.transition("is supported")?o.transition({animation:y.transition+" out",duration:y.duration,debug:y.debug,verbose:y.verbose,queue:!0,onStart:a,onComplete:function(){t.call(U)}}):w.error(D.transition))}},hideAndClear:function(){w.is.searchSelection()?(w.remove.searchTerm(),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,y.delay.show)},hide:function(){w.verbose("Delaying hide event to ensure user intent"),clearTimeout(w.timer),w.timer=setTimeout(w.hide,y.delay.hide)}},escape:{regExp:function(e){return e=String(e),e.replace(k.escape,"\\$&")}},setting:function(t,n){if(w.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,y,t);else{if(n===i)return y[t];y[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(){y.debug&&(y.performance?w.performance.log(arguments):(w.debug=Function.prototype.bind.call(console.info,console,y.name+":"),w.debug.apply(console,arguments)))},verbose:function(){y.verbose&&y.debug&&(y.performance?w.performance.log(arguments):(w.verbose=Function.prototype.bind.call(console.info,console,y.name+":"),w.verbose.apply(console,arguments)))},error:function(){w.error=Function.prototype.bind.call(console.error,console,y.name+":"),w.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;y.performance&&(t=(new Date).getTime(),i=u||t,n=t-i,u=t,d.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:U,"Execution Time":n})),clearTimeout(w.performance.timer),w.performance.timer=setTimeout(w.performance.display,500)},display:function(){var t=y.name+":",n=0;u=!1,clearTimeout(w.performance.timer),e.each(d,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",l&&(t+=" '"+l+"'"),(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 s,r,l,c=K;return n=n||m,o=U||o,"string"==typeof t&&c!==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(c[a])&&n!=s)c=c[a];else{if(c[a]!==i)return r=c[a],!1;if(!e.isPlainObject(c[o])||n==s)return c[o]!==i?(r=c[o],!1):(w.error(D.method,t),!1);c=c[o]}})),e.isFunction(r)?l=r.apply(o,n):r!==i&&(l=r),e.isArray(a)?a.push(l):a!==i?a=[a,l]:l!==i&&(a=l),r}},f?(K===i&&w.initialize(),w.invoke(v)):(K!==i&&K.invoke("destroy"),w.initialize())}),a!==i?a:s},e.fn.dropdown.settings={debug:!1,verbose:!1,performance:!0,on:"click",action:"activate",allowTab:!0,showOnFocus:!0,fullTextSearch:!1,placeholder:"auto",preserveHTML:!0,sortSelect:!1,match:"both",allowCategorySelection:!1,forceSelection:!0,transition:"auto",duration:250,delay:{hide:300,show:200,search:50,touch:50},glyphWidth:1.0714,allowAdditions:!1,tokenize:"missing",delimiter:",",label:{transition:"horizontal flip",duration:150,variation:!1},useLabels:!0,onLabelSelect:function(){},onNoResults:function(){return!0},onChange:function(){},onShow:function(){},onHide:function(){},name:"Dropdown",namespace:"dropdown",message:{addResult:"Add {term}",count:"{count} selected",noResults:"No results found."},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",method:"The method you called is not defined.",noTransition:"This module requires ui transitions "},regExp:{escape:/[-[\]{}()*+?.,\\^$|#\s]/g},metadata:{defaultText:"defaultText",defaultValue:"defaultValue",placeholderText:"placeholderText",text:"text",value:"value"},selector:{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)"},className:{active:"active",animating:"animating",disabled:"disabled",dropdown:"ui dropdown",filtered:"filtered",hidden:"hidden transition",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={message:function(e){return'
'+e+"
"},menu:function(t){var n=(t.placeholder||!1,t.values||{},"");return e.each(t.values,function(e,t){n+='
'+t.name+"
"}),n},label:function(e,t){return t+''},dropdown:function(t){var n=t.placeholder||!1,i=(t.values||{},"");return i+='',i+=t.placeholder?'
'+n+"
":'
',i+='"}},e.extend(e.easing,{easeOutQuad:function(e,t,n,i,o){return-i*(t/=o)*(t-2)+n}})}(jQuery,window,document); \ No newline at end of file +!function(e,t,n,i){"use strict";e.fn.dropdown=function(o){var a,s=e(this),r=e(n),l=s.selector||"",c="ontouchstart"in n.documentElement,u=(new Date).getTime(),d=[],v=arguments[0],f="string"==typeof v,m=[].slice.call(arguments,1);return s.each(function(){var h,g,p,b,w,y=e.isPlainObject(o)?e.extend(!0,{},e.fn.dropdown.settings,o):e.extend({},e.fn.dropdown.settings),x=y.className,C=y.message,S=y.metadata,T=y.namespace,k=y.regExp,A=y.selector,D=y.error,E=y.templates,L="."+T,I="module-"+T,O=e(this),q=O.find(A.text),F=O.find(A.search),R=O.find(A.input),z=O.find(A.icon),V=O.prev().find(A.text).length>0?O.prev().find(A.text):O.prev(),M=O.children(A.menu),P=M.find(A.item),j=!1,H=!1,U=this,K=O.data(I);w={initialize:function(){w.debug("Initializing dropdown",y),w.is.alreadySetup()?w.setup.reference():(w.setup.layout(),w.save.defaults(),w.set.selected(),w.create.id(),c&&w.bind.touchEvents(),w.bind.mouseEvents(),w.bind.keyboardEvents(),w.observeChanges(),w.instantiate())},instantiate:function(){w.verbose("Storing instance of dropdown",w),K=w,O.data(I,w)},destroy:function(){w.verbose("Destroying previous dropdown for",O),w.remove.tabbable(),O.off(L).removeData(I),M.off(L),r.off(h),p&&p.disconnect(),b&&b.disconnect()},observeChanges:function(){"MutationObserver"in t&&(p=new MutationObserver(function(){w.debug("").addClass(x.search).insertBefore(q)),y.allowTab&&w.set.tabbable()},select:function(){var t=w.get.selectValues();w.debug("Dropdown initialized on a select",t),O.is("select")&&(R=O),R.parent(A.dropdown).length>0?(w.debug("UI dropdown already exists. Creating dropdown menu only"),O=R.closest(A.dropdown),M=O.children(A.menu),0===M.length&&(M=e("
").addClass(x.menu).appendTo(O)),M.html(E.menu(t))):(w.debug("Creating entire dropdown from select"),O=e("
").attr("class",R.attr("class")).addClass(x.selection).addClass(x.dropdown).html(E.dropdown(t)).insertBefore(R),R.removeAttr("class").detach().prependTo(O)),R.is("[multiple]")&&w.set.multiple(),w.refresh()},reference:function(){var e,t,n=s.index(O);w.debug("Dropdown behavior was called on select, replacing with closest dropdown"),O=O.parent(A.dropdown),w.refresh(),e=s.slice(0,n),t=s.slice(n+1),s=e.add(O).add(t),f&&(K=w,w.invoke(v))}},refresh:function(){w.verbose("Refreshing selector cache"),q=O.find(A.text),F=O.find(A.search),R=O.find(A.input),z=O.find(A.icon),V=O.prev().find(A.text).length>0?O.prev().find(A.text):O.prev(),M=O.children(A.menu),P=M.find(A.item)},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.animate.show(function(){w.can.click()&&w.bind.intent(),w.set.visible(),t.call(U)}),y.onShow.call(U)}},hide:function(t){t=e.isFunction(t)?t:function(){},w.is.active()&&(w.debug("Hiding dropdown"),w.animate.hide(function(){w.remove.visible(),t.call(U)}),y.onHide.call(U))},hideOthers:function(){w.verbose("Finding other dropdowns to hide"),s.not(O).has(A.menu+":visible:not(."+x.animating+")").dropdown("hide")},hideMenu:function(){w.verbose("Hiding menu instantaneously"),w.remove.active(),w.remove.visible(),M.transition("hide")},hideSubMenus:function(){var e=M.children(A.item).find(A.menu);w.verbose("Hiding sub menus",e),e.transition("hide")},bind:{keyboardEvents:function(){w.debug("Binding keyboard events"),O.on("keydown"+L,w.event.keydown),w.has.search()&&O.on(w.get.inputEvent()+L,A.search,w.event.input),w.is.multiple()&&r.on("keydown"+h,w.event.document.keydown)},touchEvents:function(){w.debug("Touch device detected binding additional touch events"),w.is.searchSelection()||O.on("touchstart"+L,w.event.test.toggle),M.on("touchstart"+L,A.item,w.event.item.mouseenter)},mouseEvents:function(){w.verbose("Mouse detected binding mouse events"),w.is.multiple()&&O.on("click"+L,A.label,w.event.label.click).on("click"+L,A.remove,w.event.remove.click),w.is.searchSelection()?(O.on("mousedown"+L,A.menu,w.event.menu.mousedown).on("mouseup"+L,A.menu,w.event.menu.mouseup).on("click"+L,A.search,w.show).on("focus"+L,A.search,w.event.search.focus).on("blur"+L,A.search,w.event.search.blur).on("click"+L,A.text,w.event.text.focus),w.is.multiple()&&O.on("click"+L,w.event.click)):("click"==y.on?O.on("click"+L,w.event.test.toggle):"hover"==y.on?O.on("mouseenter"+L,w.delay.show).on("mouseleave"+L,w.delay.hide):O.on(y.on+L,w.toggle),O.on("mousedown"+L,w.event.mousedown).on("mouseup"+L,w.event.mouseup).on("focus"+L,w.event.focus).on("blur"+L,w.event.blur)),M.on("mouseenter"+L,A.item,w.event.item.mouseenter).on("mouseleave"+L,A.item,w.event.item.mouseleave).on("click"+L,A.item,w.event.item.click)},intent:function(){w.verbose("Binding hide intent event to document"),c&&r.on("touchstart"+h,w.event.test.touch).on("touchmove"+h,w.event.test.touch),r.on("click"+h,w.event.test.hide)}},unbind:{intent:function(){w.verbose("Removing hide intent event from document"),c&&r.off("touchstart"+h).off("touchmove"+h),r.off("click"+h)}},filter:function(t){var n=e(),i=w.escape.regExp(t),o=new RegExp("^"+i,"igm");w.verbose("Searching for matching values"),P.each(function(){var i,a,s=e(this);if("both"==y.match||"text"==y.match){if(i=String(w.get.choiceText(s,!1)),i.match(o))return n=n.add(s),!0;if(y.fullTextSearch&&w.fuzzySearch(t,i))return n=n.add(s),!0}if("both"==y.match||"value"==y.match){if(a=String(w.get.choiceValue(s,i)),a.match(o))return n=n.add(s),!0;if(y.fullTextSearch&&w.fuzzySearch(t,a))return n=n.add(s),!0}}),w.debug("Setting filter",t),w.remove.filteredItem(),P.not(n).addClass(x.filtered),w.is.multiple()&&w.filterActive(),w.select.firstUnfiltered(),w.is.allFiltered()?y.onNoResults.call(U,t)?y.allowAdditions||(w.verbose("All items filtered, showing message",t),w.add.message(C.noResults)):(w.verbose("All items filtered, hiding dropdown",t),w.hideMenu()):w.remove.message()},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 s=e.charCodeAt(o);n>a;)if(t.charCodeAt(a++)===s)continue e;return!1}return!0},filterActive:function(){y.useLabels&&P.filter("."+x.active).addClass(x.filtered)},focusSearch:function(){w.is.search()&&!w.is.focusedOnSearch()&&F[0].focus()},forceSelection:function(){var e=P.not(x.filtered).filter("."+x.selected).eq(0),t=P.not(x.filtered).filter("."+x.active).eq(0),n=e.length>0?e:t,i=n.size()>0;i?(w.debug("Forcing partial selection to selected item",n),w.event.item.click.call(n),w.remove.filteredItem()):w.hide()},event:{focus:function(){y.showOnFocus&&!j&&w.is.hidden()&&w.show()},click:function(t){var n=e(t.target);!n.is(O)&&!n.is(z)||w.is.focusedOnSearch()||F.focus()},blur:function(){var e=n.activeElement===this;j||e||(w.remove.activeLabel(),w.hide())},mousedown:function(){j=!0},mouseup:function(){j=!1},search:{focus:function(){j=!0,w.is.multiple()&&w.remove.activeLabel(),y.showOnFocus&&w.show()},blur:function(){var e=n.activeElement===this;H||e||(w.is.multiple()?w.remove.activeLabel():y.forceSelection?w.forceSelection():w.hide())}},text:{focus:function(){j=!0,F.focus()}},input:function(){(w.is.multiple()||w.is.searchSelection())&&w.set.filtered(),clearTimeout(w.timer),w.timer=setTimeout(w.search,y.delay.search)},label:{click:function(t){var n=e(this),i=O.find(A.label),o=i.filter("."+x.active),a=n.nextAll("."+x.active),s=n.prevAll("."+x.active),r=a.length>0?n.nextUntil(a).add(o).add(n):n.prevUntil(s).add(o).add(n);t.shiftKey?(o.removeClass(x.active),r.addClass(x.active)):t.ctrlKey?n.toggleClass(x.active):(o.removeClass(x.active),n.addClass(x.active)),y.onLabelSelect.apply(this,i.filter("."+x.active))}},remove:{click:function(){var t=e(this).parent();t.hasClass(x.active)?w.remove.labels():w.remove.labels(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(w.hide,y.delay.touch):"touchmove"==e.type&&clearTimeout(w.timer)}),e.stopPropagation()},hide:function(e){w.determine.eventInModule(e,w.hide)}},menu:{mousedown:function(){H=!0},mouseup:function(){H=!1}},item:{mouseenter:function(t){var n=e(this).children(A.menu),i=e(this).siblings(A.item).children(A.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)},y.delay.show),t.preventDefault())},mouseleave:function(){var t=e(this).children(A.menu);t.length>0&&(clearTimeout(w.itemTimer),w.itemTimer=setTimeout(function(){w.verbose("Hiding sub-menu",t),w.animate.hide(!1,t)},y.delay.hide))},click:function(t){var n=e(this),i=e(t?t.target:""),o=n.find(A.menu),a=w.get.choiceText(n),s=w.get.choiceValue(n,a),r=o.length>0,l=o.find(i).length>0;l||r&&!y.allowCategorySelection||w.determine.selectAction.call(this,a,s)}},document:{keydown:function(e){var t=e.which,n=w.get.shortcutKeys(),i=w.is.inObject(t,n);if(i){var o=O.find(A.label),a=o.filter("."+x.active),s=a.data("value"),r=o.index(a),l=o.length,c=a.length>0,u=a.length>1,d=0===r,v=r+1==l,f=w.is.searchSelection(),m=w.is.focusedOnSearch(),h=w.is.focused(),g=m&&0===w.get.caretPosition();y.allowAdditions&&m&&t==n.delimiter?(w.verbose("Delimiter key pressed. Tokenizing"),e.preventDefault()):t==n.leftArrow?!h&&!g||c?c&&(e.shiftKey?w.verbose("Adding previous label to selection"):(w.verbose("Selecting previous label"),o.removeClass(x.active)),d&&!u?a.addClass(x.active):a.prev(A.siblingLabel).addClass(x.active).end(),e.preventDefault()):(w.verbose("Selecting previous label"),o.last().addClass(x.active)):t==n.rightArrow?(h&&!c&&o.first().addClass(x.active),c&&(e.shiftKey?w.verbose("Adding next label to selection"):(w.verbose("Selecting next label"),o.removeClass(x.active)),v?f&&!m?w.focusSearch():u?a.next(A.siblingLabel).addClass(x.active):a.addClass(x.active):a.next(A.siblingLabel).addClass(x.active),e.preventDefault())):t==n.deleteKey||t==n.backspace?c?(w.verbose("Removing active labels"),v&&f&&!m&&w.focusSearch(),a.last().next(A.siblingLabel).addClass(x.active),w.remove.labels(a),e.preventDefault()):g&&!c&&t==n.backspace&&(w.verbose("Removing last label on input backspace"),a=o.last().addClass(x.active),s=a.data("value"),w.remove.selected(s),e.preventDefault()):a.removeClass(x.active)}}},keydown:function(e){var t=e.which,n=w.get.shortcutKeys(),i=w.is.inObject(t,n);if(i){var o,a,s=P.not("."+x.filtered).filter("."+x.selected).eq(0),r=M.children("."+x.active).eq(0),l=s.length>0?s:r,c=l.length>0?l.siblings(":not(."+x.filtered+")").andSelf():M.children(":not(."+x.filtered+")"),u=l.children(A.menu),d=l.closest(A.menu),v=d.hasClass(x.visible)||d.hasClass(x.animating)||d.parent(A.menu).length>0,f=u.length>0,m=l.length>0,h=l.not("."+x.filtered).length>0;if(w.is.visible()){if(t==n.enter&&m&&(f&&!y.allowCategorySelection?(w.verbose("Pressed enter on unselectable category, opening sub menu"),t=n.rightArrow):h&&(w.verbose("Enter key pressed, choosing selected item"),w.event.item.click.call(l,e),y.useLabels||w.remove.searchTerm(),e.stopImmediatePropagation()),e.preventDefault()),t==n.leftArrow&&(a=d[0]!==M[0],a&&(w.verbose("Left key pressed, closing sub-menu"),w.animate.hide(!1,d),l.removeClass(x.selected),d.closest(A.item).addClass(x.selected),e.preventDefault())),t==n.rightArrow&&f&&(w.verbose("Right key pressed, opening sub-menu"),w.animate.show(!1,u),l.removeClass(x.selected),u.find(A.item).eq(0).addClass(x.selected),e.preventDefault()),t==n.upArrow){if(o=m&&v?l.prevAll(A.item+":not(."+x.filtered+")").eq(0):P.eq(0),c.index(o)<0)return w.verbose("Up key pressed but reached top of current menu"),void e.preventDefault();w.verbose("Up key pressed, changing active item"),l.removeClass(x.selected),o.addClass(x.selected),w.set.scrollPosition(o),e.preventDefault()}if(t==n.downArrow){if(o=m&&v?o=l.nextAll(A.item+":not(."+x.filtered+")").eq(0):P.eq(0),0===o.length)return w.verbose("Down key pressed but reached bottom of current menu"),void e.preventDefault();w.verbose("Down key pressed, changing active item"),P.removeClass(x.selected),o.addClass(x.selected),w.set.scrollPosition(o),e.preventDefault()}t==n.escape&&(w.verbose("Escape key pressed, closing dropdown"),w.hide())}else t==n.enter&&(w.verbose("Enter key pressed, showing dropdown"),w.show(),e.preventDefault()),t==n.downArrow&&(w.verbose("Down key pressed, showing dropdown"),w.show(),e.preventDefault())}}},determine:{selectAction:function(t,n){w.verbose("Determining action",y.action),e.isFunction(w.action[y.action])?(w.verbose("Triggering preset action",y.action,t,n),w.action[y.action].call(this,t,n)):e.isFunction(y.action)?(w.verbose("Triggering user action",y.action,t,n),y.action.call(this,t,n)):w.error(D.action,y.action)},eventInModule:function(t,n){return n=e.isFunction(n)?n:function(){},0===e(t.target).closest(O).length?(w.verbose("Triggering event",n),n(),!0):(w.verbose("Event occurred in dropdown, canceling callback"),!1)},eventOnElement:function(t,n){var i=e(t.target);return n=e.isFunction(n)?n:function(){},0===i.closest(M).length?(w.verbose("Triggering event",n),n(),!0):(w.verbose("Event occurred in dropdown menu, canceling callback"),!1)}},action:{nothing:function(){},activate:function(t,n){n=n!==i?n:t,w.set.selected(n,e(this)),(!w.is.multiple()||w.is.allFiltered())&&w.hideAndClear()},select:function(){w.action.activate.call(this)},combo:function(t,n){n=n!==i?n:t,w.set.selected(n,e(this)),w.hideAndClear()},hide:function(){w.hideAndClear()}},get:{id:function(){return g},text:function(){return q.text()},query:function(){return F.val()},uniqueArray:function(t){return e.grep(t,function(n,i){return e.inArray(n,t)===i})},caretPosition:function(){var e,t,i=F.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},shortcutKeys:function(){return{backspace:8,delimiter:188,deleteKey:46,enter:13,escape:27,leftArrow:37,upArrow:38,rightArrow:39,downArrow:40}},value:function(){return R.length>0?R.val():O.data(S.value)},values:function(){var e=w.get.value();return""===e?"":!R.is("select")&&w.is.multiple()?"string"==typeof e?e.split(y.delimiter):"":e},choiceText:function(e,t){return t=t!==i?t:y.preserveHTML,e?(e.find(A.menu).length>0&&(w.verbose("Retreiving text of element with sub-menu"),e=e.clone(),e.find(A.menu).remove(),e.find(A.menuIcon).remove()),e.data(S.text)!==i?e.data(S.text):t?e.html().trim():e.text().trim()):void 0},choiceValue:function(e,t){return t=t||w.get.choiceText(e),e?e.data(S.value)!==i?e.data(S.value):"string"==typeof t?t.toLowerCase().trim():t:!1},inputEvent:function(){var e=F[0];return e?e.oninput!==i?"input":e.onpropertychange!==i?"propertychange":"keyup":!1},selectValues:function(){var t={};return t.values=y.sortSelect?{}:[],O.find("option").each(function(){var n=e(this).html(),o=e(this).attr("value")!==i?e(this).attr("value"):n;"auto"===y.placeholder&&""===o?t.placeholder=n:y.sortSelect?t.values[o]={name:n,value:o}:t.values.push({name:n,value:o})}),y.placeholder&&"auto"!==y.placeholder&&(w.debug("Setting placeholder value to",y.placeholder),t.placeholder=y.placeholder),y.sortSelect?w.debug("Retrieved and sorted values from select",t):w.debug("Retreived values from select",t),t},activeItem:function(){return P.filter("."+x.active)},item:function(t,n){var o,a=!1;return t=t!==i?t:w.get.values()!==i?w.get.values():w.get.text(),o=w.is.multiple()&&e.isArray(t),n=""===t||0===t?!0:n||!1,t!==i&&P.each(function(){var i=e(this),s=w.get.choiceText(i),r=w.get.choiceValue(i,s);if(o)(-1!==e.inArray(r.toString(),t)||-1!==e.inArray(s,t))&&(a=a?a.add(i):i);else if(n){if(w.verbose("Ambiguous dropdown value using strict type check",i,t),r===t||s===t)return a=i,!0}else if(r==t||s==t)return w.verbose("Found select item by value",r,t),a=i,!0}),a}},restore:{defaults:function(){w.restore.defaultText(),w.restore.defaultValue()},defaultText:function(){var e=O.data(S.defaultText);w.debug("Restoring default text",e),w.set.text(e),q.addClass(x.placeholder)},defaultValue:function(){var e=O.data(S.defaultValue);e!==i&&(w.debug("Restoring default value",e),e.length?w.set.selected(e):(w.remove.activeItem(),w.remove.selectedItem()))}},save:{defaults:function(){w.save.defaultText(),w.save.placeholderText(),w.save.defaultValue()},defaultValue:function(){O.data(S.defaultValue,w.get.value())},defaultText:function(){O.data(S.defaultText,q.text())},placeholderText:function(){q.hasClass(x.placeholder)&&O.data(S.placeholderText,q.text())}},clear:function(){w.set.placeholderText(),w.clearValue(),w.remove.activeItem(),w.remove.selectedItem()},clearValue:function(){w.set.value("")},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=i.length*y.glyphWidth+"em",s=""!==R.val();e&&o&&(w.verbose("Adjusting input width",a,y.glyphWidth),F.css("width",a)),o||n&&s?(w.verbose("Hiding placeholder text"),q.addClass(x.filtered)):(!e||n&&!s)&&(w.verbose("Showing placeholder text"),q.removeClass(x.filtered))},placeholderText:function(e){w.debug("Restoring placeholder text"),e=e||O.data(S.placeholderText),w.set.text(e),q.addClass(x.placeholder)},tabbable:function(){w.has.search()?(w.debug("Searchable dropdown initialized"),F.val("").attr("tabindex",0),M.attr("tabindex","-1")):(w.debug("Simple selection dropdown initialized"),O.attr("tabindex")||(O.attr("tabindex",0),M.attr("tabindex","-1")))},scrollPosition:function(e,t){var n,o,a,s,r,l,c,u,d,v,f=5;e=e||w.get.activeItem(),n=e.closest(A.menu),o=e&&e.length>0,t=t!==i?t:!1,e&&o&&(n.hasClass(x.visible)||n.addClass(x.loading),u=n.height(),s=e.height(),c=n.scrollTop(),l=n.offset().top,r=e.offset().top,a=c-l+r,v=a+f>c+u,d=c>a-f,w.debug("Scrolling to active item",a),(d||v||t)&&n.scrollTop(a).removeClass(x.loading))},text:function(e){"select"!==y.action?(w.debug("Changing text",e,q),q.removeClass(x.filtered).removeClass(x.placeholder),y.preserveHTML?q.html(e):q.text(e)):"combo"==y.action&&(w.debug("Changing combo button text",e,V),y.preserveHTML?V.html(e):V.text(e))},value:function(t,n,i){var o=(R.length>0,w.get.values());if(R.length>0){if(w.is.multiple()&&(t=[t],e.isArray(o)&&(t=o.concat(t),t=w.get.uniqueArray(t)),R.is("select")?w.debug("Setting multiple removing selected"),R.find('option[value="'+i+'"]').prop("selected",!1)):(w.verbose("Input is csv removing value"),n=w.remove.delimitedValue(i,n),R.val(n).trigger("change")),w.is.multiple()&&(y.useLabels?w.remove.label(i):w.set.text(w.add.variables(C.count))),t.removeClass(x.filtered).removeClass(x.active),y.useLabels&&t.removeClass(x.selected))},selectedItem:function(){P.removeClass(x.selected)},delimitedValue:function(t,n){return"string"!=typeof n?!1:(n=n.split(y.delimiter),n=e.grep(n,function(e){return t!=e}),n=n.join(y.delimiter),w.verbose("Removed value from delimited string",t,n),n)},label:function(e){var t=O.find(A.label),n=t.filter('[data-value="'+e+'"]'),i=t.length,o=t.index(n)+1==i,a=1==i,s=a||o;s?(w.verbose("Animating and removing label",n),n.transition(y.label.transition,y.label.duration,function(){n.remove()})):(w.verbose("Removing label",n),n.remove())},labels:function(t){t=t||O.find(A.label).filter("."+x.active),w.verbose("Removing active label selections",t),t.each(function(){w.remove.selected(e(this).data("value"))})},tabbable:function(){w.has.search()?(w.debug("Searchable dropdown initialized"),F.attr("tabindex","-1"),M.attr("tabindex","-1")):(w.debug("Simple selection dropdown initialized"),O.attr("tabindex","-1"),M.attr("tabindex","-1"))}},has:{search:function(){return F.length>0},input:function(){return R.length>0},menu:function(){return M.length>0}},is:{active:function(){return O.hasClass(x.active)},alreadySetup:function(){return O.is("select")&&O.parent(A.dropdown).length>0},animating:function(e){return e?e.transition&&e.transition("is animating"):M.transition&&M.transition("is animating")},focused:function(){return n.activeElement===O[0]},focusedOnSearch:function(){return n.activeElement===F[0]},allFiltered:function(){return(w.is.multiple()||w.has.search())&&P.filter("."+x.filtered).length===P.length},hidden:function(e){return e?e.is(":hidden"):M.is(":hidden")},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 O.hasClass(x.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 O.hasClass(x.search)},searchSelection:function(){return w.has.search()&&0===F.closest(A.menu).length},selection:function(){return O.hasClass(x.selection)},upward:function(){return O.hasClass(x.upward)},visible:function(e){return e?e.is(":visible"):M.is(":visible")}},can:{click:function(){return c||"click"==y.on},show:function(){return!O.hasClass(x.disabled)}},animate:{show:function(t,n){var o=n||M,a=n?function(){}:function(){w.hideSubMenus(),w.hideOthers(),w.set.active()};t=e.isFunction(t)?t:function(){},w.is.single()&&w.set.scrollPosition(w.get.activeItem(),!0),w.verbose("Doing menu show animation",o),(w.is.hidden(o)||w.is.animating(o))&&("auto"==y.transition&&(y.transition=w.is.upward()?"slide up":"slide down",w.verbose("Automatically determining animation based on animation direction",y.transition)),"none"==y.transition?(a(),o.transition("show"),t.call(U)):e.fn.transition!==i&&O.transition("is supported")?o.transition({animation:y.transition+" in",debug:y.debug,verbose:y.verbose,duration:y.duration,queue:!0,onStart:a,onComplete:function(){t.call(U)}}):w.error(D.noTransition,y.transition))},hide:function(t,n){var o=n||M,a=(n?.9*y.duration:y.duration,n?function(){}:function(){w.can.click()&&w.unbind.intent(),w.focusSearch(),w.remove.active()});t=e.isFunction(t)?t:function(){},(w.is.visible(o)||w.is.animating(o))&&(w.verbose("Doing menu hide animation",o),"auto"==y.transition&&(y.transition=w.is.upward()?"slide up":"slide down"),"none"==y.transition?(a(),o.transition("hide"),t.call(U)):e.fn.transition!==i&&O.transition("is supported")?o.transition({animation:y.transition+" out",duration:y.duration,debug:y.debug,verbose:y.verbose,queue:!0,onStart:a,onComplete:function(){t.call(U)}}):w.error(D.transition))}},hideAndClear:function(){w.is.searchSelection()?(w.remove.searchTerm(),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,y.delay.show)},hide:function(){w.verbose("Delaying hide event to ensure user intent"),clearTimeout(w.timer),w.timer=setTimeout(w.hide,y.delay.hide)}},escape:{regExp:function(e){return e=String(e),e.replace(k.escape,"\\$&")}},setting:function(t,n){if(w.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,y,t);else{if(n===i)return y[t];y[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(){y.debug&&(y.performance?w.performance.log(arguments):(w.debug=Function.prototype.bind.call(console.info,console,y.name+":"),w.debug.apply(console,arguments)))},verbose:function(){y.verbose&&y.debug&&(y.performance?w.performance.log(arguments):(w.verbose=Function.prototype.bind.call(console.info,console,y.name+":"),w.verbose.apply(console,arguments)))},error:function(){w.error=Function.prototype.bind.call(console.error,console,y.name+":"),w.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;y.performance&&(t=(new Date).getTime(),i=u||t,n=t-i,u=t,d.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:U,"Execution Time":n})),clearTimeout(w.performance.timer),w.performance.timer=setTimeout(w.performance.display,500)},display:function(){var t=y.name+":",n=0;u=!1,clearTimeout(w.performance.timer),e.each(d,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",l&&(t+=" '"+l+"'"),(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 s,r,l,c=K;return n=n||m,o=U||o,"string"==typeof t&&c!==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(c[a])&&n!=s)c=c[a];else{if(c[a]!==i)return r=c[a],!1;if(!e.isPlainObject(c[o])||n==s)return c[o]!==i?(r=c[o],!1):(w.error(D.method,t),!1);c=c[o]}})),e.isFunction(r)?l=r.apply(o,n):r!==i&&(l=r),e.isArray(a)?a.push(l):a!==i?a=[a,l]:l!==i&&(a=l),r}},f?(K===i&&w.initialize(),w.invoke(v)):(K!==i&&K.invoke("destroy"),w.initialize())}),a!==i?a:s},e.fn.dropdown.settings={debug:!1,verbose:!1,performance:!0,on:"click",action:"activate",allowTab:!0,showOnFocus:!0,fullTextSearch:!1,placeholder:"auto",preserveHTML:!0,sortSelect:!1,match:"both",allowCategorySelection:!1,forceSelection:!0,transition:"auto",duration:250,delay:{hide:300,show:200,search:50,touch:50},glyphWidth:1.0714,allowAdditions:!1,tokenize:"missing",delimiter:",",label:{transition:"horizontal flip",duration:150,variation:!1},useLabels:!0,onLabelSelect:function(){},onNoResults:function(){return!0},onChange:function(){},onShow:function(){},onHide:function(){},name:"Dropdown",namespace:"dropdown",message:{addResult:"Add {term}",count:"{count} selected",noResults:"No results found."},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",method:"The method you called is not defined.",noTransition:"This module requires ui transitions "},regExp:{escape:/[-[\]{}()*+?.,\\^$|#\s]/g},metadata:{defaultText:"defaultText",defaultValue:"defaultValue",placeholderText:"placeholderText",text:"text",value:"value"},selector:{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)"},className:{active:"active",animating:"animating",disabled:"disabled",dropdown:"ui dropdown",filtered:"filtered",hidden:"hidden transition",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={message:function(e){return'
'+e+"
"},menu:function(t){var n=(t.placeholder||!1,t.values||{},"");return e.each(t.values,function(e,t){n+='
'+t.name+"
"}),n},label:function(e,t){return t+''},dropdown:function(t){var n=t.placeholder||!1,i=(t.values||{},"");return i+='',i+=t.placeholder?'
'+n+"
":'
',i+='"}},e.extend(e.easing,{easeOutQuad:function(e,t,n,i,o){return-i*(t/=o)*(t-2)+n}})}(jQuery,window,document); \ No newline at end of file diff --git a/dist/components/modal.js b/dist/components/modal.js index f1ac85719..240c71e9f 100644 --- a/dist/components/modal.js +++ b/dist/components/modal.js @@ -108,7 +108,7 @@ $.fn.modal = function(parameters) { ; if(settings.inverted) { dimmerSettings.variation = (dimmerSettings.variation !== undefined) - ? dimmer.settings.variation + ' inverted' + ? dimmerSettings.variation + ' inverted' : 'inverted' ; } diff --git a/dist/components/modal.min.js b/dist/components/modal.min.js index 6016bb0e3..125426f8e 100644 --- a/dist/components/modal.min.js +++ b/dist/components/modal.min.js @@ -8,4 +8,4 @@ * http://opensource.org/licenses/MIT * */ -!function(e,i,n,t){"use strict";e.fn.modal=function(o){var a,s=e(this),r=e(i),c=e(n),l=e("body"),d=s.selector||"",u=(new Date).getTime(),m=[],g=arguments[0],f="string"==typeof g,h=[].slice.call(arguments,1),v=i.requestAnimationFrame||i.mozRequestAnimationFrame||i.webkitRequestAnimationFrame||i.msRequestAnimationFrame||function(e){setTimeout(e,0)};return s.each(function(){var s,b,p,y,w,k,S,C,M,A=e.isPlainObject(o)?e.extend(!0,{},e.fn.modal.settings,o):e.extend({},e.fn.modal.settings),D=A.selector,F=A.className,H=A.namespace,T=A.error,O="."+H,x="module-"+H,z=e(this),q=e(A.context),E=z.find(D.close),j=this,N=z.data(x);M={initialize:function(){M.verbose("Initializing dimmer",q),M.create.id(),M.create.dimmer(),M.refreshModals(),M.bind.events(),M.observeChanges(),M.instantiate()},instantiate:function(){M.verbose("Storing instance of modal"),N=M,z.data(x,N)},create:{dimmer:function(){var i={debug:A.debug,dimmerName:"modals",duration:{show:A.duration,hide:A.duration}},n=e.extend(!0,i,A.dimmerSettings);return A.inverted&&(n.variation=n.variation!==t?dimmer.settings.variation+" inverted":"inverted"),e.fn.dimmer===t?void M.error(T.dimmer):(M.debug("Creating dimmer with settings",n),y=q.dimmer(n),A.detachable?(M.verbose("Modal is detachable, moving content into dimmer"),y.dimmer("add content",z)):M.set.undetached(),A.blurring&&y.addClass(F.blurring),void(w=y.dimmer("get dimmer")))},id:function(){S=(Math.random().toString(16)+"000000000").substr(2,8),k="."+S,M.verbose("Creating unique id for element",S)}},destroy:function(){M.verbose("Destroying previous modal"),z.removeData(x).off(O),r.off(k),E.off(O),q.dimmer("destroy")},observeChanges:function(){"MutationObserver"in i&&(C=new MutationObserver(function(){M.debug("DOM tree modified, refreshing"),M.refresh()}),C.observe(j,{childList:!0,subtree:!0}),M.debug("Setting up mutation observer",C))},refresh:function(){M.remove.scrolling(),M.cacheSizes(),M.set.screenHeight(),M.set.type(),M.set.position()},refreshModals:function(){b=z.siblings(D.modal),s=b.add(z)},attachEvents:function(i,n){var t=e(i);n=e.isFunction(M[n])?M[n]:M.toggle,t.length>0?(M.debug("Attaching modal events to element",i,n),t.off(O).on("click"+O,n)):M.error(T.notFound,i)},bind:{events:function(){M.verbose("Attaching events"),z.on("click"+O,D.close,M.event.close),r.on("resize"+k,M.event.resize)}},get:{id:function(){return(Math.random().toString(16)+"000000000").substr(2,8)}},event:{close:function(){M.verbose("Closing element pressed"),e(this).is(D.approve)?A.onApprove.call(j)!==!1?M.hide():M.verbose("Approve callback returned false cancelling hide"):e(this).is(D.deny)?A.onDeny.call(j)!==!1?M.hide():M.verbose("Deny callback returned false cancelling hide"):M.hide()},click:function(i){var t=e(i.target),o=t.closest(D.modal).length>0,a=e.contains(n.documentElement,i.target);!o&&a&&(M.debug("Dimmer clicked, hiding all modals"),M.is.active()&&(M.remove.clickaway(),A.allowMultiple?M.hide():M.hideAll()))},debounce:function(e,i){clearTimeout(M.timer),M.timer=setTimeout(e,i)},keyboard:function(e){var i=e.which,n=27;i==n&&(A.closable?(M.debug("Escape key pressed hiding modal"),M.hide()):M.debug("Escape key pressed, but closable is set to false"),e.preventDefault())},resize:function(){y.dimmer("is active")&&v(M.refresh)}},toggle:function(){M.is.active()||M.is.animating()?M.hide():M.show()},show:function(i){i=e.isFunction(i)?i:function(){},M.refreshModals(),M.showModal(i)},hide:function(i){i=e.isFunction(i)?i:function(){},M.refreshModals(),M.hideModal(i)},showModal:function(i){i=e.isFunction(i)?i:function(){},M.is.animating()||!M.is.active()?(M.showDimmer(),M.cacheSizes(),M.set.position(),M.set.screenHeight(),M.set.type(),M.set.clickaway(),!A.allowMultiple&&b.filter("."+F.active).length>0?(M.debug("Other modals visible, queueing show animation"),M.hideOthers(M.showModal)):(A.onShow.call(j),A.transition&&e.fn.transition!==t&&z.transition("is supported")?(M.debug("Showing modal with css animations"),z.transition({debug:A.debug,animation:A.transition+" in",queue:A.queue,duration:A.duration,useFailSafe:!0,onComplete:function(){A.onVisible.apply(j),M.add.keyboardShortcuts(),M.save.focus(),M.set.active(),M.set.autofocus(),i()}})):(M.debug("Showing modal with javascript"),z.fadeIn(A.duration,A.easing,function(){A.onVisible.apply(j),M.add.keyboardShortcuts(),M.save.focus(),M.set.active(),i()})))):M.debug("Modal is already visible")},hideModal:function(i,n){i=e.isFunction(i)?i:function(){},M.debug("Hiding modal"),A.onHide.call(j),(M.is.animating()||M.is.active())&&(A.transition&&e.fn.transition!==t&&z.transition("is supported")?(M.remove.active(),z.transition({debug:A.debug,animation:A.transition+" out",queue:A.queue,duration:A.duration,useFailSafe:!0,onStart:function(){M.othersActive()||n||M.hideDimmer(),M.remove.keyboardShortcuts()},onComplete:function(){A.onHidden.call(j),M.restore.focus(),i()}})):(M.remove.active(),M.othersActive()||M.hideDimmer(),M.remove.keyboardShortcuts(),z.fadeOut(A.duration,A.easing,function(){A.onHidden.call(j),M.restore.focus(),i()})))},showDimmer:function(){y.dimmer("is animating")||!y.dimmer("is active")?(M.debug("Showing dimmer"),y.dimmer("show")):M.debug("Dimmer already visible")},hideDimmer:function(){return y.dimmer("is animating")||y.dimmer("is active")?void y.dimmer("hide",function(){A.transition&&e.fn.transition!==t&&z.transition("is supported")&&(M.remove.clickaway(),M.remove.screenHeight())}):void M.debug("Dimmer is not visible cannot hide")},hideAll:function(i){var n=s.filter(":visible");i=e.isFunction(i)?i:function(){},n.length>0&&(M.debug("Hiding all visible modals"),M.hideDimmer(),n.modal("hide modal",i))},hideOthers:function(i){var n=b.filter(":visible");i=e.isFunction(i)?i:function(){},n.length>0&&(M.debug("Hiding other modals",b),n.modal("hide modal",i,!0))},othersActive:function(){return b.filter("."+F.active+", ."+F.animating).length>0},add:{keyboardShortcuts:function(){M.verbose("Adding keyboard shortcuts"),c.on("keyup"+O,M.event.keyboard)}},save:{focus:function(){p=e(n.activeElement).blur()}},restore:{focus:function(){p&&p.length>0&&p.focus()}},remove:{active:function(){z.removeClass(F.active)},clickaway:function(){A.closable&&w.off("click"+k)},screenHeight:function(){M.cache.height>M.cache.pageHeight&&(M.debug("Removing page height"),l.css("height",""))},keyboardShortcuts:function(){M.verbose("Removing keyboard shortcuts"),c.off("keyup"+O)},scrolling:function(){y.removeClass(F.scrolling),z.removeClass(F.scrolling)}},cacheSizes:function(){var o=z.outerHeight();(M.cache===t||0!==o)&&(M.cache={pageHeight:e(n).outerHeight(),height:o+A.offset,contextHeight:"body"==A.context?e(i).height():y.height()}),M.debug("Caching modal and container sizes",M.cache)},can:{fit:function(){return M.cache.height+2*A.padding0?i:e;n.first().focus()}},clickaway:function(){A.closable&&w.on("click"+k,M.event.click)},screenHeight:function(){M.can.fit()?l.css("height",""):(M.debug("Modal is taller than page content, resizing page height"),l.css("height",M.cache.height+2*A.padding))},active:function(){z.addClass(F.active)},scrolling:function(){y.addClass(F.scrolling),z.addClass(F.scrolling)},type:function(){M.can.fit()?(M.verbose("Modal fits on screen"),M.othersActive()||M.remove.scrolling()):(M.verbose("Modal cannot fit on screen setting to scrolling"),M.set.scrolling())},position:function(){M.verbose("Centering modal on page",M.cache),z.css(M.can.fit()?{top:"",marginTop:-(M.cache.height/2)}:{marginTop:"",top:c.scrollTop()})},undetached:function(){y.addClass(F.undetached)}},setting:function(i,n){if(M.debug("Changing setting",i,n),e.isPlainObject(i))e.extend(!0,A,i);else{if(n===t)return A[i];A[i]=n}},internal:function(i,n){if(e.isPlainObject(i))e.extend(!0,M,i);else{if(n===t)return M[i];M[i]=n}},debug:function(){A.debug&&(A.performance?M.performance.log(arguments):(M.debug=Function.prototype.bind.call(console.info,console,A.name+":"),M.debug.apply(console,arguments)))},verbose:function(){A.verbose&&A.debug&&(A.performance?M.performance.log(arguments):(M.verbose=Function.prototype.bind.call(console.info,console,A.name+":"),M.verbose.apply(console,arguments)))},error:function(){M.error=Function.prototype.bind.call(console.error,console,A.name+":"),M.error.apply(console,arguments)},performance:{log:function(e){var i,n,t;A.performance&&(i=(new Date).getTime(),t=u||i,n=i-t,u=i,m.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:j,"Execution Time":n})),clearTimeout(M.performance.timer),M.performance.timer=setTimeout(M.performance.display,500)},display:function(){var i=A.name+":",n=0;u=!1,clearTimeout(M.performance.timer),e.each(m,function(e,i){n+=i["Execution Time"]}),i+=" "+n+"ms",d&&(i+=" '"+d+"'"),(console.group!==t||console.table!==t)&&m.length>0&&(console.groupCollapsed(i),console.table?console.table(m):e.each(m,function(e,i){console.log(i.Name+": "+i["Execution Time"]+"ms")}),console.groupEnd()),m=[]}},invoke:function(i,n,o){var s,r,c,l=N;return n=n||h,o=j||o,"string"==typeof i&&l!==t&&(i=i.split(/[\. ]/),s=i.length-1,e.each(i,function(n,o){var a=n!=s?o+i[n+1].charAt(0).toUpperCase()+i[n+1].slice(1):i;if(e.isPlainObject(l[a])&&n!=s)l=l[a];else{if(l[a]!==t)return r=l[a],!1;if(!e.isPlainObject(l[o])||n==s)return l[o]!==t?(r=l[o],!1):!1;l=l[o]}})),e.isFunction(r)?c=r.apply(o,n):r!==t&&(c=r),e.isArray(a)?a.push(c):a!==t?a=[a,c]:c!==t&&(a=c),r}},f?(N===t&&M.initialize(),M.invoke(g)):(N!==t&&N.invoke("destroy"),M.initialize())}),a!==t?a:this},e.fn.modal.settings={name:"Modal",namespace:"modal",debug:!1,verbose:!1,performance:!0,allowMultiple:!1,detachable:!0,closable:!0,autofocus:!0,inverted:!1,blurring:!1,dimmerSettings:{closable:!1,useCSS:!0},context:"body",queue:!1,duration:500,easing:"easeOutExpo",offset:0,transition:"scale",padding:50,onShow:function(){},onVisible:function(){},onHide: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",animating:"animating",blurring:"blurring",scrolling:"scrolling",undetached:"undetached"}}}(jQuery,window,document); \ No newline at end of file +!function(e,i,n,t){"use strict";e.fn.modal=function(o){var a,s=e(this),r=e(i),c=e(n),l=e("body"),u=s.selector||"",d=(new Date).getTime(),m=[],g=arguments[0],f="string"==typeof g,h=[].slice.call(arguments,1),v=i.requestAnimationFrame||i.mozRequestAnimationFrame||i.webkitRequestAnimationFrame||i.msRequestAnimationFrame||function(e){setTimeout(e,0)};return s.each(function(){var s,b,p,y,w,k,S,C,M,A=e.isPlainObject(o)?e.extend(!0,{},e.fn.modal.settings,o):e.extend({},e.fn.modal.settings),D=A.selector,F=A.className,H=A.namespace,T=A.error,O="."+H,x="module-"+H,z=e(this),q=e(A.context),E=z.find(D.close),j=this,N=z.data(x);M={initialize:function(){M.verbose("Initializing dimmer",q),M.create.id(),M.create.dimmer(),M.refreshModals(),M.bind.events(),M.observeChanges(),M.instantiate()},instantiate:function(){M.verbose("Storing instance of modal"),N=M,z.data(x,N)},create:{dimmer:function(){var i={debug:A.debug,dimmerName:"modals",duration:{show:A.duration,hide:A.duration}},n=e.extend(!0,i,A.dimmerSettings);return A.inverted&&(n.variation=n.variation!==t?n.variation+" inverted":"inverted"),e.fn.dimmer===t?void M.error(T.dimmer):(M.debug("Creating dimmer with settings",n),y=q.dimmer(n),A.detachable?(M.verbose("Modal is detachable, moving content into dimmer"),y.dimmer("add content",z)):M.set.undetached(),A.blurring&&y.addClass(F.blurring),void(w=y.dimmer("get dimmer")))},id:function(){S=(Math.random().toString(16)+"000000000").substr(2,8),k="."+S,M.verbose("Creating unique id for element",S)}},destroy:function(){M.verbose("Destroying previous modal"),z.removeData(x).off(O),r.off(k),E.off(O),q.dimmer("destroy")},observeChanges:function(){"MutationObserver"in i&&(C=new MutationObserver(function(){M.debug("DOM tree modified, refreshing"),M.refresh()}),C.observe(j,{childList:!0,subtree:!0}),M.debug("Setting up mutation observer",C))},refresh:function(){M.remove.scrolling(),M.cacheSizes(),M.set.screenHeight(),M.set.type(),M.set.position()},refreshModals:function(){b=z.siblings(D.modal),s=b.add(z)},attachEvents:function(i,n){var t=e(i);n=e.isFunction(M[n])?M[n]:M.toggle,t.length>0?(M.debug("Attaching modal events to element",i,n),t.off(O).on("click"+O,n)):M.error(T.notFound,i)},bind:{events:function(){M.verbose("Attaching events"),z.on("click"+O,D.close,M.event.close),r.on("resize"+k,M.event.resize)}},get:{id:function(){return(Math.random().toString(16)+"000000000").substr(2,8)}},event:{close:function(){M.verbose("Closing element pressed"),e(this).is(D.approve)?A.onApprove.call(j)!==!1?M.hide():M.verbose("Approve callback returned false cancelling hide"):e(this).is(D.deny)?A.onDeny.call(j)!==!1?M.hide():M.verbose("Deny callback returned false cancelling hide"):M.hide()},click:function(i){var t=e(i.target),o=t.closest(D.modal).length>0,a=e.contains(n.documentElement,i.target);!o&&a&&(M.debug("Dimmer clicked, hiding all modals"),M.is.active()&&(M.remove.clickaway(),A.allowMultiple?M.hide():M.hideAll()))},debounce:function(e,i){clearTimeout(M.timer),M.timer=setTimeout(e,i)},keyboard:function(e){var i=e.which,n=27;i==n&&(A.closable?(M.debug("Escape key pressed hiding modal"),M.hide()):M.debug("Escape key pressed, but closable is set to false"),e.preventDefault())},resize:function(){y.dimmer("is active")&&v(M.refresh)}},toggle:function(){M.is.active()||M.is.animating()?M.hide():M.show()},show:function(i){i=e.isFunction(i)?i:function(){},M.refreshModals(),M.showModal(i)},hide:function(i){i=e.isFunction(i)?i:function(){},M.refreshModals(),M.hideModal(i)},showModal:function(i){i=e.isFunction(i)?i:function(){},M.is.animating()||!M.is.active()?(M.showDimmer(),M.cacheSizes(),M.set.position(),M.set.screenHeight(),M.set.type(),M.set.clickaway(),!A.allowMultiple&&b.filter("."+F.active).length>0?(M.debug("Other modals visible, queueing show animation"),M.hideOthers(M.showModal)):(A.onShow.call(j),A.transition&&e.fn.transition!==t&&z.transition("is supported")?(M.debug("Showing modal with css animations"),z.transition({debug:A.debug,animation:A.transition+" in",queue:A.queue,duration:A.duration,useFailSafe:!0,onComplete:function(){A.onVisible.apply(j),M.add.keyboardShortcuts(),M.save.focus(),M.set.active(),M.set.autofocus(),i()}})):(M.debug("Showing modal with javascript"),z.fadeIn(A.duration,A.easing,function(){A.onVisible.apply(j),M.add.keyboardShortcuts(),M.save.focus(),M.set.active(),i()})))):M.debug("Modal is already visible")},hideModal:function(i,n){i=e.isFunction(i)?i:function(){},M.debug("Hiding modal"),A.onHide.call(j),(M.is.animating()||M.is.active())&&(A.transition&&e.fn.transition!==t&&z.transition("is supported")?(M.remove.active(),z.transition({debug:A.debug,animation:A.transition+" out",queue:A.queue,duration:A.duration,useFailSafe:!0,onStart:function(){M.othersActive()||n||M.hideDimmer(),M.remove.keyboardShortcuts()},onComplete:function(){A.onHidden.call(j),M.restore.focus(),i()}})):(M.remove.active(),M.othersActive()||M.hideDimmer(),M.remove.keyboardShortcuts(),z.fadeOut(A.duration,A.easing,function(){A.onHidden.call(j),M.restore.focus(),i()})))},showDimmer:function(){y.dimmer("is animating")||!y.dimmer("is active")?(M.debug("Showing dimmer"),y.dimmer("show")):M.debug("Dimmer already visible")},hideDimmer:function(){return y.dimmer("is animating")||y.dimmer("is active")?void y.dimmer("hide",function(){A.transition&&e.fn.transition!==t&&z.transition("is supported")&&(M.remove.clickaway(),M.remove.screenHeight())}):void M.debug("Dimmer is not visible cannot hide")},hideAll:function(i){var n=s.filter(":visible");i=e.isFunction(i)?i:function(){},n.length>0&&(M.debug("Hiding all visible modals"),M.hideDimmer(),n.modal("hide modal",i))},hideOthers:function(i){var n=b.filter(":visible");i=e.isFunction(i)?i:function(){},n.length>0&&(M.debug("Hiding other modals",b),n.modal("hide modal",i,!0))},othersActive:function(){return b.filter("."+F.active+", ."+F.animating).length>0},add:{keyboardShortcuts:function(){M.verbose("Adding keyboard shortcuts"),c.on("keyup"+O,M.event.keyboard)}},save:{focus:function(){p=e(n.activeElement).blur()}},restore:{focus:function(){p&&p.length>0&&p.focus()}},remove:{active:function(){z.removeClass(F.active)},clickaway:function(){A.closable&&w.off("click"+k)},screenHeight:function(){M.cache.height>M.cache.pageHeight&&(M.debug("Removing page height"),l.css("height",""))},keyboardShortcuts:function(){M.verbose("Removing keyboard shortcuts"),c.off("keyup"+O)},scrolling:function(){y.removeClass(F.scrolling),z.removeClass(F.scrolling)}},cacheSizes:function(){var o=z.outerHeight();(M.cache===t||0!==o)&&(M.cache={pageHeight:e(n).outerHeight(),height:o+A.offset,contextHeight:"body"==A.context?e(i).height():y.height()}),M.debug("Caching modal and container sizes",M.cache)},can:{fit:function(){return M.cache.height+2*A.padding0?i:e;n.first().focus()}},clickaway:function(){A.closable&&w.on("click"+k,M.event.click)},screenHeight:function(){M.can.fit()?l.css("height",""):(M.debug("Modal is taller than page content, resizing page height"),l.css("height",M.cache.height+2*A.padding))},active:function(){z.addClass(F.active)},scrolling:function(){y.addClass(F.scrolling),z.addClass(F.scrolling)},type:function(){M.can.fit()?(M.verbose("Modal fits on screen"),M.othersActive()||M.remove.scrolling()):(M.verbose("Modal cannot fit on screen setting to scrolling"),M.set.scrolling())},position:function(){M.verbose("Centering modal on page",M.cache),z.css(M.can.fit()?{top:"",marginTop:-(M.cache.height/2)}:{marginTop:"",top:c.scrollTop()})},undetached:function(){y.addClass(F.undetached)}},setting:function(i,n){if(M.debug("Changing setting",i,n),e.isPlainObject(i))e.extend(!0,A,i);else{if(n===t)return A[i];A[i]=n}},internal:function(i,n){if(e.isPlainObject(i))e.extend(!0,M,i);else{if(n===t)return M[i];M[i]=n}},debug:function(){A.debug&&(A.performance?M.performance.log(arguments):(M.debug=Function.prototype.bind.call(console.info,console,A.name+":"),M.debug.apply(console,arguments)))},verbose:function(){A.verbose&&A.debug&&(A.performance?M.performance.log(arguments):(M.verbose=Function.prototype.bind.call(console.info,console,A.name+":"),M.verbose.apply(console,arguments)))},error:function(){M.error=Function.prototype.bind.call(console.error,console,A.name+":"),M.error.apply(console,arguments)},performance:{log:function(e){var i,n,t;A.performance&&(i=(new Date).getTime(),t=d||i,n=i-t,d=i,m.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:j,"Execution Time":n})),clearTimeout(M.performance.timer),M.performance.timer=setTimeout(M.performance.display,500)},display:function(){var i=A.name+":",n=0;d=!1,clearTimeout(M.performance.timer),e.each(m,function(e,i){n+=i["Execution Time"]}),i+=" "+n+"ms",u&&(i+=" '"+u+"'"),(console.group!==t||console.table!==t)&&m.length>0&&(console.groupCollapsed(i),console.table?console.table(m):e.each(m,function(e,i){console.log(i.Name+": "+i["Execution Time"]+"ms")}),console.groupEnd()),m=[]}},invoke:function(i,n,o){var s,r,c,l=N;return n=n||h,o=j||o,"string"==typeof i&&l!==t&&(i=i.split(/[\. ]/),s=i.length-1,e.each(i,function(n,o){var a=n!=s?o+i[n+1].charAt(0).toUpperCase()+i[n+1].slice(1):i;if(e.isPlainObject(l[a])&&n!=s)l=l[a];else{if(l[a]!==t)return r=l[a],!1;if(!e.isPlainObject(l[o])||n==s)return l[o]!==t?(r=l[o],!1):!1;l=l[o]}})),e.isFunction(r)?c=r.apply(o,n):r!==t&&(c=r),e.isArray(a)?a.push(c):a!==t?a=[a,c]:c!==t&&(a=c),r}},f?(N===t&&M.initialize(),M.invoke(g)):(N!==t&&N.invoke("destroy"),M.initialize())}),a!==t?a:this},e.fn.modal.settings={name:"Modal",namespace:"modal",debug:!1,verbose:!1,performance:!0,allowMultiple:!1,detachable:!0,closable:!0,autofocus:!0,inverted:!1,blurring:!1,dimmerSettings:{closable:!1,useCSS:!0},context:"body",queue:!1,duration:500,easing:"easeOutExpo",offset:0,transition:"scale",padding:50,onShow:function(){},onVisible:function(){},onHide: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",animating:"animating",blurring:"blurring",scrolling:"scrolling",undetached:"undetached"}}}(jQuery,window,document); \ No newline at end of file diff --git a/dist/components/popup.js b/dist/components/popup.js index 0dd46606b..ac4946295 100644 --- a/dist/components/popup.js +++ b/dist/components/popup.js @@ -600,7 +600,7 @@ $.fn.popup = function(parameters) { position: function(position, arrowOffset) { // exit conditions - if($target.length == 0 || $popup.length == 0) { + if($target.length === 0 || $popup.length === 0) { module.error(error.notFound); return; } @@ -641,7 +641,7 @@ $.fn.popup = function(parameters) { position = position || $module.data(metadata.position) || settings.position; arrowOffset = arrowOffset || $module.data(metadata.offset) || settings.offset; - if(target.top == 0 && target.left == 0) { + if(target.top === 0 && target.left === 0) { module.debug('Popup target is hidden, no action taken'); return false; } diff --git a/dist/components/popup.min.js b/dist/components/popup.min.js index fcacffd89..b1ecf1dc2 100644 --- a/dist/components/popup.min.js +++ b/dist/components/popup.min.js @@ -8,4 +8,4 @@ * http://opensource.org/licenses/MIT * */ -!function(e,t,o,n){"use strict";e.fn.popup=function(i){var r,s=e(this),a=e(o),p=s.selector||"",l="ontouchstart"in o.documentElement,u=(new Date).getTime(),c=[],d=arguments[0],f="string"==typeof d,g=[].slice.call(arguments,1);return s.each(function(){var o,s,h,m,b,v=e.isPlainObject(i)?e.extend(!0,{},e.fn.popup.settings,i):e.extend({},e.fn.popup.settings),y=v.selector,w=v.className,P=v.error,T=v.metadata,C=v.namespace,x="."+v.namespace,k="module-"+C,S=e(this),O=e(v.context),E=v.target?e(v.target):S,j=e(t),A=e("body"),R=0,F=!1,D=this,H=S.data(k);b={initialize:function(){b.debug("Initializing",S),b.createID(),b.bind.events(),!b.exists()&&v.preserve&&b.create(),b.instantiate()},instantiate:function(){b.verbose("Storing instance",b),H=b,S.data(k,H)},refresh:function(){v.popup?o=e(v.popup).eq(0):v.inline&&(o=E.next(y.popup).eq(0),v.popup=o),v.popup?(o.addClass(w.loading),s=b.get.offsetParent(),o.removeClass(w.loading),v.movePopup&&b.has.popup()&&b.get.offsetParent(o)[0]!==s[0]&&(b.debug("Moving popup to the same offset parent as activating element"),o.detach().appendTo(s))):s=v.inline?b.get.offsetParent(E):b.has.popup()?b.get.offsetParent(o):A,s.is("html")&&(b.debug("Setting page as offset parent"),s=A)},reposition:function(){b.refresh(),b.set.position()},destroy:function(){b.debug("Destroying previous module"),o&&!v.preserve&&b.removePopup(),clearTimeout(b.hideTimer),clearTimeout(b.showTimer),j.off(h),S.off(x).removeData(k)},event:{start:function(){var t=e.isPlainObject(v.delay)?v.delay.show:v.delay;clearTimeout(b.hideTimer),b.showTimer=setTimeout(function(){!b.is.hidden()||b.is.active()&&b.is.dropdown()||b.show()},t)},end:function(){var t=e.isPlainObject(v.delay)?v.delay.hide:v.delay;clearTimeout(b.showTimer),b.hideTimer=setTimeout(function(){b.is.visible()&&b.hide()},t)},resize:function(){b.is.visible()&&b.set.position()}},create:function(){var t=S.data(T.html)||v.html,n=S.data(T.variation)||v.variation,i=S.data(T.title)||v.title,r=S.data(T.content)||S.attr("title")||v.content;t||r||i?(b.debug("Creating pop-up html"),t||(t=v.templates.popup({title:i,content:r})),o=e("
").addClass(w.popup).addClass(n).data(T.activator,S).html(t),n&&o.addClass(n),v.inline?(b.verbose("Inserting popup element inline",o),o.insertAfter(S)):(b.verbose("Appending popup element to body",o),o.appendTo(O)),b.refresh(),v.hoverable&&b.bind.popup(),v.onCreate.call(o,D)):0!==E.next(y.popup).length?(b.verbose("Pre-existing popup found"),v.inline=!0,v.popups=E.next(y.popup).data(T.activator,S),b.refresh(),v.hoverable&&b.bind.popup()):v.popup?(e(v.popup).data(T.activator,S),b.verbose("Used popup specified in settings"),b.refresh(),v.hoverable&&b.bind.popup()):b.debug("No content specified skipping display",D)},createID:function(){m=(Math.random().toString(16)+"000000000").substr(2,8),h="."+m,b.verbose("Creating unique id for element",m)},toggle:function(){b.debug("Toggling pop-up"),b.is.hidden()?(b.debug("Popup is hidden, showing pop-up"),b.unbind.close(),b.show()):(b.debug("Popup is visible, hiding pop-up"),b.hide())},show:function(t){t=e.isFunction(t)?t:function(){},b.debug("Showing pop-up",v.transition),b.exists()?v.preserve||v.popup||b.refresh():b.create(),o&&b.set.position()&&(b.save.conditions(),v.exclusive&&b.hideAll(),b.animate.show(t))},hide:function(t){t=e.isFunction(t)?t:function(){},b.remove.visible(),b.unbind.close(),b.is.visible()&&(b.restore.conditions(),b.animate.hide(t))},hideAll:function(){e(y.popup).filter("."+w.visible).each(function(){e(this).data(T.activator).popup("hide")})},hideGracefully:function(t){t&&0===e(t.target).closest(y.popup).length?(b.debug("Click occurred outside popup hiding popup"),b.hide()):b.debug("Click was inside popup, keeping popup open")},exists:function(){return o?v.inline||v.popup?b.has.popup():o.closest(O).length>=1?!0:!1:!1},removePopup:function(){b.debug("Removing popup",o),b.has.popup()&&!v.popup&&(o.remove(),o=n),v.onRemove.call(o,D)},save:{conditions:function(){b.cache={title:S.attr("title")},b.cache.title&&S.removeAttr("title"),b.verbose("Saving original attributes",b.cache.title)}},restore:{conditions:function(){return b.cache&&b.cache.title&&(S.attr("title",b.cache.title),b.verbose("Restoring original attributes",b.cache.title)),!0}},animate:{show:function(t){t=e.isFunction(t)?t:function(){},v.transition&&e.fn.transition!==n&&S.transition("is supported")?(b.set.visible(),o.transition({animation:v.transition+" in",queue:!1,debug:v.debug,verbose:v.verbose,duration:v.duration,onComplete:function(){b.bind.close(),t.call(o,D),v.onVisible.call(o,D)}})):(b.set.visible(),o.stop().fadeIn(v.duration,v.easing,function(){b.bind.close(),t.call(o,D),v.onVisible.call(o,D)})),v.onShow.call(o,D)},hide:function(t){t=e.isFunction(t)?t:function(){},b.debug("Hiding pop-up"),v.transition&&e.fn.transition!==n&&S.transition("is supported")?o.transition({animation:v.transition+" out",queue:!1,duration:v.duration,debug:v.debug,verbose:v.verbose,onComplete:function(){b.reset(),t.call(o,D),v.onHidden.call(o,D)}}):o.stop().fadeOut(v.duration,v.easing,function(){b.reset(),t.call(o,D),v.onHidden.call(o,D)}),v.onHide.call(o,D)}},get:{id:function(){return m},startEvent:function(){return"hover"==v.on?l?"touchstart mouseenter":"mouseenter":"focus"==v.on?"focus":!1},scrollEvent:function(){return l?"touchmove scroll":"scroll"},endEvent:function(){return"hover"==v.on?"mouseleave":"focus"==v.on?"blur":!1},offsetParent:function(t){var o=t!==n?t[0]:S[0],i=o.parentNode,r=e(i);if(i)for(var s="none"===r.css("transform"),a="static"===r.css("position"),p=r.is("html");i&&!p&&a&&s;)i=i.parentNode,r=e(i),s="none"===r.css("transform"),a="static"===r.css("position"),p=r.is("html");return r&&r.length>0?r:e()},offstagePosition:function(n){var i={top:e(t).scrollTop(),bottom:e(t).scrollTop()+e(t).height(),left:0,right:e(t).width()},r={width:o.width(),height:o.height(),offset:o.offset()},s={},a=[];return n=n||!1,r.offset&&n&&(b.verbose("Checking if outside viewable area",r.offset),s={top:r.offset.topi.bottom,right:r.offset.left+r.width>i.right,left:r.offset.left0?a.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(" "),o=t[0],n=t[1],i={top:"bottom",bottom:"top",left:"right",right:"left"},r={left:"center",center:"right",right:"left"},s={"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"},a="top"==o||"bottom"==o,p=!1,l=!1,u=!1;return F||(b.verbose("All available positions available"),F=b.get.positions()),b.debug("Recording last position tried",e),F[e]=!0,"opposite"===v.prefer&&(u=[i[o],n],u=u.join(" "),p=F[u]===!0,b.debug("Trying opposite strategy",u)),"adjacent"===v.prefer&&a&&(u=[o,r[n]],u=u.join(" "),l=F[u]===!0,b.debug("Trying adjacent strategy",u)),(l||p)&&(b.debug("Using backup position",u),u=s[e]),u}},set:{position:function(i,r){if(0==E.length||0==o.length)return void b.error(P.notFound);var a,p,l,u=(e(t).width(),e(t).height(),E.outerWidth()),c=E.outerHeight(),d=o.outerWidth(),f=o.outerHeight(),g=s.outerWidth(),h=s.outerHeight(),m=v.distanceAway,y=E[0],C=v.inline?parseInt(t.getComputedStyle(y).getPropertyValue("margin-top"),10):0,x=v.inline?b.is.rtl()?parseInt(t.getComputedStyle(y).getPropertyValue("margin-right"),10):parseInt(t.getComputedStyle(y).getPropertyValue("margin-left"),10):0,k=v.inline||v.popup?E.position():E.offset();if(i=i||S.data(T.position)||v.position,r=r||S.data(T.offset)||v.offset,0==k.top&&0==k.left)return b.debug("Popup target is hidden, no action taken"),!1;switch(R==v.maxSearchDepth&&v.lastResort&&(b.debug("Using last resort position to display",v.lastResort),i=v.lastResort),v.inline&&(b.debug("Adding targets margin to calculation"),"left center"==i||"right center"==i?(r+=C,m+=-x):"top left"==i||"top center"==i||"top right"==i?(r+=x,m-=C):(r+=x,m+=C)),b.debug("Calculating popup positioning",i),a=i,b.is.rtl()&&(a=a.replace(/left|right/g,function(e){return"left"==e?"right":"left"}),b.debug("RTL: Popup positioning updated",a)),a){case"top left":p={top:"auto",bottom:h-k.top+m,left:k.left+r,right:"auto"};break;case"top center":p={bottom:h-k.top+m,left:k.left+u/2-d/2+r,top:"auto",right:"auto"};break;case"top right":p={bottom:h-k.top+m,right:g-k.left-u-r,top:"auto",left:"auto"};break;case"left center":p={top:k.top+c/2-f/2+r,right:g-k.left+m,left:"auto",bottom:"auto"};break;case"right center":p={top:k.top+c/2-f/2+r,left:k.left+u+m,bottom:"auto",right:"auto"};break;case"bottom left":p={top:k.top+c+m,left:k.left+r,bottom:"auto",right:"auto"};break;case"bottom center":p={top:k.top+c+m,left:k.left+u/2-d/2+r,bottom:"auto",right:"auto"};break;case"bottom right":p={top:k.top+c+m,right:g-k.left-u-r,left:"auto",bottom:"auto"}}if(p===n&&b.error(P.invalidPosition,i),b.debug("Calculated popup positioning values",p),o.css(p).removeClass(w.position).addClass(i).addClass(w.loading),l=b.get.offstagePosition(i)){if(b.debug("Popup cant fit into viewport",l),R0}},is:{active:function(){return S.hasClass(w.active)},animating:function(){return o&&o.is(":animated")||o.hasClass(w.animating)},visible:function(){return o&&o.is(":visible")},dropdown:function(){return S.hasClass(w.dropdown)},hidden:function(){return!b.is.visible()},rtl:function(){return"rtl"==S.css("direction")}},reset:function(){b.remove.visible(),v.preserve?e.fn.transition!==n&&o.transition("remove transition"):b.removePopup()},setting:function(t,o){if(e.isPlainObject(t))e.extend(!0,v,t);else{if(o===n)return v[t];v[t]=o}},internal:function(t,o){if(e.isPlainObject(t))e.extend(!0,b,t);else{if(o===n)return b[t];b[t]=o}},debug:function(){v.debug&&(v.performance?b.performance.log(arguments):(b.debug=Function.prototype.bind.call(console.info,console,v.name+":"),b.debug.apply(console,arguments)))},verbose:function(){v.verbose&&v.debug&&(v.performance?b.performance.log(arguments):(b.verbose=Function.prototype.bind.call(console.info,console,v.name+":"),b.verbose.apply(console,arguments)))},error:function(){b.error=Function.prototype.bind.call(console.error,console,v.name+":"),b.error.apply(console,arguments)},performance:{log:function(e){var t,o,n;v.performance&&(t=(new Date).getTime(),n=u||t,o=t-n,u=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:D,"Execution Time":o})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(b.performance.display,500)},display:function(){var t=v.name+":",o=0;u=!1,clearTimeout(b.performance.timer),e.each(c,function(e,t){o+=t["Execution Time"]}),t+=" "+o+"ms",p&&(t+=" '"+p+"'"),(console.group!==n||console.table!==n)&&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,o,i){var s,a,p,l=H;return o=o||g,i=D||i,"string"==typeof t&&l!==n&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(o,i){var r=o!=s?i+t[o+1].charAt(0).toUpperCase()+t[o+1].slice(1):t;if(e.isPlainObject(l[r])&&o!=s)l=l[r];else{if(l[r]!==n)return a=l[r],!1;if(!e.isPlainObject(l[i])||o==s)return l[i]!==n?(a=l[i],!1):!1;l=l[i]}})),e.isFunction(a)?p=a.apply(i,o):a!==n&&(p=a),e.isArray(r)?r.push(p):r!==n?r=[r,p]:p!==n&&(r=p),a}},f?(H===n&&b.initialize(),b.invoke(d)):(H!==n&&H.invoke("destroy"),b.initialize())}),r!==n?r: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",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:!0,context:"body",prefer:"opposite",lastResort:!1,delay:{show:30,hide:0},setFluidWidth:!0,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.",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,o=/[&<>"'`]/,n={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},i=function(e){return n[e]};return o.test(e)?e.replace(t,i):e},popup:function(t){var o="",i=e.fn.popup.settings.templates.escape;return typeof t!==n&&(typeof t.title!==n&&t.title&&(t.title=i(t.title),o+='
'+t.title+"
"),typeof t.content!==n&&t.content&&(t.content=i(t.content),o+='
'+t.content+"
")),o}}},e.extend(e.easing,{easeOutQuad:function(e,t,o,n,i){return-n*(t/=i)*(t-2)+o}})}(jQuery,window,document); \ No newline at end of file +!function(e,t,o,n){"use strict";e.fn.popup=function(i){var r,s=e(this),a=e(o),p=s.selector||"",l="ontouchstart"in o.documentElement,u=(new Date).getTime(),c=[],d=arguments[0],f="string"==typeof d,g=[].slice.call(arguments,1);return s.each(function(){var o,s,h,m,b,v=e.isPlainObject(i)?e.extend(!0,{},e.fn.popup.settings,i):e.extend({},e.fn.popup.settings),y=v.selector,w=v.className,P=v.error,T=v.metadata,C=v.namespace,x="."+v.namespace,k="module-"+C,S=e(this),O=e(v.context),E=v.target?e(v.target):S,j=e(t),A=e("body"),R=0,F=!1,D=this,H=S.data(k);b={initialize:function(){b.debug("Initializing",S),b.createID(),b.bind.events(),!b.exists()&&v.preserve&&b.create(),b.instantiate()},instantiate:function(){b.verbose("Storing instance",b),H=b,S.data(k,H)},refresh:function(){v.popup?o=e(v.popup).eq(0):v.inline&&(o=E.next(y.popup).eq(0),v.popup=o),v.popup?(o.addClass(w.loading),s=b.get.offsetParent(),o.removeClass(w.loading),v.movePopup&&b.has.popup()&&b.get.offsetParent(o)[0]!==s[0]&&(b.debug("Moving popup to the same offset parent as activating element"),o.detach().appendTo(s))):s=v.inline?b.get.offsetParent(E):b.has.popup()?b.get.offsetParent(o):A,s.is("html")&&(b.debug("Setting page as offset parent"),s=A)},reposition:function(){b.refresh(),b.set.position()},destroy:function(){b.debug("Destroying previous module"),o&&!v.preserve&&b.removePopup(),clearTimeout(b.hideTimer),clearTimeout(b.showTimer),j.off(h),S.off(x).removeData(k)},event:{start:function(){var t=e.isPlainObject(v.delay)?v.delay.show:v.delay;clearTimeout(b.hideTimer),b.showTimer=setTimeout(function(){!b.is.hidden()||b.is.active()&&b.is.dropdown()||b.show()},t)},end:function(){var t=e.isPlainObject(v.delay)?v.delay.hide:v.delay;clearTimeout(b.showTimer),b.hideTimer=setTimeout(function(){b.is.visible()&&b.hide()},t)},resize:function(){b.is.visible()&&b.set.position()}},create:function(){var t=S.data(T.html)||v.html,n=S.data(T.variation)||v.variation,i=S.data(T.title)||v.title,r=S.data(T.content)||S.attr("title")||v.content;t||r||i?(b.debug("Creating pop-up html"),t||(t=v.templates.popup({title:i,content:r})),o=e("
").addClass(w.popup).addClass(n).data(T.activator,S).html(t),n&&o.addClass(n),v.inline?(b.verbose("Inserting popup element inline",o),o.insertAfter(S)):(b.verbose("Appending popup element to body",o),o.appendTo(O)),b.refresh(),v.hoverable&&b.bind.popup(),v.onCreate.call(o,D)):0!==E.next(y.popup).length?(b.verbose("Pre-existing popup found"),v.inline=!0,v.popups=E.next(y.popup).data(T.activator,S),b.refresh(),v.hoverable&&b.bind.popup()):v.popup?(e(v.popup).data(T.activator,S),b.verbose("Used popup specified in settings"),b.refresh(),v.hoverable&&b.bind.popup()):b.debug("No content specified skipping display",D)},createID:function(){m=(Math.random().toString(16)+"000000000").substr(2,8),h="."+m,b.verbose("Creating unique id for element",m)},toggle:function(){b.debug("Toggling pop-up"),b.is.hidden()?(b.debug("Popup is hidden, showing pop-up"),b.unbind.close(),b.show()):(b.debug("Popup is visible, hiding pop-up"),b.hide())},show:function(t){t=e.isFunction(t)?t:function(){},b.debug("Showing pop-up",v.transition),b.exists()?v.preserve||v.popup||b.refresh():b.create(),o&&b.set.position()&&(b.save.conditions(),v.exclusive&&b.hideAll(),b.animate.show(t))},hide:function(t){t=e.isFunction(t)?t:function(){},b.remove.visible(),b.unbind.close(),b.is.visible()&&(b.restore.conditions(),b.animate.hide(t))},hideAll:function(){e(y.popup).filter("."+w.visible).each(function(){e(this).data(T.activator).popup("hide")})},hideGracefully:function(t){t&&0===e(t.target).closest(y.popup).length?(b.debug("Click occurred outside popup hiding popup"),b.hide()):b.debug("Click was inside popup, keeping popup open")},exists:function(){return o?v.inline||v.popup?b.has.popup():o.closest(O).length>=1?!0:!1:!1},removePopup:function(){b.debug("Removing popup",o),b.has.popup()&&!v.popup&&(o.remove(),o=n),v.onRemove.call(o,D)},save:{conditions:function(){b.cache={title:S.attr("title")},b.cache.title&&S.removeAttr("title"),b.verbose("Saving original attributes",b.cache.title)}},restore:{conditions:function(){return b.cache&&b.cache.title&&(S.attr("title",b.cache.title),b.verbose("Restoring original attributes",b.cache.title)),!0}},animate:{show:function(t){t=e.isFunction(t)?t:function(){},v.transition&&e.fn.transition!==n&&S.transition("is supported")?(b.set.visible(),o.transition({animation:v.transition+" in",queue:!1,debug:v.debug,verbose:v.verbose,duration:v.duration,onComplete:function(){b.bind.close(),t.call(o,D),v.onVisible.call(o,D)}})):(b.set.visible(),o.stop().fadeIn(v.duration,v.easing,function(){b.bind.close(),t.call(o,D),v.onVisible.call(o,D)})),v.onShow.call(o,D)},hide:function(t){t=e.isFunction(t)?t:function(){},b.debug("Hiding pop-up"),v.transition&&e.fn.transition!==n&&S.transition("is supported")?o.transition({animation:v.transition+" out",queue:!1,duration:v.duration,debug:v.debug,verbose:v.verbose,onComplete:function(){b.reset(),t.call(o,D),v.onHidden.call(o,D)}}):o.stop().fadeOut(v.duration,v.easing,function(){b.reset(),t.call(o,D),v.onHidden.call(o,D)}),v.onHide.call(o,D)}},get:{id:function(){return m},startEvent:function(){return"hover"==v.on?l?"touchstart mouseenter":"mouseenter":"focus"==v.on?"focus":!1},scrollEvent:function(){return l?"touchmove scroll":"scroll"},endEvent:function(){return"hover"==v.on?"mouseleave":"focus"==v.on?"blur":!1},offsetParent:function(t){var o=t!==n?t[0]:S[0],i=o.parentNode,r=e(i);if(i)for(var s="none"===r.css("transform"),a="static"===r.css("position"),p=r.is("html");i&&!p&&a&&s;)i=i.parentNode,r=e(i),s="none"===r.css("transform"),a="static"===r.css("position"),p=r.is("html");return r&&r.length>0?r:e()},offstagePosition:function(n){var i={top:e(t).scrollTop(),bottom:e(t).scrollTop()+e(t).height(),left:0,right:e(t).width()},r={width:o.width(),height:o.height(),offset:o.offset()},s={},a=[];return n=n||!1,r.offset&&n&&(b.verbose("Checking if outside viewable area",r.offset),s={top:r.offset.topi.bottom,right:r.offset.left+r.width>i.right,left:r.offset.left0?a.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(" "),o=t[0],n=t[1],i={top:"bottom",bottom:"top",left:"right",right:"left"},r={left:"center",center:"right",right:"left"},s={"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"},a="top"==o||"bottom"==o,p=!1,l=!1,u=!1;return F||(b.verbose("All available positions available"),F=b.get.positions()),b.debug("Recording last position tried",e),F[e]=!0,"opposite"===v.prefer&&(u=[i[o],n],u=u.join(" "),p=F[u]===!0,b.debug("Trying opposite strategy",u)),"adjacent"===v.prefer&&a&&(u=[o,r[n]],u=u.join(" "),l=F[u]===!0,b.debug("Trying adjacent strategy",u)),(l||p)&&(b.debug("Using backup position",u),u=s[e]),u}},set:{position:function(i,r){if(0===E.length||0===o.length)return void b.error(P.notFound);var a,p,l,u=(e(t).width(),e(t).height(),E.outerWidth()),c=E.outerHeight(),d=o.outerWidth(),f=o.outerHeight(),g=s.outerWidth(),h=s.outerHeight(),m=v.distanceAway,y=E[0],C=v.inline?parseInt(t.getComputedStyle(y).getPropertyValue("margin-top"),10):0,x=v.inline?b.is.rtl()?parseInt(t.getComputedStyle(y).getPropertyValue("margin-right"),10):parseInt(t.getComputedStyle(y).getPropertyValue("margin-left"),10):0,k=v.inline||v.popup?E.position():E.offset();if(i=i||S.data(T.position)||v.position,r=r||S.data(T.offset)||v.offset,0===k.top&&0===k.left)return b.debug("Popup target is hidden, no action taken"),!1;switch(R==v.maxSearchDepth&&v.lastResort&&(b.debug("Using last resort position to display",v.lastResort),i=v.lastResort),v.inline&&(b.debug("Adding targets margin to calculation"),"left center"==i||"right center"==i?(r+=C,m+=-x):"top left"==i||"top center"==i||"top right"==i?(r+=x,m-=C):(r+=x,m+=C)),b.debug("Calculating popup positioning",i),a=i,b.is.rtl()&&(a=a.replace(/left|right/g,function(e){return"left"==e?"right":"left"}),b.debug("RTL: Popup positioning updated",a)),a){case"top left":p={top:"auto",bottom:h-k.top+m,left:k.left+r,right:"auto"};break;case"top center":p={bottom:h-k.top+m,left:k.left+u/2-d/2+r,top:"auto",right:"auto"};break;case"top right":p={bottom:h-k.top+m,right:g-k.left-u-r,top:"auto",left:"auto"};break;case"left center":p={top:k.top+c/2-f/2+r,right:g-k.left+m,left:"auto",bottom:"auto"};break;case"right center":p={top:k.top+c/2-f/2+r,left:k.left+u+m,bottom:"auto",right:"auto"};break;case"bottom left":p={top:k.top+c+m,left:k.left+r,bottom:"auto",right:"auto"};break;case"bottom center":p={top:k.top+c+m,left:k.left+u/2-d/2+r,bottom:"auto",right:"auto"};break;case"bottom right":p={top:k.top+c+m,right:g-k.left-u-r,left:"auto",bottom:"auto"}}if(p===n&&b.error(P.invalidPosition,i),b.debug("Calculated popup positioning values",p),o.css(p).removeClass(w.position).addClass(i).addClass(w.loading),l=b.get.offstagePosition(i)){if(b.debug("Popup cant fit into viewport",l),R0}},is:{active:function(){return S.hasClass(w.active)},animating:function(){return o&&o.is(":animated")||o.hasClass(w.animating)},visible:function(){return o&&o.is(":visible")},dropdown:function(){return S.hasClass(w.dropdown)},hidden:function(){return!b.is.visible()},rtl:function(){return"rtl"==S.css("direction")}},reset:function(){b.remove.visible(),v.preserve?e.fn.transition!==n&&o.transition("remove transition"):b.removePopup()},setting:function(t,o){if(e.isPlainObject(t))e.extend(!0,v,t);else{if(o===n)return v[t];v[t]=o}},internal:function(t,o){if(e.isPlainObject(t))e.extend(!0,b,t);else{if(o===n)return b[t];b[t]=o}},debug:function(){v.debug&&(v.performance?b.performance.log(arguments):(b.debug=Function.prototype.bind.call(console.info,console,v.name+":"),b.debug.apply(console,arguments)))},verbose:function(){v.verbose&&v.debug&&(v.performance?b.performance.log(arguments):(b.verbose=Function.prototype.bind.call(console.info,console,v.name+":"),b.verbose.apply(console,arguments)))},error:function(){b.error=Function.prototype.bind.call(console.error,console,v.name+":"),b.error.apply(console,arguments)},performance:{log:function(e){var t,o,n;v.performance&&(t=(new Date).getTime(),n=u||t,o=t-n,u=t,c.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:D,"Execution Time":o})),clearTimeout(b.performance.timer),b.performance.timer=setTimeout(b.performance.display,500)},display:function(){var t=v.name+":",o=0;u=!1,clearTimeout(b.performance.timer),e.each(c,function(e,t){o+=t["Execution Time"]}),t+=" "+o+"ms",p&&(t+=" '"+p+"'"),(console.group!==n||console.table!==n)&&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,o,i){var s,a,p,l=H;return o=o||g,i=D||i,"string"==typeof t&&l!==n&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(o,i){var r=o!=s?i+t[o+1].charAt(0).toUpperCase()+t[o+1].slice(1):t;if(e.isPlainObject(l[r])&&o!=s)l=l[r];else{if(l[r]!==n)return a=l[r],!1;if(!e.isPlainObject(l[i])||o==s)return l[i]!==n?(a=l[i],!1):!1;l=l[i]}})),e.isFunction(a)?p=a.apply(i,o):a!==n&&(p=a),e.isArray(r)?r.push(p):r!==n?r=[r,p]:p!==n&&(r=p),a}},f?(H===n&&b.initialize(),b.invoke(d)):(H!==n&&H.invoke("destroy"),b.initialize())}),r!==n?r: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",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:!0,context:"body",prefer:"opposite",lastResort:!1,delay:{show:30,hide:0},setFluidWidth:!0,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.",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,o=/[&<>"'`]/,n={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},i=function(e){return n[e]};return o.test(e)?e.replace(t,i):e},popup:function(t){var o="",i=e.fn.popup.settings.templates.escape;return typeof t!==n&&(typeof t.title!==n&&t.title&&(t.title=i(t.title),o+='
'+t.title+"
"),typeof t.content!==n&&t.content&&(t.content=i(t.content),o+='
'+t.content+"
")),o}}},e.extend(e.easing,{easeOutQuad:function(e,t,o,n,i){return-n*(t/=i)*(t-2)+o}})}(jQuery,window,document); \ No newline at end of file diff --git a/dist/components/search.js b/dist/components/search.js index 04b54790d..10ece6305 100644 --- a/dist/components/search.js +++ b/dist/components/search.js @@ -550,6 +550,9 @@ $.fn.search = function(parameters) { clear: { cache: function(value) { + var + cache = $module.data(metadata.cache) + ; if(!value) { module.debug('Clearing cache', value); $module.removeData(metadata.cache); diff --git a/dist/components/search.min.js b/dist/components/search.min.js index 245f70a28..41129a8a6 100644 --- a/dist/components/search.min.js +++ b/dist/components/search.min.js @@ -8,4 +8,4 @@ * http://opensource.org/licenses/MIT * */ -!function(e,t,s,r){"use strict";e.fn.search=function(n){var a,i=e(this),o=i.selector||"",c=(new Date).getTime(),u=[],l=arguments[0],d="string"==typeof l,f=[].slice.call(arguments,1);return e(this).each(function(){var g,p=e.extend(!0,{},e.fn.search.settings,n),m=p.className,h=p.metadata,v=p.regExp,b=p.selector,y=p.error,R=p.namespace,w="."+R,C=R+"-module",x=e(this),k=x.find(b.prompt),A=x.find(b.searchButton),q=x.find(b.results),S=(x.find(b.result),x.find(b.category),this),E=x.data(C);g={initialize:function(){g.verbose("Initializing module");var e=k[0],t=e!==r&&e.oninput!==r?"input":e!==r&&e.onpropertychange!==r?"propertychange":"keyup";p.automatic&&(x.on(t+w,b.prompt,g.throttle),k.attr("autocomplete","off")),x.on("focus"+w,b.prompt,g.event.focus).on("blur"+w,b.prompt,g.event.blur).on("keydown"+w,b.prompt,g.handleKeyboard).on("click"+w,b.searchButton,g.query).on("mousedown"+w,b.results,g.event.result.mousedown).on("mouseup"+w,b.results,g.event.result.mouseup).on("click"+w,b.result,g.event.result.click),g.instantiate()},instantiate:function(){g.verbose("Storing instance of module",g),E=g,x.data(C,g)},destroy:function(){g.verbose("Destroying instance"),x.off(w).removeData(C)},event:{focus:function(){g.set.focus(),g.has.minimumCharacters()&&g.showResults()},blur:function(){var e=s.activeElement===this;e||g.resultsClicked||(g.cancel.query(),g.remove.focus(),g.timer=setTimeout(g.hideResults,p.hideDelay))},result:{mousedown:function(){g.resultsClicked=!0},mouseup:function(){g.resultsClicked=!1},click:function(s){g.debug("Search result selected");var r=e(this),n=r.find(b.title).eq(0),a=r.find("a[href]").eq(0),i=a.attr("href")||!1,o=a.attr("target")||!1,c=(n.html(),n.length>0?n.text():!1),u=g.get.results(),l=g.get.result(c,u);return e.isFunction(p.onSelect)&&p.onSelect.call(S,l,u)===!1?void g.debug("Custom onSelect callback cancelled default select action"):(g.hideResults(),c&&g.set.value(c),void(i&&(g.verbose("Opening search link found in result",a),"_blank"==o||s.ctrlKey?t.open(i):t.location.href=i)))}}},handleKeyboard:function(e){var t,s=x.find(b.result),r=x.find(b.category),n=s.index(s.filter("."+m.active)),a=s.length,i=e.which,o={backspace:8,enter:13,escape:27,upArrow:38,downArrow:40};if(i==o.escape&&(g.verbose("Escape key pressed, blurring search field"),k.trigger("blur")),g.is.visible())if(i==o.enter){if(g.verbose("Enter key pressed, selecting active result"),s.filter("."+m.active).length>0)return g.event.result.click.call(s.filter("."+m.active),e),e.preventDefault(),!1}else i==o.upArrow?(g.verbose("Up key pressed, changing active result"),t=0>n-1?n:n-1,r.removeClass(m.active),s.removeClass(m.active).eq(t).addClass(m.active).closest(r).addClass(m.active),e.preventDefault()):i==o.downArrow&&(g.verbose("Down key pressed, changing active result"),t=n+1>=a?n:n+1,r.removeClass(m.active),s.removeClass(m.active).eq(t).addClass(m.active).closest(r).addClass(m.active),e.preventDefault());else i==o.enter&&(g.verbose("Enter key pressed, executing query"),g.query(),g.set.buttonPressed(),k.one("keyup",g.remove.buttonFocus))},setup:{api:function(){var e={debug:p.debug,on:!1,action:"search",onFailure:g.error};g.verbose("First request, initializing API"),x.api(e)}},can:{useAPI:function(){return e.fn.api!==r},transition:function(){return p.transition&&e.fn.transition!==r&&x.transition("is supported")}},is:{empty:function(){return""===q.html()},visible:function(){return q.filter(":visible").length>0},focused:function(){return k.filter(":focus").length>0}},get:{value:function(){return k.val()},results:function(){var e=x.data(h.results);return e},result:function(t,s){var r=!1;return t=t||g.get.value(),s=s||g.get.results(),"category"===p.type?(g.debug("Finding result that matches",t),e.each(s,function(s,n){return e.isArray(n.results)&&(r=g.search.object(t,n.results,!0)[0])?!1:void 0})):(g.debug("Finding result in results object",t),r=g.search.object(t,s,!0)[0]),r}},set:{focus:function(){x.addClass(m.focus)},loading:function(){x.addClass(m.loading)},value:function(e){g.verbose("Setting search input value",e),k.val(e),g.query()},buttonPressed:function(){A.addClass(m.pressed)}},remove:{loading:function(){x.removeClass(m.loading)},focus:function(){x.removeClass(m.focus)},buttonPressed:function(){A.removeClass(m.pressed)}},query:function(){var t=g.get.value(),s=g.read.cache(t);s?(g.debug("Reading result for "+t+" from cache"),g.save.results(s.results),g.addResults(s.html)):(g.debug("Querying for "+t),e.isPlainObject(p.source)||e.isArray(p.source)?g.search.local(t):g.can.useAPI()?g.search.remote(t):g.error(y.source),p.onSearchQuery.call(S,t))},search:{local:function(e){var t,s=g.search.object(e,p.content);g.set.loading(),g.save.results(s),g.debug("Returned local search results",s),t=g.generateResults({results:s}),g.remove.loading(),g.write.cache(e,{html:t,results:s}),g.addResults(t)},remote:function(t){var s={onSuccess:function(e){g.parse.response.call(S,e,t)},urlData:{query:t}};x.api("get request")||g.setup.api(),e.extend(!0,s,p.apiSettings),g.debug("Executing search",s),g.cancel.query(),x.api("setting",s).api("query")},object:function(t,s,n){var a=[],i=[],o=t.replace(v.escape,"\\$&"),c=new RegExp(v.beginsWith+o,"i"),u=e.isArray(p.searchFields)?p.searchFields:[p.searchFields],l=function(t,s){var r=-1==e.inArray(s,a),n=-1==e.inArray(s,i);r&&n&&t.push(s)};return s=s||p.source,s===r?(g.error(y.source),[]):(e.each(u,function(r,o){e.each(s,function(e,s){var r="string"==typeof s[o];r&&(n?s[o]==t&&l(a,s):s[o].match(c)?l(a,s):p.searchFullText&&g.fuzzySearch(t,s[o])&&l(i,s))})}),e.merge(a,i))}},fuzzySearch:function(e,t){var s=t.length,r=e.length;if(e=e.toLowerCase(),t=t.toLowerCase(),r>s)return!1;if(r===s)return e===t;e:for(var n=0,a=0;r>n;n++){for(var i=e.charCodeAt(n);s>a;)if(t.charCodeAt(a++)===i)continue e;return!1}return!0},parse:{response:function(e,t){var s=g.generateResults(e);g.verbose("Parsing server response",e),e!==r&&t!==r&&e.results!==r&&(g.write.cache(t,{html:s,results:e.results}),g.save.results(e.results),g.addResults(s))}},throttle:function(){clearTimeout(g.timer),g.has.minimumCharacters()?g.timer=setTimeout(g.query,p.searchDelay):g.hideResults()},cancel:{query:function(){g.can.useAPI()&&x.api("abort")}},has:{minimumCharacters:function(){var e=g.get.value(),t=e.length;return t>=p.minCharacters}},clear:{cache:function(e){e?e&&cache&&cache[e]&&(g.debug("Removing value from cache",e),delete cache[e],x.data(h.cache,cache)):(g.debug("Clearing cache",e),x.removeData(h.cache))}},read:{cache:function(e){var t=x.data(h.cache);return p.cache?(g.verbose("Checking cache for generated html for query",e),"object"==typeof t&&t[e]!==r?t[e]:!1):!1}},save:{results:function(e){g.verbose("Saving current search results to metadata",e),x.data(h.results,e)}},write:{cache:function(e,t){var s=x.data(h.cache)!==r?x.data(h.cache):{};p.cache&&(g.verbose("Writing generated html to cache",e,t),s[e]=t,x.data(h.cache,s))}},addResults:function(t){return e.isFunction(p.onResultsAdd)&&p.onResultsAdd.call(q,t)===!1?(g.debug("onResultsAdd callback cancelled default action"),!1):(q.html(t),void g.showResults())},showResults:function(){g.is.visible()||!g.is.focused()||g.is.empty()||(g.can.transition()?(g.debug("Showing results with css animations"),q.transition({animation:p.transition+" in",debug:p.debug,verbose:p.verbose,duration:p.duration,queue:!0})):(g.debug("Showing results with javascript"),q.stop().fadeIn(p.duration,p.easing)),p.onResultsOpen.call(q))},hideResults:function(){g.is.visible()&&(g.can.transition()?(g.debug("Hiding results with css animations"),q.transition({animation:p.transition+" out",debug:p.debug,verbose:p.verbose,duration:p.duration,queue:!0})):(g.debug("Hiding results with javascript"),q.stop().fadeOut(p.duration,p.easing)),p.onResultsClose.call(q))},generateResults:function(t){g.debug("Generating html from response",t);var s=p.templates[p.type],r=e.isPlainObject(t.results)&&!e.isEmptyObject(t.results),n=e.isArray(t.results)&&t.results.length>0,a="";return r||n?(p.maxResults>0&&(r?"standard"==p.type&&g.error(y.maxResults):t.results=t.results.slice(0,p.maxResults)),e.isFunction(s)?a=s(t):g.error(y.noTemplate,!1)):a=g.displayMessage(y.noResults,"empty"),p.onResults.call(S,t),a},displayMessage:function(e,t){return t=t||"standard",g.debug("Displaying message",e,t),g.addResults(p.templates.message(e,t)),p.templates.message(e,t)},setting:function(t,s){if(e.isPlainObject(t))e.extend(!0,p,t);else{if(s===r)return p[t];p[t]=s}},internal:function(t,s){if(e.isPlainObject(t))e.extend(!0,g,t);else{if(s===r)return g[t];g[t]=s}},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,s,r;p.performance&&(t=(new Date).getTime(),r=c||t,s=t-r,c=t,u.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:S,"Execution Time":s})),clearTimeout(g.performance.timer),g.performance.timer=setTimeout(g.performance.display,500)},display:function(){var t=p.name+":",s=0;c=!1,clearTimeout(g.performance.timer),e.each(u,function(e,t){s+=t["Execution Time"]}),t+=" "+s+"ms",o&&(t+=" '"+o+"'"),i.length>1&&(t+=" ("+i.length+")"),(console.group!==r||console.table!==r)&&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,s,n){var i,o,c,u=E;return s=s||f,n=S||n,"string"==typeof t&&u!==r&&(t=t.split(/[\. ]/),i=t.length-1,e.each(t,function(s,n){var a=s!=i?n+t[s+1].charAt(0).toUpperCase()+t[s+1].slice(1):t;if(e.isPlainObject(u[a])&&s!=i)u=u[a];else{if(u[a]!==r)return o=u[a],!1;if(!e.isPlainObject(u[n])||s==i)return u[n]!==r?(o=u[n],!1):!1;u=u[n]}})),e.isFunction(o)?c=o.apply(n,s):o!==r&&(c=o),e.isArray(a)?a.push(c):a!==r?a=[a,c]:c!==r&&(a=c),o}},d?(E===r&&g.initialize(),g.invoke(l)):(E!==r&&E.invoke("destroy"),g.initialize())}),a!==r?a:this},e.fn.search.settings={name:"Search Module",namespace:"search",debug:!1,verbose:!1,performance:!0,type:"standard",minCharacters:1,apiSettings:!1,source:!1,searchFields:["title","description"],searchFullText:!0,automatic:!0,hideDelay:0,searchDelay:200,maxResults:7,cache:!0,transition:"scale",duration:300,easing:"easeOutExpo",onSelect:!1,onResultsAdd:!1,onSearchQuery:function(){},onResults:function(){},onResultsOpen:function(){},onResultsClose:function(){},className:{active:"active",empty:"empty",focus:"focus",loading:"loading",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.",maxResults:"Results must be an array to use maxResults setting",method:"The method you called is not defined."},metadata:{cache:"cache",results:"results"},regExp:{escape:/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,beginsWith:"(?:s|^)"},selector:{prompt:".prompt",searchButton:".search.button",results:".results",category:".category",result:".result",title:".title, .name"},templates:{escape:function(e){var t=/[&<>"'`]/g,s=/[&<>"'`]/,r={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},n=function(e){return r[e]};return s.test(e)?e.replace(t,n):e},message:function(e,t){var s="";return e!==r&&t!==r&&(s+='
',s+="empty"==t?'
No Results
'+e+'
':'
'+e+"
",s+="
"),s},category:function(t){var s="",n=e.fn.search.settings.templates.escape;return t.results!==r?(e.each(t.results,function(t,a){a.results!==r&&a.results.length>0&&(s+='
'+a.name+"
",e.each(a.results,function(e,t){s+='
',t.url&&(s+=''),t.image!==r&&(t.image=n(t.image),s+='
'),s+='
',t.price!==r&&(t.price=n(t.price),s+='
'+t.price+"
"),t.title!==r&&(t.title=n(t.title),s+='
'+t.title+"
"),t.description!==r&&(s+='
'+t.description+"
"),s+="
"}),s+="
")}),t.action&&(s+=''+t.action.text+""),s):!1},standard:function(t){var s="";return t.results!==r?(e.each(t.results,function(e,t){s+=t.url?'':'',t.image!==r&&(s+='
'),s+='
',t.price!==r&&(s+='
'+t.price+"
"),t.title!==r&&(s+='
'+t.title+"
"),t.description!==r&&(s+='
'+t.description+"
"),s+="
",s+="
"}),t.action&&(s+=''+t.action.text+""),s):!1}}}}(jQuery,window,document); \ No newline at end of file +!function(e,t,s,r){"use strict";e.fn.search=function(n){var a,i=e(this),o=i.selector||"",c=(new Date).getTime(),u=[],l=arguments[0],d="string"==typeof l,f=[].slice.call(arguments,1);return e(this).each(function(){var g,p=e.extend(!0,{},e.fn.search.settings,n),m=p.className,v=p.metadata,h=p.regExp,b=p.selector,y=p.error,R=p.namespace,w="."+R,C=R+"-module",x=e(this),k=x.find(b.prompt),A=x.find(b.searchButton),q=x.find(b.results),S=(x.find(b.result),x.find(b.category),this),E=x.data(C);g={initialize:function(){g.verbose("Initializing module");var e=k[0],t=e!==r&&e.oninput!==r?"input":e!==r&&e.onpropertychange!==r?"propertychange":"keyup";p.automatic&&(x.on(t+w,b.prompt,g.throttle),k.attr("autocomplete","off")),x.on("focus"+w,b.prompt,g.event.focus).on("blur"+w,b.prompt,g.event.blur).on("keydown"+w,b.prompt,g.handleKeyboard).on("click"+w,b.searchButton,g.query).on("mousedown"+w,b.results,g.event.result.mousedown).on("mouseup"+w,b.results,g.event.result.mouseup).on("click"+w,b.result,g.event.result.click),g.instantiate()},instantiate:function(){g.verbose("Storing instance of module",g),E=g,x.data(C,g)},destroy:function(){g.verbose("Destroying instance"),x.off(w).removeData(C)},event:{focus:function(){g.set.focus(),g.has.minimumCharacters()&&g.showResults()},blur:function(){var e=s.activeElement===this;e||g.resultsClicked||(g.cancel.query(),g.remove.focus(),g.timer=setTimeout(g.hideResults,p.hideDelay))},result:{mousedown:function(){g.resultsClicked=!0},mouseup:function(){g.resultsClicked=!1},click:function(s){g.debug("Search result selected");var r=e(this),n=r.find(b.title).eq(0),a=r.find("a[href]").eq(0),i=a.attr("href")||!1,o=a.attr("target")||!1,c=(n.html(),n.length>0?n.text():!1),u=g.get.results(),l=g.get.result(c,u);return e.isFunction(p.onSelect)&&p.onSelect.call(S,l,u)===!1?void g.debug("Custom onSelect callback cancelled default select action"):(g.hideResults(),c&&g.set.value(c),void(i&&(g.verbose("Opening search link found in result",a),"_blank"==o||s.ctrlKey?t.open(i):t.location.href=i)))}}},handleKeyboard:function(e){var t,s=x.find(b.result),r=x.find(b.category),n=s.index(s.filter("."+m.active)),a=s.length,i=e.which,o={backspace:8,enter:13,escape:27,upArrow:38,downArrow:40};if(i==o.escape&&(g.verbose("Escape key pressed, blurring search field"),k.trigger("blur")),g.is.visible())if(i==o.enter){if(g.verbose("Enter key pressed, selecting active result"),s.filter("."+m.active).length>0)return g.event.result.click.call(s.filter("."+m.active),e),e.preventDefault(),!1}else i==o.upArrow?(g.verbose("Up key pressed, changing active result"),t=0>n-1?n:n-1,r.removeClass(m.active),s.removeClass(m.active).eq(t).addClass(m.active).closest(r).addClass(m.active),e.preventDefault()):i==o.downArrow&&(g.verbose("Down key pressed, changing active result"),t=n+1>=a?n:n+1,r.removeClass(m.active),s.removeClass(m.active).eq(t).addClass(m.active).closest(r).addClass(m.active),e.preventDefault());else i==o.enter&&(g.verbose("Enter key pressed, executing query"),g.query(),g.set.buttonPressed(),k.one("keyup",g.remove.buttonFocus))},setup:{api:function(){var e={debug:p.debug,on:!1,action:"search",onFailure:g.error};g.verbose("First request, initializing API"),x.api(e)}},can:{useAPI:function(){return e.fn.api!==r},transition:function(){return p.transition&&e.fn.transition!==r&&x.transition("is supported")}},is:{empty:function(){return""===q.html()},visible:function(){return q.filter(":visible").length>0},focused:function(){return k.filter(":focus").length>0}},get:{value:function(){return k.val()},results:function(){var e=x.data(v.results);return e},result:function(t,s){var r=!1;return t=t||g.get.value(),s=s||g.get.results(),"category"===p.type?(g.debug("Finding result that matches",t),e.each(s,function(s,n){return e.isArray(n.results)&&(r=g.search.object(t,n.results,!0)[0])?!1:void 0})):(g.debug("Finding result in results object",t),r=g.search.object(t,s,!0)[0]),r}},set:{focus:function(){x.addClass(m.focus)},loading:function(){x.addClass(m.loading)},value:function(e){g.verbose("Setting search input value",e),k.val(e),g.query()},buttonPressed:function(){A.addClass(m.pressed)}},remove:{loading:function(){x.removeClass(m.loading)},focus:function(){x.removeClass(m.focus)},buttonPressed:function(){A.removeClass(m.pressed)}},query:function(){var t=g.get.value(),s=g.read.cache(t);s?(g.debug("Reading result for "+t+" from cache"),g.save.results(s.results),g.addResults(s.html)):(g.debug("Querying for "+t),e.isPlainObject(p.source)||e.isArray(p.source)?g.search.local(t):g.can.useAPI()?g.search.remote(t):g.error(y.source),p.onSearchQuery.call(S,t))},search:{local:function(e){var t,s=g.search.object(e,p.content);g.set.loading(),g.save.results(s),g.debug("Returned local search results",s),t=g.generateResults({results:s}),g.remove.loading(),g.write.cache(e,{html:t,results:s}),g.addResults(t)},remote:function(t){var s={onSuccess:function(e){g.parse.response.call(S,e,t)},urlData:{query:t}};x.api("get request")||g.setup.api(),e.extend(!0,s,p.apiSettings),g.debug("Executing search",s),g.cancel.query(),x.api("setting",s).api("query")},object:function(t,s,n){var a=[],i=[],o=t.replace(h.escape,"\\$&"),c=new RegExp(h.beginsWith+o,"i"),u=e.isArray(p.searchFields)?p.searchFields:[p.searchFields],l=function(t,s){var r=-1==e.inArray(s,a),n=-1==e.inArray(s,i);r&&n&&t.push(s)};return s=s||p.source,s===r?(g.error(y.source),[]):(e.each(u,function(r,o){e.each(s,function(e,s){var r="string"==typeof s[o];r&&(n?s[o]==t&&l(a,s):s[o].match(c)?l(a,s):p.searchFullText&&g.fuzzySearch(t,s[o])&&l(i,s))})}),e.merge(a,i))}},fuzzySearch:function(e,t){var s=t.length,r=e.length;if(e=e.toLowerCase(),t=t.toLowerCase(),r>s)return!1;if(r===s)return e===t;e:for(var n=0,a=0;r>n;n++){for(var i=e.charCodeAt(n);s>a;)if(t.charCodeAt(a++)===i)continue e;return!1}return!0},parse:{response:function(e,t){var s=g.generateResults(e);g.verbose("Parsing server response",e),e!==r&&t!==r&&e.results!==r&&(g.write.cache(t,{html:s,results:e.results}),g.save.results(e.results),g.addResults(s))}},throttle:function(){clearTimeout(g.timer),g.has.minimumCharacters()?g.timer=setTimeout(g.query,p.searchDelay):g.hideResults()},cancel:{query:function(){g.can.useAPI()&&x.api("abort")}},has:{minimumCharacters:function(){var e=g.get.value(),t=e.length;return t>=p.minCharacters}},clear:{cache:function(e){var t=x.data(v.cache);e?e&&t&&t[e]&&(g.debug("Removing value from cache",e),delete t[e],x.data(v.cache,t)):(g.debug("Clearing cache",e),x.removeData(v.cache))}},read:{cache:function(e){var t=x.data(v.cache);return p.cache?(g.verbose("Checking cache for generated html for query",e),"object"==typeof t&&t[e]!==r?t[e]:!1):!1}},save:{results:function(e){g.verbose("Saving current search results to metadata",e),x.data(v.results,e)}},write:{cache:function(e,t){var s=x.data(v.cache)!==r?x.data(v.cache):{};p.cache&&(g.verbose("Writing generated html to cache",e,t),s[e]=t,x.data(v.cache,s))}},addResults:function(t){return e.isFunction(p.onResultsAdd)&&p.onResultsAdd.call(q,t)===!1?(g.debug("onResultsAdd callback cancelled default action"),!1):(q.html(t),void g.showResults())},showResults:function(){g.is.visible()||!g.is.focused()||g.is.empty()||(g.can.transition()?(g.debug("Showing results with css animations"),q.transition({animation:p.transition+" in",debug:p.debug,verbose:p.verbose,duration:p.duration,queue:!0})):(g.debug("Showing results with javascript"),q.stop().fadeIn(p.duration,p.easing)),p.onResultsOpen.call(q))},hideResults:function(){g.is.visible()&&(g.can.transition()?(g.debug("Hiding results with css animations"),q.transition({animation:p.transition+" out",debug:p.debug,verbose:p.verbose,duration:p.duration,queue:!0})):(g.debug("Hiding results with javascript"),q.stop().fadeOut(p.duration,p.easing)),p.onResultsClose.call(q))},generateResults:function(t){g.debug("Generating html from response",t);var s=p.templates[p.type],r=e.isPlainObject(t.results)&&!e.isEmptyObject(t.results),n=e.isArray(t.results)&&t.results.length>0,a="";return r||n?(p.maxResults>0&&(r?"standard"==p.type&&g.error(y.maxResults):t.results=t.results.slice(0,p.maxResults)),e.isFunction(s)?a=s(t):g.error(y.noTemplate,!1)):a=g.displayMessage(y.noResults,"empty"),p.onResults.call(S,t),a},displayMessage:function(e,t){return t=t||"standard",g.debug("Displaying message",e,t),g.addResults(p.templates.message(e,t)),p.templates.message(e,t)},setting:function(t,s){if(e.isPlainObject(t))e.extend(!0,p,t);else{if(s===r)return p[t];p[t]=s}},internal:function(t,s){if(e.isPlainObject(t))e.extend(!0,g,t);else{if(s===r)return g[t];g[t]=s}},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,s,r;p.performance&&(t=(new Date).getTime(),r=c||t,s=t-r,c=t,u.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:S,"Execution Time":s})),clearTimeout(g.performance.timer),g.performance.timer=setTimeout(g.performance.display,500)},display:function(){var t=p.name+":",s=0;c=!1,clearTimeout(g.performance.timer),e.each(u,function(e,t){s+=t["Execution Time"]}),t+=" "+s+"ms",o&&(t+=" '"+o+"'"),i.length>1&&(t+=" ("+i.length+")"),(console.group!==r||console.table!==r)&&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,s,n){var i,o,c,u=E;return s=s||f,n=S||n,"string"==typeof t&&u!==r&&(t=t.split(/[\. ]/),i=t.length-1,e.each(t,function(s,n){var a=s!=i?n+t[s+1].charAt(0).toUpperCase()+t[s+1].slice(1):t;if(e.isPlainObject(u[a])&&s!=i)u=u[a];else{if(u[a]!==r)return o=u[a],!1;if(!e.isPlainObject(u[n])||s==i)return u[n]!==r?(o=u[n],!1):!1;u=u[n]}})),e.isFunction(o)?c=o.apply(n,s):o!==r&&(c=o),e.isArray(a)?a.push(c):a!==r?a=[a,c]:c!==r&&(a=c),o}},d?(E===r&&g.initialize(),g.invoke(l)):(E!==r&&E.invoke("destroy"),g.initialize())}),a!==r?a:this},e.fn.search.settings={name:"Search Module",namespace:"search",debug:!1,verbose:!1,performance:!0,type:"standard",minCharacters:1,apiSettings:!1,source:!1,searchFields:["title","description"],searchFullText:!0,automatic:!0,hideDelay:0,searchDelay:200,maxResults:7,cache:!0,transition:"scale",duration:300,easing:"easeOutExpo",onSelect:!1,onResultsAdd:!1,onSearchQuery:function(){},onResults:function(){},onResultsOpen:function(){},onResultsClose:function(){},className:{active:"active",empty:"empty",focus:"focus",loading:"loading",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.",maxResults:"Results must be an array to use maxResults setting",method:"The method you called is not defined."},metadata:{cache:"cache",results:"results"},regExp:{escape:/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,beginsWith:"(?:s|^)"},selector:{prompt:".prompt",searchButton:".search.button",results:".results",category:".category",result:".result",title:".title, .name"},templates:{escape:function(e){var t=/[&<>"'`]/g,s=/[&<>"'`]/,r={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},n=function(e){return r[e]};return s.test(e)?e.replace(t,n):e},message:function(e,t){var s="";return e!==r&&t!==r&&(s+='
',s+="empty"==t?'
No Results
'+e+'
':'
'+e+"
",s+="
"),s},category:function(t){var s="",n=e.fn.search.settings.templates.escape;return t.results!==r?(e.each(t.results,function(t,a){a.results!==r&&a.results.length>0&&(s+='
'+a.name+"
",e.each(a.results,function(e,t){s+='
',t.url&&(s+=''),t.image!==r&&(t.image=n(t.image),s+='
'),s+='
',t.price!==r&&(t.price=n(t.price),s+='
'+t.price+"
"),t.title!==r&&(t.title=n(t.title),s+='
'+t.title+"
"),t.description!==r&&(s+='
'+t.description+"
"),s+="
"}),s+="
")}),t.action&&(s+=''+t.action.text+""),s):!1},standard:function(t){var s="";return t.results!==r?(e.each(t.results,function(e,t){s+=t.url?'':'',t.image!==r&&(s+='
'),s+='
',t.price!==r&&(s+='
'+t.price+"
"),t.title!==r&&(s+='
'+t.title+"
"),t.description!==r&&(s+='
'+t.description+"
"),s+="
",s+="
"}),t.action&&(s+=''+t.action.text+""),s):!1}}}}(jQuery,window,document); \ No newline at end of file diff --git a/dist/components/tab.js b/dist/components/tab.js index 0db4a88f6..2148d5899 100644 --- a/dist/components/tab.js +++ b/dist/components/tab.js @@ -331,7 +331,7 @@ $.fn.tab = function(parameters) { } else if(tabPath.search('/') == -1 && tabPath !== '') { // look for in page anchor - $anchor = $('#' + tabPath + ', a[name="' + tabPath + '"]'), + $anchor = $('#' + tabPath + ', a[name="' + tabPath + '"]'); currentPath = $anchor.closest('[data-tab]').data('tab'); $tab = module.get.tabElement(currentPath); // if anchor exists use parent tab @@ -359,9 +359,9 @@ $.fn.tab = function(parameters) { var $tab = module.get.tabElement(tabPath), apiSettings = { - dataType : 'html', - on : 'now', - onSuccess : function(response) { + dataType : 'html', + on : 'now', + onSuccess : function(response) { module.cache.add(fullTabPath, response); module.content.update(tabPath, response); if(tabPath == activeTabPath) { @@ -374,7 +374,9 @@ $.fn.tab = function(parameters) { settings.onTabInit.call($tab, tabPath, parameterArray, historyEvent); settings.onTabLoad.call($tab, tabPath, parameterArray, historyEvent); }, - urlData: { tab: fullTabPath } + urlData: { + tab: fullTabPath + } }, request = $tab.api('get request') || false, existingRequest = ( request && request.state() === 'pending' ), @@ -389,8 +391,13 @@ $.fn.tab = function(parameters) { module.activate.tab(tabPath); if(settings.cache && cachedContent) { - module.debug('Showing existing content', fullTabPath); - module.content.update(tabPath, cachedContent); + module.debug('Adding cached content', fullTabPath); + if(settings.evaluateScripts == 'once') { + module.content.update(tabPath, cachedContent, false); + } + else { + module.content.update(tabPath, cachedContent); + } settings.onTabLoad.call($tab, tabPath, parameterArray, historyEvent); } else if(existingRequest) { @@ -399,24 +406,35 @@ $.fn.tab = function(parameters) { } else if($.api !== undefined) { requestSettings = $.extend(true, { - headers: { 'X-Remote': true } + headers: { + 'X-Remote': true + } }, settings.apiSettings, apiSettings); module.debug('Retrieving remote content', fullTabPath, requestSettings); - $tab.api( requestSettings ); + $tab.api(requestSettings); } else { module.error(error.api); } }, - update: function(tabPath, html) { - module.debug('Updating html for', tabPath); + update: function(tabPath, html, evaluateScripts) { var - $tab = module.get.tabElement(tabPath) + $tab = module.get.tabElement(tabPath), + tab = $tab[0] ; - $tab - .html(html) + 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; + } } }, @@ -765,10 +783,12 @@ $.fn.tab.settings = { 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 + 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 - onTabInit : function(tabPath, parameterArray, historyEvent) {}, // called first time loaded - onTabLoad : function(tabPath, parameterArray, historyEvent) {}, // called on every load + onTabInit : function(tabPath, parameterArray, historyEvent) {}, // called first time loaded + onTabLoad : function(tabPath, parameterArray, historyEvent) {}, // called on every load templates : { determineTitle: function(tabArray) {} // returns page title for path diff --git a/dist/components/tab.min.js b/dist/components/tab.min.js index 125363fc4..dde8a1b4f 100644 --- a/dist/components/tab.min.js +++ b/dist/components/tab.min.js @@ -8,4 +8,4 @@ * http://opensource.org/licenses/MIT * */ -!function(e,t,a,n){"use strict";e.fn.tab=function(a){var i,o,r=e(e.isFunction(this)?t:this),s=e.isPlainObject(a)?e.extend(!0,{},e.fn.tab.settings,a):e.extend({},e.fn.tab.settings),c=r.selector||"",l=(new Date).getTime(),u=[],d=arguments[0],b="string"==typeof d,g=[].slice.call(arguments,1);return r.each(function(){var a,f,h,p,m,v=s.className,y=s.metadata,T=s.selector,x=s.error,A="."+s.namespace,P="module-"+s.namespace,C=e(this),E={},S=!0,w=0,j=this,D=C.data(P);i={initialize:function(){i.debug("Initializing tab menu item",C),i.determineTabs(),i.debug("Determining tabs",s.context,f),s.auto&&i.set.auto(),e.isWindow(j)||(i.debug("Attaching tab activation events to element",C),C.on("click"+A,i.event.click)),i.instantiate()},determineTabs:function(){var t;"parent"===s.context?(C.closest(T.ui).length>0?(t=C.closest(T.ui),i.verbose("Using closest UI element for determining parent",t)):t=C,a=t.parent(),i.verbose("Determined parent element for creating context",a)):s.context?(a=e(s.context),i.verbose("Using selector for tab context",s.context,a)):a=e("body"),s.childrenOnly?(f=a.children(T.tabs),i.debug("Searching tab context children for tabs",a,f)):(f=a.find(T.tabs),i.debug("Searching tab context for tabs",a,f))},initializeHistory:function(){if(s.history){if(i.debug("Initializing page state"),e.address===n)return i.error(x.state),!1;if("state"==s.historyType){if(i.debug("Using HTML5 to manage state"),s.path===!1)return i.error(x.path),!1;e.address.history(!0).state(s.path)}e.address.bind("change",i.event.history.change)}},instantiate:function(){i.verbose("Storing instance of module",i),D=i,C.data(P,i)},destroy:function(){i.debug("Destroying tabs",C),C.removeData(P).off(A)},event:{click:function(t){var a=e(this).data(y.tab);a!==n?(s.history?(i.verbose("Updating page state",t),e.address.value(a)):(i.verbose("Changing tab",t),i.changeTab(a)),t.preventDefault()):i.debug("No tab specified")},history:{change:function(t){var a=t.pathNames.join("/")||i.get.initialPath(),o=s.templates.determineTitle(a)||!1;i.performance.display(),i.debug("History change event",a,t),m=t,a!==n&&i.changeTab(a),o&&e.address.title(o)}}},refresh:function(){h&&(i.debug("Refreshing tab",h),i.changeTab(h))},cache:{read:function(e){return e!==n?E[e]:!1},add:function(e,t){e=e||h,i.debug("Adding cached content for",e),E[e]=t},remove:function(e){e=e||h,i.debug("Removing cached content for",e),delete E[e]}},set:{auto:function(){var t="string"==typeof s.path?s.path.replace(/\/$/,"")+"/{$tab}":"/{$tab}";i.verbose("Setting up automatic tab retrieval from server",t),e.isPlainObject(s.apiSettings)?s.apiSettings.url=t:s.apiSettings={url:t}},state:function(t){e.address.value(t)}},changeTab:function(n){var n="string"==typeof n?n.toLowerCase():n,o=t.history&&t.history.pushState,r=o&&s.ignoreFirstLoad&&S,c=s.auto||e.isPlainObject(s.apiSettings),l=c&&!r?i.utilities.pathToArray(n):i.get.defaultPathArray(n);n=i.utilities.arrayToPath(l),e.each(l,function(t,o){var u,d,b,g,f=l.slice(0,t+1),v=i.utilities.arrayToPath(f),y=i.is.tab(v),T=t+1==l.length,A=i.get.tabElement(v);if(i.verbose("Looking for tab",o),y){if(i.verbose("Tab was found",o),h=v,p=i.utilities.filterArray(l,f),T?g=!0:(d=l.slice(0,t+2),b=i.utilities.arrayToPath(d),g=!i.is.tab(b),g&&i.verbose("Tab parameters found",d)),g&&c)return r?(i.debug("Ignoring remote content on first tab load",v),S=!1,i.cache.add(n,A.html()),i.activate.all(v),s.onTabInit.call(A,v,p,m),s.onTabLoad.call(A,v,p,m)):(i.activate.navigation(v),i.content.fetch(v,n)),!1;i.debug("Opened local tab",v),i.activate.all(v),i.cache.read(v)||(i.cache.add(v,!0),i.debug("First time tab loaded calling tab init"),s.onTabInit.call(A,v,p,m)),s.onTabLoad.call(A,v,p,m)}else{if(-1!=n.search("/")||""===n)return i.error(x.missingTab,C,a,v),!1;if(u=e("#"+n+', a[name="'+n+'"]'),v=u.closest("[data-tab]").data("tab"),A=i.get.tabElement(v),u&&u.length>0&&v)return i.debug("No tab found, but deep anchor link present, opening parent tab"),i.activate.all(v),i.cache.read(v)||(i.cache.add(v,!0),i.debug("First time tab loaded calling tab init"),s.onTabInit.call(A,v,p,m)),!1}})},content:{fetch:function(t,a){var o,r,c=i.get.tabElement(t),l={dataType:"html",on:"now",onSuccess:function(e){i.cache.add(a,e),i.content.update(t,e),t==h?(i.debug("Content loaded",t),i.activate.tab(t)):i.debug("Content loaded in background",t),s.onTabInit.call(c,t,p,m),s.onTabLoad.call(c,t,p,m)},urlData:{tab:a}},u=c.api("get request")||!1,d=u&&"pending"===u.state();a=a||t,r=i.cache.read(a),i.activate.tab(t),s.cache&&r?(i.debug("Showing existing content",a),i.content.update(t,r),s.onTabLoad.call(c,t,p,m)):d?(i.debug("Content is already loading",a),c.addClass(v.loading)):e.api!==n?(o=e.extend(!0,{headers:{"X-Remote":!0}},s.apiSettings,l),i.debug("Retrieving remote content",a,o),c.api(o)):i.error(x.api)},update:function(e,t){i.debug("Updating html for",e);var a=i.get.tabElement(e);a.html(t)}},activate:{all:function(e){i.activate.tab(e),i.activate.navigation(e)},tab:function(e){var t=i.get.tabElement(e);i.verbose("Showing tab content for",t),t.addClass(v.active).siblings(f).removeClass(v.active+" "+v.loading)},navigation:function(e){var t=i.get.navElement(e);i.verbose("Activating tab navigation for",t,e),t.addClass(v.active).siblings(r).removeClass(v.active+" "+v.loading)}},deactivate:{all:function(){i.deactivate.navigation(),i.deactivate.tabs()},navigation:function(){r.removeClass(v.active)},tabs:function(){f.removeClass(v.active+" "+v.loading)}},is:{tab:function(e){return e!==n?i.get.tabElement(e).length>0:!1}},get:{initialPath:function(){return r.eq(0).data(y.tab)||f.eq(0).data(y.tab)},path:function(){return e.address.value()},defaultPathArray:function(e){return i.utilities.pathToArray(i.get.defaultPath(e))},defaultPath:function(e){var t=r.filter("[data-"+y.tab+'^="'+e+'/"]').eq(0),a=t.data(y.tab)||!1;if(a){if(i.debug("Found default tab",a),w0?t:a},tab:function(){return h}},utilities:{filterArray:function(t,a){return e.grep(t,function(t){return-1==e.inArray(t,a)})},last:function(t){return e.isArray(t)?t[t.length-1]:!1},pathToArray:function(e){return e===n&&(e=h),"string"==typeof e?e.split("/"):[e]},arrayToPath:function(t){return e.isArray(t)?t.join("/"):!1}},setting:function(t,a){if(i.debug("Changing setting",t,a),e.isPlainObject(t))e.extend(!0,s,t);else{if(a===n)return s[t];s[t]=a}},internal:function(t,a){if(e.isPlainObject(t))e.extend(!0,i,t);else{if(a===n)return i[t];i[t]=a}},debug:function(){s.debug&&(s.performance?i.performance.log(arguments):(i.debug=Function.prototype.bind.call(console.info,console,s.name+":"),i.debug.apply(console,arguments)))},verbose:function(){s.verbose&&s.debug&&(s.performance?i.performance.log(arguments):(i.verbose=Function.prototype.bind.call(console.info,console,s.name+":"),i.verbose.apply(console,arguments)))},error:function(){i.error=Function.prototype.bind.call(console.error,console,s.name+":"),i.error.apply(console,arguments)},performance:{log:function(e){var t,a,n;s.performance&&(t=(new Date).getTime(),n=l||t,a=t-n,l=t,u.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:j,"Execution Time":a})),clearTimeout(i.performance.timer),i.performance.timer=setTimeout(i.performance.display,500)},display:function(){var t=s.name+":",a=0;l=!1,clearTimeout(i.performance.timer),e.each(u,function(e,t){a+=t["Execution Time"]}),t+=" "+a+"ms",c&&(t+=" '"+c+"'"),(console.group!==n||console.table!==n)&&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,a,r){var s,c,l,u=D;return a=a||g,r=j||r,"string"==typeof t&&u!==n&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(a,o){var r=a!=s?o+t[a+1].charAt(0).toUpperCase()+t[a+1].slice(1):t;if(e.isPlainObject(u[r])&&a!=s)u=u[r];else{if(u[r]!==n)return c=u[r],!1;if(!e.isPlainObject(u[o])||a==s)return u[o]!==n?(c=u[o],!1):(i.error(x.method,t),!1);u=u[o]}})),e.isFunction(c)?l=c.apply(r,a):c!==n&&(l=c),e.isArray(o)?o.push(l):o!==n?o=[o,l]:l!==n&&(o=l),c}},b?(D===n&&i.initialize(),i.invoke(d)):(D!==n&&D.invoke("destroy"),i.initialize())}),i&&!b&&i.initializeHistory(),o!==n?o: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,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 "},metadata:{tab:"tab",loaded:"loaded",promise:"promise"},className:{loading:"loading",active:"active"},selector:{tabs:".ui.tab",ui:".ui"}}}(jQuery,window,document); \ No newline at end of file +!function(e,t,a,n){"use strict";e.fn.tab=function(a){var i,o,r=e(e.isFunction(this)?t:this),s=e.isPlainObject(a)?e.extend(!0,{},e.fn.tab.settings,a):e.extend({},e.fn.tab.settings),c=r.selector||"",l=(new Date).getTime(),u=[],d=arguments[0],b="string"==typeof d,g=[].slice.call(arguments,1);return r.each(function(){var a,f,p,h,m,v=s.className,y=s.metadata,T=s.selector,x=s.error,A="."+s.namespace,P="module-"+s.namespace,C=e(this),S={},E=!0,L=0,w=this,j=C.data(P);i={initialize:function(){i.debug("Initializing tab menu item",C),i.determineTabs(),i.debug("Determining tabs",s.context,f),s.auto&&i.set.auto(),e.isWindow(w)||(i.debug("Attaching tab activation events to element",C),C.on("click"+A,i.event.click)),i.instantiate()},determineTabs:function(){var t;"parent"===s.context?(C.closest(T.ui).length>0?(t=C.closest(T.ui),i.verbose("Using closest UI element for determining parent",t)):t=C,a=t.parent(),i.verbose("Determined parent element for creating context",a)):s.context?(a=e(s.context),i.verbose("Using selector for tab context",s.context,a)):a=e("body"),s.childrenOnly?(f=a.children(T.tabs),i.debug("Searching tab context children for tabs",a,f)):(f=a.find(T.tabs),i.debug("Searching tab context for tabs",a,f))},initializeHistory:function(){if(s.history){if(i.debug("Initializing page state"),e.address===n)return i.error(x.state),!1;if("state"==s.historyType){if(i.debug("Using HTML5 to manage state"),s.path===!1)return i.error(x.path),!1;e.address.history(!0).state(s.path)}e.address.bind("change",i.event.history.change)}},instantiate:function(){i.verbose("Storing instance of module",i),j=i,C.data(P,i)},destroy:function(){i.debug("Destroying tabs",C),C.removeData(P).off(A)},event:{click:function(t){var a=e(this).data(y.tab);a!==n?(s.history?(i.verbose("Updating page state",t),e.address.value(a)):(i.verbose("Changing tab",t),i.changeTab(a)),t.preventDefault()):i.debug("No tab specified")},history:{change:function(t){var a=t.pathNames.join("/")||i.get.initialPath(),o=s.templates.determineTitle(a)||!1;i.performance.display(),i.debug("History change event",a,t),m=t,a!==n&&i.changeTab(a),o&&e.address.title(o)}}},refresh:function(){p&&(i.debug("Refreshing tab",p),i.changeTab(p))},cache:{read:function(e){return e!==n?S[e]:!1},add:function(e,t){e=e||p,i.debug("Adding cached content for",e),S[e]=t},remove:function(e){e=e||p,i.debug("Removing cached content for",e),delete S[e]}},set:{auto:function(){var t="string"==typeof s.path?s.path.replace(/\/$/,"")+"/{$tab}":"/{$tab}";i.verbose("Setting up automatic tab retrieval from server",t),e.isPlainObject(s.apiSettings)?s.apiSettings.url=t:s.apiSettings={url:t}},state:function(t){e.address.value(t)}},changeTab:function(n){var n="string"==typeof n?n.toLowerCase():n,o=t.history&&t.history.pushState,r=o&&s.ignoreFirstLoad&&E,c=s.auto||e.isPlainObject(s.apiSettings),l=c&&!r?i.utilities.pathToArray(n):i.get.defaultPathArray(n);n=i.utilities.arrayToPath(l),e.each(l,function(t,o){var u,d,b,g,f=l.slice(0,t+1),v=i.utilities.arrayToPath(f),y=i.is.tab(v),T=t+1==l.length,A=i.get.tabElement(v);if(i.verbose("Looking for tab",o),y){if(i.verbose("Tab was found",o),p=v,h=i.utilities.filterArray(l,f),T?g=!0:(d=l.slice(0,t+2),b=i.utilities.arrayToPath(d),g=!i.is.tab(b),g&&i.verbose("Tab parameters found",d)),g&&c)return r?(i.debug("Ignoring remote content on first tab load",v),E=!1,i.cache.add(n,A.html()),i.activate.all(v),s.onTabInit.call(A,v,h,m),s.onTabLoad.call(A,v,h,m)):(i.activate.navigation(v),i.content.fetch(v,n)),!1;i.debug("Opened local tab",v),i.activate.all(v),i.cache.read(v)||(i.cache.add(v,!0),i.debug("First time tab loaded calling tab init"),s.onTabInit.call(A,v,h,m)),s.onTabLoad.call(A,v,h,m)}else{if(-1!=n.search("/")||""===n)return i.error(x.missingTab,C,a,v),!1;if(u=e("#"+n+', a[name="'+n+'"]'),v=u.closest("[data-tab]").data("tab"),A=i.get.tabElement(v),u&&u.length>0&&v)return i.debug("No tab found, but deep anchor link present, opening parent tab"),i.activate.all(v),i.cache.read(v)||(i.cache.add(v,!0),i.debug("First time tab loaded calling tab init"),s.onTabInit.call(A,v,h,m)),!1}})},content:{fetch:function(t,a){var o,r,c=i.get.tabElement(t),l={dataType:"html",on:"now",onSuccess:function(e){i.cache.add(a,e),i.content.update(t,e),t==p?(i.debug("Content loaded",t),i.activate.tab(t)):i.debug("Content loaded in background",t),s.onTabInit.call(c,t,h,m),s.onTabLoad.call(c,t,h,m)},urlData:{tab:a}},u=c.api("get request")||!1,d=u&&"pending"===u.state();a=a||t,r=i.cache.read(a),i.activate.tab(t),s.cache&&r?(i.debug("Adding cached content",a),"once"==s.evaluateScripts?i.content.update(t,r,!1):i.content.update(t,r),s.onTabLoad.call(c,t,h,m)):d?(i.debug("Content is already loading",a),c.addClass(v.loading)):e.api!==n?(o=e.extend(!0,{headers:{"X-Remote":!0}},s.apiSettings,l),i.debug("Retrieving remote content",a,o),c.api(o)):i.error(x.api)},update:function(e,t,a){var o=i.get.tabElement(e),r=o[0];a=a!==n?a:s.evaluateScripts,a?(i.debug("Updating HTML and evaluating inline scripts",e,t),o.html(t)):(i.debug("Updating HTML",e,t),r.innerHTML=t)}},activate:{all:function(e){i.activate.tab(e),i.activate.navigation(e)},tab:function(e){var t=i.get.tabElement(e);i.verbose("Showing tab content for",t),t.addClass(v.active).siblings(f).removeClass(v.active+" "+v.loading)},navigation:function(e){var t=i.get.navElement(e);i.verbose("Activating tab navigation for",t,e),t.addClass(v.active).siblings(r).removeClass(v.active+" "+v.loading)}},deactivate:{all:function(){i.deactivate.navigation(),i.deactivate.tabs()},navigation:function(){r.removeClass(v.active)},tabs:function(){f.removeClass(v.active+" "+v.loading)}},is:{tab:function(e){return e!==n?i.get.tabElement(e).length>0:!1}},get:{initialPath:function(){return r.eq(0).data(y.tab)||f.eq(0).data(y.tab)},path:function(){return e.address.value()},defaultPathArray:function(e){return i.utilities.pathToArray(i.get.defaultPath(e))},defaultPath:function(e){var t=r.filter("[data-"+y.tab+'^="'+e+'/"]').eq(0),a=t.data(y.tab)||!1;if(a){if(i.debug("Found default tab",a),L0?t:a},tab:function(){return p}},utilities:{filterArray:function(t,a){return e.grep(t,function(t){return-1==e.inArray(t,a)})},last:function(t){return e.isArray(t)?t[t.length-1]:!1},pathToArray:function(e){return e===n&&(e=p),"string"==typeof e?e.split("/"):[e]},arrayToPath:function(t){return e.isArray(t)?t.join("/"):!1}},setting:function(t,a){if(i.debug("Changing setting",t,a),e.isPlainObject(t))e.extend(!0,s,t);else{if(a===n)return s[t];s[t]=a}},internal:function(t,a){if(e.isPlainObject(t))e.extend(!0,i,t);else{if(a===n)return i[t];i[t]=a}},debug:function(){s.debug&&(s.performance?i.performance.log(arguments):(i.debug=Function.prototype.bind.call(console.info,console,s.name+":"),i.debug.apply(console,arguments)))},verbose:function(){s.verbose&&s.debug&&(s.performance?i.performance.log(arguments):(i.verbose=Function.prototype.bind.call(console.info,console,s.name+":"),i.verbose.apply(console,arguments)))},error:function(){i.error=Function.prototype.bind.call(console.error,console,s.name+":"),i.error.apply(console,arguments)},performance:{log:function(e){var t,a,n;s.performance&&(t=(new Date).getTime(),n=l||t,a=t-n,l=t,u.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:w,"Execution Time":a})),clearTimeout(i.performance.timer),i.performance.timer=setTimeout(i.performance.display,500)},display:function(){var t=s.name+":",a=0;l=!1,clearTimeout(i.performance.timer),e.each(u,function(e,t){a+=t["Execution Time"]}),t+=" "+a+"ms",c&&(t+=" '"+c+"'"),(console.group!==n||console.table!==n)&&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,a,r){var s,c,l,u=j;return a=a||g,r=w||r,"string"==typeof t&&u!==n&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(a,o){var r=a!=s?o+t[a+1].charAt(0).toUpperCase()+t[a+1].slice(1):t;if(e.isPlainObject(u[r])&&a!=s)u=u[r];else{if(u[r]!==n)return c=u[r],!1;if(!e.isPlainObject(u[o])||a==s)return u[o]!==n?(c=u[o],!1):(i.error(x.method,t),!1);u=u[o]}})),e.isFunction(c)?l=c.apply(r,a):c!==n&&(l=c),e.isArray(o)?o.push(l):o!==n?o=[o,l]:l!==n&&(o=l),c}},b?(j===n&&i.initialize(),i.invoke(d)):(j!==n&&j.invoke("destroy"),i.initialize())}),i&&!b&&i.initializeHistory(),o!==n?o: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",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 "},metadata:{tab:"tab",loaded:"loaded",promise:"promise"},className:{loading:"loading",active:"active"},selector:{tabs:".ui.tab",ui:".ui"}}}(jQuery,window,document); \ No newline at end of file diff --git a/dist/components/transition.js b/dist/components/transition.js index 4a6c37dd8..a42118356 100644 --- a/dist/components/transition.js +++ b/dist/components/transition.js @@ -437,7 +437,7 @@ $.fn.transition = function() { module.remove.completeCallback(); }, queueCallback: function() { - $module.off('.queue' + eventNamespace) + $module.off('.queue' + eventNamespace); }, completeCallback: function() { $module.off('.complete' + eventNamespace); @@ -769,7 +769,7 @@ $.fn.transition = function() { clear: { queue: function() { - module.debug('Clearing animation queue') + module.debug('Clearing animation queue'); module.remove.queueCallback(); } }, diff --git a/dist/semantic.js b/dist/semantic.js index e60a3808e..b7c6fb262 100644 --- a/dist/semantic.js +++ b/dist/semantic.js @@ -4194,7 +4194,6 @@ $.fn.dropdown = function(parameters) { $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); @@ -4324,12 +4323,12 @@ $.fn.dropdown = function(parameters) { labelCount = $label.length, hasActiveLabel = ($activeLabel.length > 0), hasMultipleActive = ($activeLabel.length > 1), - isFirstLabel = (labelIndex == 0), + 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), + caretAtStart = (isFocusedOnSearch && module.get.caretPosition() === 0), $nextLabel ; if(settings.allowAdditions && isFocusedOnSearch && (pressedKey == keys.delimiter)) { @@ -4345,7 +4344,7 @@ $.fn.dropdown = function(parameters) { else if(hasActiveLabel) { if(!event.shiftKey) { module.verbose('Selecting previous label'); - $label.removeClass(className.active) + $label.removeClass(className.active); } else { module.verbose('Adding previous label to selection'); @@ -4371,7 +4370,7 @@ $.fn.dropdown = function(parameters) { if(hasActiveLabel) { if(!event.shiftKey) { module.verbose('Selecting next label'); - $label.removeClass(className.active) + $label.removeClass(className.active); } else { module.verbose('Adding next label to selection'); @@ -4613,7 +4612,7 @@ $.fn.dropdown = function(parameters) { ? callback : function(){} ; - if($target.closest($menu).length == 0) { + if($target.closest($menu).length === 0) { module.verbose('Triggering event', callback); callback(); return true; @@ -4718,7 +4717,7 @@ $.fn.dropdown = function(parameters) { var value = module.get.value() ; - if(value == '') { + if(value === '') { return ''; } return (!$input.is('select') && module.is.multiple()) @@ -4949,10 +4948,10 @@ $.fn.dropdown = function(parameters) { : '', hasSearchValue = (typeof searchValue === 'string' && searchValue.length > 0), searchWidth = (searchValue.length * settings.glyphWidth) + 'em', - valueIsSet = $input.val() != '' + valueIsSet = $input.val() !== '' ; if(isMultiple && hasSearchValue) { - module.verbose('Adjusting input width', searchWidth, settings.glyphWidth) + module.verbose('Adjusting input width', searchWidth, settings.glyphWidth); $search.css('width', searchWidth); } if(hasSearchValue || (isSearchMultiple && valueIsSet)) { @@ -5154,7 +5153,7 @@ $.fn.dropdown = function(parameters) { } else { module.set.value(selectedValue, selectedText, $selected); - module.set.text(module.add.variables(message.count)) + module.set.text(module.add.variables(message.count)); $selected.addClass(className.active); } } @@ -5190,7 +5189,7 @@ $.fn.dropdown = function(parameters) { if(settings.label.variation) { $label.addClass(settings.label.variation); } - if(shouldAnimate == true) { + if(shouldAnimate === true) { module.debug('Animating in label', $label); $label .addClass(className.hidden) @@ -5297,7 +5296,7 @@ $.fn.dropdown = function(parameters) { module.remove.label(selectedValue); } else { - module.set.text(module.add.variables(message.count)) + module.set.text(module.add.variables(message.count)); } } $selectedItem @@ -5348,7 +5347,7 @@ $.fn.dropdown = function(parameters) { }, labels: function($activeLabels) { $activeLabels = $activeLabels || $module.find(selector.label).filter('.' + className.active); - module.verbose('Removing active labels', $activeLabels); + module.verbose('Removing active label selections', $activeLabels); $activeLabels .each(function(){ module.remove.selected($(this).data('value')); @@ -5451,7 +5450,7 @@ $.fn.dropdown = function(parameters) { return $module.hasClass(className.search); }, searchSelection: function() { - return ( module.has.search() && $search.closest(selector.menu).length == 0 ); + return ( module.has.search() && $search.closest(selector.menu).length === 0 ); }, selection: function() { return $module.hasClass(className.selection); @@ -5869,7 +5868,7 @@ $.fn.dropdown.settings = { /* Callbacks */ onLabelSelect : function($selectedLabels){}, - onNoResults : function(searchTerm) { return true }, + onNoResults : function(searchTerm) { return true; }, onChange : function(value, text, $selected){}, onShow : function(){}, onHide : function(){}, @@ -6103,7 +6102,7 @@ $.fn.modal = function(parameters) { ; if(settings.inverted) { dimmerSettings.variation = (dimmerSettings.variation !== undefined) - ? dimmer.settings.variation + ' inverted' + ? dimmerSettings.variation + ' inverted' : 'inverted' ; } @@ -7972,7 +7971,7 @@ $.fn.popup = function(parameters) { position: function(position, arrowOffset) { // exit conditions - if($target.length == 0 || $popup.length == 0) { + if($target.length === 0 || $popup.length === 0) { module.error(error.notFound); return; } @@ -8013,7 +8012,7 @@ $.fn.popup = function(parameters) { position = position || $module.data(metadata.position) || settings.position; arrowOffset = arrowOffset || $module.data(metadata.offset) || settings.offset; - if(target.top == 0 && target.left == 0) { + if(target.top === 0 && target.left === 0) { module.debug('Popup target is hidden, no action taken'); return false; } @@ -10444,6 +10443,9 @@ $.fn.search = function(parameters) { clear: { cache: function(value) { + var + cache = $module.data(metadata.cache) + ; if(!value) { module.debug('Clearing cache', value); $module.removeData(metadata.cache); @@ -14140,7 +14142,7 @@ $.fn.tab = function(parameters) { } else if(tabPath.search('/') == -1 && tabPath !== '') { // look for in page anchor - $anchor = $('#' + tabPath + ', a[name="' + tabPath + '"]'), + $anchor = $('#' + tabPath + ', a[name="' + tabPath + '"]'); currentPath = $anchor.closest('[data-tab]').data('tab'); $tab = module.get.tabElement(currentPath); // if anchor exists use parent tab @@ -14168,9 +14170,9 @@ $.fn.tab = function(parameters) { var $tab = module.get.tabElement(tabPath), apiSettings = { - dataType : 'html', - on : 'now', - onSuccess : function(response) { + dataType : 'html', + on : 'now', + onSuccess : function(response) { module.cache.add(fullTabPath, response); module.content.update(tabPath, response); if(tabPath == activeTabPath) { @@ -14183,7 +14185,9 @@ $.fn.tab = function(parameters) { settings.onTabInit.call($tab, tabPath, parameterArray, historyEvent); settings.onTabLoad.call($tab, tabPath, parameterArray, historyEvent); }, - urlData: { tab: fullTabPath } + urlData: { + tab: fullTabPath + } }, request = $tab.api('get request') || false, existingRequest = ( request && request.state() === 'pending' ), @@ -14198,8 +14202,13 @@ $.fn.tab = function(parameters) { module.activate.tab(tabPath); if(settings.cache && cachedContent) { - module.debug('Showing existing content', fullTabPath); - module.content.update(tabPath, cachedContent); + module.debug('Adding cached content', fullTabPath); + if(settings.evaluateScripts == 'once') { + module.content.update(tabPath, cachedContent, false); + } + else { + module.content.update(tabPath, cachedContent); + } settings.onTabLoad.call($tab, tabPath, parameterArray, historyEvent); } else if(existingRequest) { @@ -14208,24 +14217,35 @@ $.fn.tab = function(parameters) { } else if($.api !== undefined) { requestSettings = $.extend(true, { - headers: { 'X-Remote': true } + headers: { + 'X-Remote': true + } }, settings.apiSettings, apiSettings); module.debug('Retrieving remote content', fullTabPath, requestSettings); - $tab.api( requestSettings ); + $tab.api(requestSettings); } else { module.error(error.api); } }, - update: function(tabPath, html) { - module.debug('Updating html for', tabPath); + update: function(tabPath, html, evaluateScripts) { var - $tab = module.get.tabElement(tabPath) + $tab = module.get.tabElement(tabPath), + tab = $tab[0] ; - $tab - .html(html) + 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; + } } }, @@ -14574,10 +14594,12 @@ $.fn.tab.settings = { 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 + 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 - onTabInit : function(tabPath, parameterArray, historyEvent) {}, // called first time loaded - onTabLoad : function(tabPath, parameterArray, historyEvent) {}, // called on every load + onTabInit : function(tabPath, parameterArray, historyEvent) {}, // called first time loaded + onTabLoad : function(tabPath, parameterArray, historyEvent) {}, // called on every load templates : { determineTitle: function(tabArray) {} // returns page title for path @@ -15051,7 +15073,7 @@ $.fn.transition = function() { module.remove.completeCallback(); }, queueCallback: function() { - $module.off('.queue' + eventNamespace) + $module.off('.queue' + eventNamespace); }, completeCallback: function() { $module.off('.complete' + eventNamespace); @@ -15383,7 +15405,7 @@ $.fn.transition = function() { clear: { queue: function() { - module.debug('Clearing animation queue') + module.debug('Clearing animation queue'); module.remove.queueCallback(); } }, diff --git a/dist/semantic.min.js b/dist/semantic.min.js index 34650cc74..d99db4092 100644 --- a/dist/semantic.min.js +++ b/dist/semantic.min.js @@ -9,10 +9,10 @@ * */ !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, 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){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","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){"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,w,C,k,T,S,A,C,P,E,R,F,O=e(this),D=this,z=[],q=!1;F={initialize:function(){F.get.settings(),d?F.invoke(l):(F.verbose("Initializing form validation",O,x),F.bindEvents(),F.set.defaults(),F.instantiate())},instantiate:function(){F.verbose("Storing instance of module",F),R=F,O.data(P,F)},destroy:function(){F.verbose("Destroying previous module",R),F.removeEvents(),O.removeData(P)},refresh:function(){F.verbose("Refreshing selector cache"),f=O.find(T.field),g=O.find(T.group),p=O.find(T.message),v=O.find(T.prompt),h=O.find(T.submit),b=O.find(T.clear),y=O.find(T.reset)},submit:function(){F.verbose("Submitting form",O),O.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"),O.on("submit"+E,F.validate.form).on("blur"+E,T.field,F.event.field.blur).on("click"+E,T.submit,F.submit).on("click"+E,T.reset,F.reset).on("click"+E,T.clear,F.clear),x.keyboardShortcuts&&O.on("keydown"+E,T.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(T.prompt),a=t.data(k.defaultValue)||"",r=n.is(T.uiCheckbox),s=n.is(T.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?n.checkbox("uncheck"):(F.verbose("Resetting field value",t,a),t.val(""))})},reset:function(){f.each(function(){var t=e(this),n=t.parent(),i=t.closest(g),o=i.find(T.prompt),a=t.data(k.defaultValue)||"",r=n.is(T.uiCheckbox),s=n.is(T.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("restore defaults")):r?(F.verbose("Resetting checkbox value",n,a),n.checkbox(a===!0?"check":"uncheck")):(F.verbose("Resetting field value",t,a),t.val(a))})},removeEvents:function(){O.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(T.input)&&n.not(T.checkbox).length>0&&(h.addClass(S.pressed),q||(n.one("keyup"+E,F.event.field.keyup),F.submit(),F.debug("Enter pressed on input submitting form")),q=!0)},keyup:function(){q=!1,h.removeClass(S.pressed)},blur:function(){var t=e(this),n=t.closest(g);n.hasClass(S.error)?(F.debug("Revalidating field",t,F.get.validation(t)),F.validate.field(F.get.validation(t))):("blur"==x.on||"change"==x.on)&&F.validate.field(F.get.validation(t))},change:function(){var t=e(this),n=t.closest(g);("change"==x.on||n.hasClass(S.error)&&x.revalidate)&&(clearTimeout(F.timer),F.timer=setTimeout(function(){F.debug("Revalidating field",t,F.get.validation(t)),F.validate.field(F.get.validation(t))},x.delay))}}},get:{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"},settings:function(){if(e.isPlainObject(t)){var n=Object.keys(t),o=n.length>0?t[n[0]].identifier!==i:!1;o?(x=e.extend(!0,{},e.fn.form.settings,u),w=e.extend({},e.fn.form.settings.defaults,t),F.error(x.error.oldSyntax,D),F.verbose("Extending settings from legacy parameters",w,x)):(x=e.extend(!0,{},e.fn.form.settings,t),w=e.extend({},e.fn.form.settings.defaults,x.fields),F.verbose("Extending settings",w,x))}else x=e.fn.form.settings,w=e.fn.form.settings.defaults,F.verbose("Using default form validation",w,x);C=x.namespace,k=x.metadata,T=x.selector,S=x.className,A=x.error,P="module-"+C,E="."+C,R=O.data(P),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-"+k.validate+'="'+t+'"]').length>0?f.filter("[data-"+k.validate+'="'+t+'"]'):e("")},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;return e.each(w,function(e,i){F.get.field(i.identifier).get(0)==t.get(0)&&(n=i)}),n||!1},value:function(e){var t,n=[];return n.push(e),t=F.get.values.call(D,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(T.checkbox),c=o.is(T.radio),l=-1!==a.indexOf("[]"),u=s?o.is(":checked"):!1;if(a)if(l)if(a=a.replace("[]",""),i[a]||(i[a]=[]),s){if(!u)return F.debug("Omitted unchecked checkbox",o),!0;i[a].push(r)}else i[a].push(r);else if(c)u&&(i[a]=r);else if(s){if(!u)return F.debug("Omitted unchecked checkbox",o),!0;i[a]=!0}else i[a]=r}),i}},has:{field:function(e){return F.verbose("Checking for existence of a field with identifier",e),f.filter("#"+e).length>0?!0:f.filter('[name="'+e+'"]').length>0?!0:f.filter("[data-"+k.validate+'="'+e+'"]').length>0?!0:!1}},add:{prompt:function(t,n){var o=F.get.field(t),a=o.closest(g),r=a.children(T.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&&O.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),p.html(x.templates.error(e))}},remove:{prompt:function(t){var n=F.get.field(t.identifier),o=n.closest(g),a=o.children(T.prompt);o.removeClass(S.error),x.inline&&a.is(":visible")&&(F.verbose("Removing prompt for field",t),x.transition&&e.fn.transition!==i&&O.transition("is supported")?a.transition(x.transition+" out",x.duration,function(){a.remove()}):a.fadeOut(x.duration,function(){a.remove()}))}},set:{success:function(){O.removeClass(S.error).addClass(S.success)},defaults:function(){f.each(function(){var t=e(this),n=t.filter(T.checkbox).length>0,i=n?t.is(":checked"):t.val();t.data(k.defaultValue,i)})},error:function(){O.removeClass(S.success).addClass(S.error)},value:function(e,t){var n={};return n[e]=t,F.set.values.call(D,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(T.uiCheckbox),c=a.is(T.uiDropdown),l=o.is(T.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(T.uiCheckbox).checkbox("check")):s?(F.verbose("Setting checkbox value",n,a),a.checkbox(n===!0?"check":"uncheck")):c?(F.verbose("Setting dropdown value",n,a),a.dropdown("set selected",n)):(F.verbose("Setting field value",n,o),o.val(n)))}),F.validate.form())}},validate:{form:function(t){var n=!0;return q?!1:(z=[],e.each(w,function(e,t){F.validate.field(t)||(n=!1)}),n?(F.debug("Form has no validation errors, submitting"),F.set.success(),x.onSuccess.call(D,t)):(F.debug("Form has errors"),F.set.error(),x.inline||F.add.errors(z),O.data("moduleApi")!==i&&t.stopImmediatePropagation(),x.onFailure.call(D,z)))},field:function(t){var n=F.get.field(t.identifier),o=!0,a=[];return n.prop("disabled")?(F.debug("Field is disabled. Skipping",t.identifier),o=!0):t.optional&&""===e.trim(n.val())?(F.debug("Field is optional and empty. Skipping",t.identifier),o=!0):t.rules!==i&&e.each(t.rules,function(e,n){F.has.field(t.identifier)&&!F.validate.rule(t,n)&&(F.debug("Field is invalid",t.identifier,n.type),a.push(n.prompt),o=!1)}),o?(F.remove.prompt(t,a),x.onValid.call(n),!0):(z=z.concat(a),F.add.prompt(t.identifier,a),x.onInvalid.call(n,a),!1)},rule:function(t,n){var i,o,a,r=F.get.field(t.identifier),s=n.type,c=r.val(),l=s.match(x.regExp.bracket),u=!0;if(c=e.trim(r.val()+""),l){if(o=""+l[1],a=s.replace(l[0],""),i=x.rules[a],!e.isFunction(i))return void F.error(A.noRule,a);u=i.call(r,c,o)}else{if(i=x.rules[s],!e.isFunction(i))return void F.error(A.noRule,s);u=i.call(r,c)}return u}},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:D,"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=R;return n=n||m,a=D||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,escape:/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,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])?",integer:/^\-?\d+$/,flags:/^\/(.*)\/(.*)?/,url:/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/i},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:{oldSyntax:"Starting in 2.0 forms now only take a single settings object. Validation settings converted to new syntax automatically.",noRule:"There is no rule matching the one you specified",method:"The method you called is not defined."},templates:{error:function(t){var n='
    ';return e.each(t,function(e,t){n+="
  • "+t+"
  • "}),n+="
",e(n)},prompt:function(t){return e("
").addClass("ui red pointing prompt label").html(t[0])}},rules:{checked:function(){return e(this).filter(":checked").length>0},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))},email:function(t){var n=new RegExp(e.fn.form.settings.regExp.email,"i");return n.test(t)},empty:function(t){return!(t===i||""===t||e.isArray(t)&&0==t.length)},integer:function(t,n){var o,a,r,s=e.fn.form.settings.regExp.integer;return n===i||""===n||".."===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)},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},length:function(e,t){return e!==i?e.length>=t:!1},match:function(t,n){var o,a=e(this);return a.find('[data-validate="'+n+'"]').length>0?o=a.find('[data-validate="'+n+'"]').val():a.find("#"+n).length>0?o=a.find("#"+n).val():a.find('[name="'+n+'"]').length>0&&(o=a.find('[name="'+n+'"]').val()),o!==i?t.toString()==o.toString():!1},maxCount:function(t,n){return t=t.split(","),e.isArray(t)&&t.length<=n},exactCount:function(t,n){return t=t.split(","),e.isArray(t)&&t.length==n},minCount:function(t,n){return t=t.split(","),e.isArray(t)&&t.length>=n},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))},maxLength:function(e,t){return e!==i?e.length<=t:!1},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},url:function(t){return e.fn.form.settings.regExp.url.match(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||"",w=e(this),C=w.find(v.title),k=w.find(v.content),T=this,S=w.data(y);m={initialize:function(){m.debug("Initializing",w),m.bind.events(),m.observeChanges(),m.instantiate()},instantiate:function(){S=m,w.data(y,m)},destroy:function(){m.debug("Destroying previous instance",w),w.off(b).removeData(y)},refresh:function(){C=w.find(v.title),k=w.find(v.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))},bind:{events:function(){m.debug("Binding delegated events"),w.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?C.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?C.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;s&&(m.debug("Opening accordion content",n),f.onOpening.call(o),f.exclusive&&m.closeOthers.call(n),n.addClass(g.active),o.addClass(g.animating),f.animateChildren&&(e.fn.transition!==i&&w.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).animate({opacity:1},f.duration,m.resetOpacity)),o.stop(!0).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?C.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.addClass(g.animating),f.animateChildren&&(e.fn.transition!==i&&w.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).animate({opacity:0},f.duration,m.resetOpacity)),o.stop(!0).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?C.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),f.animateChildren&&(e.fn.transition!==i&&w.transition("is supported")?a.children().transition({animation:"fade out",useFailSafe:!0,debug:f.debug,verbose:f.verbose,duration:f.duration}):a.children().stop().animate({opacity:0},f.duration,m.resetOpacity)),a.stop().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:T,"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=S;return n=n||u,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(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?(S===i&&m.initialize(),m.invoke(c)):(S!==i&&S.invoke("destroy"),m.initialize())}),o!==i?o:this},e.fn.accordion.settings={name:"Accordion",namespace:"accordion",debug:!1,verbose:!1,performance:!0,exclusive:!0,collapsible:!0,closeNested:!1,animateChildren:!0,duration:350,easing:"easeOutQuad",on:"click",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(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=e.extend(!0,{},e.fn.checkbox.settings,n),g=f.className,p=f.namespace,v=f.selector,h=f.error,b="."+p,y="module-"+p,x=e(this),w=e(this).find(v.label),C=e(this).find(v.input),k=x.data(y),T=this;m={initialize:function(){m.verbose("Initializing checkbox",f),m.create.label(),m.add.events(),m.setup(),m.observeChanges(),m.instantiate()},instantiate:function(){m.verbose("Storing instance of module",m),k=m,x.data(y,m)},destroy:function(){m.verbose("Destroying module"),m.remove.events(),x.removeData(y)},setup:function(){m.is.checked()?(m.debug("Setting initial value to checked"),m.set.checked(),f.fireOnInit&&f.onChecked.call(C.get())):(m.debug("Setting initial value to unchecked"),m.remove.checked(),f.fireOnInit&&f.onUnchecked.call(C.get()))},refresh:function(){w=x.find(v.label),C=x.find(v.input)},observeChanges:function(){"MutationObserver"in t&&(a=new MutationObserver(function(){m.debug("DOM tree modified, updating selector cache"),m.refresh()}),a.observe(T,{childList:!0,subtree:!0}),m.debug("Setting up mutation observer",a))},attachEvents:function(t,n){var i=e(t);n=e.isFunction(m[n])?m[n]:m.toggle,i.length>0?(m.debug("Attaching checkbox events to element",t,n),i.on("click"+b,n)):m.error(h.notFound)},event:{keydown:function(e){var t=e.which,n={enter:13,space:32,escape:27};t==n.escape&&(m.verbose("Escape key pressed blurring field"),x.blur()),e.ctrlKey||t!=n.enter&&t!=n.space||(m.verbose("Enter key pressed, toggling checkbox"),m.toggle.call(this),e.preventDefault())}},get:{radios:function(){return e('input[name="'+m.get.name()+'"]').closest(v.checkbox)},name:function(){return C.attr("name")}},is:{radio:function(){return C.hasClass(g.radio)||"radio"==C.attr("type")},checked:function(){return C.prop("checked")!==i&&C.prop("checked")},unchecked:function(){return!m.is.checked()}},can:{change:function(){return!(x.hasClass(g.disabled)||x.hasClass(g.readOnly)||C.prop("disabled"))},uncheck:function(){return"boolean"==typeof f.uncheckable?f.uncheckable:!m.is.radio()}},set:{checked:function(){var e;m.is.radio()&&(e=m.get.radios(),m.debug("Unchecking other radios",e),e.removeClass(g.checked)),x.addClass(g.checked)},tab:function(){C.attr("tabindex")===i&&C.attr("tabindex",0)}},create:{label:function(){C.prevAll(v.label).length>0?(C.prev(v.label).detach().insertAfter(C),m.debug("Moving existing label",w)):m.has.label()||(w=e("