diff --git a/semantic/dist/components/api.js b/semantic/dist/components/api.js index 97a24b6..a757d1f 100644 --- a/semantic/dist/components/api.js +++ b/semantic/dist/components/api.js @@ -1,5 +1,5 @@ /*! - * # Semantic UI 2.2.13 - API + * # Semantic UI 2.5.0 - API * http://github.com/semantic-org/semantic-ui/ * * @@ -10,7 +10,7 @@ ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; var window = (typeof window != 'undefined' && window.Math == Math) diff --git a/semantic/dist/components/api.min.js b/semantic/dist/components/api.min.js index bc1ce08..56256ca 100644 --- a/semantic/dist/components/api.min.js +++ b/semantic/dist/components/api.min.js @@ -1 +1 @@ -!function(j,O,e,w){"use strict";O=void 0!==O&&O.Math==Math?O:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();j.api=j.fn.api=function(q){var R,e=j.isFunction(this)?j(O):j(this),x=e.selector||"",S=(new Date).getTime(),A=[],k=q,T="string"==typeof k,P=[].slice.call(arguments,1);return e.each(function(){var s,i,r,e,a,u,c=j.isPlainObject(q)?j.extend(!0,{},j.fn.api.settings,q):j.extend({},j.fn.api.settings),t=c.namespace,n=c.metadata,o=c.selector,d=c.error,l=c.className,g="."+t,f="module-"+t,p=j(this),m=p.closest(o.form),b=c.stateContext?j(c.stateContext):p,v=this,h=b[0],y=p.data(f);u={initialize:function(){T||u.bind.events(),u.instantiate()},instantiate:function(){u.verbose("Storing instance of module",u),y=u,p.data(f,y)},destroy:function(){u.verbose("Destroying previous module for",v),p.removeData(f).off(g)},bind:{events:function(){var e=u.get.event();e?(u.verbose("Attaching API events to element",e),p.on(e+g,u.event.trigger)):"now"==c.on&&(u.debug("Querying API endpoint immediately"),u.query())}},decode:{json:function(e){if(e!==w&&"string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}},read:{cachedResponse:function(e){var t;if(O.Storage!==w)return t=sessionStorage.getItem(e),u.debug("Using cached response",e,t),t=u.decode.json(t);u.error(d.noStorage)}},write:{cachedResponse:function(e,t){t&&""===t?u.debug("Response empty, not caching",t):O.Storage!==w?(j.isPlainObject(t)&&(t=JSON.stringify(t)),sessionStorage.setItem(e,t),u.verbose("Storing cached response for url",e,t)):u.error(d.noStorage)}},query:function(){if(u.is.disabled())u.debug("Element is disabled API request aborted");else{if(u.is.loading()){if(!c.interruptRequests)return void u.debug("Cancelling request, previous request is still pending");u.debug("Interrupting previous request"),u.abort()}if(c.defaultData&&j.extend(!0,c.urlData,u.get.defaultData()),c.serializeForm&&(c.data=u.add.formData(c.data)),!1===(i=u.get.settings()))return u.cancelled=!0,void u.error(d.beforeSend);if(u.cancelled=!1,(r=u.get.templatedURL())||u.is.mocked()){if((r=u.add.urlData(r))||u.is.mocked()){if(i.url=c.base+r,s=j.extend(!0,{},c,{type:c.method||c.type,data:e,url:c.base+r,beforeSend:c.beforeXHR,success:function(){},failure:function(){},complete:function(){}}),u.debug("Querying URL",s.url),u.verbose("Using AJAX settings",s),"local"===c.cache&&u.read.cachedResponse(r))return u.debug("Response returned from local cache"),u.request=u.create.request(),void u.request.resolveWith(h,[u.read.cachedResponse(r)]);c.throttle?c.throttleFirstRequest||u.timer?(u.debug("Throttling request",c.throttle),clearTimeout(u.timer),u.timer=setTimeout(function(){u.timer&&delete u.timer,u.debug("Sending throttled request",e,s.method),u.send.request()},c.throttle)):(u.debug("Sending request",e,s.method),u.send.request(),u.timer=setTimeout(function(){},c.throttle)):(u.debug("Sending request",e,s.method),u.send.request())}}else u.error(d.missingURL)}},should:{removeError:function(){return!0===c.hideError||"auto"===c.hideError&&!u.is.form()}},is:{disabled:function(){return 0 adjusting invoked element"),d=d.closest(o.checkbox),r.refresh())}},setup:function(){r.set.initialLoad(),r.is.indeterminate()?(r.debug("Initial value is indeterminate"),r.indeterminate()):r.is.checked()?(r.debug("Initial value is checked"),r.check()):(r.debug("Initial value is unchecked"),r.uncheck()),r.remove.initialLoad()},refresh:function(){s=d.children(o.label),u=d.children(o.input),b=u[0]},hide:{input:function(){r.verbose("Modifying z-index to be unselectable"),u.addClass(n.hidden)}},show:{input:function(){r.verbose("Modifying z-index to be selectable"),u.removeClass(n.hidden)}},observeChanges:function(){"MutationObserver"in S&&((e=new MutationObserver(function(e){r.debug("DOM tree modified, updating selector cache"),r.refresh()})).observe(p,{childList:!0,subtree:!0}),r.debug("Setting up mutation observer",e))},attachEvents:function(e,n){var t=D(e);n=D.isFunction(r[n])?r[n]:r.toggle,0").insertAfter(u),r.debug("Creating label",s))}},has:{label:function(){return 0 adjusting invoked element"),l=l.closest(o.checkbox),p.refresh())}},setup:function(){p.set.initialLoad(),p.is.indeterminate()?(p.debug("Initial value is indeterminate"),p.indeterminate()):p.is.checked()?(p.debug("Initial value is checked"),p.check()):(p.debug("Initial value is unchecked"),p.uncheck()),p.remove.initialLoad()},refresh:function(){d=l.children(o.label),s=l.children(o.input),u=s[0]},hide:{input:function(){p.verbose("Modifying z-index to be unselectable"),s.addClass(n.hidden)}},show:{input:function(){p.verbose("Modifying z-index to be selectable"),s.removeClass(n.hidden)}},observeChanges:function(){"MutationObserver"in S&&((e=new MutationObserver(function(e){p.debug("DOM tree modified, updating selector cache"),p.refresh()})).observe(f,{childList:!0,subtree:!0}),p.debug("Setting up mutation observer",e))},attachEvents:function(e,n){var t=D(e);n=D.isFunction(p[n])?p[n]:p.toggle,0").insertAfter(s),p.debug("Creating label",d))}},has:{label:function(){return 0 .ui.dimmer",content:".ui.dimmer > .content, .ui.dimmer > .content > .center"},template:{dimmer:function(){return D("
").attr("class","ui dimmer")}}}}(jQuery,window,document); \ No newline at end of file +!function(x,e,F,T){"use strict";void 0!==e&&e.Math==Math||"undefined"!=typeof self&&self.Math==Math||Function("return this")(),x.fn.dimmer=function(p){var b,h=x(this),v=(new Date).getTime(),y=[],C=p,w="string"==typeof C,S=[].slice.call(arguments,1);return h.each(function(){var a,i,r=x.isPlainObject(p)?x.extend(!0,{},x.fn.dimmer.settings,p):x.extend({},x.fn.dimmer.settings),n=r.selector,e=r.namespace,t=r.className,s=r.error,o="."+e,m="module-"+e,d=h.selector||"",c="ontouchstart"in F.documentElement?"touchstart":"click",l=x(this),u=this,f=l.data(m),g={preinitialize:function(){a=g.is.dimmer()?(i=l.parent(),l):(i=l,g.has.dimmer()?r.dimmerName?i.find(n.dimmer).filter("."+r.dimmerName):i.find(n.dimmer):g.create())},initialize:function(){g.debug("Initializing dimmer",r),g.bind.events(),g.set.dimmable(),g.instantiate()},instantiate:function(){g.verbose("Storing instance of module",g),f=g,l.data(m,f)},destroy:function(){g.verbose("Destroying previous module",a),g.unbind.events(),g.remove.variation(),i.off(o)},bind:{events:function(){"hover"==r.on?i.on("mouseenter"+o,g.show).on("mouseleave"+o,g.hide):"click"==r.on&&i.on(c+o,g.toggle),g.is.page()&&(g.debug("Setting as a page dimmer",i),g.set.pageDimmer()),g.is.closable()&&(g.verbose("Adding dimmer close event",a),i.on(c+o,n.dimmer,g.event.click))}},unbind:{events:function(){l.removeData(m),i.off(o)}},event:{click:function(e){g.verbose("Determining if event occurred on dimmer",e),0!==a.find(e.target).length&&!x(e.target).is(n.content)||(g.hide(),e.stopImmediatePropagation())}},addContent:function(e){e=x(e);g.debug("Add content to dimmer",e),e.parent()[0]!==a[0]&&e.detach().appendTo(a)},create:function(){var e=x(r.template.dimmer());return r.dimmerName&&(g.debug("Creating named dimmer",r.dimmerName),e.addClass(r.dimmerName)),e.appendTo(i),e},show:function(e){e=x.isFunction(e)?e:function(){},g.debug("Showing dimmer",a,r),g.set.variation(),g.is.dimmed()&&!g.is.animating()||!g.is.enabled()?g.debug("Dimmer is already shown or disabled"):(g.animate.show(e),r.onShow.call(u),r.onChange.call(u))},hide:function(e){e=x.isFunction(e)?e:function(){},g.is.dimmed()||g.is.animating()?(g.debug("Hiding dimmer",a),g.animate.hide(e),r.onHide.call(u),r.onChange.call(u)):g.debug("Dimmer is not visible")},toggle:function(){g.verbose("Toggling dimmer visibility",a),g.is.dimmed()?g.hide():g.show()},animate:{show:function(e){e=x.isFunction(e)?e:function(){},r.useCSS&&x.fn.transition!==T&&a.transition("is supported")?((r.useFlex?(g.debug("Using flex dimmer"),g.remove):(g.debug("Using legacy non-flex dimmer"),g.set)).legacy(),"auto"!==r.opacity&&g.set.opacity(),a.transition({displayType:r.useFlex?"flex":"block",animation:r.transition+" in",queue:!1,duration:g.get.duration(),useFailSafe:!0,onStart:function(){g.set.dimmed()},onComplete:function(){g.set.active(),e()}})):(g.verbose("Showing dimmer animation with javascript"),g.set.dimmed(),"auto"==r.opacity&&(r.opacity=.8),a.stop().css({opacity:0,width:"100%",height:"100%"}).fadeTo(g.get.duration(),r.opacity,function(){a.removeAttr("style"),g.set.active(),e()}))},hide:function(e){e=x.isFunction(e)?e:function(){},r.useCSS&&x.fn.transition!==T&&a.transition("is supported")?(g.verbose("Hiding dimmer with css"),a.transition({displayType:r.useFlex?"flex":"block",animation:r.transition+" out",queue:!1,duration:g.get.duration(),useFailSafe:!0,onStart:function(){g.remove.dimmed()},onComplete:function(){g.remove.variation(),g.remove.active(),e()}})):(g.verbose("Hiding dimmer with javascript"),g.remove.dimmed(),a.stop().fadeOut(g.get.duration(),function(){g.remove.active(),a.removeAttr("style"),e()}))}},get:{dimmer:function(){return a},duration:function(){return"object"==typeof r.duration?g.is.active()?r.duration.hide:r.duration.show:r.duration}},has:{dimmer:function(){return r.dimmerName?0 .ui.dimmer",content:".ui.dimmer > .content, .ui.dimmer > .content > .center"},template:{dimmer:function(){return x("
").attr("class","ui dimmer")}}}}(jQuery,window,document); \ No newline at end of file diff --git a/semantic/dist/components/dropdown.js b/semantic/dist/components/dropdown.js index 15e5bdd..f3ffff0 100644 --- a/semantic/dist/components/dropdown.js +++ b/semantic/dist/components/dropdown.js @@ -1,5 +1,5 @@ /*! - * # Semantic UI 2.2.13 - Dropdown + * # Semantic UI 2.5.0 - Dropdown * http://github.com/semantic-org/semantic-ui/ * * @@ -10,7 +10,7 @@ ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -496,7 +496,7 @@ $.fn.dropdown = function(parameters) { ? callback : function(){} ; - if( module.is.active() ) { + if( module.is.active() && !module.is.animatingOutward() ) { module.debug('Hiding dropdown'); if(settings.onHide.call(element) !== false) { module.animate.hide(function() { @@ -605,7 +605,6 @@ $.fn.dropdown = function(parameters) { else { if(settings.on == 'click') { $module - .on('click' + eventNamespace, selector.icon, module.event.icon.click) .on('click' + eventNamespace, module.event.test.toggle) ; } @@ -621,6 +620,7 @@ $.fn.dropdown = function(parameters) { ; } $module + .on('click' + eventNamespace, selector.icon, module.event.icon.click) .on('mousedown' + eventNamespace, module.event.mousedown) .on('mouseup' + eventNamespace, module.event.mouseup) .on('focus' + eventNamespace, module.event.focus) @@ -754,10 +754,19 @@ $.fn.dropdown = function(parameters) { callback(); }, onSuccess : function(response) { - module.remove.message(); - module.setup.menu({ - values: response[fields.remoteValues] - }); + var + values = response[fields.remoteValues], + hasRemoteValues = ($.isArray(values) && values.length > 0) + ; + if(hasRemoteValues) { + module.remove.message(); + module.setup.menu({ + values: response[fields.remoteValues] + }); + } + else { + module.add.message(message.noResults); + } callback(); } } @@ -1010,7 +1019,12 @@ $.fn.dropdown = function(parameters) { }, icon: { click: function(event) { - module.toggle(); + if($icon.hasClass(className.clear)) { + module.clear(); + } + else if (module.can.click()) { + module.toggle(); + } } }, text: { @@ -1617,7 +1631,7 @@ $.fn.dropdown = function(parameters) { : text ; if( module.can.activate( $(element) ) ) { - module.set.value(value, $(element)); + module.set.value(value, text, $(element)); if(module.is.multiple() && !module.is.allFiltered()) { return; } @@ -1637,7 +1651,7 @@ $.fn.dropdown = function(parameters) { }, hide: function(text, value, element) { - module.set.value(value, text); + module.set.value(value, text, $(element)); module.hideAndClear(); } @@ -2283,7 +2297,7 @@ $.fn.dropdown = function(parameters) { var length = module.get.query().length ; - $search.val( text.substr(0 , length)); + $search.val( text.substr(0, length)); }, scrollPosition: function($item, forceScroll) { var @@ -2435,7 +2449,6 @@ $.fn.dropdown = function(parameters) { var escapedValue = module.escape.value(value), hasInput = ($input.length > 0), - isAddition = !module.has.value(value), currentValue = module.get.values(), stringValue = (value !== undefined) ? String(value) @@ -2473,6 +2486,15 @@ $.fn.dropdown = function(parameters) { $module.data(metadata.value, stringValue); } } + if(module.is.single() && settings.clearable) { + // treat undefined or '' as empty + if(!escapedValue) { + module.remove.clearable(); + } + else { + module.set.clearable(); + } + } if(settings.fireOnInit === false && module.is.initialLoad()) { module.verbose('No callback on initial load', settings.onChange); } @@ -2538,8 +2560,8 @@ $.fn.dropdown = function(parameters) { module.save.remoteData(selectedText, selectedValue); } if(settings.useLabels) { - module.add.value(selectedValue, selectedText, $selected); module.add.label(selectedValue, selectedText, shouldAnimate); + module.add.value(selectedValue, selectedText, $selected); module.set.activeItem($selected); module.filterActive(); module.select.nextAvailable($selectedItem); @@ -2568,7 +2590,10 @@ $.fn.dropdown = function(parameters) { } }) ; - } + }, + clearable: function() { + $icon.addClass(className.clear); + }, }, add: { @@ -2580,6 +2605,9 @@ $.fn.dropdown = function(parameters) { escapedValue = module.escape.value(value), $label ; + if(settings.ignoreCase) { + escapedValue = escapedValue.toLowerCase(); + } $label = $('') .addClass(className.label) .attr('data-' + metadata.value, escapedValue) @@ -2588,7 +2616,7 @@ $.fn.dropdown = function(parameters) { $label = settings.onLabelCreate.call($label, escapedValue, text); if(module.has.label(value)) { - module.debug('Label already exists, skipping', escapedValue); + module.debug('User selection already exists, skipping', escapedValue); return; } if(settings.label.variation) { @@ -2727,6 +2755,10 @@ $.fn.dropdown = function(parameters) { currentValue = module.get.values(), newValue ; + if(module.has.value(addedValue)) { + module.debug('Value already selected'); + return; + } if(addedValue === '') { module.debug('Cannot select blank values from multiselect'); return; @@ -2759,7 +2791,7 @@ $.fn.dropdown = function(parameters) { } module.set.value(newValue, addedValue, addedText, $selectedItem); module.check.maxSelections(); - } + }, }, remove: { @@ -2984,6 +3016,9 @@ $.fn.dropdown = function(parameters) { .removeAttr('tabindex') ; } + }, + clearable: function() { + $icon.removeClass(className.clear); } }, @@ -3040,6 +3075,9 @@ $.fn.dropdown = function(parameters) { escapedValue = module.escape.value(value), $labels = $module.find(selector.label) ; + if(settings.ignoreCase) { + escapedValue = escapedValue.toLowerCase(); + } return ($labels.filter('[data-' + metadata.value + '="' + module.escape.string(escapedValue) +'"]').length > 0); }, maxSelections: function() { @@ -3058,6 +3096,12 @@ $.fn.dropdown = function(parameters) { return (module.get.query() !== ''); }, value: function(value) { + return (settings.ignoreCase) + ? module.has.valueIgnoringCase(value) + : module.has.valueMatchingCase(value) + ; + }, + valueMatchingCase: function(value) { var values = module.get.values(), hasValue = $.isArray(values) @@ -3068,6 +3112,22 @@ $.fn.dropdown = function(parameters) { ? true : false ; + }, + valueIgnoringCase: function(value) { + var + values = module.get.values(), + hasValue = false + ; + if(!$.isArray(values)) { + values = [values]; + } + $.each(values, function(index, existingValue) { + if(String(value).toLowerCase() == String(existingValue).toLowerCase()) { + hasValue = true; + return false; + } + }); + return hasValue; } }, @@ -3075,6 +3135,12 @@ $.fn.dropdown = function(parameters) { active: function() { return $module.hasClass(className.active); }, + animatingInward: function() { + return $menu.transition('is inward'); + }, + animatingOutward: function() { + return $menu.transition('is outward'); + }, bubbledLabelClick: function(event) { return $(event.target).is('select, input') && $module.closest('label').length > 0; }, @@ -3210,6 +3276,9 @@ $.fn.dropdown = function(parameters) { ; calculations = { context: { + offset : ($context.get(0) === window) + ? { top: 0, left: 0} + : $context.offset(), scrollTop : $context.scrollTop(), height : $context.outerHeight() }, @@ -3222,8 +3291,8 @@ $.fn.dropdown = function(parameters) { calculations.menu.offset.top += calculations.context.scrollTop; } onScreen = { - above : (calculations.context.scrollTop) <= calculations.menu.offset.top - calculations.menu.height, - below : (calculations.context.scrollTop + calculations.context.height) >= calculations.menu.offset.top + calculations.menu.height + above : (calculations.context.scrollTop) <= calculations.menu.offset.top - calculations.context.offset.top - calculations.menu.height, + below : (calculations.context.scrollTop + calculations.context.height) >= calculations.menu.offset.top - calculations.context.offset.top + calculations.menu.height }; if(onScreen.below) { module.verbose('Dropdown can fit in context downward', onScreen); @@ -3252,6 +3321,9 @@ $.fn.dropdown = function(parameters) { ; calculations = { context: { + offset : ($context.get(0) === window) + ? { top: 0, left: 0} + : $context.offset(), scrollLeft : $context.scrollLeft(), width : $context.outerWidth() }, @@ -3263,7 +3335,7 @@ $.fn.dropdown = function(parameters) { if(module.is.horizontallyScrollableContext()) { calculations.menu.offset.left += calculations.context.scrollLeft; } - isOffscreenRight = (calculations.menu.offset.left + calculations.menu.width >= calculations.context.scrollLeft + calculations.context.width); + isOffscreenRight = (calculations.menu.offset.left - calculations.context.offset.left + calculations.menu.width >= calculations.context.scrollLeft + calculations.context.width); if(isOffscreenRight) { module.verbose('Dropdown cannot fit in context rightward', isOffscreenRight); canOpenRightward = false; @@ -3369,7 +3441,7 @@ $.fn.dropdown = function(parameters) { duration : settings.duration, debug : settings.debug, verbose : settings.verbose, - queue : true, + queue : false, onStart : start, onComplete : function() { callback.call(element); @@ -3634,6 +3706,8 @@ $.fn.dropdown.settings = { values : false, // specify values to use for dropdown + clearable : false, // whether the value of the dropdown can be cleared + apiSettings : false, selectOnKeydown : true, // Whether selection should occur automatically when keyboard shortcuts used minCharacters : 0, // Minimum characters required to trigger API call @@ -3657,7 +3731,8 @@ $.fn.dropdown.settings = { forceSelection : true, // force a choice on blur with search selection allowAdditions : false, // whether multiple select should allow user added values - hideAdditions : true, // whether or not to hide special message prompting a user they can enter a value + ignoreCase : false, // whether to consider values not matching in case to be the same + hideAdditions : true, // whether or not to hide special message prompting a user they can enter a value maxSelections : false, // When set to a number limits the number of selections to this count useLabels : true, // whether multiple select should filter currently active selections from choices @@ -3785,6 +3860,7 @@ $.fn.dropdown.settings = { active : 'active', addition : 'addition', animating : 'animating', + clear : 'clear', disabled : 'disabled', empty : 'empty', dropdown : 'ui dropdown', @@ -3851,7 +3927,7 @@ $.fn.dropdown.settings.templates = { ? 'disabled ' : '' ; - html += '
' + html += '
'; html += option[fields.name]; html += '
'; }); diff --git a/semantic/dist/components/dropdown.min.js b/semantic/dist/components/dropdown.min.js index 3f5b6ee..0271f91 100644 --- a/semantic/dist/components/dropdown.min.js +++ b/semantic/dist/components/dropdown.min.js @@ -1 +1 @@ -!function(X,Y,G,J){"use strict";Y=void 0!==Y&&Y.Math==Math?Y:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),X.fn.dropdown=function(z){var P,H=X(this),j=X(G),N=H.selector||"",U="ontouchstart"in G.documentElement,K=(new Date).getTime(),W=[],B=z,$="string"==typeof B,Q=[].slice.call(arguments,1);return H.each(function(n){var e,t,i,a,o,s,r,m,h=X.isPlainObject(z)?X.extend(!0,{},X.fn.dropdown.settings,z):X.extend({},X.fn.dropdown.settings),g=h.className,c=h.message,l=h.fields,p=h.keys,b=h.metadata,u=h.namespace,d=h.regExp,w=h.selector,v=h.error,f=h.templates,x="."+u,C="module-"+u,S=X(this),y=X(h.context),A=S.find(w.text),T=S.find(w.search),k=S.find(w.sizer),L=S.find(w.input),I=S.find(w.icon),D=0").html(a).attr("data-"+b.value,t).attr("data-"+b.text,t).addClass(g.addition).addClass(g.item),h.hideAdditions&&i.addClass(g.hidden),n=n===J?i:n.add(i),m.verbose("Creating user choices for value",t,i))}),n)},userLabels:function(e){var t=m.get.userValues();t&&(m.debug("Adding user labels",t),X.each(t,function(e,t){m.verbose("Adding custom user value"),m.add.label(t,t)}))},menu:function(){q=X("
").addClass(g.menu).appendTo(S)},sizer:function(){k=X("").addClass(g.sizer).insertAfter(T)}},search:function(e){e=e!==J?e:m.get.query(),m.verbose("Searching for query",e),m.has.minCharacters(e)?m.filter(e):m.hide()},select:{firstUnfiltered:function(){m.verbose("Selecting first non-filtered element"),m.remove.selectedItem(),R.not(w.unselectable).not(w.addition+w.hidden).eq(0).addClass(g.selected)},nextAvailable:function(e){var t=(e=e.eq(0)).nextAll(w.item).not(w.unselectable).eq(0),n=e.prevAll(w.item).not(w.unselectable).eq(0);0").addClass(g.search).prop("autocomplete","off").insertBefore(A)),m.is.multiple()&&m.is.searchSelection()&&!m.has.sizer()&&m.create.sizer(),h.allowTab&&m.set.tabbable()},select:function(){var e=m.get.selectValues();m.debug("Dropdown initialized on a select",e),S.is("select")&&(L=S),0").attr("class",L.attr("class")).addClass(g.selection).addClass(g.dropdown).html(f.dropdown(e)).insertBefore(L),L.hasClass(g.multiple)&&!1===L.prop("multiple")&&(m.error(v.missingMultiple),L.prop("multiple",!0)),L.is("[multiple]")&&m.set.multiple(),L.prop("disabled")&&(m.debug("Disabling dropdown"),S.addClass(g.disabled)),L.removeAttr("class").detach().prependTo(S)),m.refresh()},menu:function(e){q.html(f.menu(e,l)),R=q.find(w.item)},reference:function(){m.debug("Dropdown behavior was called on select, replacing with closest dropdown"),S=S.parent(w.dropdown),M=S.data(C),F=S.get(0),m.refresh(),m.setup.returnedObject()},returnedObject:function(){var e=H.slice(0,n),t=H.slice(n+1);H=e.add(S).add(t)}},refresh:function(){m.refreshSelectors(),m.refreshData()},refreshItems:function(){R=q.find(w.item)},refreshSelectors:function(){m.verbose("Refreshing selector cache"),A=S.find(w.text),T=S.find(w.search),L=S.find(w.input),I=S.find(w.icon),D=0 modified, recreating menu");var n=!1;X.each(e,function(e,t){if(X(t.target).is("select")||X(t.addedNodes).is("select"))return n=!0}),n&&(m.disconnect.selectObserver(),m.refresh(),m.setup.select(),m.set.selected(),m.observe.select())}},menu:{mutation:function(e){var t=e[0],n=t.addedNodes?X(t.addedNodes[0]):X(!1),i=t.removedNodes?X(t.removedNodes[0]):X(!1),a=n.add(i),o=a.is(w.addition)||0t.name?1:-1}),m.debug("Retrieved and sorted values from select",a)):m.debug("Retrieved values from select",a),a},activeItem:function(){return R.filter("."+g.active)},selectedItem:function(){var e=R.not(w.unselectable).filter("."+g.selected);return 0=h.maxSelections?(m.debug("Maximum selection count reached"),h.useLabels&&(R.addClass(g.filtered),m.add.message(c.maxSelections)),!0):(m.verbose("No longer at maximum selection count"),m.remove.message(),m.remove.filteredItem(),m.is.searchSelection()&&m.filterItems(),!1))}},restore:{defaults:function(){m.clear(),m.restore.defaultText(),m.restore.defaultValue()},defaultText:function(){var e=m.get.defaultText();e===m.get.placeholderText?(m.debug("Restoring default placeholder text",e),m.set.placeholderText(e)):(m.debug("Restoring default text",e),m.set.text(e))},placeholderText:function(){m.set.placeholderText()},defaultValue:function(){var e=m.get.defaultValue();e!==J&&(m.debug("Restoring default value",e),""!==e?(m.set.value(e),m.set.selected()):(m.remove.activeItem(),m.remove.selectedItem()))},labels:function(){h.allowAdditions&&(h.useLabels||(m.error(v.labels),h.useLabels=!0),m.debug("Restoring selected values"),m.create.userLabels()),m.check.maxSelections()},selected:function(){m.restore.values(),m.is.multiple()?(m.debug("Restoring previously selected values and labels"),m.restore.labels()):m.debug("Restoring previously selected values")},values:function(){m.set.initialLoad(),h.apiSettings&&h.saveRemoteData&&m.get.remoteValues()?m.restore.remoteValues():m.set.selected(),m.remove.initialLoad()},remoteValues:function(){var e=m.get.remoteValues();m.debug("Recreating selected from session data",e),e&&(m.is.single()?X.each(e,function(e,t){m.set.text(t)}):X.each(e,function(e,t){m.add.label(e,t)}))}},read:{remoteData:function(e){var t;if(Y.Storage!==J)return(t=sessionStorage.getItem(e))!==J&&t;m.error(v.noStorage)}},save:{defaults:function(){m.save.defaultText(),m.save.placeholderText(),m.save.defaultValue()},defaultValue:function(){var e=m.get.value();m.verbose("Saving default value as",e),S.data(b.defaultValue,e)},defaultText:function(){var e=m.get.text();m.verbose("Saving default text as",e),S.data(b.defaultText,e)},placeholderText:function(){var e;!1!==h.placeholder&&A.hasClass(g.placeholder)&&(e=m.get.text(),m.verbose("Saving placeholder text as",e),S.data(b.placeholderText,e))},remoteData:function(e,t){Y.Storage!==J?(m.verbose("Saving remote data to session storage",t,e),sessionStorage.setItem(t,e)):m.error(v.noStorage)}},clear:function(){m.is.multiple()&&h.useLabels?m.remove.labels():(m.remove.activeItem(),m.remove.selectedItem()),m.set.placeholderText(),m.clearValue()},clearValue:function(){m.set.value("")},scrollPage:function(e,t){var n,i,a=t||m.get.selectedItem(),o=a.closest(w.menu),s=o.outerHeight(),r=o.scrollTop(),l=R.eq(0).outerHeight(),c=Math.floor(s/l),u=(o.prop("scrollHeight"),"up"==e?r-l*c:r+l*c),d=R.not(w.unselectable);i="up"==e?d.index(a)-c:d.index(a)+c,0<(n=("up"==e?0<=i:i").addClass(g.label).attr("data-"+b.value,o).html(f.label(o,t)),i=h.onLabelCreate.call(i,o,t),m.has.label(e)?m.debug("Label already exists, skipping",o):(h.label.variation&&i.addClass(h.label.variation),!0===n?(m.debug("Animating in label",i),i.addClass(g.hidden).insertBefore(a).transition(h.label.transition,h.label.duration)):(m.debug("Adding selection label",i),i.insertBefore(a)))},message:function(e){var t=q.children(w.message),n=h.templates.message(m.add.variables(e));0").html(n).addClass(g.message).appendTo(q)},optionValue:function(e){var t=m.escape.value(e);0").prop("value",t).addClass(g.addition).html(e).appendTo(L),m.verbose("Adding user addition as an
").addClass(f.menu).appendTo(x)},sizer:function(){A=X("").addClass(f.sizer).insertAfter(y)}},search:function(e){e=e!==J?e:M.get.query(),M.verbose("Searching for query",e),M.has.minCharacters(e)?M.filter(e):M.hide()},select:{firstUnfiltered:function(){M.verbose("Selecting first non-filtered element"),M.remove.selectedItem(),D.not(g.unselectable).not(g.addition+g.hidden).eq(0).addClass(f.selected)},nextAvailable:function(e){var t=(e=e.eq(0)).nextAll(g.item).not(g.unselectable).eq(0),e=e.prevAll(g.item).not(g.unselectable).eq(0);(0").addClass(f.search).prop("autocomplete","off").insertBefore(S)),M.is.multiple()&&M.is.searchSelection()&&!M.has.sizer()&&M.create.sizer(),v.allowTab&&M.set.tabbable()},select:function(){var e=M.get.selectValues();M.debug("Dropdown initialized on a select",e),0<(T=x.is("select")?x:T).parent(g.dropdown).length?(M.debug("UI dropdown already exists. Creating dropdown menu only"),x=T.closest(g.dropdown),M.has.menu()||M.create.menu(),I=x.children(g.menu),M.setup.menu(e)):(M.debug("Creating entire dropdown from select"),x=X("
").attr("class",T.attr("class")).addClass(f.selection).addClass(f.dropdown).html(p.dropdown(e)).insertBefore(T),T.hasClass(f.multiple)&&!1===T.prop("multiple")&&(M.error(d.missingMultiple),T.prop("multiple",!0)),T.is("[multiple]")&&M.set.multiple(),T.prop("disabled")&&(M.debug("Disabling dropdown"),x.addClass(f.disabled)),T.removeAttr("class").detach().prependTo(x)),M.refresh()},menu:function(e){I.html(p.menu(e,l)),D=I.find(g.item)},reference:function(){M.debug("Dropdown behavior was called on select, replacing with closest dropdown"),x=x.parent(g.dropdown),E=x.data(w),V=x.get(0),M.refresh(),M.setup.returnedObject()},returnedObject:function(){var e=H.slice(0,n),t=H.slice(n+1);H=e.add(x).add(t)}},refresh:function(){M.refreshSelectors(),M.refreshData()},refreshItems:function(){D=I.find(g.item)},refreshSelectors:function(){M.verbose("Refreshing selector cache"),S=x.find(g.text),y=x.find(g.search),T=x.find(g.input),k=x.find(g.icon),L=0 modified, recreating menu");var n=!1;X.each(e,function(e,t){if(X(t.target).is("select")||X(t.addedNodes).is("select"))return n=!0}),n&&(M.disconnect.selectObserver(),M.refresh(),M.setup.select(),M.set.selected(),M.observe.select())}},menu:{mutation:function(e){var e=e[0],t=e.addedNodes?X(e.addedNodes[0]):X(!1),e=e.removedNodes?X(e.removedNodes[0]):X(!1),t=t.add(e),e=t.is(g.addition)||0t.name?1:-1}),M.debug("Retrieved and sorted values from select",i)):M.debug("Retrieved values from select",i),i},activeItem:function(){return D.filter("."+f.active)},selectedItem:function(){var e=D.not(g.unselectable).filter("."+f.selected);return 0=v.maxSelections?(M.debug("Maximum selection count reached"),v.useLabels&&(D.addClass(f.filtered),M.add.message(c.maxSelections)),!0):(M.verbose("No longer at maximum selection count"),M.remove.message(),M.remove.filteredItem(),M.is.searchSelection()&&M.filterItems(),!1))}},restore:{defaults:function(){M.clear(),M.restore.defaultText(),M.restore.defaultValue()},defaultText:function(){var e=M.get.defaultText();e===M.get.placeholderText?(M.debug("Restoring default placeholder text",e),M.set.placeholderText(e)):(M.debug("Restoring default text",e),M.set.text(e))},placeholderText:function(){M.set.placeholderText()},defaultValue:function(){var e=M.get.defaultValue();e!==J&&(M.debug("Restoring default value",e),""!==e?(M.set.value(e),M.set.selected()):(M.remove.activeItem(),M.remove.selectedItem()))},labels:function(){v.allowAdditions&&(v.useLabels||(M.error(d.labels),v.useLabels=!0),M.debug("Restoring selected values"),M.create.userLabels()),M.check.maxSelections()},selected:function(){M.restore.values(),M.is.multiple()?(M.debug("Restoring previously selected values and labels"),M.restore.labels()):M.debug("Restoring previously selected values")},values:function(){M.set.initialLoad(),v.apiSettings&&v.saveRemoteData&&M.get.remoteValues()?M.restore.remoteValues():M.set.selected(),M.remove.initialLoad()},remoteValues:function(){var e=M.get.remoteValues();M.debug("Recreating selected from session data",e),e&&(M.is.single()?X.each(e,function(e,t){M.set.text(t)}):X.each(e,function(e,t){M.add.label(e,t)}))}},read:{remoteData:function(e){if(Y.Storage!==J)return(e=sessionStorage.getItem(e))!==J&&e;M.error(d.noStorage)}},save:{defaults:function(){M.save.defaultText(),M.save.placeholderText(),M.save.defaultValue()},defaultValue:function(){var e=M.get.value();M.verbose("Saving default value as",e),x.data(h.defaultValue,e)},defaultText:function(){var e=M.get.text();M.verbose("Saving default text as",e),x.data(h.defaultText,e)},placeholderText:function(){var e;!1!==v.placeholder&&S.hasClass(f.placeholder)&&(e=M.get.text(),M.verbose("Saving placeholder text as",e),x.data(h.placeholderText,e))},remoteData:function(e,t){Y.Storage===J?M.error(d.noStorage):(M.verbose("Saving remote data to session storage",t,e),sessionStorage.setItem(t,e))}},clear:function(){M.is.multiple()&&v.useLabels?M.remove.labels():(M.remove.activeItem(),M.remove.selectedItem()),M.set.placeholderText(),M.clearValue()},clearValue:function(){M.set.value("")},scrollPage:function(e,t){var t=t||M.get.selectedItem(),n=t.closest(g.menu),i=n.outerHeight(),a=n.scrollTop(),o=D.eq(0).outerHeight(),i=Math.floor(i/o),a=(n.prop("scrollHeight"),"up"==e?a-o*i:a+o*i),o=D.not(g.unselectable),i="up"==e?o.index(t)-i:o.index(t)+i,i=("up"==e?0<=i:i").addClass(f.label).attr("data-"+h.value,o).html(p.label(o,t)),i=v.onLabelCreate.call(i,o,t),M.has.label(e)?M.debug("User selection already exists, skipping",o):(v.label.variation&&i.addClass(v.label.variation),!0===n?(M.debug("Animating in label",i),i.addClass(f.hidden).insertBefore(a).transition(v.label.transition,v.label.duration)):(M.debug("Adding selection label",i),i.insertBefore(a)))},message:function(e){var t=I.children(g.message),e=v.templates.message(M.add.variables(e));0").html(e).addClass(f.message).appendTo(I)},optionValue:function(e){var t=M.escape.value(e);0").prop("value",t).addClass(f.addition).html(e).appendTo(T),M.verbose("Adding user addition as an
").addClass("ui basic red pointing prompt label").html(e[0])}},rules:{empty:function(e){return!(e===O||""===e||T.isArray(e)&&0===e.length)},checked:function(){return 0=t},length:function(e,t){return e!==O&&e.length>=t},exactLength:function(e,t){return e!==O&&e.length==t},maxLength:function(e,t){return e!==O&&e.length<=t},match:function(e,t){var n;T(this);return 0=t)},exactCount:function(e,t){return 0==t?""===e:1==t?""!==e&&-1===e.search(","):e.split(",").length==t},maxCount:function(e,t){return 0!=t&&(1==t?-1===e.search(","):e.split(",").length<=t)}}}}(jQuery,window,document); \ No newline at end of file +!function(T,e,D,O){"use strict";void 0!==e&&e.Math==Math||"undefined"!=typeof self&&self.Math==Math||Function("return this")(),T.fn.form=function(x){var k,E=T(this),w=E.selector||"",C=(new Date).getTime(),V=[],R=x,F=arguments[1],S="string"==typeof R,A=[].slice.call(arguments,1);return E.each(function(){var t,s,n,e,u,l,c,d,f,r,a,i,o,p,m,g=T(this),h=this,v=[],b=!1,y={initialize:function(){y.get.settings(),S?(m===O&&y.instantiate(),y.invoke(R)):(m!==O&&m.invoke("destroy"),y.verbose("Initializing form validation",g,u),y.bindEvents(),y.set.defaults(),y.instantiate())},instantiate:function(){y.verbose("Storing instance of module",y),m=y,g.data(o,y)},destroy:function(){y.verbose("Destroying previous module",m),y.removeEvents(),g.removeData(o)},refresh:function(){y.verbose("Refreshing selector cache"),t=g.find(d.field),s=g.find(d.group),n=g.find(d.message),g.find(d.prompt),e=g.find(d.submit),g.find(d.clear),g.find(d.reset)},submit:function(){y.verbose("Submitting form",g),g.submit()},attachEvents:function(e,t){t=t||"submit",T(e).on("click"+p,function(e){y[t](),e.preventDefault()})},bindEvents:function(){y.verbose("Attaching form events"),g.on("submit"+p,y.validate.form).on("blur"+p,d.field,y.event.field.blur).on("click"+p,d.submit,y.submit).on("click"+p,d.reset,y.reset).on("click"+p,d.clear,y.clear),u.keyboardShortcuts&&g.on("keydown"+p,d.field,y.event.field.keydown),t.each(function(){var e=T(this),t=e.prop("type"),t=y.get.changeEvent(t,e);T(this).on(t+p,y.event.field.change)})},clear:function(){t.each(function(){var e=T(this),t=e.parent(),n=e.closest(s),r=n.find(d.prompt),i=e.data(c.defaultValue)||"",a=t.is(d.uiCheckbox),o=t.is(d.uiDropdown);n.hasClass(f.error)&&(y.verbose("Resetting error on field",n),n.removeClass(f.error),r.remove()),o?(y.verbose("Resetting dropdown value",t,i),t.dropdown("clear")):a?e.prop("checked",!1):(y.verbose("Resetting field value",e,i),e.val(""))})},reset:function(){t.each(function(){var e=T(this),t=e.parent(),n=e.closest(s),r=n.find(d.prompt),i=e.data(c.defaultValue),a=t.is(d.uiCheckbox),o=t.is(d.uiDropdown),l=n.hasClass(f.error);i!==O&&(l&&(y.verbose("Resetting error on field",n),n.removeClass(f.error),r.remove()),o?(y.verbose("Resetting dropdown value",t,i),t.dropdown("restore defaults")):a?(y.verbose("Resetting checkbox value",t,i),e.prop("checked",i)):(y.verbose("Resetting field value",e,i),e.val(i)))})},determine:{isValid:function(){var n=!0;return T.each(l,function(e,t){y.validate.field(t,e,!0)||(n=!1)}),n}},is:{bracketedRule:function(e){return e.type&&e.type.match(u.regExp.bracket)},shorthandFields:function(e){e=e[Object.keys(e)[0]];return y.is.shorthandRules(e)},shorthandRules:function(e){return"string"==typeof e||T.isArray(e)},empty:function(e){return!e||0===e.length||(e.is('input[type="checkbox"]')?!e.is(":checked"):y.is.blank(e))},blank:function(e){return""===T.trim(e.val())},valid:function(e){var n=!0;return e?(y.verbose("Checking if field is valid",e),y.validate.field(l[e],e,!1)):(y.verbose("Checking if form is valid"),T.each(l,function(e,t){y.is.valid(e)||(n=!1)}),n)}},removeEvents:function(){g.off(p),t.off(p),e.off(p),t.off(p)},event:{field:{keydown:function(e){var t=T(this),n=e.which,r=t.is(d.input),i=t.is(d.checkbox),a=0")},fields:function(e){var n=T();return T.each(e,function(e,t){n=n.add(y.get.field(t))}),n},validation:function(n){var r,i;return l&&(T.each(l,function(e,t){i=t.identifier||e,y.get.field(i)[0]==n[0]&&(t.identifier=i,r=t)}),r)||!1},value:function(e){var t=[];return t.push(e),y.get.values.call(h,t)[e]},values:function(e){var e=T.isArray(e)?y.get.fields(e):t,l={};return e.each(function(e,t){var t=T(t),n=(t.prop("type"),t.prop("name")),r=t.val(),i=t.is(d.checkbox),a=t.is(d.radio),o=-1!==n.indexOf("[]"),t=!!i&&t.is(":checked");n&&(o?(n=n.replace("[]",""),l[n]||(l[n]=[]),i?t?l[n].push(r||!0):l[n].push(!1):l[n].push(r)):a?l[n]!==O&&0!=l[n]||(l[n]=!!t&&(r||!0)):l[n]=i?!!t&&(r||!0):r)}),l}},has:{field:function(e){return y.verbose("Checking for existence of a field with identifier",e),"string"!=typeof(e=y.escape.string(e))&&y.error(a.identifier,e),0"}),T(n+="")},prompt:function(e){return T("
").addClass("ui basic red pointing prompt label").html(e[0])}},rules:{empty:function(e){return!(e===O||""===e||T.isArray(e)&&0===e.length)},checked:function(){return 0=t},length:function(e,t){return e!==O&&e.length>=t},exactLength:function(e,t){return e!==O&&e.length==t},maxLength:function(e,t){return e!==O&&e.length<=t},match:function(e,t){var n;T(this);return 0=t)},exactCount:function(e,t){return 0==t?""===e:1==t?""!==e&&-1===e.search(","):e.split(",").length==t},maxCount:function(e,t){return 0!=t&&(1==t?-1===e.search(","):e.split(",").length<=t)}}}}(jQuery,window,document); \ No newline at end of file diff --git a/semantic/dist/components/modal.js b/semantic/dist/components/modal.js index 59bf35c..9188a3a 100755 --- a/semantic/dist/components/modal.js +++ b/semantic/dist/components/modal.js @@ -1,5 +1,5 @@ /*! - * # Semantic UI 2.2.13 - Modal + * # Semantic UI 2.5.0 - Modal * http://github.com/semantic-org/semantic-ui/ * * @@ -10,7 +10,7 @@ ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -108,6 +108,9 @@ $.fn.modal = function(parameters) { var defaultSettings = { debug : settings.debug, + variation : settings.centered + ? false + : 'top aligned', dimmerName : 'modals' }, dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings) @@ -128,13 +131,16 @@ $.fn.modal = function(parameters) { $dimmer = $dimmable.dimmer('get dimmer'); }, id: function() { - id = (Math.random().toString(16) + '000000000').substr(2,8); + id = (Math.random().toString(16) + '000000000').substr(2, 8); elementEventNamespace = '.' + id; module.verbose('Creating unique id for element', id); } }, destroy: function() { + if (observer) { + observer.disconnect(); + } module.verbose('Destroying previous modal'); $module .removeData(moduleNamespace) @@ -163,9 +169,11 @@ $.fn.modal = function(parameters) { refresh: function() { module.remove.scrolling(); module.cacheSizes(); + if(!module.can.useFlex()) { + module.set.modalOffset(); + } module.set.screenHeight(); module.set.type(); - module.set.position(); }, refreshModals: function() { @@ -204,12 +212,22 @@ $.fn.modal = function(parameters) { $window .on('resize' + elementEventNamespace, module.event.resize) ; + }, + scrollLock: function() { + // touch events default to passive, due to changes in chrome to optimize mobile perf + $dimmable.get(0).addEventListener('touchmove', module.event.preventScroll, { passive: false }); + } + }, + + unbind: { + scrollLock: function() { + $dimmable.get(0).removeEventListener('touchmove', module.event.preventScroll, { passive: false }); } }, get: { id: function() { - return (Math.random().toString(16) + '000000000').substr(2,8); + return (Math.random().toString(16) + '000000000').substr(2, 8); } }, @@ -224,6 +242,9 @@ $.fn.modal = function(parameters) { ignoreRepeatedEvents = false; }); }, + preventScroll: function(event) { + event.preventDefault(); + }, deny: function() { if(ignoreRepeatedEvents || settings.onDeny.call(element, $(this)) === false) { module.verbose('Deny callback returned false cancelling hide'); @@ -238,21 +259,23 @@ $.fn.modal = function(parameters) { module.hide(); }, click: function(event) { + if(!settings.closable) { + module.verbose('Dimmer clicked but closable setting is disabled'); + return; + } var $target = $(event.target), isInModal = ($target.closest(selector.modal).length > 0), isInDOM = $.contains(document.documentElement, event.target) ; - if(!isInModal && isInDOM) { + if(!isInModal && isInDOM && module.is.active()) { module.debug('Dimmer clicked, hiding all modals'); - if( module.is.active() ) { - module.remove.clickaway(); - if(settings.allowMultiple) { - module.hide(); - } - else { - module.hideAll(); - } + module.remove.clickaway(); + if(settings.allowMultiple) { + module.hide(); + } + else { + module.hideAll(); } } }, @@ -299,6 +322,8 @@ $.fn.modal = function(parameters) { ; module.refreshModals(); module.set.dimmerSettings(); + module.set.dimmerStyles(); + module.showModal(callback); }, @@ -317,10 +342,16 @@ $.fn.modal = function(parameters) { : function(){} ; if( module.is.animating() || !module.is.active() ) { - module.showDimmer(); module.cacheSizes(); - module.set.position(); + if(module.can.useFlex()) { + module.remove.legacy(); + } + else { + module.set.legacy(); + module.set.modalOffset(); + module.debug('Using non-flex legacy modal positioning.'); + } module.set.screenHeight(); module.set.type(); module.set.clickaway(); @@ -398,6 +429,7 @@ $.fn.modal = function(parameters) { }, onComplete : function() { settings.onHidden.call(element); + module.remove.dimmerStyles(); module.restore.focus(); callback(); } @@ -422,6 +454,7 @@ $.fn.modal = function(parameters) { hideDimmer: function() { if( $dimmable.dimmer('is animating') || ($dimmable.dimmer('is active')) ) { + module.unbind.scrollLock(); $dimmable.dimmer('hide', function() { module.remove.clickaway(); module.remove.screenHeight(); @@ -487,7 +520,13 @@ $.fn.modal = function(parameters) { save: { focus: function() { - $focusedElement = $(document.activeElement).blur(); + var + $activeElement = $(document.activeElement), + inCurrentModal = $activeElement.closest($module).length > 0 + ; + if(!inCurrentModal) { + $focusedElement = $(document.activeElement).blur(); + } } }, @@ -503,12 +542,17 @@ $.fn.modal = function(parameters) { active: function() { $module.removeClass(className.active); }, + legacy: function() { + $module.removeClass(className.legacy); + }, clickaway: function() { - if(settings.closable) { - $dimmer - .off('click' + elementEventNamespace) - ; - } + $dimmer + .off('click' + elementEventNamespace) + ; + }, + dimmerStyles: function() { + $dimmer.removeClass(className.inverted); + $dimmable.removeClass(className.blurring); }, bodyStyle: function() { if($body.attr('style') === '') { @@ -538,11 +582,13 @@ $.fn.modal = function(parameters) { $module.addClass(className.loading); var scrollHeight = $module.prop('scrollHeight'), + modalWidth = $module.outerWidth(), modalHeight = $module.outerHeight() ; if(module.cache === undefined || modalHeight !== 0) { module.cache = { pageHeight : $(document).outerHeight(), + width : modalWidth, height : modalHeight + settings.offset, scrollHeight : scrollHeight + settings.offset, contextHeight : (settings.context == 'body') @@ -556,6 +602,12 @@ $.fn.modal = function(parameters) { }, can: { + useFlex: function() { + return (settings.useFlex == 'auto') + ? settings.detachable && !module.is.ie() + : settings.useFlex + ; + }, fit: function() { var contextHeight = module.cache.contextHeight, @@ -577,6 +629,13 @@ $.fn.modal = function(parameters) { active: function() { return $module.hasClass(className.active); }, + ie: function() { + var + isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window), + isIE = ('ActiveXObject' in window) + ; + return (isIE11 || isIE); + }, animating: function() { return $module.transition('is supported') ? $module.transition('is animating') @@ -588,7 +647,7 @@ $.fn.modal = function(parameters) { }, modernBrowser: function() { // appName for IE11 reports 'Netscape' can no longer use - return !(window.ActiveXObject || "ActiveXObject" in window); + return !(window.ActiveXObject || 'ActiveXObject' in window); } }, @@ -606,11 +665,9 @@ $.fn.modal = function(parameters) { } }, clickaway: function() { - if(settings.closable) { - $dimmer - .on('click' + elementEventNamespace, module.event.click) - ; - } + $dimmer + .on('click' + elementEventNamespace, module.event.click) + ; }, dimmerSettings: function() { if($.fn.dimmer === undefined) { @@ -621,8 +678,11 @@ $.fn.modal = function(parameters) { defaultSettings = { debug : settings.debug, dimmerName : 'modals', - variation : false, closable : 'auto', + useFlex : module.can.useFlex(), + variation : settings.centered + ? false + : 'top aligned', duration : { show : settings.duration, hide : settings.duration @@ -635,6 +695,11 @@ $.fn.modal = function(parameters) { ? dimmerSettings.variation + ' inverted' : 'inverted' ; + } + $context.dimmer('setting', dimmerSettings); + }, + dimmerStyles: function() { + if(settings.inverted) { $dimmer.addClass(className.inverted); } else { @@ -646,7 +711,21 @@ $.fn.modal = function(parameters) { else { $dimmable.removeClass(className.blurring); } - $context.dimmer('setting', dimmerSettings); + }, + modalOffset: function() { + var + width = module.cache.width, + height = module.cache.height + ; + $module + .css({ + marginTop: (settings.centered && module.can.fit()) + ? -(height / 2) + : 0, + marginLeft: -(width / 2) + }) + ; + module.verbose('Setting modal offset for legacy mode'); }, screenHeight: function() { if( module.can.fit() ) { @@ -665,12 +744,17 @@ $.fn.modal = function(parameters) { scrolling: function() { $dimmable.addClass(className.scrolling); $module.addClass(className.scrolling); + module.unbind.scrollLock(); + }, + legacy: function() { + $module.addClass(className.legacy); }, type: function() { if(module.can.fit()) { module.verbose('Modal fits on screen'); if(!module.others.active() && !module.others.animating()) { module.remove.scrolling(); + module.bind.scrollLock(); } } else { @@ -678,25 +762,6 @@ $.fn.modal = function(parameters) { module.set.scrolling(); } }, - position: function() { - module.verbose('Centering modal on page', module.cache); - if(module.can.fit()) { - $module - .css({ - top: '', - marginTop: module.cache.topOffset - }) - ; - } - else { - $module - .css({ - marginTop : '', - top : $document.scrollTop() - }) - ; - } - }, undetached: function() { $dimmable.addClass(className.undetached); } @@ -890,6 +955,9 @@ $.fn.modal.settings = { name : 'Modal', namespace : 'modal', + useFlex : 'auto', + offset : 0, + silent : false, debug : false, verbose : false, @@ -905,6 +973,8 @@ $.fn.modal.settings = { inverted : false, blurring : false, + centered : true, + dimmerSettings : { closable : false, useCSS : true @@ -917,7 +987,6 @@ $.fn.modal.settings = { queue : false, duration : 500, - offset : 0, transition : 'scale', // padding with edge of page @@ -957,6 +1026,7 @@ $.fn.modal.settings = { animating : 'animating', blurring : 'blurring', inverted : 'inverted', + legacy : 'legacy', loading : 'loading', scrolling : 'scrolling', undetached : 'undetached' diff --git a/semantic/dist/components/modal.min.js b/semantic/dist/components/modal.min.js index 459f850..8a79a88 100755 --- a/semantic/dist/components/modal.min.js +++ b/semantic/dist/components/modal.min.js @@ -1 +1 @@ -!function(E,j,N,P){"use strict";j=void 0!==j&&j.Math==Math?j:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),E.fn.modal=function(C){var S,e=E(this),M=E(j),H=E(N),F=E("body"),T=e.selector||"",A=(new Date).getTime(),D=[],x=C,O="string"==typeof x,z=[].slice.call(arguments,1),q=j.requestAnimationFrame||j.mozRequestAnimationFrame||j.webkitRequestAnimationFrame||j.msRequestAnimationFrame||function(e){setTimeout(e,0)};return e.each(function(){var i,t,e,o,a,n,r,s,c,l=E.isPlainObject(C)?E.extend(!0,{},E.fn.modal.settings,C):E.extend({},E.fn.modal.settings),d=l.selector,u=l.className,m=l.namespace,f=l.error,g="."+m,h="module-"+m,v=E(this),b=E(l.context),p=v.find(d.close),y=this,k=v.data(h),w=!1;c={initialize:function(){c.verbose("Initializing dimmer",b),c.create.id(),c.create.dimmer(),c.refreshModals(),c.bind.events(),l.observeChanges&&c.observeChanges(),c.instantiate()},instantiate:function(){c.verbose("Storing instance of modal"),k=c,v.data(h,k)},create:{dimmer:function(){var e={debug:l.debug,dimmerName:"modals"},n=E.extend(!0,e,l.dimmerSettings);E.fn.dimmer!==P?(c.debug("Creating dimmer"),o=b.dimmer(n),l.detachable?(c.verbose("Modal is detachable, moving content into dimmer"),o.dimmer("add content",v)):c.set.undetached(),a=o.dimmer("get dimmer")):c.error(f.dimmer)},id:function(){r=(Math.random().toString(16)+"000000000").substr(2,8),n="."+r,c.verbose("Creating unique id for element",r)}},destroy:function(){c.verbose("Destroying previous modal"),v.removeData(h).off(g),M.off(n),a.off(n),p.off(g),b.dimmer("destroy")},observeChanges:function(){"MutationObserver"in j&&((s=new MutationObserver(function(e){c.debug("DOM tree modified, refreshing"),c.refresh()})).observe(y,{childList:!0,subtree:!0}),c.debug("Setting up mutation observer",s))},refresh:function(){c.remove.scrolling(),c.cacheSizes(),c.set.screenHeight(),c.set.type(),c.set.position()},refreshModals:function(){t=v.siblings(d.modal),i=t.add(v)},attachEvents:function(e,n){var i=E(e);n=E.isFunction(c[n])?c[n]:c.toggle,0 .close",approve:".actions .positive, .actions .approve, .actions .ok",deny:".actions .negative, .actions .deny, .actions .cancel",modal:".ui.modal"},error:{dimmer:"UI Dimmer, a required component is not included in this page",method:"The method you called is not defined.",notFound:"The element you specified could not be found"},className:{active:"active",animating:"animating",blurring:"blurring",inverted:"inverted",loading:"loading",scrolling:"scrolling",undetached:"undetached"}}}(jQuery,window,document); \ No newline at end of file +!function(j,q,L,N){"use strict";q=void 0!==q&&q.Math==Math?q:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),j.fn.modal=function(w){var C,e=j(this),F=j(q),M=j(L),x=j("body"),H=e.selector||"",A=(new Date).getTime(),O=[],D=w,T="string"==typeof D,z=[].slice.call(arguments,1),E=q.requestAnimationFrame||q.mozRequestAnimationFrame||q.webkitRequestAnimationFrame||q.msRequestAnimationFrame||function(e){setTimeout(e,0)};return e.each(function(){var i,t,e,o,n,a,r,s,c=j.isPlainObject(w)?j.extend(!0,{},j.fn.modal.settings,w):j.extend({},j.fn.modal.settings),l=c.selector,d=c.className,u=c.namespace,m=c.error,f="."+u,g="module-"+u,h=j(this),v=j(c.context),b=h.find(l.close),p=this,y=h.data(g),k=!1,S={initialize:function(){S.verbose("Initializing dimmer",v),S.create.id(),S.create.dimmer(),S.refreshModals(),S.bind.events(),c.observeChanges&&S.observeChanges(),S.instantiate()},instantiate:function(){S.verbose("Storing instance of modal"),y=S,h.data(g,y)},create:{dimmer:function(){var e={debug:c.debug,variation:!c.centered&&"top aligned",dimmerName:"modals"},e=j.extend(!0,e,c.dimmerSettings);j.fn.dimmer===N?S.error(m.dimmer):(S.debug("Creating dimmer"),o=v.dimmer(e),c.detachable?(S.verbose("Modal is detachable, moving content into dimmer"),o.dimmer("add content",h)):S.set.undetached(),n=o.dimmer("get dimmer"))},id:function(){r=(Math.random().toString(16)+"000000000").substr(2,8),a="."+r,S.verbose("Creating unique id for element",r)}},destroy:function(){s&&s.disconnect(),S.verbose("Destroying previous modal"),h.removeData(g).off(f),F.off(a),n.off(a),b.off(f),v.dimmer("destroy")},observeChanges:function(){"MutationObserver"in q&&((s=new MutationObserver(function(e){S.debug("DOM tree modified, refreshing"),S.refresh()})).observe(p,{childList:!0,subtree:!0}),S.debug("Setting up mutation observer",s))},refresh:function(){S.remove.scrolling(),S.cacheSizes(),S.can.useFlex()||S.set.modalOffset(),S.set.screenHeight(),S.set.type()},refreshModals:function(){t=h.siblings(l.modal),i=t.add(h)},attachEvents:function(e,n){var i=j(e);n=j.isFunction(S[n])?S[n]:S.toggle,0 .close",approve:".actions .positive, .actions .approve, .actions .ok",deny:".actions .negative, .actions .deny, .actions .cancel",modal:".ui.modal"},error:{dimmer:"UI Dimmer, a required component is not included in this page",method:"The method you called is not defined.",notFound:"The element you specified could not be found"},className:{active:"active",animating:"animating",blurring:"blurring",inverted:"inverted",legacy:"legacy",loading:"loading",scrolling:"scrolling",undetached:"undetached"}}}(jQuery,window,document); \ No newline at end of file diff --git a/semantic/dist/components/popup.js b/semantic/dist/components/popup.js index 37c77cf..c596da0 100644 --- a/semantic/dist/components/popup.js +++ b/semantic/dist/components/popup.js @@ -1,5 +1,5 @@ /*! - * # Semantic UI 2.2.13 - Popup + * # Semantic UI 2.5.0 - Popup * http://github.com/semantic-org/semantic-ui/ * * @@ -10,7 +10,7 @@ ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -488,7 +488,7 @@ $.fn.popup = function(parameters) { }, content: function() { $module.removeData(metadata.content); - return $module.data(metadata.content) || $module.attr('title') || settings.content; + return $module.data(metadata.content) || settings.content || $module.attr('title'); }, variation: function() { $module.removeData(metadata.variation); @@ -502,9 +502,10 @@ $.fn.popup = function(parameters) { }, calculations: function() { var - targetElement = $target[0], - isWindow = ($boundary[0] == window), - targetPosition = (settings.inline || (settings.popup && settings.movePopup)) + $popupOffsetParent = module.get.offsetParent($popup), + targetElement = $target[0], + isWindow = ($boundary[0] == window), + targetPosition = (settings.inline || (settings.popup && settings.movePopup)) ? $target.position() : $target.offset(), screenPosition = (isWindow) @@ -549,6 +550,17 @@ $.fn.popup = function(parameters) { } }; + // if popup offset context is not same as target, then adjust calculations + if($popupOffsetParent.get(0) !== $offsetParent.get(0)) { + var + popupOffset = $popupOffsetParent.offset() + ; + calculations.target.top -= popupOffset.top; + calculations.target.left -= popupOffset.left; + calculations.parent.width = $popupOffsetParent.outerWidth(); + calculations.parent.height = $popupOffsetParent.outerHeight(); + } + // add in container calcs if fluid if( settings.setFluidWidth && module.is.fluid() ) { calculations.container = { @@ -625,11 +637,11 @@ $.fn.popup = function(parameters) { } return distanceFromBoundary; }, - offsetParent: function($target) { + offsetParent: function($element) { var - element = ($target !== undefined) - ? $target[0] - : $module[0], + element = ($element !== undefined) + ? $element[0] + : $target[0], parentNode = element.parentNode, $node = $(parentNode) ; @@ -637,14 +649,14 @@ $.fn.popup = function(parameters) { var is2D = ($node.css('transform') === 'none'), isStatic = ($node.css('position') === 'static'), - isHTML = $node.is('html') + isBody = $node.is('body') ; - while(parentNode && !isHTML && isStatic && is2D) { + while(parentNode && !isBody && isStatic && is2D) { parentNode = parentNode.parentNode; $node = $(parentNode); is2D = ($node.css('transform') === 'none'); isStatic = ($node.css('position') === 'static'); - isHTML = $node.is('html'); + isBody = $node.is('body'); } } return ($node && $node.length > 0) @@ -753,6 +765,18 @@ $.fn.popup = function(parameters) { popup = calculations.popup; parent = calculations.parent; + if(module.should.centerArrow(calculations)) { + module.verbose('Adjusting offset to center arrow on small target element'); + if(position == 'top left' || position == 'bottom left') { + offset += (target.width / 2) + offset -= settings.arrowPixelsFromEdge; + } + if(position == 'top right' || position == 'bottom right') { + offset -= (target.width / 2) + offset += settings.arrowPixelsFromEdge; + } + } + if(target.width === 0 && target.height === 0 && !module.is.svg(target.element)) { module.debug('Popup target is hidden, no action taken'); return false; @@ -988,12 +1012,12 @@ $.fn.popup = function(parameters) { if(settings.hideOnScroll === true || (settings.hideOnScroll == 'auto' && settings.on != 'click')) { module.bind.closeOnScroll(); } - if(settings.on == 'hover' && openedWithTouch) { - module.bind.touchClose(); - } - if(settings.on == 'click' && settings.closable) { + if(module.is.closable()) { module.bind.clickaway(); } + else if(settings.on == 'hover' && openedWithTouch) { + module.bind.touchClose(); + } }, closeOnScroll: function() { module.verbose('Binding scroll close event to document'); @@ -1046,7 +1070,22 @@ $.fn.popup = function(parameters) { } }, + should: { + centerArrow: function(calculations) { + return !module.is.basic() && calculations.target.width <= (settings.arrowPixelsFromEdge * 2); + }, + }, + is: { + closable: function() { + if(settings.closable == 'auto') { + if(settings.on == 'hover') { + return false; + } + return true; + } + return settings.closable; + }, offstage: function(distanceFromBoundary, position) { var offstage = [] @@ -1068,6 +1107,9 @@ $.fn.popup = function(parameters) { svg: function(element) { return module.supports.svg() && (element instanceof SVGGraphicsElement); }, + basic: function() { + return $module.hasClass(className.basic); + }, active: function() { return $module.hasClass(className.active); }, @@ -1380,8 +1422,11 @@ $.fn.popup.settings = { // specify position to appear even if it doesn't fit lastResort : false, + // number of pixels from edge of popup to pointing arrow center (used from centering) + arrowPixelsFromEdge: 20, + // delay used to prevent accidental refiring of animations due to user error - delay : { + delay : { show : 50, hide : 70 }, @@ -1425,6 +1470,7 @@ $.fn.popup.settings = { className : { active : 'active', + basic : 'basic', animating : 'animating', dropdown : 'dropdown', fluid : 'fluid', diff --git a/semantic/dist/components/popup.min.js b/semantic/dist/components/popup.min.js index 865db88..685ab80 100644 --- a/semantic/dist/components/popup.min.js +++ b/semantic/dist/components/popup.min.js @@ -1 +1 @@ -!function(N,V,M,W){"use strict";V=void 0!==V&&V.Math==Math?V:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),N.fn.popup=function(x){var k,t=N(this),S=N(M),E=N(V),O=N("body"),A=t.selector||"",D=(new Date).getTime(),j=[],F=x,R="string"==typeof F,H=[].slice.call(arguments,1);return t.each(function(){var u,s,t,e,o,c,d=N.isPlainObject(x)?N.extend(!0,{},N.fn.popup.settings,x):N.extend({},N.fn.popup.settings),i=d.selector,f=d.className,g=d.error,h=d.metadata,n=d.namespace,r="."+d.namespace,a="module-"+n,m=N(this),p=N(d.context),l=N(d.scrollContext),v=N(d.boundary),b=d.target?N(d.target):m,w=0,y=!1,C=!1,T=this,P=m.data(a);c={initialize:function(){c.debug("Initializing",m),c.createID(),c.bind.events(),!c.exists()&&d.preserve&&c.create(),d.observeChanges&&c.observeChanges(),c.instantiate()},instantiate:function(){c.verbose("Storing instance",c),P=c,m.data(a,P)},observeChanges:function(){"MutationObserver"in V&&((t=new MutationObserver(c.event.documentChanged)).observe(M,{childList:!0,subtree:!0}),c.debug("Setting up mutation observer",t))},refresh:function(){d.popup?u=N(d.popup).eq(0):d.inline&&(u=b.nextAll(i.popup).eq(0),d.popup=u),d.popup?(u.addClass(f.loading),s=c.get.offsetParent(),u.removeClass(f.loading),d.movePopup&&c.has.popup()&&c.get.offsetParent(u)[0]!==s[0]&&(c.debug("Moving popup to the same offset parent as target"),u.detach().appendTo(s))):s=d.inline?c.get.offsetParent(b):c.has.popup()?c.get.offsetParent(u):O,s.is("html")&&s[0]!==O[0]&&(c.debug("Setting page as offset parent"),s=O),c.get.variation()&&c.set.variation()},reposition:function(){c.refresh(),c.set.position()},destroy:function(){c.debug("Destroying previous module"),t&&t.disconnect(),u&&!d.preserve&&c.removePopup(),clearTimeout(c.hideTimer),clearTimeout(c.showTimer),c.unbind.close(),c.unbind.events(),m.removeData(a)},event:{start:function(t){var e=N.isPlainObject(d.delay)?d.delay.show:d.delay;clearTimeout(c.hideTimer),C||(c.showTimer=setTimeout(c.show,e))},end:function(){var t=N.isPlainObject(d.delay)?d.delay.hide:d.delay;clearTimeout(c.showTimer),c.hideTimer=setTimeout(c.hide,t)},touchstart:function(t){C=!0,c.show()},resize:function(){c.is.visible()&&c.set.position()},documentChanged:function(t){[].forEach.call(t,function(t){t.removedNodes&&[].forEach.call(t.removedNodes,function(t){(t==T||0").addClass(f.popup).data(h.activator,m).html(t),d.inline?(c.verbose("Inserting popup element inline",u),u.insertAfter(m)):(c.verbose("Appending popup element to body",u),u.appendTo(p)),c.refresh(),c.set.variation(),d.hoverable&&c.bind.popup(),d.onCreate.call(u,T)):0!==b.next(i.popup).length?(c.verbose("Pre-existing popup found"),d.inline=!0,d.popup=b.next(i.popup).data(h.activator,m),c.refresh(),d.hoverable&&c.bind.popup()):d.popup?(N(d.popup).data(h.activator,m),c.verbose("Used popup specified in settings"),c.refresh(),d.hoverable&&c.bind.popup()):c.debug("No content specified skipping display",T)},createID:function(){o=(Math.random().toString(16)+"000000000").substr(2,8),e="."+o,c.verbose("Creating unique id for element",o)},toggle:function(){c.debug("Toggling pop-up"),c.is.hidden()?(c.debug("Popup is hidden, showing pop-up"),c.unbind.close(),c.show()):(c.debug("Popup is visible, hiding pop-up"),c.hide())},show:function(t){if(t=t||function(){},c.debug("Showing pop-up",d.transition),c.is.hidden()&&(!c.is.active()||!c.is.dropdown())){if(c.exists()||c.create(),!1===d.onShow.call(u,T))return void c.debug("onShow callback returned false, cancelling popup animation");d.preserve||d.popup||c.refresh(),u&&c.set.position()&&(c.save.conditions(),d.exclusive&&c.hideAll(),c.animate.show(t))}},hide:function(t){if(t=t||function(){},c.is.visible()||c.is.animating()){if(!1===d.onHide.call(u,T))return void c.debug("onHide callback returned false, cancelling popup animation");c.remove.visible(),c.unbind.close(),c.restore.conditions(),c.animate.hide(t)}},hideAll:function(){N(i.popup).filter("."+f.popupVisible).each(function(){N(this).data(h.activator).popup("hide")})},exists:function(){return!!u&&(d.inline||d.popup?c.has.popup():1<=u.closest(p).length)},removePopup:function(){c.has.popup()&&!d.popup&&(c.debug("Removing popup",u),u.remove(),u=W,d.onRemove.call(u,T))},save:{conditions:function(){c.cache={title:m.attr("title")},c.cache.title&&m.removeAttr("title"),c.verbose("Saving original attributes",c.cache.title)}},restore:{conditions:function(){return c.cache&&c.cache.title&&(m.attr("title",c.cache.title),c.verbose("Restoring original attributes",c.cache.title)),!0}},supports:{svg:function(){return"undefined"==typeof SVGGraphicsElement}},animate:{show:function(t){t=N.isFunction(t)?t:function(){},d.transition&&N.fn.transition!==W&&m.transition("is supported")?(c.set.visible(),u.transition({animation:d.transition+" in",queue:!1,debug:d.debug,verbose:d.verbose,duration:d.duration,onComplete:function(){c.bind.close(),t.call(u,T),d.onVisible.call(u,T)}})):c.error(g.noTransition)},hide:function(t){t=N.isFunction(t)?t:function(){},c.debug("Hiding pop-up"),!1!==d.onHide.call(u,T)?d.transition&&N.fn.transition!==W&&m.transition("is supported")?u.transition({animation:d.transition+" out",queue:!1,duration:d.duration,debug:d.debug,verbose:d.verbose,onComplete:function(){c.reset(),t.call(u,T),d.onHidden.call(u,T)}}):c.error(g.noTransition):c.debug("onHide callback returned false, cancelling popup animation")}},change:{content:function(t){u.html(t)}},get:{html:function(){return m.removeData(h.html),m.data(h.html)||d.html},title:function(){return m.removeData(h.title),m.data(h.title)||d.title},content:function(){return m.removeData(h.content),m.data(h.content)||m.attr("title")||d.content},variation:function(){return m.removeData(h.variation),m.data(h.variation)||d.variation},popup:function(){return u},popupOffset:function(){return u.offset()},calculations:function(){var t,e=b[0],o=v[0]==V,n=d.inline||d.popup&&d.movePopup?b.position():b.offset(),i=o?{top:0,left:0}:v.offset(),r={},a=o?{top:E.scrollTop(),left:E.scrollLeft()}:{top:0,left:0};return r={target:{element:b[0],width:b.outerWidth(),height:b.outerHeight(),top:n.top,left:n.left,margin:{}},popup:{width:u.outerWidth(),height:u.outerHeight()},parent:{width:s.outerWidth(),height:s.outerHeight()},screen:{top:i.top,left:i.left,scroll:{top:a.top,left:a.left},width:v.width(),height:v.height()}},d.setFluidWidth&&c.is.fluid()&&(r.container={width:u.parent().outerWidth()},r.popup.width=r.container.width),r.target.margin.top=d.inline?parseInt(V.getComputedStyle(e).getPropertyValue("margin-top"),10):0,r.target.margin.left=d.inline?c.is.rtl()?parseInt(V.getComputedStyle(e).getPropertyValue("margin-right"),10):parseInt(V.getComputedStyle(e).getPropertyValue("margin-left"),10):0,t=r.screen,r.boundary={top:t.top+t.scroll.top,bottom:t.top+t.scroll.top+t.height,left:t.left+t.scroll.left,right:t.left+t.scroll.left+t.width},r},id:function(){return o},startEvent:function(){return"hover"==d.on?"mouseenter":"focus"==d.on&&"focus"},scrollEvent:function(){return"scroll"},endEvent:function(){return"hover"==d.on?"mouseleave":"focus"==d.on&&"blur"},distanceFromBoundary:function(t,e){var o,n,i={};return o=(e=e||c.get.calculations()).popup,n=e.boundary,t&&(i={top:t.top-n.top,left:t.left-n.left,right:n.right-(t.left+o.width),bottom:n.bottom-(t.top+o.height)},c.verbose("Distance from boundaries determined",t,i)),i},offsetParent:function(t){var e=(t!==W?t[0]:m[0]).parentNode,o=N(e);if(e)for(var n="none"===o.css("transform"),i="static"===o.css("position"),r=o.is("html");e&&!r&&i&&n;)e=e.parentNode,n="none"===(o=N(e)).css("transform"),i="static"===o.css("position"),r=o.is("html");return o&&0",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",popupVisible:"visible"},selector:{popup:".ui.popup"},templates:{escape:function(t){var e={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};return/[&<>"'`]/.test(t)?t.replace(/[&<>"'`]/g,function(t){return e[t]}):t},popup:function(t){var e="",o=N.fn.popup.settings.templates.escape;return typeof t!==W&&(typeof t.title!==W&&t.title&&(t.title=o(t.title),e+='
'+t.title+"
"),typeof t.content!==W&&t.content&&(t.content=o(t.content),e+='
'+t.content+"
")),e}}}}(jQuery,window,document); \ No newline at end of file +!function(N,V,W,M){"use strict";V=void 0!==V&&V.Math==Math?V:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),N.fn.popup=function(x){var k,t=N(this),E=N(W),S=N(V),A=N("body"),F=t.selector||"",O=(new Date).getTime(),D=[],j=x,H="string"==typeof j,R=[].slice.call(arguments,1);return t.each(function(){var p,a,t,e,o,u=N.isPlainObject(x)?N.extend(!0,{},N.fn.popup.settings,x):N.extend({},N.fn.popup.settings),n=u.selector,c=u.className,d=u.error,f=u.metadata,i=u.namespace,r="."+u.namespace,s="module-"+i,g=N(this),l=N(u.context),h=N(u.scrollContext),m=N(u.boundary),b=u.target?N(u.target):g,v=0,w=!1,y=!1,P=this,C=g.data(s),T={initialize:function(){T.debug("Initializing",g),T.createID(),T.bind.events(),!T.exists()&&u.preserve&&T.create(),u.observeChanges&&T.observeChanges(),T.instantiate()},instantiate:function(){T.verbose("Storing instance",T),C=T,g.data(s,C)},observeChanges:function(){"MutationObserver"in V&&((t=new MutationObserver(T.event.documentChanged)).observe(W,{childList:!0,subtree:!0}),T.debug("Setting up mutation observer",t))},refresh:function(){u.popup?p=N(u.popup).eq(0):u.inline&&(p=b.nextAll(n.popup).eq(0),u.popup=p),u.popup?(p.addClass(c.loading),a=T.get.offsetParent(),p.removeClass(c.loading),u.movePopup&&T.has.popup()&&T.get.offsetParent(p)[0]!==a[0]&&(T.debug("Moving popup to the same offset parent as target"),p.detach().appendTo(a))):a=u.inline?T.get.offsetParent(b):T.has.popup()?T.get.offsetParent(p):A,a.is("html")&&a[0]!==A[0]&&(T.debug("Setting page as offset parent"),a=A),T.get.variation()&&T.set.variation()},reposition:function(){T.refresh(),T.set.position()},destroy:function(){T.debug("Destroying previous module"),t&&t.disconnect(),p&&!u.preserve&&T.removePopup(),clearTimeout(T.hideTimer),clearTimeout(T.showTimer),T.unbind.close(),T.unbind.events(),g.removeData(s)},event:{start:function(t){var e=N.isPlainObject(u.delay)?u.delay.show:u.delay;clearTimeout(T.hideTimer),y||(T.showTimer=setTimeout(T.show,e))},end:function(){var t=N.isPlainObject(u.delay)?u.delay.hide:u.delay;clearTimeout(T.showTimer),T.hideTimer=setTimeout(T.hide,t)},touchstart:function(t){y=!0,T.show()},resize:function(){T.is.visible()&&T.set.position()},documentChanged:function(t){[].forEach.call(t,function(t){t.removedNodes&&[].forEach.call(t.removedNodes,function(t){(t==P||0").addClass(c.popup).data(f.activator,g).html(t),u.inline?(T.verbose("Inserting popup element inline",p),p.insertAfter(g)):(T.verbose("Appending popup element to body",p),p.appendTo(l)),T.refresh(),T.set.variation(),u.hoverable&&T.bind.popup(),u.onCreate.call(p,P)):0!==b.next(n.popup).length?(T.verbose("Pre-existing popup found"),u.inline=!0,u.popup=b.next(n.popup).data(f.activator,g),T.refresh(),u.hoverable&&T.bind.popup()):u.popup?(N(u.popup).data(f.activator,g),T.verbose("Used popup specified in settings"),T.refresh(),u.hoverable&&T.bind.popup()):T.debug("No content specified skipping display",P)},createID:function(){o=(Math.random().toString(16)+"000000000").substr(2,8),e="."+o,T.verbose("Creating unique id for element",o)},toggle:function(){T.debug("Toggling pop-up"),T.is.hidden()?(T.debug("Popup is hidden, showing pop-up"),T.unbind.close(),T.show()):(T.debug("Popup is visible, hiding pop-up"),T.hide())},show:function(t){t=t||function(){},T.debug("Showing pop-up",u.transition),!T.is.hidden()||T.is.active()&&T.is.dropdown()||(T.exists()||T.create(),!1===u.onShow.call(p,P)?T.debug("onShow callback returned false, cancelling popup animation"):(u.preserve||u.popup||T.refresh(),p&&T.set.position()&&(T.save.conditions(),u.exclusive&&T.hideAll(),T.animate.show(t))))},hide:function(t){t=t||function(){},(T.is.visible()||T.is.animating())&&(!1===u.onHide.call(p,P)?T.debug("onHide callback returned false, cancelling popup animation"):(T.remove.visible(),T.unbind.close(),T.restore.conditions(),T.animate.hide(t)))},hideAll:function(){N(n.popup).filter("."+c.popupVisible).each(function(){N(this).data(f.activator).popup("hide")})},exists:function(){return!!p&&(u.inline||u.popup?T.has.popup():1<=p.closest(l).length)},removePopup:function(){T.has.popup()&&!u.popup&&(T.debug("Removing popup",p),p.remove(),p=M,u.onRemove.call(p,P))},save:{conditions:function(){T.cache={title:g.attr("title")},T.cache.title&&g.removeAttr("title"),T.verbose("Saving original attributes",T.cache.title)}},restore:{conditions:function(){return T.cache&&T.cache.title&&(g.attr("title",T.cache.title),T.verbose("Restoring original attributes",T.cache.title)),!0}},supports:{svg:function(){return"undefined"==typeof SVGGraphicsElement}},animate:{show:function(t){t=N.isFunction(t)?t:function(){},u.transition&&N.fn.transition!==M&&g.transition("is supported")?(T.set.visible(),p.transition({animation:u.transition+" in",queue:!1,debug:u.debug,verbose:u.verbose,duration:u.duration,onComplete:function(){T.bind.close(),t.call(p,P),u.onVisible.call(p,P)}})):T.error(d.noTransition)},hide:function(t){t=N.isFunction(t)?t:function(){},T.debug("Hiding pop-up"),!1===u.onHide.call(p,P)?T.debug("onHide callback returned false, cancelling popup animation"):u.transition&&N.fn.transition!==M&&g.transition("is supported")?p.transition({animation:u.transition+" out",queue:!1,duration:u.duration,debug:u.debug,verbose:u.verbose,onComplete:function(){T.reset(),t.call(p,P),u.onHidden.call(p,P)}}):T.error(d.noTransition)}},change:{content:function(t){p.html(t)}},get:{html:function(){return g.removeData(f.html),g.data(f.html)||u.html},title:function(){return g.removeData(f.title),g.data(f.title)||u.title},content:function(){return g.removeData(f.content),g.data(f.content)||u.content||g.attr("title")},variation:function(){return g.removeData(f.variation),g.data(f.variation)||u.variation},popup:function(){return p},popupOffset:function(){return p.offset()},calculations:function(){var t=T.get.offsetParent(p),e=b[0],o=m[0]==V,n=u.inline||u.popup&&u.movePopup?b.position():b.offset(),i=o?{top:0,left:0}:m.offset(),r={},o=o?{top:S.scrollTop(),left:S.scrollLeft()}:{top:0,left:0},r={target:{element:b[0],width:b.outerWidth(),height:b.outerHeight(),top:n.top,left:n.left,margin:{}},popup:{width:p.outerWidth(),height:p.outerHeight()},parent:{width:a.outerWidth(),height:a.outerHeight()},screen:{top:i.top,left:i.left,scroll:{top:o.top,left:o.left},width:m.width(),height:m.height()}};return t.get(0)!==a.get(0)&&(n=t.offset(),r.target.top-=n.top,r.target.left-=n.left,r.parent.width=t.outerWidth(),r.parent.height=t.outerHeight()),u.setFluidWidth&&T.is.fluid()&&(r.container={width:p.parent().outerWidth()},r.popup.width=r.container.width),r.target.margin.top=u.inline?parseInt(V.getComputedStyle(e).getPropertyValue("margin-top"),10):0,r.target.margin.left=u.inline?T.is.rtl()?parseInt(V.getComputedStyle(e).getPropertyValue("margin-right"),10):parseInt(V.getComputedStyle(e).getPropertyValue("margin-left"),10):0,r.boundary={top:(i=r.screen).top+i.scroll.top,bottom:i.top+i.scroll.top+i.height,left:i.left+i.scroll.left,right:i.left+i.scroll.left+i.width},r},id:function(){return o},startEvent:function(){return"hover"==u.on?"mouseenter":"focus"==u.on&&"focus"},scrollEvent:function(){return"scroll"},endEvent:function(){return"hover"==u.on?"mouseleave":"focus"==u.on&&"blur"},distanceFromBoundary:function(t,e){var o={},n=(e=e||T.get.calculations()).popup,e=e.boundary;return t&&(o={top:t.top-e.top,left:t.left-e.left,right:e.right-(t.left+n.width),bottom:e.bottom-(t.top+n.height)},T.verbose("Distance from boundaries determined",t,o)),o},offsetParent:function(t){var e=(t!==M?t:b)[0].parentNode,o=N(e);if(e)for(var n="none"===o.css("transform"),i="static"===o.css("position"),r=o.is("body");e&&!r&&i&&n;)e=e.parentNode,n="none"===(o=N(e)).css("transform"),i="static"===o.css("position"),r=o.is("body");return o&&0",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",basic:"basic",animating:"animating",dropdown:"dropdown",fluid:"fluid",loading:"loading",popup:"ui popup",position:"top left center bottom right",visible:"visible",popupVisible:"visible"},selector:{popup:".ui.popup"},templates:{escape:function(t){var e={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};return/[&<>"'`]/.test(t)?t.replace(/[&<>"'`]/g,function(t){return e[t]}):t},popup:function(t){var e="",o=N.fn.popup.settings.templates.escape;return typeof t!==M&&(typeof t.title!==M&&t.title&&(t.title=o(t.title),e+='
'+t.title+"
"),typeof t.content!==M)&&t.content&&(t.content=o(t.content),e+='
'+t.content+"
"),e}}}}(jQuery,window,document); \ No newline at end of file diff --git a/semantic/dist/components/progress.js b/semantic/dist/components/progress.js index 1dfde3a..8b1103c 100644 --- a/semantic/dist/components/progress.js +++ b/semantic/dist/components/progress.js @@ -1,5 +1,5 @@ /*! - * # Semantic UI 2.2.13 - Progress + * # Semantic UI 2.5.0 - Progress * http://github.com/semantic-org/semantic-ui/ * * @@ -10,7 +10,7 @@ ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; window = (typeof window != 'undefined' && window.Math == Math) ? window diff --git a/semantic/dist/components/progress.min.js b/semantic/dist/components/progress.min.js index 3b82edf..0f65431 100644 --- a/semantic/dist/components/progress.min.js +++ b/semantic/dist/components/progress.min.js @@ -1 +1 @@ -!function(E,e,P,T){"use strict";void 0!==(e=void 0!==e&&e.Math==Math?e:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")())&&e.Math==Math||("undefined"!=typeof self&&self.Math==Math?self:Function("return this")());E.fn.progress=function(m){var b,e=E(this),h=e.selector||"",x=(new Date).getTime(),w=[],y=m,V="string"==typeof y,C=[].slice.call(arguments,1);return e.each(function(){var s,r=E.isPlainObject(m)?E.extend(!0,{},E.fn.progress.settings,m):E.extend({},E.fn.progress.settings),t=r.className,n=r.metadata,e=r.namespace,a=r.selector,l=r.error,o="."+e,i="module-"+e,c=E(this),u=E(this).find(a.bar),d=E(this).find(a.progress),g=E(this).find(a.label),v=this,p=c.data(i),f=!1;s={initialize:function(){s.debug("Initializing progress bar",r),s.set.duration(),s.set.transitionEvent(),s.read.metadata(),s.read.settings(),s.instantiate()},instantiate:function(){s.verbose("Storing instance of progress",s),p=s,c.data(i,s)},destroy:function(){s.verbose("Destroying previous progress for",c),clearInterval(p.interval),s.remove.state(),c.removeData(i),p=T},reset:function(){s.remove.nextValue(),s.update.progress(0)},complete:function(){(s.percent===T||s.percent<100)&&(s.remove.progressPoll(),s.set.percent(100))},read:{metadata:function(){var e={percent:c.data(n.percent),total:c.data(n.total),value:c.data(n.value)};e.percent&&(s.debug("Current percent value set from metadata",e.percent),s.set.percent(e.percent)),e.total&&(s.debug("Total value set from metadata",e.total),s.set.total(e.total)),e.value&&(s.debug("Current value set from metadata",e.value),s.set.value(e.value),s.set.progress(e.value))},settings:function(){!1!==r.total&&(s.debug("Current total set in settings",r.total),s.set.total(r.total)),!1!==r.value&&(s.debug("Current value set in settings",r.value),s.set.value(r.value),s.set.progress(s.value)),!1!==r.percent&&(s.debug("Current percent set in settings",r.percent),s.set.percent(r.percent))}},bind:{transitionEnd:function(t){var e=s.get.transitionEnd();u.one(e+o,function(e){clearTimeout(s.failSafeTimer),t.call(this,e)}),s.failSafeTimer=setTimeout(function(){u.triggerHandler(e)},r.duration+r.failSafeDelay),s.verbose("Adding fail safe timer",s.timer)}},increment:function(e){var t,n;s.has.total()?n=(t=s.get.value())+(e=e||1):(n=(t=s.get.percent())+(e=e||s.get.randomValue()),100,s.debug("Incrementing percentage by",t,n)),n=s.get.normalizedValue(n),s.set.progress(n)},decrement:function(e){var t,n;s.get.total()?(n=(t=s.get.value())-(e=e||1),s.debug("Decrementing value by",e,t)):(n=(t=s.get.percent())-(e=e||s.get.randomValue()),s.debug("Decrementing percentage by",e,t)),n=s.get.normalizedValue(n),s.set.progress(n)},has:{progressPoll:function(){return s.progressPoll},total:function(){return!1!==s.get.total()}},get:{text:function(e){var t=s.value||0,n=s.total||0,r=f?s.get.displayPercent():s.percent||0,a=0s.total)return s.debug("Value cannot increment above total",s.total),s.total}else if(100 .bar",label:"> .label",progress:".bar > .progress"},text:{active:!1,error:!1,success:!1,warning:!1,percent:"{percent}%",ratio:"{value} of {total}"},className:{active:"active",error:"error",success:"success",warning:"warning"}}}(jQuery,window,document); \ No newline at end of file +!function(E,e,P,T){"use strict";void 0!==(e=void 0!==e&&e.Math==Math?e:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")())&&e.Math==Math||"undefined"!=typeof self&&self.Math==Math||Function("return this")();E.fn.progress=function(m){var b,e=E(this),h=e.selector||"",x=(new Date).getTime(),w=[],y=m,V="string"==typeof y,C=[].slice.call(arguments,1);return e.each(function(){var r=E.isPlainObject(m)?E.extend(!0,{},E.fn.progress.settings,m):E.extend({},E.fn.progress.settings),t=r.className,n=r.metadata,e=r.namespace,a=r.selector,s=r.error,o="."+e,i="module-"+e,l=E(this),c=E(this).find(a.bar),u=E(this).find(a.progress),d=E(this).find(a.label),g=this,v=l.data(i),p=!1,f={initialize:function(){f.debug("Initializing progress bar",r),f.set.duration(),f.set.transitionEvent(),f.read.metadata(),f.read.settings(),f.instantiate()},instantiate:function(){f.verbose("Storing instance of progress",f),v=f,l.data(i,f)},destroy:function(){f.verbose("Destroying previous progress for",l),clearInterval(v.interval),f.remove.state(),l.removeData(i),v=T},reset:function(){f.remove.nextValue(),f.update.progress(0)},complete:function(){(f.percent===T||f.percent<100)&&(f.remove.progressPoll(),f.set.percent(100))},read:{metadata:function(){var e={percent:l.data(n.percent),total:l.data(n.total),value:l.data(n.value)};e.percent&&(f.debug("Current percent value set from metadata",e.percent),f.set.percent(e.percent)),e.total&&(f.debug("Total value set from metadata",e.total),f.set.total(e.total)),e.value&&(f.debug("Current value set from metadata",e.value),f.set.value(e.value),f.set.progress(e.value))},settings:function(){!1!==r.total&&(f.debug("Current total set in settings",r.total),f.set.total(r.total)),!1!==r.value&&(f.debug("Current value set in settings",r.value),f.set.value(r.value),f.set.progress(f.value)),!1!==r.percent&&(f.debug("Current percent set in settings",r.percent),f.set.percent(r.percent))}},bind:{transitionEnd:function(t){var e=f.get.transitionEnd();c.one(e+o,function(e){clearTimeout(f.failSafeTimer),t.call(this,e)}),f.failSafeTimer=setTimeout(function(){c.triggerHandler(e)},r.duration+r.failSafeDelay),f.verbose("Adding fail safe timer",f.timer)}},increment:function(e){var t,n;f.has.total()?n=(t=f.get.value())+(e=e||1):(t=f.get.percent(),e=e||f.get.randomValue(),f.debug("Incrementing percentage by",t,n=t+e)),n=f.get.normalizedValue(n),f.set.progress(n)},decrement:function(e){var t,n;f.get.total()?(n=(t=f.get.value())-(e=e||1),f.debug("Decrementing value by",e,t)):(n=(t=f.get.percent())-(e=e||f.get.randomValue()),f.debug("Decrementing percentage by",e,t)),n=f.get.normalizedValue(n),f.set.progress(n)},has:{progressPoll:function(){return f.progressPoll},total:function(){return!1!==f.get.total()}},get:{text:function(e){var t=f.value||0,n=f.total||0,r=p?f.get.displayPercent():f.percent||0,a=0f.total)return f.debug("Value cannot increment above total",f.total),f.total}else if(100 .bar",label:"> .label",progress:".bar > .progress"},text:{active:!1,error:!1,success:!1,warning:!1,percent:"{percent}%",ratio:"{value} of {total}"},className:{active:"active",error:"error",success:"success",warning:"warning"}}}(jQuery,window,document); \ No newline at end of file diff --git a/semantic/dist/components/search.js b/semantic/dist/components/search.js index 349e26b..198cba9 100644 --- a/semantic/dist/components/search.js +++ b/semantic/dist/components/search.js @@ -1,5 +1,5 @@ /*! - * # Semantic UI 2.2.13 - Search + * # Semantic UI 2.5.0 - Search * http://github.com/semantic-org/semantic-ui/ * * @@ -10,7 +10,7 @@ ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -70,6 +70,7 @@ $.fn.search = function(parameters) { initialize: function() { module.verbose('Initializing module'); + module.get.settings(); module.determine.searchFields(); module.bind.events(); module.set.type(); @@ -336,7 +337,7 @@ $.fn.search = function(parameters) { apiSettings = { debug : settings.debug, on : false, - cache : true, + cache : settings.cache, action : 'search', urlData : { query : searchTerm @@ -402,6 +403,12 @@ $.fn.search = function(parameters) { }, get: { + settings: function() { + if($.isPlainObject(parameters) && parameters.searchFullText) { + settings.fullTextSearch = parameters.searchFullText; + module.error(settings.error.oldSearchSyntax, element); + } + }, inputEvent: function() { var prompt = $prompt[0], @@ -545,8 +552,14 @@ $.fn.search = function(parameters) { ; module.set.loading(); module.save.results(results); - module.debug('Returned local search results', results); - + module.debug('Returned full local search results', results); + if(settings.maxResults > 0) { + module.debug('Using specified max results', results); + results = results.slice(0, settings.maxResults); + } + if(settings.type == 'category') { + results = module.create.categoryResults(results); + } searchHTML = module.generateResults({ results: results }); @@ -574,6 +587,7 @@ $.fn.search = function(parameters) { object: function(searchTerm, source, searchFields) { var results = [], + exactResults = [], fuzzyResults = [], searchExp = searchTerm.toString().replace(regExp.escape, '\\$&'), matchRegExp = new RegExp(regExp.beginsWith + searchExp, 'i'), @@ -582,9 +596,10 @@ $.fn.search = function(parameters) { addResult = function(array, result) { var notResult = ($.inArray(result, results) == -1), - notFuzzyResult = ($.inArray(result, fuzzyResults) == -1) + notFuzzyResult = ($.inArray(result, fuzzyResults) == -1), + notExactResults = ($.inArray(result, exactResults) == -1) ; - if(notResult && notFuzzyResult) { + if(notResult && notFuzzyResult && notExactResults) { array.push(result); } } @@ -605,7 +620,6 @@ $.fn.search = function(parameters) { module.error(error.source); return []; } - // iterate through search fields looking for matches $.each(searchFields, function(index, field) { $.each(source, function(label, content) { @@ -617,17 +631,30 @@ $.fn.search = function(parameters) { // content starts with value (first in results) addResult(results, content); } - else if(settings.searchFullText && module.fuzzySearch(searchTerm, content[field]) ) { + else if(settings.fullTextSearch === 'exact' && module.exactSearch(searchTerm, content[field]) ) { + // content fuzzy matches (last in results) + addResult(exactResults, content); + } + else if(settings.fullTextSearch == true && module.fuzzySearch(searchTerm, content[field]) ) { // content fuzzy matches (last in results) addResult(fuzzyResults, content); } } }); }); - return $.merge(results, fuzzyResults); + $.merge(exactResults, fuzzyResults) + $.merge(results, exactResults); + return results; } }, - + exactSearch: function (query, term) { + query = query.toLowerCase(); + term = term.toLowerCase(); + if(term.indexOf(query) > -1) { + return true; + } + return false; + }, fuzzySearch: function(query, term) { var termLength = term.length, @@ -739,6 +766,27 @@ $.fn.search = function(parameters) { }, create: { + categoryResults: function(results) { + var + categoryResults = {} + ; + $.each(results, function(index, result) { + if(!result.category) { + return; + } + if(categoryResults[result.category] === undefined) { + module.verbose('Creating new category of results', result.category); + categoryResults[result.category] = { + name : result.category, + results : [result] + } + } + else { + categoryResults[result.category].results.push(result); + } + }); + return categoryResults; + }, id: function(resultIndex, categoryIndex) { var resultID = (resultIndex + 1), // not zero indexed @@ -776,7 +824,10 @@ $.fn.search = function(parameters) { $selectedResult = (categoryIndex !== undefined) ? $results .children().eq(categoryIndex) - .children(selector.result).eq(resultIndex) + .children(selector.results) + .first() + .children(selector.result) + .eq(resultIndex) : $results .children(selector.result).eq(resultIndex) ; @@ -1197,8 +1248,8 @@ $.fn.search.settings = { // field to display in standard results template displayField : '', - // whether to include fuzzy results in local search - searchFullText : true, + // search anywhere in value (set to 'exact' to require exact matches + fullTextSearch : 'exact', // whether to add events to prompt automatically automatic : true, @@ -1209,7 +1260,7 @@ $.fn.search.settings = { // delay before searching searchDelay : 200, - // maximum results returned from local + // maximum results returned from search maxResults : 7, // whether to store lookups in local cache @@ -1245,14 +1296,15 @@ $.fn.search.settings = { }, error : { - source : 'Cannot search. No source used, and Semantic API module was not included', - noResults : 'Your search returned no results', - logging : 'Error in debug logging, exiting.', - noEndpoint : 'No search endpoint was specified', - noTemplate : 'A valid template name was not specified.', - serverError : 'There was an issue querying the server.', - maxResults : 'Results must be an array to use maxResults setting', - method : 'The method you called is not defined.' + 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.', + oldSearchSyntax : 'searchFullText setting has been renamed fullTextSearch for consistency, please adjust your settings.', + serverError : 'There was an issue querying the server.', + maxResults : 'Results must be an array to use maxResults setting', + method : 'The method you called is not defined.' }, metadata: { @@ -1354,6 +1406,7 @@ $.fn.search.settings = { } // each item inside category + html += '
'; html += '' + '
' ; diff --git a/semantic/dist/components/search.min.js b/semantic/dist/components/search.min.js index a26b946..314c284 100644 --- a/semantic/dist/components/search.min.js +++ b/semantic/dist/components/search.min.js @@ -1 +1 @@ -!function(A,E,T,D){"use strict";E=void 0!==E&&E.Math==Math?E:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),A.fn.search=function(R){var C,w=A(this),x=w.selector||"",F=(new Date).getTime(),j=[],k=R,q="string"==typeof k,S=[].slice.call(arguments,1);return A(this).each(function(){var f,u=A.isPlainObject(R)?A.extend(!0,{},A.fn.search.settings,R):A.extend({},A.fn.search.settings),g=u.className,l=u.metadata,c=u.regExp,i=u.fields,h=u.selector,d=u.error,e=u.namespace,n="."+e,t=e+"-module",p=A(this),m=p.find(h.prompt),s=p.find(h.searchButton),r=p.find(h.results),a=p.find(h.result),v=(p.find(h.category),this),o=p.data(t),b=!1,y=!1;f={initialize:function(){f.verbose("Initializing module"),f.determine.searchFields(),f.bind.events(),f.set.type(),f.create.results(),f.instantiate()},instantiate:function(){f.verbose("Storing instance of module",f),o=f,p.data(t,f)},destroy:function(){f.verbose("Destroying instance"),p.off(n).removeData(t)},refresh:function(){f.debug("Refreshing selector cache"),m=p.find(h.prompt),s=p.find(h.searchButton),p.find(h.category),r=p.find(h.results),a=p.find(h.result)},refreshResults:function(){r=p.find(h.results),a=p.find(h.result)},bind:{events:function(){f.verbose("Binding events to search"),u.automatic&&(p.on(f.get.inputEvent()+n,h.prompt,f.event.input),m.attr("autocomplete","off")),p.on("focus"+n,h.prompt,f.event.focus).on("blur"+n,h.prompt,f.event.blur).on("keydown"+n,h.prompt,f.handleKeyboard).on("click"+n,h.searchButton,f.query).on("mousedown"+n,h.results,f.event.result.mousedown).on("mouseup"+n,h.results,f.event.result.mouseup).on("click"+n,h.result,f.event.result.click)}},determine:{searchFields:function(){R&&R.searchFields!==D&&(u.searchFields=R.searchFields)}},event:{input:function(){u.searchDelay?(clearTimeout(f.timer),f.timer=setTimeout(function(){f.is.focused()&&f.query()},u.searchDelay)):f.query()},focus:function(){f.set.focus(),u.searchOnFocus&&f.has.minimumCharacters()&&f.query(function(){f.can.show()&&f.showResults()})},blur:function(e){var t=T.activeElement===this,s=function(){f.cancel.query(),f.remove.focus(),f.timer=setTimeout(f.hideResults,u.hideDelay)};t||(y=!1,f.resultsClicked?(f.debug("Determining if user action caused search to close"),p.one("click.close"+n,h.results,function(e){f.is.inMessage(e)||b?m.focus():(b=!1,f.is.animating()||f.is.hidden()||s())})):(f.debug("Input blurred without user action, closing results"),s()))},result:{mousedown:function(){f.resultsClicked=!0},mouseup:function(){f.resultsClicked=!1},click:function(e){f.debug("Search result selected");var t=A(this),s=t.find(h.title).eq(0),n=t.is("a[href]")?t:t.find("a[href]").eq(0),r=n.attr("href")||!1,i=n.attr("target")||!1,a=(s.html(),0=u.minCharacters},results:function(){return 0!==r.length&&""!=r.html()}},clear:{cache:function(e){var t=p.data(l.cache);e?e&&t&&t[e]&&(f.debug("Removing value from cache",e),delete t[e],p.data(l.cache,t)):(f.debug("Clearing cache",e),p.removeData(l.cache))}},read:{cache:function(e){var t=p.data(l.cache);return!!u.cache&&(f.verbose("Checking cache for generated html for query",e),"object"==typeof t&&t[e]!==D&&t[e])}},create:{id:function(e,t){var s,n=e+1;return t!==D?(s=String.fromCharCode(97+t)+n,f.verbose("Creating category result id",s)):(s=n,f.verbose("Creating result id",s)),s},results:function(){0===r.length&&(r=A("
").addClass(g.results).appendTo(p))}},inject:{result:function(e,t,s){f.verbose("Injecting result into results");var n=s!==D?r.children().eq(s).children(h.result).eq(t):r.children(h.result).eq(t);f.verbose("Injecting results metadata",n),n.data(l.result,e)},id:function(n){f.debug("Injecting unique ids into results");var r=0,i=0;return"category"===u.type?A.each(n,function(e,n){i=0,A.each(n.results,function(e,t){var s=n.results[e];s.id===D&&(s.id=f.create.id(i,r)),f.inject.result(s,i,r),i++}),r++}):A.each(n,function(e,t){var s=n[e];s.id===D&&(s.id=f.create.id(i)),f.inject.result(s,i),i++}),n}},save:{results:function(e){f.verbose("Saving current search results to metadata",e),p.data(l.results,e)}},write:{cache:function(e,t){var s=p.data(l.cache)!==D?p.data(l.cache):{};u.cache&&(f.verbose("Writing generated html to cache",e,t),s[e]=t,p.data(l.cache,s))}},addResults:function(e){if(A.isFunction(u.onResultsAdd)&&!1===u.onResultsAdd.call(r,e))return f.debug("onResultsAdd callback cancelled default action"),!1;e?(r.html(e),f.refreshResults(),u.selectFirstResult&&f.select.firstResult(),f.showResults()):f.hideResults(function(){r.empty()})},showResults:function(e){e=A.isFunction(e)?e:function(){},y||!f.is.visible()&&f.has.results()&&(f.can.transition()?(f.debug("Showing results with css animations"),r.transition({animation:u.transition+" in",debug:u.debug,verbose:u.verbose,duration:u.duration,onComplete:function(){e()},queue:!0})):(f.debug("Showing results with javascript"),r.stop().fadeIn(u.duration,u.easing)),u.onResultsOpen.call(r))},hideResults:function(e){e=A.isFunction(e)?e:function(){},f.is.visible()&&(f.can.transition()?(f.debug("Hiding results with css animations"),r.transition({animation:u.transition+" out",debug:u.debug,verbose:u.verbose,duration:u.duration,onComplete:function(){e()},queue:!0})):(f.debug("Hiding results with javascript"),r.stop().fadeOut(u.duration,u.easing)),u.onResultsClose.call(r))},generateResults:function(e){f.debug("Generating html from response",e);var t=u.templates[u.type],s=A.isPlainObject(e[i.results])&&!A.isEmptyObject(e[i.results]),n=A.isArray(e[i.results])&&0 .message",category:".category",result:".result",title:".title, .name"},templates:{escape:function(e){var t={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};return/[&<>"'`]/.test(e)?e.replace(/[&<>"'`]/g,function(e){return t[e]}):e},message:function(e,t){var s="";return e!==D&&t!==D&&(s+='
',s+="empty"==t?'
No Results
'+e+'
':'
'+e+"
",s+="
"),s},category:function(e,s){var n="";A.fn.search.settings.templates.escape;return e[s.categoryResults]!==D&&(A.each(e[s.categoryResults],function(e,t){t[s.results]!==D&&0',t[s.categoryName]!==D&&(n+='
'+t[s.categoryName]+"
"),A.each(t.results,function(e,t){t[s.url]?n+='':n+='',t[s.image]!==D&&(n+='
'),n+='
',t[s.price]!==D&&(n+='
'+t[s.price]+"
"),t[s.title]!==D&&(n+='
'+t[s.title]+"
"),t[s.description]!==D&&(n+='
'+t[s.description]+"
"),n+="
",n+="
"}),n+="
")}),e[s.action]&&(n+=''+e[s.action][s.actionText]+""),n)},standard:function(e,s){var n="";return e[s.results]!==D&&(A.each(e[s.results],function(e,t){t[s.url]?n+='':n+='',t[s.image]!==D&&(n+='
'),n+='
',t[s.price]!==D&&(n+='
'+t[s.price]+"
"),t[s.title]!==D&&(n+='
'+t[s.title]+"
"),t[s.description]!==D&&(n+='
'+t[s.description]+"
"),n+="
",n+="
"}),e[s.action]&&(n+=''+e[s.action][s.actionText]+""),n)}}}}(jQuery,window,document); \ No newline at end of file +!function(q,A,E,D){"use strict";A=void 0!==A&&A.Math==Math?A:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),q.fn.search=function(R){var C,x=q(this),w=x.selector||"",S=(new Date).getTime(),F=[],j=R,T="string"==typeof j,k=[].slice.call(arguments,1);return q(this).each(function(){var u=q.isPlainObject(R)?q.extend(!0,{},q.fn.search.settings,R):q.extend({},q.fn.search.settings),d=u.className,c=u.metadata,l=u.regExp,i=u.fields,f=u.selector,g=u.error,e=u.namespace,n="."+e,t=e+"-module",h=q(this),p=h.find(f.prompt),s=h.find(f.searchButton),r=h.find(f.results),a=h.find(f.result),o=(h.find(f.category),this),m=h.data(t),v=!1,y=!1,b={initialize:function(){b.verbose("Initializing module"),b.get.settings(),b.determine.searchFields(),b.bind.events(),b.set.type(),b.create.results(),b.instantiate()},instantiate:function(){b.verbose("Storing instance of module",b),m=b,h.data(t,b)},destroy:function(){b.verbose("Destroying instance"),h.off(n).removeData(t)},refresh:function(){b.debug("Refreshing selector cache"),p=h.find(f.prompt),s=h.find(f.searchButton),h.find(f.category),r=h.find(f.results),a=h.find(f.result)},refreshResults:function(){r=h.find(f.results),a=h.find(f.result)},bind:{events:function(){b.verbose("Binding events to search"),u.automatic&&(h.on(b.get.inputEvent()+n,f.prompt,b.event.input),p.attr("autocomplete","off")),h.on("focus"+n,f.prompt,b.event.focus).on("blur"+n,f.prompt,b.event.blur).on("keydown"+n,f.prompt,b.handleKeyboard).on("click"+n,f.searchButton,b.query).on("mousedown"+n,f.results,b.event.result.mousedown).on("mouseup"+n,f.results,b.event.result.mouseup).on("click"+n,f.result,b.event.result.click)}},determine:{searchFields:function(){R&&R.searchFields!==D&&(u.searchFields=R.searchFields)}},event:{input:function(){u.searchDelay?(clearTimeout(b.timer),b.timer=setTimeout(function(){b.is.focused()&&b.query()},u.searchDelay)):b.query()},focus:function(){b.set.focus(),u.searchOnFocus&&b.has.minimumCharacters()&&b.query(function(){b.can.show()&&b.showResults()})},blur:function(e){function t(){b.cancel.query(),b.remove.focus(),b.timer=setTimeout(b.hideResults,u.hideDelay)}var s=E.activeElement===this;s||(y=!1,b.resultsClicked?(b.debug("Determining if user action caused search to close"),h.one("click.close"+n,f.results,function(e){b.is.inMessage(e)||v?p.focus():(v=!1,b.is.animating()||b.is.hidden()||t())})):(b.debug("Input blurred without user action, closing results"),t()))},result:{mousedown:function(){b.resultsClicked=!0},mouseup:function(){b.resultsClicked=!1},click:function(e){b.debug("Search result selected");var t=q(this),s=t.find(f.title).eq(0),n=t.is("a[href]")?t:t.find("a[href]").eq(0),r=n.attr("href")||!1,i=n.attr("target")||!1,s=(s.html(),0=u.minCharacters},results:function(){return 0!==r.length&&""!=r.html()}},clear:{cache:function(e){var t=h.data(c.cache);e?t&&t[e]&&(b.debug("Removing value from cache",e),delete t[e],h.data(c.cache,t)):(b.debug("Clearing cache",e),h.removeData(c.cache))}},read:{cache:function(e){var t=h.data(c.cache);return!!u.cache&&(b.verbose("Checking cache for generated html for query",e),"object"==typeof t)&&t[e]!==D&&t[e]}},create:{categoryResults:function(e){var s={};return q.each(e,function(e,t){t.category&&(s[t.category]===D?(b.verbose("Creating new category of results",t.category),s[t.category]={name:t.category,results:[t]}):s[t.category].results.push(t))}),s},id:function(e,t){var s,e=e+1;return t!==D?(t=String.fromCharCode(97+t),b.verbose("Creating category result id",s=t+e)):b.verbose("Creating result id",s=e),s},results:function(){0===r.length&&(r=q("
").addClass(d.results).appendTo(h))}},inject:{result:function(e,t,s){b.verbose("Injecting result into results");s=(s!==D?r.children().eq(s).children(f.results).first():r).children(f.result).eq(t);b.verbose("Injecting results metadata",s),s.data(c.result,e)},id:function(s){b.debug("Injecting unique ids into results");var n=0,r=0;return"category"===u.type?q.each(s,function(e,s){r=0,q.each(s.results,function(e,t){e=s.results[e];e.id===D&&(e.id=b.create.id(r,n)),b.inject.result(e,r,n),r++}),n++}):q.each(s,function(e,t){e=s[e];e.id===D&&(e.id=b.create.id(r)),b.inject.result(e,r),r++}),s}},save:{results:function(e){b.verbose("Saving current search results to metadata",e),h.data(c.results,e)}},write:{cache:function(e,t){var s=h.data(c.cache)!==D?h.data(c.cache):{};u.cache&&(b.verbose("Writing generated html to cache",e,t),s[e]=t,h.data(c.cache,s))}},addResults:function(e){if(q.isFunction(u.onResultsAdd)&&!1===u.onResultsAdd.call(r,e))return b.debug("onResultsAdd callback cancelled default action"),!1;e?(r.html(e),b.refreshResults(),u.selectFirstResult&&b.select.firstResult(),b.showResults()):b.hideResults(function(){r.empty()})},showResults:function(e){e=q.isFunction(e)?e:function(){},y||!b.is.visible()&&b.has.results()&&(b.can.transition()?(b.debug("Showing results with css animations"),r.transition({animation:u.transition+" in",debug:u.debug,verbose:u.verbose,duration:u.duration,onComplete:function(){e()},queue:!0})):(b.debug("Showing results with javascript"),r.stop().fadeIn(u.duration,u.easing)),u.onResultsOpen.call(r))},hideResults:function(e){e=q.isFunction(e)?e:function(){},b.is.visible()&&(b.can.transition()?(b.debug("Hiding results with css animations"),r.transition({animation:u.transition+" out",debug:u.debug,verbose:u.verbose,duration:u.duration,onComplete:function(){e()},queue:!0})):(b.debug("Hiding results with javascript"),r.stop().fadeOut(u.duration,u.easing)),u.onResultsClose.call(r))},generateResults:function(e){b.debug("Generating html from response",e);var t=u.templates[u.type],s=q.isPlainObject(e[i.results])&&!q.isEmptyObject(e[i.results]),n=q.isArray(e[i.results])&&0 .message",category:".category",result:".result",title:".title, .name"},templates:{escape:function(e){var t={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"};return/[&<>"'`]/.test(e)?e.replace(/[&<>"'`]/g,function(e){return t[e]}):e},message:function(e,t){var s="";return s=e!==D&&t!==D?(s+='
')+("empty"==t?'
No Results
'+e+'
':'
'+e+"
")+"
":s},category:function(e,s){var n="";q.fn.search.settings.templates.escape;return e[s.categoryResults]!==D&&(q.each(e[s.categoryResults],function(e,t){t[s.results]!==D&&0',t[s.categoryName]!==D&&(n+='
'+t[s.categoryName]+"
"),n+='
")}),e[s.action]&&(n+=''+e[s.action][s.actionText]+""),n)},standard:function(e,s){var n="";return e[s.results]!==D&&(q.each(e[s.results],function(e,t){t[s.url]?n+='':n+='',t[s.image]!==D&&(n+='
'),n+='
',t[s.price]!==D&&(n+='
'+t[s.price]+"
"),t[s.title]!==D&&(n+='
'+t[s.title]+"
"),t[s.description]!==D&&(n+='
'+t[s.description]+"
"),n+="
"}),e[s.action]&&(n+=''+e[s.action][s.actionText]+""),n)}}}}(jQuery,window,document); \ No newline at end of file diff --git a/semantic/dist/components/sidebar.js b/semantic/dist/components/sidebar.js index bab3cb9..857e926 100644 --- a/semantic/dist/components/sidebar.js +++ b/semantic/dist/components/sidebar.js @@ -1,5 +1,5 @@ /*! - * # Semantic UI 2.2.13 - Sidebar + * # Semantic UI 2.5.0 - Sidebar * http://github.com/semantic-org/semantic-ui/ * * @@ -10,7 +10,7 @@ ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; window = (typeof window != 'undefined' && window.Math == Math) ? window diff --git a/semantic/dist/components/sidebar.min.js b/semantic/dist/components/sidebar.min.js index 3aa8535..4265faf 100644 --- a/semantic/dist/components/sidebar.min.js +++ b/semantic/dist/components/sidebar.min.js @@ -1 +1 @@ -!function(D,j,R,z){"use strict";j=void 0!==j&&j.Math==Math?j:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),D.fn.sidebar=function(C){var k,e=D(this),w=D(j),T=D(R),x=D("html"),S=D("head"),A=e.selector||"",F=(new Date).getTime(),O=[],P=C,E="string"==typeof P,H=[].slice.call(arguments,1),M=j.requestAnimationFrame||j.mozRequestAnimationFrame||j.webkitRequestAnimationFrame||j.msRequestAnimationFrame||function(e){setTimeout(e,0)};return e.each(function(){var s,a,e,i,l,c,d=D.isPlainObject(C)?D.extend(!0,{},D.fn.sidebar.settings,C):D.extend({},D.fn.sidebar.settings),n=d.selector,r=d.className,t=d.namespace,o=d.regExp,u=d.error,f="."+t,b="module-"+t,h=D(this),m=D(d.context),g=h.children(n.sidebar),v=(m.children(n.fixed),m.children(n.pusher)),p=this,y=h.data(b);c={initialize:function(){c.debug("Initializing sidebar",C),c.create.id(),l=c.get.transitionEvent(),d.delaySetup?M(c.setup.layout):c.setup.layout(),M(function(){c.setup.cache()}),c.instantiate()},instantiate:function(){c.verbose("Storing instance of module",c),y=c,h.data(b,c)},create:{id:function(){e=(Math.random().toString(16)+"000000000").substr(2,8),a="."+e,c.verbose("Creating unique id for element",e)}},destroy:function(){c.verbose("Destroying previous module for",h),h.off(f).removeData(b),c.is.ios()&&c.remove.ios(),m.off(a),w.off(a),T.off(a)},event:{clickaway:function(e){var i=0=p.scrollHeight&&(p.scrollTop=p.scrollHeight-p.offsetHeight-1)},scroll:function(e){0===D(e.target).closest(n.sidebar).length&&e.preventDefault()}},bind:{clickaway:function(){c.verbose("Adding clickaway events to context",m),d.closable&&m.on("click"+a,c.event.clickaway).on("touchend"+a,c.event.clickaway)},scrollLock:function(){d.scrollLock&&(c.debug("Disabling page scroll"),w.on("DOMMouseScroll"+a,c.event.scroll)),c.verbose("Adding events to contain sidebar scroll"),T.on("touchmove"+a,c.event.touch),h.on("scroll"+f,c.event.containScroll)}},unbind:{clickaway:function(){c.verbose("Removing clickaway events from context",m),m.off(a)},scrollLock:function(){c.verbose("Removing scroll lock from page"),T.off(a),w.off(a),h.off("scroll"+f)}},add:{inlineCSS:function(){var e,i=c.cache.width||h.outerWidth(),n=c.cache.height||h.outerHeight(),t=c.is.rtl(),o=c.get.direction(),r={left:i,right:-i,top:n,bottom:-n};t&&(c.verbose("RTL detected, flipping widths"),r.left=-i,r.right=i),e="").appendTo(S),c.debug("Adding sizing css to head",s)}},refresh:function(){c.verbose("Refreshing selector cache"),m=D(d.context),g=m.children(n.sidebar),v=m.children(n.pusher),m.children(n.fixed),c.clear.cache()},refreshSidebars:function(){c.verbose("Refreshing other sidebars"),g=m.children(n.sidebar)},repaint:function(){c.verbose("Forcing repaint event"),p.style.display="none";p.offsetHeight;p.scrollTop=p.scrollTop,p.style.display=""},setup:{cache:function(){c.cache={width:h.outerWidth(),height:h.outerHeight(),rtl:"rtl"==h.css("direction")}},layout:function(){0===m.children(n.pusher).length&&(c.debug("Adding wrapper element for sidebar"),c.error(u.pusher),v=D('
'),m.children().not(n.omitted).not(g).wrapAll(v),c.refresh()),0!==h.nextAll(n.pusher).length&&h.nextAll(n.pusher)[0]===v[0]||(c.debug("Moved sidebar to correct parent element"),c.error(u.movedSidebar,p),h.detach().prependTo(m),c.refresh()),c.clear.cache(),c.set.pushable(),c.set.direction()}},attachEvents:function(e,i){var n=D(e);i=D.isFunction(c[i])?c[i]:c.toggle,0=v.scrollHeight&&(v.scrollTop=v.scrollHeight-v.offsetHeight-1)},scroll:function(e){0===D(e.target).closest(n.sidebar).length&&e.preventDefault()}},bind:{clickaway:function(){y.verbose("Adding clickaway events to context",h),a.closable&&h.on("click"+r,y.event.clickaway).on("touchend"+r,y.event.clickaway)},scrollLock:function(){a.scrollLock&&(y.debug("Disabling page scroll"),w.on("DOMMouseScroll"+r,y.event.scroll)),y.verbose("Adding events to contain sidebar scroll"),T.on("touchmove"+r,y.event.touch),b.on("scroll"+u,y.event.containScroll)}},unbind:{clickaway:function(){y.verbose("Removing clickaway events from context",h),h.off(r)},scrollLock:function(){y.verbose("Removing scroll lock from page"),T.off(r),w.off(r),b.off("scroll"+u)}},add:{inlineCSS:function(){var e=y.cache.width||b.outerWidth(),i=y.cache.height||b.outerHeight(),n=y.is.rtl(),t=y.get.direction(),i={left:e,right:-e,top:i,bottom:-i};n&&(y.verbose("RTL detected, flipping widths"),i.left=-e,i.right=e),n="").appendTo(S),y.debug("Adding sizing css to head",o)}},refresh:function(){y.verbose("Refreshing selector cache"),h=D(a.context),m=h.children(n.sidebar),g=h.children(n.pusher),h.children(n.fixed),y.clear.cache()},refreshSidebars:function(){y.verbose("Refreshing other sidebars"),m=h.children(n.sidebar)},repaint:function(){y.verbose("Forcing repaint event"),v.style.display="none";v.offsetHeight;v.scrollTop=v.scrollTop,v.style.display=""},setup:{cache:function(){y.cache={width:b.outerWidth(),height:b.outerHeight(),rtl:"rtl"==b.css("direction")}},layout:function(){0===h.children(n.pusher).length&&(y.debug("Adding wrapper element for sidebar"),y.error(d.pusher),g=D('
'),h.children().not(n.omitted).not(m).wrapAll(g),y.refresh()),0!==b.nextAll(n.pusher).length&&b.nextAll(n.pusher)[0]===g[0]||(y.debug("Moved sidebar to correct parent element"),y.error(d.movedSidebar,v),b.detach().prependTo(h),y.refresh()),y.clear.cache(),y.set.pushable(),y.set.direction()}},attachEvents:function(e,i){var n=D(e);i=D.isFunction(y[i])?y[i]:y.toggle,0").addClass(e).insertAfter(f)).addClass(s).removeClass(c.inward).removeClass(c.outward).addClass(c.animating).addClass(c.transition).css("animationName"),o=t.addClass(c.inward).css("animationName"),u||(u=t.attr("class",e).removeAttr("style").removeClass(c.hidden).removeClass(c.visible).show().css("display"),m.verbose("Determining final display state",u),m.save.displayType(u)),t.remove(),a!=o)m.debug("Direction exists for animation",s),r=!0;else{if("none"==a||!a)return void m.debug("No animation defined in css",s);m.debug("Static animation found",s,u),r=!1}m.save.transitionExists(s,r)}return l!==S?l:r},animate:function(){return m.can.transition()!==S}},is:{animating:function(){return f.hasClass(c.animating)},inward:function(){return f.hasClass(c.inward)},outward:function(){return f.hasClass(c.outward)},looping:function(){return f.hasClass(c.looping)},occurring:function(n){return n="."+(n=n||d.animation).replace(" ","."),0").addClass(n).insertAfter(c)).addClass(o).removeClass(u.inward).removeClass(u.outward).addClass(u.animating).addClass(u.transition).css("animationName"),t=e.addClass(u.inward).css("animationName"),s||(s=e.attr("class",n).removeAttr("style").removeClass(u.hidden).removeClass(u.visible).show().css("display"),m.verbose("Determining final display state",s),m.save.displayType(s)),e.remove(),i!=t)m.debug("Direction exists for animation",o),a=!0;else{if("none"==i||!i)return void m.debug("No animation defined in css",o);m.debug("Static animation found",o,s),a=!1}m.save.transitionExists(o,a)}return r!==S?r:a},animate:function(){return m.can.transition()!==S}},is:{animating:function(){return c.hasClass(u.animating)},inward:function(){return c.hasClass(u.inward)},outward:function(){return c.hasClass(u.outward)},looping:function(){return c.hasClass(u.looping)},occurring:function(n){return n="."+(n=n||l.animation).replace(" ","."),0 0) + ; + if(hasRemoteValues) { + module.remove.message(); + module.setup.menu({ + values: response[fields.remoteValues] + }); + } + else { + module.add.message(message.noResults); + } callback(); } } @@ -3729,7 +3763,12 @@ $.fn.dropdown = function(parameters) { }, icon: { click: function(event) { - module.toggle(); + if($icon.hasClass(className.clear)) { + module.clear(); + } + else if (module.can.click()) { + module.toggle(); + } } }, text: { @@ -4336,7 +4375,7 @@ $.fn.dropdown = function(parameters) { : text ; if( module.can.activate( $(element) ) ) { - module.set.value(value, $(element)); + module.set.value(value, text, $(element)); if(module.is.multiple() && !module.is.allFiltered()) { return; } @@ -4356,7 +4395,7 @@ $.fn.dropdown = function(parameters) { }, hide: function(text, value, element) { - module.set.value(value, text); + module.set.value(value, text, $(element)); module.hideAndClear(); } @@ -5002,7 +5041,7 @@ $.fn.dropdown = function(parameters) { var length = module.get.query().length ; - $search.val( text.substr(0 , length)); + $search.val( text.substr(0, length)); }, scrollPosition: function($item, forceScroll) { var @@ -5154,7 +5193,6 @@ $.fn.dropdown = function(parameters) { var escapedValue = module.escape.value(value), hasInput = ($input.length > 0), - isAddition = !module.has.value(value), currentValue = module.get.values(), stringValue = (value !== undefined) ? String(value) @@ -5192,6 +5230,15 @@ $.fn.dropdown = function(parameters) { $module.data(metadata.value, stringValue); } } + if(module.is.single() && settings.clearable) { + // treat undefined or '' as empty + if(!escapedValue) { + module.remove.clearable(); + } + else { + module.set.clearable(); + } + } if(settings.fireOnInit === false && module.is.initialLoad()) { module.verbose('No callback on initial load', settings.onChange); } @@ -5257,8 +5304,8 @@ $.fn.dropdown = function(parameters) { module.save.remoteData(selectedText, selectedValue); } if(settings.useLabels) { - module.add.value(selectedValue, selectedText, $selected); module.add.label(selectedValue, selectedText, shouldAnimate); + module.add.value(selectedValue, selectedText, $selected); module.set.activeItem($selected); module.filterActive(); module.select.nextAvailable($selectedItem); @@ -5287,7 +5334,10 @@ $.fn.dropdown = function(parameters) { } }) ; - } + }, + clearable: function() { + $icon.addClass(className.clear); + }, }, add: { @@ -5299,6 +5349,9 @@ $.fn.dropdown = function(parameters) { escapedValue = module.escape.value(value), $label ; + if(settings.ignoreCase) { + escapedValue = escapedValue.toLowerCase(); + } $label = $('') .addClass(className.label) .attr('data-' + metadata.value, escapedValue) @@ -5307,7 +5360,7 @@ $.fn.dropdown = function(parameters) { $label = settings.onLabelCreate.call($label, escapedValue, text); if(module.has.label(value)) { - module.debug('Label already exists, skipping', escapedValue); + module.debug('User selection already exists, skipping', escapedValue); return; } if(settings.label.variation) { @@ -5446,6 +5499,10 @@ $.fn.dropdown = function(parameters) { currentValue = module.get.values(), newValue ; + if(module.has.value(addedValue)) { + module.debug('Value already selected'); + return; + } if(addedValue === '') { module.debug('Cannot select blank values from multiselect'); return; @@ -5478,7 +5535,7 @@ $.fn.dropdown = function(parameters) { } module.set.value(newValue, addedValue, addedText, $selectedItem); module.check.maxSelections(); - } + }, }, remove: { @@ -5703,6 +5760,9 @@ $.fn.dropdown = function(parameters) { .removeAttr('tabindex') ; } + }, + clearable: function() { + $icon.removeClass(className.clear); } }, @@ -5759,6 +5819,9 @@ $.fn.dropdown = function(parameters) { escapedValue = module.escape.value(value), $labels = $module.find(selector.label) ; + if(settings.ignoreCase) { + escapedValue = escapedValue.toLowerCase(); + } return ($labels.filter('[data-' + metadata.value + '="' + module.escape.string(escapedValue) +'"]').length > 0); }, maxSelections: function() { @@ -5777,6 +5840,12 @@ $.fn.dropdown = function(parameters) { return (module.get.query() !== ''); }, value: function(value) { + return (settings.ignoreCase) + ? module.has.valueIgnoringCase(value) + : module.has.valueMatchingCase(value) + ; + }, + valueMatchingCase: function(value) { var values = module.get.values(), hasValue = $.isArray(values) @@ -5787,6 +5856,22 @@ $.fn.dropdown = function(parameters) { ? true : false ; + }, + valueIgnoringCase: function(value) { + var + values = module.get.values(), + hasValue = false + ; + if(!$.isArray(values)) { + values = [values]; + } + $.each(values, function(index, existingValue) { + if(String(value).toLowerCase() == String(existingValue).toLowerCase()) { + hasValue = true; + return false; + } + }); + return hasValue; } }, @@ -5794,6 +5879,12 @@ $.fn.dropdown = function(parameters) { active: function() { return $module.hasClass(className.active); }, + animatingInward: function() { + return $menu.transition('is inward'); + }, + animatingOutward: function() { + return $menu.transition('is outward'); + }, bubbledLabelClick: function(event) { return $(event.target).is('select, input') && $module.closest('label').length > 0; }, @@ -5929,6 +6020,9 @@ $.fn.dropdown = function(parameters) { ; calculations = { context: { + offset : ($context.get(0) === window) + ? { top: 0, left: 0} + : $context.offset(), scrollTop : $context.scrollTop(), height : $context.outerHeight() }, @@ -5941,8 +6035,8 @@ $.fn.dropdown = function(parameters) { calculations.menu.offset.top += calculations.context.scrollTop; } onScreen = { - above : (calculations.context.scrollTop) <= calculations.menu.offset.top - calculations.menu.height, - below : (calculations.context.scrollTop + calculations.context.height) >= calculations.menu.offset.top + calculations.menu.height + above : (calculations.context.scrollTop) <= calculations.menu.offset.top - calculations.context.offset.top - calculations.menu.height, + below : (calculations.context.scrollTop + calculations.context.height) >= calculations.menu.offset.top - calculations.context.offset.top + calculations.menu.height }; if(onScreen.below) { module.verbose('Dropdown can fit in context downward', onScreen); @@ -5971,6 +6065,9 @@ $.fn.dropdown = function(parameters) { ; calculations = { context: { + offset : ($context.get(0) === window) + ? { top: 0, left: 0} + : $context.offset(), scrollLeft : $context.scrollLeft(), width : $context.outerWidth() }, @@ -5982,7 +6079,7 @@ $.fn.dropdown = function(parameters) { if(module.is.horizontallyScrollableContext()) { calculations.menu.offset.left += calculations.context.scrollLeft; } - isOffscreenRight = (calculations.menu.offset.left + calculations.menu.width >= calculations.context.scrollLeft + calculations.context.width); + isOffscreenRight = (calculations.menu.offset.left - calculations.context.offset.left + calculations.menu.width >= calculations.context.scrollLeft + calculations.context.width); if(isOffscreenRight) { module.verbose('Dropdown cannot fit in context rightward', isOffscreenRight); canOpenRightward = false; @@ -6088,7 +6185,7 @@ $.fn.dropdown = function(parameters) { duration : settings.duration, debug : settings.debug, verbose : settings.verbose, - queue : true, + queue : false, onStart : start, onComplete : function() { callback.call(element); @@ -6353,6 +6450,8 @@ $.fn.dropdown.settings = { values : false, // specify values to use for dropdown + clearable : false, // whether the value of the dropdown can be cleared + apiSettings : false, selectOnKeydown : true, // Whether selection should occur automatically when keyboard shortcuts used minCharacters : 0, // Minimum characters required to trigger API call @@ -6376,7 +6475,8 @@ $.fn.dropdown.settings = { forceSelection : true, // force a choice on blur with search selection allowAdditions : false, // whether multiple select should allow user added values - hideAdditions : true, // whether or not to hide special message prompting a user they can enter a value + ignoreCase : false, // whether to consider values not matching in case to be the same + hideAdditions : true, // whether or not to hide special message prompting a user they can enter a value maxSelections : false, // When set to a number limits the number of selections to this count useLabels : true, // whether multiple select should filter currently active selections from choices @@ -6504,6 +6604,7 @@ $.fn.dropdown.settings = { active : 'active', addition : 'addition', animating : 'animating', + clear : 'clear', disabled : 'disabled', empty : 'empty', dropdown : 'ui dropdown', @@ -6570,7 +6671,7 @@ $.fn.dropdown.settings.templates = { ? 'disabled ' : '' ; - html += '
' + html += '
'; html += option[fields.name]; html += '
'; }); @@ -6598,7 +6699,7 @@ $.fn.dropdown.settings.templates = { })( jQuery, window, document ); /*! - * # Semantic UI 2.2.13 - Form Validation + * # Semantic UI 2.5.0 - Form Validation * http://github.com/semantic-org/semantic-ui/ * * @@ -6609,7 +6710,7 @@ $.fn.dropdown.settings.templates = { ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -6957,7 +7058,7 @@ $.fn.form = function(parameters) { module.validate.field( validationRules ); } } - else if(settings.on == 'blur' || settings.on == 'change') { + else if(settings.on == 'blur') { if(validationRules) { module.validate.field( validationRules ); } @@ -7034,16 +7135,16 @@ $.fn.form = function(parameters) { var ruleName = module.get.ruleName(rule), ancillary = module.get.ancillaryValue(rule), - prompt = rule.prompt || settings.prompt[ruleName] || settings.text.unspecifiedRule, + $field = module.get.field(field.identifier), + value = $field.val(), + prompt = $.isFunction(rule.prompt) + ? rule.prompt(value) + : rule.prompt || settings.prompt[ruleName] || settings.text.unspecifiedRule, requiresValue = (prompt.search('{value}') !== -1), requiresName = (prompt.search('{name}') !== -1), $label, - $field, name ; - if(requiresName || requiresValue) { - $field = module.get.field(field.identifier); - } if(requiresValue) { prompt = prompt.replace('{value}', $field.val()); } @@ -7202,9 +7303,9 @@ $.fn.form = function(parameters) { } else { if(isRadio) { - if(values[name] === undefined) { + if(values[name] === undefined || values[name] == false) { values[name] = (isChecked) - ? true + ? value || true : false ; } @@ -7862,10 +7963,10 @@ $.fn.form.settings = { isExactly : '{name} must be exactly "{ruleValue}"', not : '{name} cannot be set to "{ruleValue}"', notExactly : '{name} cannot be set to exactly "{ruleValue}"', - contain : '{name} cannot contain "{ruleValue}"', - containExactly : '{name} cannot contain exactly "{ruleValue}"', - doesntContain : '{name} must contain "{ruleValue}"', - doesntContainExactly : '{name} must contain exactly "{ruleValue}"', + contain : '{name} must contain "{ruleValue}"', + containExactly : '{name} must contain exactly "{ruleValue}"', + doesntContain : '{name} cannot contain "{ruleValue}"', + doesntContainExactly : '{name} cannot contain exactly "{ruleValue}"', minLength : '{name} must be at least {ruleValue} characters', length : '{name} must be at least {ruleValue} characters', exactLength : '{name} must be exactly {ruleValue} characters', @@ -8305,7 +8406,7 @@ $.fn.form.settings = { })( jQuery, window, document ); /*! - * # Semantic UI 2.2.13 - Modal + * # Semantic UI 2.5.0 - Modal * http://github.com/semantic-org/semantic-ui/ * * @@ -8316,7 +8417,7 @@ $.fn.form.settings = { ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -8414,6 +8515,9 @@ $.fn.modal = function(parameters) { var defaultSettings = { debug : settings.debug, + variation : settings.centered + ? false + : 'top aligned', dimmerName : 'modals' }, dimmerSettings = $.extend(true, defaultSettings, settings.dimmerSettings) @@ -8434,13 +8538,16 @@ $.fn.modal = function(parameters) { $dimmer = $dimmable.dimmer('get dimmer'); }, id: function() { - id = (Math.random().toString(16) + '000000000').substr(2,8); + id = (Math.random().toString(16) + '000000000').substr(2, 8); elementEventNamespace = '.' + id; module.verbose('Creating unique id for element', id); } }, destroy: function() { + if (observer) { + observer.disconnect(); + } module.verbose('Destroying previous modal'); $module .removeData(moduleNamespace) @@ -8469,9 +8576,11 @@ $.fn.modal = function(parameters) { refresh: function() { module.remove.scrolling(); module.cacheSizes(); + if(!module.can.useFlex()) { + module.set.modalOffset(); + } module.set.screenHeight(); module.set.type(); - module.set.position(); }, refreshModals: function() { @@ -8510,12 +8619,22 @@ $.fn.modal = function(parameters) { $window .on('resize' + elementEventNamespace, module.event.resize) ; + }, + scrollLock: function() { + // touch events default to passive, due to changes in chrome to optimize mobile perf + $dimmable.get(0).addEventListener('touchmove', module.event.preventScroll, { passive: false }); + } + }, + + unbind: { + scrollLock: function() { + $dimmable.get(0).removeEventListener('touchmove', module.event.preventScroll, { passive: false }); } }, get: { id: function() { - return (Math.random().toString(16) + '000000000').substr(2,8); + return (Math.random().toString(16) + '000000000').substr(2, 8); } }, @@ -8530,6 +8649,9 @@ $.fn.modal = function(parameters) { ignoreRepeatedEvents = false; }); }, + preventScroll: function(event) { + event.preventDefault(); + }, deny: function() { if(ignoreRepeatedEvents || settings.onDeny.call(element, $(this)) === false) { module.verbose('Deny callback returned false cancelling hide'); @@ -8544,21 +8666,23 @@ $.fn.modal = function(parameters) { module.hide(); }, click: function(event) { + if(!settings.closable) { + module.verbose('Dimmer clicked but closable setting is disabled'); + return; + } var $target = $(event.target), isInModal = ($target.closest(selector.modal).length > 0), isInDOM = $.contains(document.documentElement, event.target) ; - if(!isInModal && isInDOM) { + if(!isInModal && isInDOM && module.is.active()) { module.debug('Dimmer clicked, hiding all modals'); - if( module.is.active() ) { - module.remove.clickaway(); - if(settings.allowMultiple) { - module.hide(); - } - else { - module.hideAll(); - } + module.remove.clickaway(); + if(settings.allowMultiple) { + module.hide(); + } + else { + module.hideAll(); } } }, @@ -8605,6 +8729,8 @@ $.fn.modal = function(parameters) { ; module.refreshModals(); module.set.dimmerSettings(); + module.set.dimmerStyles(); + module.showModal(callback); }, @@ -8623,10 +8749,16 @@ $.fn.modal = function(parameters) { : function(){} ; if( module.is.animating() || !module.is.active() ) { - module.showDimmer(); module.cacheSizes(); - module.set.position(); + if(module.can.useFlex()) { + module.remove.legacy(); + } + else { + module.set.legacy(); + module.set.modalOffset(); + module.debug('Using non-flex legacy modal positioning.'); + } module.set.screenHeight(); module.set.type(); module.set.clickaway(); @@ -8704,6 +8836,7 @@ $.fn.modal = function(parameters) { }, onComplete : function() { settings.onHidden.call(element); + module.remove.dimmerStyles(); module.restore.focus(); callback(); } @@ -8728,6 +8861,7 @@ $.fn.modal = function(parameters) { hideDimmer: function() { if( $dimmable.dimmer('is animating') || ($dimmable.dimmer('is active')) ) { + module.unbind.scrollLock(); $dimmable.dimmer('hide', function() { module.remove.clickaway(); module.remove.screenHeight(); @@ -8793,7 +8927,13 @@ $.fn.modal = function(parameters) { save: { focus: function() { - $focusedElement = $(document.activeElement).blur(); + var + $activeElement = $(document.activeElement), + inCurrentModal = $activeElement.closest($module).length > 0 + ; + if(!inCurrentModal) { + $focusedElement = $(document.activeElement).blur(); + } } }, @@ -8809,12 +8949,17 @@ $.fn.modal = function(parameters) { active: function() { $module.removeClass(className.active); }, + legacy: function() { + $module.removeClass(className.legacy); + }, clickaway: function() { - if(settings.closable) { - $dimmer - .off('click' + elementEventNamespace) - ; - } + $dimmer + .off('click' + elementEventNamespace) + ; + }, + dimmerStyles: function() { + $dimmer.removeClass(className.inverted); + $dimmable.removeClass(className.blurring); }, bodyStyle: function() { if($body.attr('style') === '') { @@ -8844,11 +8989,13 @@ $.fn.modal = function(parameters) { $module.addClass(className.loading); var scrollHeight = $module.prop('scrollHeight'), + modalWidth = $module.outerWidth(), modalHeight = $module.outerHeight() ; if(module.cache === undefined || modalHeight !== 0) { module.cache = { pageHeight : $(document).outerHeight(), + width : modalWidth, height : modalHeight + settings.offset, scrollHeight : scrollHeight + settings.offset, contextHeight : (settings.context == 'body') @@ -8862,6 +9009,12 @@ $.fn.modal = function(parameters) { }, can: { + useFlex: function() { + return (settings.useFlex == 'auto') + ? settings.detachable && !module.is.ie() + : settings.useFlex + ; + }, fit: function() { var contextHeight = module.cache.contextHeight, @@ -8883,6 +9036,13 @@ $.fn.modal = function(parameters) { active: function() { return $module.hasClass(className.active); }, + ie: function() { + var + isIE11 = (!(window.ActiveXObject) && 'ActiveXObject' in window), + isIE = ('ActiveXObject' in window) + ; + return (isIE11 || isIE); + }, animating: function() { return $module.transition('is supported') ? $module.transition('is animating') @@ -8894,7 +9054,7 @@ $.fn.modal = function(parameters) { }, modernBrowser: function() { // appName for IE11 reports 'Netscape' can no longer use - return !(window.ActiveXObject || "ActiveXObject" in window); + return !(window.ActiveXObject || 'ActiveXObject' in window); } }, @@ -8912,11 +9072,9 @@ $.fn.modal = function(parameters) { } }, clickaway: function() { - if(settings.closable) { - $dimmer - .on('click' + elementEventNamespace, module.event.click) - ; - } + $dimmer + .on('click' + elementEventNamespace, module.event.click) + ; }, dimmerSettings: function() { if($.fn.dimmer === undefined) { @@ -8927,8 +9085,11 @@ $.fn.modal = function(parameters) { defaultSettings = { debug : settings.debug, dimmerName : 'modals', - variation : false, closable : 'auto', + useFlex : module.can.useFlex(), + variation : settings.centered + ? false + : 'top aligned', duration : { show : settings.duration, hide : settings.duration @@ -8941,6 +9102,11 @@ $.fn.modal = function(parameters) { ? dimmerSettings.variation + ' inverted' : 'inverted' ; + } + $context.dimmer('setting', dimmerSettings); + }, + dimmerStyles: function() { + if(settings.inverted) { $dimmer.addClass(className.inverted); } else { @@ -8952,7 +9118,21 @@ $.fn.modal = function(parameters) { else { $dimmable.removeClass(className.blurring); } - $context.dimmer('setting', dimmerSettings); + }, + modalOffset: function() { + var + width = module.cache.width, + height = module.cache.height + ; + $module + .css({ + marginTop: (settings.centered && module.can.fit()) + ? -(height / 2) + : 0, + marginLeft: -(width / 2) + }) + ; + module.verbose('Setting modal offset for legacy mode'); }, screenHeight: function() { if( module.can.fit() ) { @@ -8971,12 +9151,17 @@ $.fn.modal = function(parameters) { scrolling: function() { $dimmable.addClass(className.scrolling); $module.addClass(className.scrolling); + module.unbind.scrollLock(); + }, + legacy: function() { + $module.addClass(className.legacy); }, type: function() { if(module.can.fit()) { module.verbose('Modal fits on screen'); if(!module.others.active() && !module.others.animating()) { module.remove.scrolling(); + module.bind.scrollLock(); } } else { @@ -8984,25 +9169,6 @@ $.fn.modal = function(parameters) { module.set.scrolling(); } }, - position: function() { - module.verbose('Centering modal on page', module.cache); - if(module.can.fit()) { - $module - .css({ - top: '', - marginTop: module.cache.topOffset - }) - ; - } - else { - $module - .css({ - marginTop : '', - top : $document.scrollTop() - }) - ; - } - }, undetached: function() { $dimmable.addClass(className.undetached); } @@ -9196,6 +9362,9 @@ $.fn.modal.settings = { name : 'Modal', namespace : 'modal', + useFlex : 'auto', + offset : 0, + silent : false, debug : false, verbose : false, @@ -9211,6 +9380,8 @@ $.fn.modal.settings = { inverted : false, blurring : false, + centered : true, + dimmerSettings : { closable : false, useCSS : true @@ -9223,7 +9394,6 @@ $.fn.modal.settings = { queue : false, duration : 500, - offset : 0, transition : 'scale', // padding with edge of page @@ -9263,6 +9433,7 @@ $.fn.modal.settings = { animating : 'animating', blurring : 'blurring', inverted : 'inverted', + legacy : 'legacy', loading : 'loading', scrolling : 'scrolling', undetached : 'undetached' @@ -9273,7 +9444,7 @@ $.fn.modal.settings = { })( jQuery, window, document ); /*! - * # Semantic UI 2.2.13 - Popup + * # Semantic UI 2.5.0 - Popup * http://github.com/semantic-org/semantic-ui/ * * @@ -9284,7 +9455,7 @@ $.fn.modal.settings = { ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -9762,7 +9933,7 @@ $.fn.popup = function(parameters) { }, content: function() { $module.removeData(metadata.content); - return $module.data(metadata.content) || $module.attr('title') || settings.content; + return $module.data(metadata.content) || settings.content || $module.attr('title'); }, variation: function() { $module.removeData(metadata.variation); @@ -9776,9 +9947,10 @@ $.fn.popup = function(parameters) { }, calculations: function() { var - targetElement = $target[0], - isWindow = ($boundary[0] == window), - targetPosition = (settings.inline || (settings.popup && settings.movePopup)) + $popupOffsetParent = module.get.offsetParent($popup), + targetElement = $target[0], + isWindow = ($boundary[0] == window), + targetPosition = (settings.inline || (settings.popup && settings.movePopup)) ? $target.position() : $target.offset(), screenPosition = (isWindow) @@ -9823,6 +9995,17 @@ $.fn.popup = function(parameters) { } }; + // if popup offset context is not same as target, then adjust calculations + if($popupOffsetParent.get(0) !== $offsetParent.get(0)) { + var + popupOffset = $popupOffsetParent.offset() + ; + calculations.target.top -= popupOffset.top; + calculations.target.left -= popupOffset.left; + calculations.parent.width = $popupOffsetParent.outerWidth(); + calculations.parent.height = $popupOffsetParent.outerHeight(); + } + // add in container calcs if fluid if( settings.setFluidWidth && module.is.fluid() ) { calculations.container = { @@ -9899,11 +10082,11 @@ $.fn.popup = function(parameters) { } return distanceFromBoundary; }, - offsetParent: function($target) { + offsetParent: function($element) { var - element = ($target !== undefined) - ? $target[0] - : $module[0], + element = ($element !== undefined) + ? $element[0] + : $target[0], parentNode = element.parentNode, $node = $(parentNode) ; @@ -9911,14 +10094,14 @@ $.fn.popup = function(parameters) { var is2D = ($node.css('transform') === 'none'), isStatic = ($node.css('position') === 'static'), - isHTML = $node.is('html') + isBody = $node.is('body') ; - while(parentNode && !isHTML && isStatic && is2D) { + while(parentNode && !isBody && isStatic && is2D) { parentNode = parentNode.parentNode; $node = $(parentNode); is2D = ($node.css('transform') === 'none'); isStatic = ($node.css('position') === 'static'); - isHTML = $node.is('html'); + isBody = $node.is('body'); } } return ($node && $node.length > 0) @@ -10027,6 +10210,18 @@ $.fn.popup = function(parameters) { popup = calculations.popup; parent = calculations.parent; + if(module.should.centerArrow(calculations)) { + module.verbose('Adjusting offset to center arrow on small target element'); + if(position == 'top left' || position == 'bottom left') { + offset += (target.width / 2) + offset -= settings.arrowPixelsFromEdge; + } + if(position == 'top right' || position == 'bottom right') { + offset -= (target.width / 2) + offset += settings.arrowPixelsFromEdge; + } + } + if(target.width === 0 && target.height === 0 && !module.is.svg(target.element)) { module.debug('Popup target is hidden, no action taken'); return false; @@ -10262,12 +10457,12 @@ $.fn.popup = function(parameters) { if(settings.hideOnScroll === true || (settings.hideOnScroll == 'auto' && settings.on != 'click')) { module.bind.closeOnScroll(); } - if(settings.on == 'hover' && openedWithTouch) { - module.bind.touchClose(); - } - if(settings.on == 'click' && settings.closable) { + if(module.is.closable()) { module.bind.clickaway(); } + else if(settings.on == 'hover' && openedWithTouch) { + module.bind.touchClose(); + } }, closeOnScroll: function() { module.verbose('Binding scroll close event to document'); @@ -10320,7 +10515,22 @@ $.fn.popup = function(parameters) { } }, + should: { + centerArrow: function(calculations) { + return !module.is.basic() && calculations.target.width <= (settings.arrowPixelsFromEdge * 2); + }, + }, + is: { + closable: function() { + if(settings.closable == 'auto') { + if(settings.on == 'hover') { + return false; + } + return true; + } + return settings.closable; + }, offstage: function(distanceFromBoundary, position) { var offstage = [] @@ -10342,6 +10552,9 @@ $.fn.popup = function(parameters) { svg: function(element) { return module.supports.svg() && (element instanceof SVGGraphicsElement); }, + basic: function() { + return $module.hasClass(className.basic); + }, active: function() { return $module.hasClass(className.active); }, @@ -10654,8 +10867,11 @@ $.fn.popup.settings = { // specify position to appear even if it doesn't fit lastResort : false, + // number of pixels from edge of popup to pointing arrow center (used from centering) + arrowPixelsFromEdge: 20, + // delay used to prevent accidental refiring of animations due to user error - delay : { + delay : { show : 50, hide : 70 }, @@ -10699,6 +10915,7 @@ $.fn.popup.settings = { className : { active : 'active', + basic : 'basic', animating : 'animating', dropdown : 'dropdown', fluid : 'fluid', @@ -10760,7 +10977,7 @@ $.fn.popup.settings = { })( jQuery, window, document ); /*! - * # Semantic UI 2.2.13 - Progress + * # Semantic UI 2.5.0 - Progress * http://github.com/semantic-org/semantic-ui/ * * @@ -10771,7 +10988,7 @@ $.fn.popup.settings = { ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -11692,7 +11909,7 @@ $.fn.progress.settings = { })( jQuery, window, document ); /*! - * # Semantic UI 2.2.13 - Search + * # Semantic UI 2.5.0 - Search * http://github.com/semantic-org/semantic-ui/ * * @@ -11703,7 +11920,7 @@ $.fn.progress.settings = { ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -11763,6 +11980,7 @@ $.fn.search = function(parameters) { initialize: function() { module.verbose('Initializing module'); + module.get.settings(); module.determine.searchFields(); module.bind.events(); module.set.type(); @@ -12029,7 +12247,7 @@ $.fn.search = function(parameters) { apiSettings = { debug : settings.debug, on : false, - cache : true, + cache : settings.cache, action : 'search', urlData : { query : searchTerm @@ -12095,6 +12313,12 @@ $.fn.search = function(parameters) { }, get: { + settings: function() { + if($.isPlainObject(parameters) && parameters.searchFullText) { + settings.fullTextSearch = parameters.searchFullText; + module.error(settings.error.oldSearchSyntax, element); + } + }, inputEvent: function() { var prompt = $prompt[0], @@ -12238,8 +12462,14 @@ $.fn.search = function(parameters) { ; module.set.loading(); module.save.results(results); - module.debug('Returned local search results', results); - + module.debug('Returned full local search results', results); + if(settings.maxResults > 0) { + module.debug('Using specified max results', results); + results = results.slice(0, settings.maxResults); + } + if(settings.type == 'category') { + results = module.create.categoryResults(results); + } searchHTML = module.generateResults({ results: results }); @@ -12267,6 +12497,7 @@ $.fn.search = function(parameters) { object: function(searchTerm, source, searchFields) { var results = [], + exactResults = [], fuzzyResults = [], searchExp = searchTerm.toString().replace(regExp.escape, '\\$&'), matchRegExp = new RegExp(regExp.beginsWith + searchExp, 'i'), @@ -12275,9 +12506,10 @@ $.fn.search = function(parameters) { addResult = function(array, result) { var notResult = ($.inArray(result, results) == -1), - notFuzzyResult = ($.inArray(result, fuzzyResults) == -1) + notFuzzyResult = ($.inArray(result, fuzzyResults) == -1), + notExactResults = ($.inArray(result, exactResults) == -1) ; - if(notResult && notFuzzyResult) { + if(notResult && notFuzzyResult && notExactResults) { array.push(result); } } @@ -12298,7 +12530,6 @@ $.fn.search = function(parameters) { module.error(error.source); return []; } - // iterate through search fields looking for matches $.each(searchFields, function(index, field) { $.each(source, function(label, content) { @@ -12310,17 +12541,30 @@ $.fn.search = function(parameters) { // content starts with value (first in results) addResult(results, content); } - else if(settings.searchFullText && module.fuzzySearch(searchTerm, content[field]) ) { + else if(settings.fullTextSearch === 'exact' && module.exactSearch(searchTerm, content[field]) ) { + // content fuzzy matches (last in results) + addResult(exactResults, content); + } + else if(settings.fullTextSearch == true && module.fuzzySearch(searchTerm, content[field]) ) { // content fuzzy matches (last in results) addResult(fuzzyResults, content); } } }); }); - return $.merge(results, fuzzyResults); + $.merge(exactResults, fuzzyResults) + $.merge(results, exactResults); + return results; } }, - + exactSearch: function (query, term) { + query = query.toLowerCase(); + term = term.toLowerCase(); + if(term.indexOf(query) > -1) { + return true; + } + return false; + }, fuzzySearch: function(query, term) { var termLength = term.length, @@ -12432,6 +12676,27 @@ $.fn.search = function(parameters) { }, create: { + categoryResults: function(results) { + var + categoryResults = {} + ; + $.each(results, function(index, result) { + if(!result.category) { + return; + } + if(categoryResults[result.category] === undefined) { + module.verbose('Creating new category of results', result.category); + categoryResults[result.category] = { + name : result.category, + results : [result] + } + } + else { + categoryResults[result.category].results.push(result); + } + }); + return categoryResults; + }, id: function(resultIndex, categoryIndex) { var resultID = (resultIndex + 1), // not zero indexed @@ -12469,7 +12734,10 @@ $.fn.search = function(parameters) { $selectedResult = (categoryIndex !== undefined) ? $results .children().eq(categoryIndex) - .children(selector.result).eq(resultIndex) + .children(selector.results) + .first() + .children(selector.result) + .eq(resultIndex) : $results .children(selector.result).eq(resultIndex) ; @@ -12890,8 +13158,8 @@ $.fn.search.settings = { // field to display in standard results template displayField : '', - // whether to include fuzzy results in local search - searchFullText : true, + // search anywhere in value (set to 'exact' to require exact matches + fullTextSearch : 'exact', // whether to add events to prompt automatically automatic : true, @@ -12902,7 +13170,7 @@ $.fn.search.settings = { // delay before searching searchDelay : 200, - // maximum results returned from local + // maximum results returned from search maxResults : 7, // whether to store lookups in local cache @@ -12938,14 +13206,15 @@ $.fn.search.settings = { }, error : { - source : 'Cannot search. No source used, and Semantic API module was not included', - noResults : 'Your search returned no results', - logging : 'Error in debug logging, exiting.', - noEndpoint : 'No search endpoint was specified', - noTemplate : 'A valid template name was not specified.', - serverError : 'There was an issue querying the server.', - maxResults : 'Results must be an array to use maxResults setting', - method : 'The method you called is not defined.' + 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.', + oldSearchSyntax : 'searchFullText setting has been renamed fullTextSearch for consistency, please adjust your settings.', + serverError : 'There was an issue querying the server.', + maxResults : 'Results must be an array to use maxResults setting', + method : 'The method you called is not defined.' }, metadata: { @@ -13047,6 +13316,7 @@ $.fn.search.settings = { } // each item inside category + html += '
'; html += '' + '
' ; @@ -13144,7 +13415,7 @@ $.fn.search.settings = { })( jQuery, window, document ); /*! - * # Semantic UI 2.2.13 - Sidebar + * # Semantic UI 2.5.0 - Sidebar * http://github.com/semantic-org/semantic-ui/ * * @@ -13155,7 +13426,7 @@ $.fn.search.settings = { ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; window = (typeof window != 'undefined' && window.Math == Math) ? window @@ -14178,7 +14449,7 @@ $.fn.sidebar.settings = { })( jQuery, window, document ); /*! - * # Semantic UI 2.2.13 - Site + * # Semantic UI 2.5.0 - Site * http://github.com/semantic-org/semantic-ui/ * * @@ -14666,7 +14937,7 @@ $.extend($.expr[ ":" ], { })( jQuery, window, document ); /*! - * # Semantic UI 2.2.13 - Transition + * # Semantic UI 2.5.0 - Transition * http://github.com/semantic-org/semantic-ui/ * * @@ -14677,7 +14948,7 @@ $.extend($.expr[ ":" ], { ;(function ($, window, document, undefined) { -"use strict"; +'use strict'; window = (typeof window != 'undefined' && window.Math == Math) ? window diff --git a/semantic/dist/semantic.min.css b/semantic/dist/semantic.min.css index 1706e85..98af5e0 100644 --- a/semantic/dist/semantic.min.css +++ b/semantic/dist/semantic.min.css @@ -1,9 +1,9 @@ /* - * # Semantic UI - 2.2.13 + * # Semantic UI - 2.5.0 * https://github.com/Semantic-Org/Semantic-UI * http://www.semantic-ui.com/ * - * Copyright 2014 Contributors + * Copyright 2022 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT * diff --git a/semantic/dist/semantic.min.js b/semantic/dist/semantic.min.js index ffa3753..cf35dbc 100644 --- a/semantic/dist/semantic.min.js +++ b/semantic/dist/semantic.min.js @@ -1,11 +1,11 @@ /* - * # Semantic UI - 2.2.13 + * # Semantic UI - 2.5.0 * https://github.com/Semantic-Org/Semantic-UI * http://www.semantic-ui.com/ * - * Copyright 2014 Contributors + * Copyright 2022 Contributors * Released under the MIT license * http://opensource.org/licenses/MIT * */ -!function(E,D,e,F){"use strict";D=void 0!==D&&D.Math==Math?D:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")();E.api=E.fn.api=function(w){var x,e=E.isFunction(this)?E(D):E(this),C=e.selector||"",k=(new Date).getTime(),S=[],T=w,A="string"==typeof T,R=[].slice.call(arguments,1);return e.each(function(){var r,a,n,e,s,l,c=E.isPlainObject(w)?E.extend(!0,{},E.fn.api.settings,w):E.extend({},E.fn.api.settings),t=c.namespace,i=c.metadata,o=c.selector,u=c.error,d=c.className,f="."+t,m="module-"+t,g=E(this),p=g.closest(o.form),h=c.stateContext?E(c.stateContext):g,v=this,b=h[0],y=g.data(m);l={initialize:function(){A||l.bind.events(),l.instantiate()},instantiate:function(){l.verbose("Storing instance of module",l),y=l,g.data(m,y)},destroy:function(){l.verbose("Destroying previous module for",v),g.removeData(m).off(f)},bind:{events:function(){var e=l.get.event();e?(l.verbose("Attaching API events to element",e),g.on(e+f,l.event.trigger)):"now"==c.on&&(l.debug("Querying API endpoint immediately"),l.query())}},decode:{json:function(e){if(e!==F&&"string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}},read:{cachedResponse:function(e){var t;if(D.Storage!==F)return t=sessionStorage.getItem(e),l.debug("Using cached response",e,t),t=l.decode.json(t);l.error(u.noStorage)}},write:{cachedResponse:function(e,t){t&&""===t?l.debug("Response empty, not caching",t):D.Storage!==F?(E.isPlainObject(t)&&(t=JSON.stringify(t)),sessionStorage.setItem(e,t),l.verbose("Storing cached response for url",e,t)):l.error(u.noStorage)}},query:function(){if(l.is.disabled())l.debug("Element is disabled API request aborted");else{if(l.is.loading()){if(!c.interruptRequests)return void l.debug("Cancelling request, previous request is still pending");l.debug("Interrupting previous request"),l.abort()}if(c.defaultData&&E.extend(!0,c.urlData,l.get.defaultData()),c.serializeForm&&(c.data=l.add.formData(c.data)),!1===(a=l.get.settings()))return l.cancelled=!0,void l.error(u.beforeSend);if(l.cancelled=!1,(n=l.get.templatedURL())||l.is.mocked()){if((n=l.add.urlData(n))||l.is.mocked()){if(a.url=c.base+n,r=E.extend(!0,{},c,{type:c.method||c.type,data:e,url:c.base+n,beforeSend:c.beforeXHR,success:function(){},failure:function(){},complete:function(){}}),l.debug("Querying URL",r.url),l.verbose("Using AJAX settings",r),"local"===c.cache&&l.read.cachedResponse(n))return l.debug("Response returned from local cache"),l.request=l.create.request(),void l.request.resolveWith(b,[l.read.cachedResponse(n)]);c.throttle?c.throttleFirstRequest||l.timer?(l.debug("Throttling request",c.throttle),clearTimeout(l.timer),l.timer=setTimeout(function(){l.timer&&delete l.timer,l.debug("Sending throttled request",e,r.method),l.send.request()},c.throttle)):(l.debug("Sending request",e,r.method),l.send.request(),l.timer=setTimeout(function(){},c.throttle)):(l.debug("Sending request",e,r.method),l.send.request())}}else l.error(u.missingURL)}},should:{removeError:function(){return!0===c.hideError||"auto"===c.hideError&&!l.is.form()}},is:{disabled:function(){return 0 adjusting invoked element"),c=c.closest(o.checkbox),s.refresh())}},setup:function(){s.set.initialLoad(),s.is.indeterminate()?(s.debug("Initial value is indeterminate"),s.indeterminate()):s.is.checked()?(s.debug("Initial value is checked"),s.check()):(s.debug("Initial value is unchecked"),s.uncheck()),s.remove.initialLoad()},refresh:function(){u=c.children(o.label),d=c.children(o.input),f=d[0]},hide:{input:function(){s.verbose("Modifying z-index to be unselectable"),d.addClass(t.hidden)}},show:{input:function(){s.verbose("Modifying z-index to be selectable"),d.removeClass(t.hidden)}},observeChanges:function(){"MutationObserver"in A&&((e=new MutationObserver(function(e){s.debug("DOM tree modified, updating selector cache"),s.refresh()})).observe(h,{childList:!0,subtree:!0}),s.debug("Setting up mutation observer",e))},attachEvents:function(e,t){var n=T(e);t=T.isFunction(s[t])?s[t]:s.toggle,0").insertAfter(d),s.debug("Creating label",u))}},has:{label:function(){return 0 .ui.dimmer",content:".ui.dimmer > .content, .ui.dimmer > .content > .center"},template:{dimmer:function(){return k("
").attr("class","ui dimmer")}}}}(jQuery,window,document),function(K,J,G,Y){"use strict";J=void 0!==J&&J.Math==Math?J:"undefined"!=typeof self&&self.Math==Math?self:Function("return this")(),K.fn.dropdown=function(L){var z,V=K(this),N=K(G),H=V.selector||"",U="ontouchstart"in G.documentElement,W=(new Date).getTime(),B=[],$=L,X="string"==typeof $,Q=[].slice.call(arguments,1);return V.each(function(n){var e,t,i,o,r,a,s,g,p=K.isPlainObject(L)?K.extend(!0,{},K.fn.dropdown.settings,L):K.extend({},K.fn.dropdown.settings),h=p.className,c=p.message,l=p.fields,v=p.keys,b=p.metadata,u=p.namespace,d=p.regExp,y=p.selector,f=p.error,m=p.templates,w="."+u,x="module-"+u,C=K(this),k=K(p.context),S=C.find(y.text),T=C.find(y.search),A=C.find(y.sizer),R=C.find(y.input),E=C.find(y.icon),D=0").html(o).attr("data-"+b.value,t).attr("data-"+b.text,t).addClass(h.addition).addClass(h.item),p.hideAdditions&&i.addClass(h.hidden),n=n===Y?i:n.add(i),g.verbose("Creating user choices for value",t,i))}),n)},userLabels:function(e){var t=g.get.userValues();t&&(g.debug("Adding user labels",t),K.each(t,function(e,t){g.verbose("Adding custom user value"),g.add.label(t,t)}))},menu:function(){F=K("
").addClass(h.menu).appendTo(C)},sizer:function(){A=K("").addClass(h.sizer).insertAfter(T)}},search:function(e){e=e!==Y?e:g.get.query(),g.verbose("Searching for query",e),g.has.minCharacters(e)?g.filter(e):g.hide()},select:{firstUnfiltered:function(){g.verbose("Selecting first non-filtered element"),g.remove.selectedItem(),q.not(y.unselectable).not(y.addition+y.hidden).eq(0).addClass(h.selected)},nextAvailable:function(e){var t=(e=e.eq(0)).nextAll(y.item).not(y.unselectable).eq(0),n=e.prevAll(y.item).not(y.unselectable).eq(0);0").addClass(h.search).prop("autocomplete","off").insertBefore(S)),g.is.multiple()&&g.is.searchSelection()&&!g.has.sizer()&&g.create.sizer(),p.allowTab&&g.set.tabbable()},select:function(){var e=g.get.selectValues();g.debug("Dropdown initialized on a select",e),C.is("select")&&(R=C),0").attr("class",R.attr("class")).addClass(h.selection).addClass(h.dropdown).html(m.dropdown(e)).insertBefore(R),R.hasClass(h.multiple)&&!1===R.prop("multiple")&&(g.error(f.missingMultiple),R.prop("multiple",!0)),R.is("[multiple]")&&g.set.multiple(),R.prop("disabled")&&(g.debug("Disabling dropdown"),C.addClass(h.disabled)),R.removeAttr("class").detach().prependTo(C)),g.refresh()},menu:function(e){F.html(m.menu(e,l)),q=F.find(y.item)},reference:function(){g.debug("Dropdown behavior was called on select, replacing with closest dropdown"),C=C.parent(y.dropdown),M=C.data(x),I=C.get(0),g.refresh(),g.setup.returnedObject()},returnedObject:function(){var e=V.slice(0,n),t=V.slice(n+1);V=e.add(C).add(t)}},refresh:function(){g.refreshSelectors(),g.refreshData()},refreshItems:function(){q=F.find(y.item)},refreshSelectors:function(){g.verbose("Refreshing selector cache"),S=C.find(y.text),T=C.find(y.search),R=C.find(y.input),E=C.find(y.icon),D=0 modified, recreating menu");var n=!1;K.each(e,function(e,t){if(K(t.target).is("select")||K(t.addedNodes).is("select"))return n=!0}),n&&(g.disconnect.selectObserver(),g.refresh(),g.setup.select(),g.set.selected(),g.observe.select())}},menu:{mutation:function(e){var t=e[0],n=t.addedNodes?K(t.addedNodes[0]):K(!1),i=t.removedNodes?K(t.removedNodes[0]):K(!1),o=n.add(i),r=o.is(y.addition)||0t.name?1:-1}),g.debug("Retrieved and sorted values from select",o)):g.debug("Retrieved values from select",o),o},activeItem:function(){return q.filter("."+h.active)},selectedItem:function(){var e=q.not(y.unselectable).filter("."+h.selected);return 0=p.maxSelections?(g.debug("Maximum selection count reached"),p.useLabels&&(q.addClass(h.filtered),g.add.message(c.maxSelections)),!0):(g.verbose("No longer at maximum selection count"),g.remove.message(),g.remove.filteredItem(),g.is.searchSelection()&&g.filterItems(),!1))}},restore:{defaults:function(){g.clear(),g.restore.defaultText(),g.restore.defaultValue()},defaultText:function(){var e=g.get.defaultText();e===g.get.placeholderText?(g.debug("Restoring default placeholder text",e),g.set.placeholderText(e)):(g.debug("Restoring default text",e),g.set.text(e))},placeholderText:function(){g.set.placeholderText()},defaultValue:function(){var e=g.get.defaultValue();e!==Y&&(g.debug("Restoring default value",e),""!==e?(g.set.value(e),g.set.selected()):(g.remove.activeItem(),g.remove.selectedItem()))},labels:function(){p.allowAdditions&&(p.useLabels||(g.error(f.labels),p.useLabels=!0),g.debug("Restoring selected values"),g.create.userLabels()),g.check.maxSelections()},selected:function(){g.restore.values(),g.is.multiple()?(g.debug("Restoring previously selected values and labels"),g.restore.labels()):g.debug("Restoring previously selected values")},values:function(){g.set.initialLoad(),p.apiSettings&&p.saveRemoteData&&g.get.remoteValues()?g.restore.remoteValues():g.set.selected(),g.remove.initialLoad()},remoteValues:function(){var e=g.get.remoteValues();g.debug("Recreating selected from session data",e),e&&(g.is.single()?K.each(e,function(e,t){g.set.text(t)}):K.each(e,function(e,t){g.add.label(e,t)}))}},read:{remoteData:function(e){var t;if(J.Storage!==Y)return(t=sessionStorage.getItem(e))!==Y&&t;g.error(f.noStorage)}},save:{defaults:function(){g.save.defaultText(),g.save.placeholderText(),g.save.defaultValue()},defaultValue:function(){var e=g.get.value();g.verbose("Saving default value as",e),C.data(b.defaultValue,e)},defaultText:function(){var e=g.get.text();g.verbose("Saving default text as",e),C.data(b.defaultText,e)},placeholderText:function(){var e;!1!==p.placeholder&&S.hasClass(h.placeholder)&&(e=g.get.text(),g.verbose("Saving placeholder text as",e),C.data(b.placeholderText,e))},remoteData:function(e,t){J.Storage!==Y?(g.verbose("Saving remote data to session storage",t,e),sessionStorage.setItem(t,e)):g.error(f.noStorage)}},clear:function(){g.is.multiple()&&p.useLabels?g.remove.labels():(g.remove.activeItem(),g.remove.selectedItem()),g.set.placeholderText(),g.clearValue()},clearValue:function(){g.set.value("")},scrollPage:function(e,t){var n,i,o=t||g.get.selectedItem(),r=o.closest(y.menu),a=r.outerHeight(),s=r.scrollTop(),l=q.eq(0).outerHeight(),c=Math.floor(a/l),u=(r.prop("scrollHeight"),"up"==e?s-l*c:s+l*c),d=q.not(y.unselectable);i="up"==e?d.index(o)-c:d.index(o)+c,0<(n=("up"==e?0<=i:i").addClass(h.label).attr("data-"+b.value,r).html(m.label(r,t)),i=p.onLabelCreate.call(i,r,t),g.has.label(e)?g.debug("Label already exists, skipping",r):(p.label.variation&&i.addClass(p.label.variation),!0===n?(g.debug("Animating in label",i),i.addClass(h.hidden).insertBefore(o).transition(p.label.transition,p.label.duration)):(g.debug("Adding selection label",i),i.insertBefore(o)))},message:function(e){var t=F.children(y.message),n=p.templates.message(g.add.variables(e));0").html(n).addClass(h.message).appendTo(F)},optionValue:function(e){var t=g.escape.value(e);0").prop("value",t).addClass(h.addition).html(e).appendTo(R),g.verbose("Adding user addition as an