diff --git a/dist/components/search.js b/dist/components/search.js index 899af6dfd..35afdabdf 100644 --- a/dist/components/search.js +++ b/dist/components/search.js @@ -1,5 +1,5 @@ /*! - * # Semantic UI 1.10.4 - Search + * # Semantic UI 1.11.0 - Search * http://github.com/semantic-org/semantic-ui/ * * @@ -68,6 +68,7 @@ $.fn.search = function(parameters) { if(settings.automatic) { $prompt .on(inputEvent + eventNamespace, module.throttle) + .attr('autocomplete', 'off') ; } $prompt @@ -356,11 +357,13 @@ $.fn.search = function(parameters) { query: function() { var searchTerm = module.get.value(), - cachedHTML = module.read.cachedHTML(searchTerm) + cache = module.read.cache(searchTerm) ; - if(cachedHTML) { + if(cache) { module.debug('Reading result for ' + searchTerm + ' from cache'); - module.addResults(cachedHTML); + module.save.results(cache.results); + module.addResults(cache.html); + } else { module.debug('Querying for ' + searchTerm); @@ -376,6 +379,9 @@ $.fn.search = function(parameters) { module.debug('Searching with default search API endpoint'); module.search.remote(searchTerm); } + else { + module.error(error.noEndpoint); + } } else { module.error(error.source); @@ -398,7 +404,10 @@ $.fn.search = function(parameters) { results: searchResults }); module.remove.loading(); - module.write.cachedHTML(searchTerm, searchHTML); + module.write.cache(searchTerm, { + html : searchHTML, + results : searchResults + }); module.addResults(searchHTML); }, remote: function(searchTerm) { @@ -470,13 +479,14 @@ $.fn.search = function(parameters) { ; module.verbose('Parsing server response', response); if(response !== undefined) { - if(searchTerm) { - module.write.cachedHTML(searchTerm, searchHTML); - if(response.results !== undefined) { - module.save.results(response.results); - } + if(searchTerm !== undefined && response.results !== undefined) { + module.write.cache(searchTerm, { + html : searchHTML, + results : response.results + }); + module.save.results(response.results); + module.addResults(searchHTML); } - module.addResults(searchHTML); } } }, @@ -510,7 +520,7 @@ $.fn.search = function(parameters) { }, read: { - cachedHTML: function(name) { + cache: function(name) { var cache = $module.data(metadata.cache) ; @@ -533,7 +543,7 @@ $.fn.search = function(parameters) { }, write: { - cachedHTML: function(name, value) { + cache: function(name, value) { var cache = ($module.data(metadata.cache) !== undefined) ? $module.data(metadata.cache) @@ -878,6 +888,7 @@ $.fn.search.settings = { source : 'Cannot search. No source used, and Semantic API module was not included', noResults : 'Your search returned no results', logging : 'Error in debug logging, exiting.', + noEndpoint : 'No search endpoint was specified', noTemplate : 'A valid template name was not specified.', serverError : 'There was an issue with querying the server.', maxResults : 'Results must be an array to use maxResults setting', diff --git a/dist/components/search.min.js b/dist/components/search.min.js index 80e2e37ec..e761ce0be 100644 --- a/dist/components/search.min.js +++ b/dist/components/search.min.js @@ -1,5 +1,5 @@ /*! - * # Semantic UI 1.10.4 - Search + * # Semantic UI 1.11.0 - Search * http://github.com/semantic-org/semantic-ui/ * * @@ -8,4 +8,4 @@ * http://opensource.org/licenses/MIT * */ -!function(e,t,s,n){"use strict";e.fn.search=function(r){var a,i=e(this),o=i.selector||"",c=(new Date).getTime(),u=[],l=arguments[0],d="string"==typeof l,g=[].slice.call(arguments,1);return e(this).each(function(){var f,p=e.extend(!0,{},e.fn.search.settings,r),m=p.className,h=p.metadata,v=p.regExp,b=p.selector,y=p.error,R=p.namespace,w="."+R,x=R+"-module",C=e(this),k=C.find(b.prompt),A=C.find(b.searchButton),T=C.find(b.results),q=(C.find(b.result),C.find(b.category),this),S=C.data(x);f={initialize:function(){f.verbose("Initializing module");var e=k[0],t=e!==n&&e.oninput!==n?"input":e!==n&&e.onpropertychange!==n?"propertychange":"keyup";p.automatic&&k.on(t+w,f.throttle),k.on("focus"+w,f.event.focus).on("blur"+w,f.event.blur).on("keydown"+w,f.handleKeyboard),A.on("click"+w,f.query),T.on("mousedown"+w,f.event.result.mousedown).on("mouseup"+w,f.event.result.mouseup).on("click"+w,b.result,f.event.result.click),f.instantiate()},instantiate:function(){f.verbose("Storing instance of module",f),S=f,C.data(x,f)},destroy:function(){f.verbose("Destroying instance"),C.removeData(x),k.off(w),A.off(w),T.off(w)},event:{focus:function(){f.set.focus(),clearTimeout(f.timer),f.throttle(),f.has.minimumCharacters()&&f.showResults()},blur:function(){var e=s.activeElement===this;e||f.resultsClicked||(f.cancel.query(),f.remove.focus(),f.timer=setTimeout(f.hideResults,p.hideDelay))},result:{mousedown:function(){f.resultsClicked=!0},mouseup:function(){f.resultsClicked=!1},click:function(s){f.debug("Search result selected");var n=e(this),r=n.find(b.title).eq(0),a=n.find("a[href]").eq(0),i=a.attr("href")||!1,o=a.attr("target")||!1,c=(r.html(),r.length>0?r.text():!1),u=f.get.results(),l=f.get.result(c,u);return e.isFunction(p.onSelect)&&p.onSelect.call(q,l,u)===!1?void f.debug("Custom onSelect callback cancelled default select action"):(f.hideResults(),c&&f.set.value(c),void(i&&(f.verbose("Opening search link found in result",a),"_blank"==o||s.ctrlKey?t.open(i):t.location.href=i)))}}},handleKeyboard:function(e){var t,s=C.find(b.result),n=C.find(b.category),r=s.index(s.filter("."+m.active)),a=s.length,i=e.which,o={backspace:8,enter:13,escape:27,upArrow:38,downArrow:40};if(i==o.escape&&(f.verbose("Escape key pressed, blurring search field"),k.trigger("blur")),f.is.visible())if(i==o.enter){if(f.verbose("Enter key pressed, selecting active result"),s.filter("."+m.active).length>0)return f.event.result.click.call(s.filter("."+m.active),e),e.preventDefault(),!1}else i==o.upArrow?(f.verbose("Up key pressed, changing active result"),t=0>r-1?r:r-1,n.removeClass(m.active),s.removeClass(m.active).eq(t).addClass(m.active).closest(n).addClass(m.active),e.preventDefault()):i==o.downArrow&&(f.verbose("Down key pressed, changing active result"),t=r+1>=a?r:r+1,n.removeClass(m.active),s.removeClass(m.active).eq(t).addClass(m.active).closest(n).addClass(m.active),e.preventDefault());else i==o.enter&&(f.verbose("Enter key pressed, executing query"),f.query(),f.set.buttonPressed(),k.one("keyup",f.remove.buttonFocus))},setup:{api:function(){var e={on:!1,action:"search",onFailure:f.error};f.verbose("First request, initializing API"),C.api(e)}},can:{useAPI:function(){return e.fn.api!==n},transition:function(){return p.transition&&e.fn.transition!==n&&C.transition("is supported")}},is:{empty:function(){return""===T.html()},visible:function(){return T.filter(":visible").length>0},focused:function(){return k.filter(":focus").length>0}},get:{value:function(){return k.val()},results:function(){var e=C.data(h.results);return e},result:function(t,s){var n=!1;return t=t||f.get.value(),s=s||f.get.results(),"category"===p.type?(f.debug("Finding result that matches",t),e.each(s,function(s,r){return e.isArray(r.results)&&(n=f.search.object(t,r.results)[0],n&&n.length>0)?!0:void 0})):(f.debug("Finding result in results object",t),n=f.search.object(t,s)[0]),n}},set:{focus:function(){C.addClass(m.focus)},loading:function(){C.addClass(m.loading)},value:function(e){f.verbose("Setting search input value",e),k.val(e),f.query()},buttonPressed:function(){A.addClass(m.pressed)}},remove:{loading:function(){C.removeClass(m.loading)},focus:function(){C.removeClass(m.focus)},buttonPressed:function(){A.removeClass(m.pressed)}},query:function(){var t=f.get.value(),s=f.read.cachedHTML(t);s?(f.debug("Reading result for "+t+" from cache"),f.addResults(s)):(f.debug("Querying for "+t),e.isPlainObject(p.source)||e.isArray(p.source)?f.search.local(t):f.can.useAPI()?p.apiSettings?(f.debug("Searching with specified API settings",p.apiSettings),f.search.remote(t)):e.api.settings.api.search!==n&&(f.debug("Searching with default search API endpoint"),f.search.remote(t)):f.error(y.source),p.onSearchQuery.call(q,t))},search:{local:function(e){var t,s=f.search.object(e,p.content);f.set.loading(),f.save.results(s),f.debug("Returned local search results",s),t=f.generateResults({results:s}),f.remove.loading(),f.write.cachedHTML(e,t),f.addResults(t)},remote:function(t){var s={onSuccess:function(e){f.parse.response.call(q,e,t)},urlData:{query:t}};C.api("get request")||f.setup.api(),e.extend(!0,s,p.apiSettings),f.debug("Executing search",s),f.cancel.query(),C.api("setting",s).api("query")},object:function(t,s){var r=[],a=[],i=e.isArray(p.searchFields)?p.searchFields:[p.searchFields],o=new RegExp(v.exact+t,"i"),c=new RegExp(t,"i");return s=s||p.source,s===n?(f.error(y.source),[]):(e.each(i,function(t,n){e.each(s,function(t,s){var i="string"==typeof s[n],u=-1==e.inArray(s,r)&&-1==e.inArray(s,a);i&&u&&(s[n].match(o)?r.push(s):p.searchFullText&&s[n].match(c)&&a.push(s))})}),e.merge(r,a))}},parse:{response:function(e,t){var s=f.generateResults(e);f.verbose("Parsing server response",e),e!==n&&(t&&(f.write.cachedHTML(t,s),e.results!==n&&f.save.results(e.results)),f.addResults(s))}},throttle:function(){clearTimeout(f.timer),f.has.minimumCharacters()?f.timer=setTimeout(f.query,p.searchDelay):f.hideResults()},cancel:{query:function(){f.can.useAPI()&&C.api("abort")}},has:{minimumCharacters:function(){var e=f.get.value(),t=e.length;return t>=p.minCharacters}},read:{cachedHTML:function(e){var t=C.data(h.cache);return p.cache?(f.verbose("Checking cache for generated html for query",e),"object"==typeof t&&t[e]!==n?t[e]:!1):!1}},save:{results:function(e){f.verbose("Saving current search results to metadata",e),C.data(h.results,e)}},write:{cachedHTML:function(e,t){var s=C.data(h.cache)!==n?C.data(h.cache):{};p.cache&&(f.verbose("Writing generated html to cache",e,t),s[e]=t,C.data(h.cache,s))}},addResults:function(t){return e.isFunction(p.onResultsAdd)&&p.onResultsAdd.call(T,t)===!1?(f.debug("onResultsAdd callback cancelled default action"),!1):(T.html(t),void f.showResults())},showResults:function(){f.is.visible()||!f.is.focused()||f.is.empty()||(f.can.transition()?(f.debug("Showing results with css animations"),T.transition({animation:p.transition+" in",duration:p.duration,queue:!0})):(f.debug("Showing results with javascript"),T.stop().fadeIn(p.duration,p.easing)),p.onResultsOpen.call(T))},hideResults:function(){f.is.visible()&&(f.can.transition()?(f.debug("Hiding results with css animations"),T.transition({animation:p.transition+" out",duration:p.duration,queue:!0})):(f.debug("Hiding results with javascript"),T.stop().fadeOut(p.duration,p.easing)),p.onResultsClose.call(T))},generateResults:function(t){f.debug("Generating html from response",t);var s=p.templates[p.type],n=e.isPlainObject(t.results)&&!e.isEmptyObject(t.results),r=e.isArray(t.results)&&t.results.length>0,a="";return n||r?(p.maxResults>0&&(n?"standard"==p.type&&f.error(y.maxResults):t.results=t.results.slice(0,p.maxResults)),e.isFunction(s)?a=s(t):f.error(y.noTemplate,!1)):a=f.displayMessage(y.noResults,"empty"),p.onResults.call(q,t),a},displayMessage:function(e,t){return t=t||"standard",f.debug("Displaying message",e,t),f.addResults(p.templates.message(e,t)),p.templates.message(e,t)},setting:function(t,s){if(e.isPlainObject(t))e.extend(!0,p,t);else{if(s===n)return p[t];p[t]=s}},internal:function(t,s){if(e.isPlainObject(t))e.extend(!0,f,t);else{if(s===n)return f[t];f[t]=s}},debug:function(){p.debug&&(p.performance?f.performance.log(arguments):(f.debug=Function.prototype.bind.call(console.info,console,p.name+":"),f.debug.apply(console,arguments)))},verbose:function(){p.verbose&&p.debug&&(p.performance?f.performance.log(arguments):(f.verbose=Function.prototype.bind.call(console.info,console,p.name+":"),f.verbose.apply(console,arguments)))},error:function(){f.error=Function.prototype.bind.call(console.error,console,p.name+":"),f.error.apply(console,arguments)},performance:{log:function(e){var t,s,n;p.performance&&(t=(new Date).getTime(),n=c||t,s=t-n,c=t,u.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:q,"Execution Time":s})),clearTimeout(f.performance.timer),f.performance.timer=setTimeout(f.performance.display,100)},display:function(){var t=p.name+":",s=0;c=!1,clearTimeout(f.performance.timer),e.each(u,function(e,t){s+=t["Execution Time"]}),t+=" "+s+"ms",o&&(t+=" '"+o+"'"),i.length>1&&(t+=" ("+i.length+")"),(console.group!==n||console.table!==n)&&u.length>0&&(console.groupCollapsed(t),console.table?console.table(u):e.each(u,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),u=[]}},invoke:function(t,s,r){var i,o,c,u=S;return s=s||g,r=q||r,"string"==typeof t&&u!==n&&(t=t.split(/[\. ]/),i=t.length-1,e.each(t,function(s,r){var a=s!=i?r+t[s+1].charAt(0).toUpperCase()+t[s+1].slice(1):t;if(e.isPlainObject(u[a])&&s!=i)u=u[a];else{if(u[a]!==n)return o=u[a],!1;if(!e.isPlainObject(u[r])||s==i)return u[r]!==n?(o=u[r],!1):!1;u=u[r]}})),e.isFunction(o)?c=o.apply(r,s):o!==n&&(c=o),e.isArray(a)?a.push(c):a!==n?a=[a,c]:c!==n&&(a=c),o}},d?(S===n&&f.initialize(),f.invoke(l)):(S!==n&&S.invoke("destroy"),f.initialize())}),a!==n?a:this},e.fn.search.settings={name:"Search Module",namespace:"search",debug:!1,verbose:!0,performance:!0,type:"standard",minCharacters:1,apiSettings:!1,source:!1,searchFields:["title","description"],searchFullText:!0,automatic:"true",hideDelay:0,searchDelay:100,maxResults:7,cache:!0,transition:"scale",duration:300,easing:"easeOutExpo",onSelect:!1,onResultsAdd:!1,onSearchQuery:function(){},onResults:function(){},onResultsOpen:function(){},onResultsClose:function(){},className:{active:"active",empty:"empty",focus:"focus",loading:"loading",pressed:"down"},error:{source:"Cannot search. No source used, and Semantic API module was not included",noResults:"Your search returned no results",logging:"Error in debug logging, exiting.",noTemplate:"A valid template name was not specified.",serverError:"There was an issue with querying the server.",maxResults:"Results must be an array to use maxResults setting",method:"The method you called is not defined."},metadata:{cache:"cache",results:"results"},regExp:{exact:"(?:s|^)"},selector:{prompt:".prompt",searchButton:".search.button",results:".results",category:".category",result:".result",title:".title, .name"},templates:{escape:function(e){var t=/[&<>"'`]/g,s=/[&<>"'`]/,n={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},r=function(e){return n[e]};return s.test(e)?e.replace(t,r):e},message:function(e,t){var s="";return e!==n&&t!==n&&(s+='
',s+="empty"==t?'
No Results
'+e+'
':'
'+e+"
",s+="
"),s},category:function(t){var s="",r=e.fn.search.settings.templates.escape;return t.results!==n?(e.each(t.results,function(t,a){a.results!==n&&a.results.length>0&&(s+='
'+a.name+"
",e.each(a.results,function(e,t){s+='
',t.url&&(s+=''),t.image!==n&&(t.image=r(t.image),s+='
'),s+='
',t.price!==n&&(t.price=r(t.price),s+='
'+t.price+"
"),t.title!==n&&(t.title=r(t.title),s+='
'+t.title+"
"),t.description!==n&&(s+='
'+t.description+"
"),s+="
"}),s+="
")}),t.action&&(s+=''+t.action.text+""),s):!1},standard:function(t){var s="";return t.results!==n?(e.each(t.results,function(e,t){s+=t.url?'':'',t.image!==n&&(s+='
'),s+='
',t.price!==n&&(s+='
'+t.price+"
"),t.title!==n&&(s+='
'+t.title+"
"),t.description!==n&&(s+='
'+t.description+"
"),s+="
",s+="
"}),t.action&&(s+=''+t.action.text+""),s):!1}}}}(jQuery,window,document); \ No newline at end of file +!function(e,t,s,n){"use strict";e.fn.search=function(r){var a,i=e(this),o=i.selector||"",c=(new Date).getTime(),u=[],l=arguments[0],d="string"==typeof l,p=[].slice.call(arguments,1);return e(this).each(function(){var f,g=e.extend(!0,{},e.fn.search.settings,r),m=g.className,h=g.metadata,v=g.regExp,b=g.selector,y=g.error,R=g.namespace,w="."+R,x=R+"-module",C=e(this),k=C.find(b.prompt),A=C.find(b.searchButton),q=C.find(b.results),S=(C.find(b.result),C.find(b.category),this),E=C.data(x);f={initialize:function(){f.verbose("Initializing module");var e=k[0],t=e!==n&&e.oninput!==n?"input":e!==n&&e.onpropertychange!==n?"propertychange":"keyup";g.automatic&&k.on(t+w,f.throttle).attr("autocomplete","off"),k.on("focus"+w,f.event.focus).on("blur"+w,f.event.blur).on("keydown"+w,f.handleKeyboard),A.on("click"+w,f.query),q.on("mousedown"+w,f.event.result.mousedown).on("mouseup"+w,f.event.result.mouseup).on("click"+w,b.result,f.event.result.click),f.instantiate()},instantiate:function(){f.verbose("Storing instance of module",f),E=f,C.data(x,f)},destroy:function(){f.verbose("Destroying instance"),C.removeData(x),k.off(w),A.off(w),q.off(w)},event:{focus:function(){f.set.focus(),clearTimeout(f.timer),f.throttle(),f.has.minimumCharacters()&&f.showResults()},blur:function(){var e=s.activeElement===this;e||f.resultsClicked||(f.cancel.query(),f.remove.focus(),f.timer=setTimeout(f.hideResults,g.hideDelay))},result:{mousedown:function(){f.resultsClicked=!0},mouseup:function(){f.resultsClicked=!1},click:function(s){f.debug("Search result selected");var n=e(this),r=n.find(b.title).eq(0),a=n.find("a[href]").eq(0),i=a.attr("href")||!1,o=a.attr("target")||!1,c=(r.html(),r.length>0?r.text():!1),u=f.get.results(),l=f.get.result(c,u);return e.isFunction(g.onSelect)&&g.onSelect.call(S,l,u)===!1?void f.debug("Custom onSelect callback cancelled default select action"):(f.hideResults(),c&&f.set.value(c),void(i&&(f.verbose("Opening search link found in result",a),"_blank"==o||s.ctrlKey?t.open(i):t.location.href=i)))}}},handleKeyboard:function(e){var t,s=C.find(b.result),n=C.find(b.category),r=s.index(s.filter("."+m.active)),a=s.length,i=e.which,o={backspace:8,enter:13,escape:27,upArrow:38,downArrow:40};if(i==o.escape&&(f.verbose("Escape key pressed, blurring search field"),k.trigger("blur")),f.is.visible())if(i==o.enter){if(f.verbose("Enter key pressed, selecting active result"),s.filter("."+m.active).length>0)return f.event.result.click.call(s.filter("."+m.active),e),e.preventDefault(),!1}else i==o.upArrow?(f.verbose("Up key pressed, changing active result"),t=0>r-1?r:r-1,n.removeClass(m.active),s.removeClass(m.active).eq(t).addClass(m.active).closest(n).addClass(m.active),e.preventDefault()):i==o.downArrow&&(f.verbose("Down key pressed, changing active result"),t=r+1>=a?r:r+1,n.removeClass(m.active),s.removeClass(m.active).eq(t).addClass(m.active).closest(n).addClass(m.active),e.preventDefault());else i==o.enter&&(f.verbose("Enter key pressed, executing query"),f.query(),f.set.buttonPressed(),k.one("keyup",f.remove.buttonFocus))},setup:{api:function(){var e={on:!1,action:"search",onFailure:f.error};f.verbose("First request, initializing API"),C.api(e)}},can:{useAPI:function(){return e.fn.api!==n},transition:function(){return g.transition&&e.fn.transition!==n&&C.transition("is supported")}},is:{empty:function(){return""===q.html()},visible:function(){return q.filter(":visible").length>0},focused:function(){return k.filter(":focus").length>0}},get:{value:function(){return k.val()},results:function(){var e=C.data(h.results);return e},result:function(t,s){var n=!1;return t=t||f.get.value(),s=s||f.get.results(),"category"===g.type?(f.debug("Finding result that matches",t),e.each(s,function(s,r){return e.isArray(r.results)&&(n=f.search.object(t,r.results)[0],n&&n.length>0)?!0:void 0})):(f.debug("Finding result in results object",t),n=f.search.object(t,s)[0]),n}},set:{focus:function(){C.addClass(m.focus)},loading:function(){C.addClass(m.loading)},value:function(e){f.verbose("Setting search input value",e),k.val(e),f.query()},buttonPressed:function(){A.addClass(m.pressed)}},remove:{loading:function(){C.removeClass(m.loading)},focus:function(){C.removeClass(m.focus)},buttonPressed:function(){A.removeClass(m.pressed)}},query:function(){var t=f.get.value(),s=f.read.cache(t);s?(f.debug("Reading result for "+t+" from cache"),f.save.results(s.results),f.addResults(s.html)):(f.debug("Querying for "+t),e.isPlainObject(g.source)||e.isArray(g.source)?f.search.local(t):f.can.useAPI()?g.apiSettings?(f.debug("Searching with specified API settings",g.apiSettings),f.search.remote(t)):e.api.settings.api.search!==n?(f.debug("Searching with default search API endpoint"),f.search.remote(t)):f.error(y.noEndpoint):f.error(y.source),g.onSearchQuery.call(S,t))},search:{local:function(e){var t,s=f.search.object(e,g.content);f.set.loading(),f.save.results(s),f.debug("Returned local search results",s),t=f.generateResults({results:s}),f.remove.loading(),f.write.cache(e,{html:t,results:s}),f.addResults(t)},remote:function(t){var s={onSuccess:function(e){f.parse.response.call(S,e,t)},urlData:{query:t}};C.api("get request")||f.setup.api(),e.extend(!0,s,g.apiSettings),f.debug("Executing search",s),f.cancel.query(),C.api("setting",s).api("query")},object:function(t,s){var r=[],a=[],i=e.isArray(g.searchFields)?g.searchFields:[g.searchFields],o=new RegExp(v.exact+t,"i"),c=new RegExp(t,"i");return s=s||g.source,s===n?(f.error(y.source),[]):(e.each(i,function(t,n){e.each(s,function(t,s){var i="string"==typeof s[n],u=-1==e.inArray(s,r)&&-1==e.inArray(s,a);i&&u&&(s[n].match(o)?r.push(s):g.searchFullText&&s[n].match(c)&&a.push(s))})}),e.merge(r,a))}},parse:{response:function(e,t){var s=f.generateResults(e);f.verbose("Parsing server response",e),e!==n&&t!==n&&e.results!==n&&(f.write.cache(t,{html:s,results:e.results}),f.save.results(e.results),f.addResults(s))}},throttle:function(){clearTimeout(f.timer),f.has.minimumCharacters()?f.timer=setTimeout(f.query,g.searchDelay):f.hideResults()},cancel:{query:function(){f.can.useAPI()&&C.api("abort")}},has:{minimumCharacters:function(){var e=f.get.value(),t=e.length;return t>=g.minCharacters}},read:{cache:function(e){var t=C.data(h.cache);return g.cache?(f.verbose("Checking cache for generated html for query",e),"object"==typeof t&&t[e]!==n?t[e]:!1):!1}},save:{results:function(e){f.verbose("Saving current search results to metadata",e),C.data(h.results,e)}},write:{cache:function(e,t){var s=C.data(h.cache)!==n?C.data(h.cache):{};g.cache&&(f.verbose("Writing generated html to cache",e,t),s[e]=t,C.data(h.cache,s))}},addResults:function(t){return e.isFunction(g.onResultsAdd)&&g.onResultsAdd.call(q,t)===!1?(f.debug("onResultsAdd callback cancelled default action"),!1):(q.html(t),void f.showResults())},showResults:function(){f.is.visible()||!f.is.focused()||f.is.empty()||(f.can.transition()?(f.debug("Showing results with css animations"),q.transition({animation:g.transition+" in",duration:g.duration,queue:!0})):(f.debug("Showing results with javascript"),q.stop().fadeIn(g.duration,g.easing)),g.onResultsOpen.call(q))},hideResults:function(){f.is.visible()&&(f.can.transition()?(f.debug("Hiding results with css animations"),q.transition({animation:g.transition+" out",duration:g.duration,queue:!0})):(f.debug("Hiding results with javascript"),q.stop().fadeOut(g.duration,g.easing)),g.onResultsClose.call(q))},generateResults:function(t){f.debug("Generating html from response",t);var s=g.templates[g.type],n=e.isPlainObject(t.results)&&!e.isEmptyObject(t.results),r=e.isArray(t.results)&&t.results.length>0,a="";return n||r?(g.maxResults>0&&(n?"standard"==g.type&&f.error(y.maxResults):t.results=t.results.slice(0,g.maxResults)),e.isFunction(s)?a=s(t):f.error(y.noTemplate,!1)):a=f.displayMessage(y.noResults,"empty"),g.onResults.call(S,t),a},displayMessage:function(e,t){return t=t||"standard",f.debug("Displaying message",e,t),f.addResults(g.templates.message(e,t)),g.templates.message(e,t)},setting:function(t,s){if(e.isPlainObject(t))e.extend(!0,g,t);else{if(s===n)return g[t];g[t]=s}},internal:function(t,s){if(e.isPlainObject(t))e.extend(!0,f,t);else{if(s===n)return f[t];f[t]=s}},debug:function(){g.debug&&(g.performance?f.performance.log(arguments):(f.debug=Function.prototype.bind.call(console.info,console,g.name+":"),f.debug.apply(console,arguments)))},verbose:function(){g.verbose&&g.debug&&(g.performance?f.performance.log(arguments):(f.verbose=Function.prototype.bind.call(console.info,console,g.name+":"),f.verbose.apply(console,arguments)))},error:function(){f.error=Function.prototype.bind.call(console.error,console,g.name+":"),f.error.apply(console,arguments)},performance:{log:function(e){var t,s,n;g.performance&&(t=(new Date).getTime(),n=c||t,s=t-n,c=t,u.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:S,"Execution Time":s})),clearTimeout(f.performance.timer),f.performance.timer=setTimeout(f.performance.display,100)},display:function(){var t=g.name+":",s=0;c=!1,clearTimeout(f.performance.timer),e.each(u,function(e,t){s+=t["Execution Time"]}),t+=" "+s+"ms",o&&(t+=" '"+o+"'"),i.length>1&&(t+=" ("+i.length+")"),(console.group!==n||console.table!==n)&&u.length>0&&(console.groupCollapsed(t),console.table?console.table(u):e.each(u,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),u=[]}},invoke:function(t,s,r){var i,o,c,u=E;return s=s||p,r=S||r,"string"==typeof t&&u!==n&&(t=t.split(/[\. ]/),i=t.length-1,e.each(t,function(s,r){var a=s!=i?r+t[s+1].charAt(0).toUpperCase()+t[s+1].slice(1):t;if(e.isPlainObject(u[a])&&s!=i)u=u[a];else{if(u[a]!==n)return o=u[a],!1;if(!e.isPlainObject(u[r])||s==i)return u[r]!==n?(o=u[r],!1):!1;u=u[r]}})),e.isFunction(o)?c=o.apply(r,s):o!==n&&(c=o),e.isArray(a)?a.push(c):a!==n?a=[a,c]:c!==n&&(a=c),o}},d?(E===n&&f.initialize(),f.invoke(l)):(E!==n&&E.invoke("destroy"),f.initialize())}),a!==n?a:this},e.fn.search.settings={name:"Search Module",namespace:"search",debug:!1,verbose:!0,performance:!0,type:"standard",minCharacters:1,apiSettings:!1,source:!1,searchFields:["title","description"],searchFullText:!0,automatic:"true",hideDelay:0,searchDelay:100,maxResults:7,cache:!0,transition:"scale",duration:300,easing:"easeOutExpo",onSelect:!1,onResultsAdd:!1,onSearchQuery:function(){},onResults:function(){},onResultsOpen:function(){},onResultsClose:function(){},className:{active:"active",empty:"empty",focus:"focus",loading:"loading",pressed:"down"},error:{source:"Cannot search. No source used, and Semantic API module was not included",noResults:"Your search returned no results",logging:"Error in debug logging, exiting.",noEndpoint:"No search endpoint was specified",noTemplate:"A valid template name was not specified.",serverError:"There was an issue with querying the server.",maxResults:"Results must be an array to use maxResults setting",method:"The method you called is not defined."},metadata:{cache:"cache",results:"results"},regExp:{exact:"(?:s|^)"},selector:{prompt:".prompt",searchButton:".search.button",results:".results",category:".category",result:".result",title:".title, .name"},templates:{escape:function(e){var t=/[&<>"'`]/g,s=/[&<>"'`]/,n={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`"},r=function(e){return n[e]};return s.test(e)?e.replace(t,r):e},message:function(e,t){var s="";return e!==n&&t!==n&&(s+='
',s+="empty"==t?'
No Results
'+e+'
':'
'+e+"
",s+="
"),s},category:function(t){var s="",r=e.fn.search.settings.templates.escape;return t.results!==n?(e.each(t.results,function(t,a){a.results!==n&&a.results.length>0&&(s+='
'+a.name+"
",e.each(a.results,function(e,t){s+='
',t.url&&(s+=''),t.image!==n&&(t.image=r(t.image),s+='
'),s+='
',t.price!==n&&(t.price=r(t.price),s+='
'+t.price+"
"),t.title!==n&&(t.title=r(t.title),s+='
'+t.title+"
"),t.description!==n&&(s+='
'+t.description+"
"),s+="
"}),s+="
")}),t.action&&(s+=''+t.action.text+""),s):!1},standard:function(t){var s="";return t.results!==n?(e.each(t.results,function(e,t){s+=t.url?'':'',t.image!==n&&(s+='
'),s+='
',t.price!==n&&(s+='
'+t.price+"
"),t.title!==n&&(s+='
'+t.title+"
"),t.description!==n&&(s+='
'+t.description+"
"),s+="
",s+="
"}),t.action&&(s+=''+t.action.text+""),s):!1}}}}(jQuery,window,document); \ No newline at end of file diff --git a/dist/semantic.js b/dist/semantic.js index 02460d2ef..da3921e4a 100644 --- a/dist/semantic.js +++ b/dist/semantic.js @@ -1,5 +1,5 @@ /* - * # Semantic UI - 1.10.4 + * # Semantic UI - 1.11.0 * https://github.com/Semantic-Org/Semantic-UI * http://www.semantic-ui.com/ * @@ -8858,7 +8858,7 @@ $.fn.rating.settings = { })( jQuery, window , document ); /*! - * # Semantic UI 1.10.4 - Search + * # Semantic UI 1.11.0 - Search * http://github.com/semantic-org/semantic-ui/ * * @@ -8927,6 +8927,7 @@ $.fn.search = function(parameters) { if(settings.automatic) { $prompt .on(inputEvent + eventNamespace, module.throttle) + .attr('autocomplete', 'off') ; } $prompt @@ -9215,11 +9216,13 @@ $.fn.search = function(parameters) { query: function() { var searchTerm = module.get.value(), - cachedHTML = module.read.cachedHTML(searchTerm) + cache = module.read.cache(searchTerm) ; - if(cachedHTML) { + if(cache) { module.debug('Reading result for ' + searchTerm + ' from cache'); - module.addResults(cachedHTML); + module.save.results(cache.results); + module.addResults(cache.html); + } else { module.debug('Querying for ' + searchTerm); @@ -9235,6 +9238,9 @@ $.fn.search = function(parameters) { module.debug('Searching with default search API endpoint'); module.search.remote(searchTerm); } + else { + module.error(error.noEndpoint); + } } else { module.error(error.source); @@ -9257,7 +9263,10 @@ $.fn.search = function(parameters) { results: searchResults }); module.remove.loading(); - module.write.cachedHTML(searchTerm, searchHTML); + module.write.cache(searchTerm, { + html : searchHTML, + results : searchResults + }); module.addResults(searchHTML); }, remote: function(searchTerm) { @@ -9329,13 +9338,14 @@ $.fn.search = function(parameters) { ; module.verbose('Parsing server response', response); if(response !== undefined) { - if(searchTerm) { - module.write.cachedHTML(searchTerm, searchHTML); - if(response.results !== undefined) { - module.save.results(response.results); - } + if(searchTerm !== undefined && response.results !== undefined) { + module.write.cache(searchTerm, { + html : searchHTML, + results : response.results + }); + module.save.results(response.results); + module.addResults(searchHTML); } - module.addResults(searchHTML); } } }, @@ -9369,7 +9379,7 @@ $.fn.search = function(parameters) { }, read: { - cachedHTML: function(name) { + cache: function(name) { var cache = $module.data(metadata.cache) ; @@ -9392,7 +9402,7 @@ $.fn.search = function(parameters) { }, write: { - cachedHTML: function(name, value) { + cache: function(name, value) { var cache = ($module.data(metadata.cache) !== undefined) ? $module.data(metadata.cache) @@ -9737,6 +9747,7 @@ $.fn.search.settings = { source : 'Cannot search. No source used, and Semantic API module was not included', noResults : 'Your search returned no results', logging : 'Error in debug logging, exiting.', + noEndpoint : 'No search endpoint was specified', noTemplate : 'A valid template name was not specified.', serverError : 'There was an issue with querying the server.', maxResults : 'Results must be an array to use maxResults setting', diff --git a/dist/semantic.min.js b/dist/semantic.min.js index 764d6a4a3..21654da67 100644 --- a/dist/semantic.min.js +++ b/dist/semantic.min.js @@ -1,5 +1,5 @@ /* - * # Semantic UI - 1.10.4 + * # Semantic UI - 1.11.0 * https://github.com/Semantic-Org/Semantic-UI * http://www.semantic-ui.com/ * @@ -11,7 +11,7 @@ !function(e,t,n,i){e.site=e.fn.site=function(o){var a,r,s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1),f=e.isPlainObject(o)?e.extend(!0,{},e.site.settings,o):e.extend({},e.site.settings),m=f.namespace,g=f.error,p="module-"+m,v=e(n),h=v,b=this,y=h.data(p);return a={initialize:function(){a.instantiate()},instantiate:function(){a.verbose("Storing instance of site",a),y=a,h.data(p,a)},normalize:function(){a.fix.console(),a.fix.requestAnimationFrame()},fix:{console:function(){a.debug("Normalizing window.console"),(console===i||console.log===i)&&(a.verbose("Console not available, normalizing events"),a.disable.console()),("undefined"==typeof console.group||"undefined"==typeof console.groupEnd||"undefined"==typeof console.groupCollapsed)&&(a.verbose("Console group not available, normalizing events"),t.console.group=function(){},t.console.groupEnd=function(){},t.console.groupCollapsed=function(){}),"undefined"==typeof console.markTimeline&&(a.verbose("Mark timeline not available, normalizing events"),t.console.markTimeline=function(){})},consoleClear:function(){a.debug("Disabling programmatic console clearing"),t.console.clear=function(){}},requestAnimationFrame:function(){a.debug("Normalizing requestAnimationFrame"),t.requestAnimationFrame===i&&(a.debug("RequestAnimationFrame not available, normailizing event"),t.requestAnimationFrame=t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)})}},moduleExists:function(t){return e.fn[t]!==i&&e.fn[t].settings!==i},enabled:{modules:function(t){var n=[];return t=t||f.modules,e.each(t,function(e,t){a.moduleExists(t)&&n.push(t)}),n}},disabled:{modules:function(t){var n=[];return t=t||f.modules,e.each(t,function(e,t){a.moduleExists(t)||n.push(t)}),n}},change:{setting:function(t,n,o,r){o="string"==typeof o?"all"===o?f.modules:[o]:o||f.modules,r=r!==i?r:!0,e.each(o,function(i,o){var s,c=a.moduleExists(o)?e.fn[o].settings.namespace||!1:!0;a.moduleExists(o)&&(a.verbose("Changing default setting",t,n,o),e.fn[o].settings[t]=n,r&&c&&(s=e(":data(module-"+c+")"),s.length>0&&(a.verbose("Modifying existing settings",s),s[o]("setting",t,n))))})},settings:function(t,n,o){n="string"==typeof n?[n]:n||f.modules,o=o!==i?o:!0,e.each(n,function(n,i){var r;a.moduleExists(i)&&(a.verbose("Changing default setting",t,i),e.extend(!0,e.fn[i].settings,t),o&&m&&(r=e(":data(module-"+m+")"),r.length>0&&(a.verbose("Modifying existing settings",r),r[i]("setting",t))))})}},enable:{console:function(){a.console(!0)},debug:function(e,t){e=e||f.modules,a.debug("Enabling debug for modules",e),a.change.setting("debug",!0,e,t)},verbose:function(e,t){e=e||f.modules,a.debug("Enabling verbose debug for modules",e),a.change.setting("verbose",!0,e,t)}},disable:{console:function(){a.console(!1)},debug:function(e,t){e=e||f.modules,a.debug("Disabling debug for modules",e),a.change.setting("debug",!1,e,t)},verbose:function(e,t){e=e||f.modules,a.debug("Disabling verbose debug for modules",e),a.change.setting("verbose",!1,e,t)}},console:function(e){if(e){if(y.cache.console===i)return void a.error(g.console);a.debug("Restoring console function"),t.console=y.cache.console}else a.debug("Disabling console function"),y.cache.console=t.console,t.console={clear:function(){},error:function(){},group:function(){},groupCollapsed:function(){},groupEnd:function(){},info:function(){},log:function(){},markTimeline:function(){},warn:function(){}}},destroy:function(){a.verbose("Destroying previous site for",h),h.removeData(p)},cache:{},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,f,t);else{if(n===i)return f[t];f[t]=n}},internal:function(t,n){if(e.isPlainObject(t))e.extend(!0,a,t);else{if(n===i)return a[t];a[t]=n}},debug:function(){f.debug&&(f.performance?a.performance.log(arguments):(a.debug=Function.prototype.bind.call(console.info,console,f.name+":"),a.debug.apply(console,arguments)))},verbose:function(){f.verbose&&f.debug&&(f.performance?a.performance.log(arguments):(a.verbose=Function.prototype.bind.call(console.info,console,f.name+":"),a.verbose.apply(console,arguments)))},error:function(){a.error=Function.prototype.bind.call(console.error,console,f.name+":"),a.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;f.performance&&(t=(new Date).getTime(),i=s||t,n=t-i,s=t,c.push({Element:b,Name:e[0],Arguments:[].slice.call(e,1)||"","Execution Time":n})),clearTimeout(a.performance.timer),a.performance.timer=setTimeout(a.performance.display,100)},display:function(){var t=f.name+":",n=0;s=!1,clearTimeout(a.performance.timer),e.each(c,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",(console.group!==i||console.table!==i)&&c.length>0&&(console.groupCollapsed(t),console.table?console.table(c):e.each(c,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),c=[]}},invoke:function(t,n,o){var s,c,l,u=y;return n=n||d,o=b||o,"string"==typeof t&&u!==i&&(t=t.split(/[\. ]/),s=t.length-1,e.each(t,function(n,o){var r=n!=s?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(u[r])&&n!=s)u=u[r];else{if(u[r]!==i)return c=u[r],!1;if(!e.isPlainObject(u[o])||n==s)return u[o]!==i?(c=u[o],!1):(a.error(g.method,t),!1);u=u[o]}})),e.isFunction(c)?l=c.apply(o,n):c!==i&&(l=c),e.isArray(r)?r.push(l):r!==i?r=[r,l]:l!==i&&(r=l),c}},u?(y===i&&a.initialize(),a.invoke(l)):(y!==i&&a.destroy(),a.initialize()),r!==i?r:this},e.site.settings={name:"Site",namespace:"site",error:{console:"Console cannot be restored, most likely it was overwritten outside of module",method:"The method you called is not defined."},debug:!1,verbose:!0,performance:!0,modules:["accordion","api","checkbox","dimmer","dropdown","form","modal","nag","popup","rating","shape","sidebar","state","sticky","tab","transition","video","visit","visibility"],siteNamespace:"site",namespaceStub:{cache:{},config:{},sections:{},section:{},utilities:{}}},e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(n){return!!e.data(n,t)}}):function(t,n,i){return!!e.data(t,i[3])}})}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.form=function(t,o){var a,r=e(this),s=e.extend(!0,{},e.fn.form.settings,o),c=e.extend({},e.fn.form.settings.defaults,t),l=s.namespace,u=s.metadata,d=s.selector,f=s.className,m=(s.error,"."+l),g="module-"+l,p=r.selector||"",v=(new Date).getTime(),h=[],b=arguments[0],y="string"==typeof b,x=[].slice.call(arguments,1);return r.each(function(){var t,o=e(this),l=e(this).find(d.field),w=e(this).find(d.group),C=e(this).find(d.message),k=(e(this).find(d.prompt),e(this).find(d.submit)),T=e(this).find(d.clear),S=e(this).find(d.reset),A=[],P=!1,E=this,F=o.data(g);t={initialize:function(){t.verbose("Initializing form validation",o,c,s),t.bindEvents(),t.set.defaults(),t.instantiate()},instantiate:function(){t.verbose("Storing instance of module",t),F=t,o.data(g,t)},destroy:function(){t.verbose("Destroying previous module",F),t.removeEvents(),o.removeData(g)},refresh:function(){t.verbose("Refreshing selector cache"),l=o.find(d.field)},submit:function(){t.verbose("Submitting form",o),o.submit()},attachEvents:function(n,i){i=i||"submit",e(n).on("click",function(e){t[i](),e.preventDefault()})},bindEvents:function(){s.keyboardShortcuts&&l.on("keydown"+m,t.event.field.keydown),o.on("submit"+m,t.validate.form),l.on("blur"+m,t.event.field.blur),t.attachEvents(k,"submit"),t.attachEvents(S,"reset"),t.attachEvents(T,"clear"),l.each(function(){var n=e(this).prop("type"),i=t.get.changeEvent(n);e(this).on(i+m,t.event.field.change)})},clear:function(){l.each(function(){var n=e(this),i=n.parent(),o=n.closest(w),a=o.find(d.prompt),r=n.data(u.defaultValue)||"",s=i.is(d.uiCheckbox),c=i.is(d.uiDropdown),l=o.hasClass(f.error);l&&(t.verbose("Resetting error on field",o),o.removeClass(f.error),a.remove()),c?(t.verbose("Resetting dropdown value",i,r),i.dropdown("clear")):s?i.checkbox("uncheck"):(t.verbose("Resetting field value",n,r),n.val(""))})},reset:function(){l.each(function(){var n=e(this),i=n.parent(),o=n.closest(w),a=o.find(d.prompt),r=n.data(u.defaultValue)||"",s=i.is(d.uiCheckbox),c=i.is(d.uiDropdown),l=o.hasClass(f.error);l&&(t.verbose("Resetting error on field",o),o.removeClass(f.error),a.remove()),c?(t.verbose("Resetting dropdown value",i,r),i.dropdown("restore defaults")):s?(t.verbose("Resetting checkbox value",i,r),i.checkbox(r===!0?"check":"uncheck")):(t.verbose("Resetting field value",n,r),n.val(r))})},removeEvents:function(){o.off(m),l.off(m),k.off(m),l.off(m)},event:{field:{keydown:function(n){var i=e(this),o=n.which,a={enter:13,escape:27};o==a.escape&&(t.verbose("Escape key pressed blurring field"),i.blur()),!n.ctrlKey&&o==a.enter&&i.is(d.input)&&i.not(d.checkbox).length>0&&(k.addClass(f.pressed),P||(i.one("keyup"+m,t.event.field.keyup),t.submit(),t.debug("Enter pressed on input submitting form")),P=!0)},keyup:function(){P=!1,k.removeClass(f.pressed)},blur:function(){var n=e(this),i=n.closest(w);i.hasClass(f.error)?(t.debug("Revalidating field",n,t.get.validation(n)),t.validate.field(t.get.validation(n))):("blur"==s.on||"change"==s.on)&&t.validate.field(t.get.validation(n))},change:function(){var n=e(this),i=n.closest(w);("change"==s.on||i.hasClass(f.error)&&s.revalidate)&&(clearTimeout(t.timer),t.timer=setTimeout(function(){t.debug("Revalidating field",n,t.get.validation(n)),t.validate.field(t.get.validation(n))},s.delay))}}},get:{changeEvent:function(e){return"checkbox"==e||"radio"==e||"hidden"==e?"change":t.get.inputEvent()},inputEvent:function(){return n.createElement("input").oninput!==i?"input":n.createElement("input").onpropertychange!==i?"propertychange":"keyup"},field:function(n){return t.verbose("Finding field with identifier",n),l.filter("#"+n).length>0?l.filter("#"+n):l.filter('[name="'+n+'"]').length>0?l.filter('[name="'+n+'"]'):l.filter('[name="'+n+'[]"]').length>0?l.filter('[name="'+n+'[]"]'):l.filter("[data-"+u.validate+'="'+n+'"]').length>0?l.filter("[data-"+u.validate+'="'+n+'"]'):e("")},fields:function(n){var i=e();return e.each(n,function(e,n){i=i.add(t.get.field(n))}),i},validation:function(n){var i;return e.each(c,function(e,o){t.get.field(o.identifier).get(0)==n.get(0)&&(i=o)}),i||!1},value:function(e){var n,i=[];return i.push(e),n=t.get.values.call(E,i),n[e]},values:function(n){var i=e.isArray(n)?t.get.fields(n):l,o={};return i.each(function(n,i){var a=e(i),r=(a.prop("type"),a.prop("name")),s=a.val(),c=a.is(d.checkbox),l=a.is(d.radio),u=-1!==r.indexOf("[]"),f=c?a.is(":checked"):!1;if(r)if(u)if(r=r.replace("[]",""),o[r]||(o[r]=[]),c){if(!f)return t.debug("Omitted unchecked checkbox",a),!0;o[r].push(s)}else o[r].push(s);else if(l)f&&(o[r]=s);else if(c){if(!f)return t.debug("Omitted unchecked checkbox",a),!0;o[r]=!0}else o[r]=s}),o}},has:{field:function(e){return t.verbose("Checking for existence of a field with identifier",e),l.filter("#"+e).length>0?!0:l.filter('[name="'+e+'"]').length>0?!0:l.filter("[data-"+u.validate+'="'+e+'"]').length>0?!0:!1}},add:{prompt:function(n,a){var r=t.get.field(n),c=r.closest(w),l=c.children(d.prompt),u=0!==l.length;a="string"==typeof a?[a]:a,t.verbose("Adding field error state",n),c.addClass(f.error),s.inline&&(u||(l=s.templates.prompt(a),l.appendTo(c)),l.html(a[0]),u?t.verbose("Inline errors are disabled, no inline error added",n):s.transition&&e.fn.transition!==i&&o.transition("is supported")?(t.verbose("Displaying error with css transition",s.transition),l.transition(s.transition+" in",s.duration)):(t.verbose("Displaying error with fallback javascript animation"),l.fadeIn(s.duration)))},errors:function(e){t.debug("Adding form error messages",e),C.html(s.templates.error(e))}},remove:{prompt:function(n){var a=t.get.field(n.identifier),r=a.closest(w),c=r.children(d.prompt);r.removeClass(f.error),s.inline&&c.is(":visible")&&(t.verbose("Removing prompt for field",n),s.transition&&e.fn.transition!==i&&o.transition("is supported")?c.transition(s.transition+" out",s.duration,function(){c.remove()}):c.fadeOut(s.duration,function(){c.remove()}))}},set:{success:function(){o.removeClass(f.error).addClass(f.success)},defaults:function(){l.each(function(){var t=e(this),n=t.filter(d.checkbox).length>0,i=n?t.is(":checked"):t.val();t.data(u.defaultValue,i)})},error:function(){o.removeClass(f.success).addClass(f.error)},value:function(e,n){var i={};return i[e]=n,t.set.values.call(E,i)},values:function(n){e.isEmptyObject(n)||(e.each(n,function(n,i){var o,a=t.get.field(n),r=a.parent(),s=e.isArray(i),c=r.is(d.uiCheckbox),l=r.is(d.uiDropdown),u=a.is(d.radio)&&c,f=a.length>0;f&&(s&&c?(t.verbose("Selecting multiple",i,a),r.checkbox("uncheck"),e.each(i,function(e,t){o=a.filter('[value="'+t+'"]'),r=o.parent(),o.length>0&&r.checkbox("check")})):u?(t.verbose("Selecting radio value",i,a),a.filter('[value="'+i+'"]').parent(d.uiCheckbox).checkbox("check")):c?(t.verbose("Setting checkbox value",i,r),r.checkbox(i===!0?"check":"uncheck")):l?(t.verbose("Setting dropdown value",i,r),r.dropdown("set selected",i)):(t.verbose("Setting field value",i,a),a.val(i)))}),t.validate.form())}},validate:{form:function(n){var a=!0;return P?!1:(A=[],e.each(c,function(e,n){t.validate.field(n)||(a=!1)}),a?(t.debug("Form has no validation errors, submitting"),t.set.success(),s.onSuccess.call(E,n)):(t.debug("Form has errors"),t.set.error(),s.inline||t.add.errors(A),o.data("moduleApi")!==i&&n.stopImmediatePropagation(),s.onFailure.call(E,A)))},field:function(n){var o=t.get.field(n.identifier),a=!0,r=[];return o.prop("disabled")?(t.debug("Field is disabled. Skipping",n.identifier),a=!0):n.optional&&""===e.trim(o.val())?(t.debug("Field is optional and empty. Skipping",n.identifier),a=!0):n.rules!==i&&e.each(n.rules,function(e,i){t.has.field(n.identifier)&&!t.validate.rule(n,i)&&(t.debug("Field is invalid",n.identifier,i.type),r.push(i.prompt),a=!1)}),a?(t.remove.prompt(n,r),s.onValid.call(o),!0):(A=A.concat(r),t.add.prompt(n.identifier,r),s.onInvalid.call(o,r),!1)},rule:function(n,o){var a,r,c=t.get.field(n.identifier),l=o.type,u=e.trim(c.val()+""),d=/\[(.*)\]/i,f=d.exec(l),m=!0;return f!==i&&null!==f?(a=""+f[1],r=l.replace(f[0],""),m=s.rules[r].call(E,u,a)):m=s.rules[l].call(c,u),m}},setting:function(t,n){if(e.isPlainObject(t))e.extend(!0,s,t);else{if(n===i)return s[t];s[t]=n}},internal:function(n,o){if(e.isPlainObject(n))e.extend(!0,t,n);else{if(o===i)return t[n];t[n]=o}},debug:function(){s.debug&&(s.performance?t.performance.log(arguments):(t.debug=Function.prototype.bind.call(console.info,console,s.name+":"),t.debug.apply(console,arguments)))},verbose:function(){s.verbose&&s.debug&&(s.performance?t.performance.log(arguments):(t.verbose=Function.prototype.bind.call(console.info,console,s.name+":"),t.verbose.apply(console,arguments)))},error:function(){t.error=Function.prototype.bind.call(console.error,console,s.name+":"),t.error.apply(console,arguments)},performance:{log:function(e){var n,i,o;s.performance&&(n=(new Date).getTime(),o=v||n,i=n-o,v=n,h.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:E,"Execution Time":i})),clearTimeout(t.performance.timer),t.performance.timer=setTimeout(t.performance.display,100)},display:function(){var n=s.name+":",o=0;v=!1,clearTimeout(t.performance.timer),e.each(h,function(e,t){o+=t["Execution Time"]}),n+=" "+o+"ms",p&&(n+=" '"+p+"'"),r.length>1&&(n+=" ("+r.length+")"),(console.group!==i||console.table!==i)&&h.length>0&&(console.groupCollapsed(n),console.table?console.table(h):e.each(h,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),h=[]}},invoke:function(t,n,o){var r,s,c,l=F;return n=n||x,o=E||o,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):!1;l=l[o]}})),e.isFunction(s)?c=s.apply(o,n):s!==i&&(c=s),e.isArray(a)?a.push(c):a!==i?a=[a,c]:c!==i&&(a=c),s}},y?(F===i&&t.initialize(),t.invoke(b)):(F!==i&&F.invoke("destroy"),t.initialize())}),a!==i?a:this},e.fn.form.settings={name:"Form",namespace:"form",debug:!1,verbose:!0,performance:!0,keyboardShortcuts:!0,on:"submit",inline:!1,delay:200,revalidate:!0,transition:"scale",duration:200,onValid:function(){},onInvalid:function(){},onSuccess:function(){return!0},onFailure:function(){return!1},metadata:{defaultValue:"default",validate:"validate"},selector:{checkbox:'input[type="checkbox"], input[type="radio"]',clear:".clear",field:"input, textarea, select",group:".field",input:"input",message:".error.message",prompt:".prompt.label",radio:'input[type="radio"]',reset:".reset",submit:".submit",uiCheckbox:".ui.checkbox",uiDropdown:".ui.dropdown"},className:{error:"error",label:"ui prompt label",pressed:"down",success:"success"},error:{method:"The method you called is not defined."},templates:{error:function(t){var n='",e(n)},prompt:function(t){return e("
").addClass("ui red pointing prompt label").html(t[0])}},rules:{checked:function(){return e(this).filter(":checked").length>0},contains:function(e,t){return t=t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),-1!==e.search(new RegExp(t,"i"))},containsExactly:function(e,t){return t=t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),-1!==e.search(new RegExp(t))},email:function(e){var t=new RegExp("[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?","i");return t.test(e)},empty:function(e){return!(e===i||""===e)},integer:function(e,t){var n,o,a,r=/^\-?\d+$/;return t===i||""===t||".."===t||(-1==t.indexOf("..")?r.test(t)&&(n=o=t-0):(a=t.split("..",2),r.test(a[0])&&(n=a[0]-0),r.test(a[1])&&(o=a[1]-0))),r.test(e)&&(n===i||e>=n)&&(o===i||o>=e)},is:function(e,t){return t="string"==typeof t?t.toLowerCase():t,e="string"==typeof e?e.toLowerCase():e,e==t},isExactly:function(e,t){return e==t},length:function(e,t){return e!==i?e.length>=t:!1},match:function(t,n){var o,a=e(this);return a.find("#"+n).length>0?o=a.find("#"+n).val():a.find('[name="'+n+'"]').length>0?o=a.find('[name="'+n+'"]').val():a.find('[data-validate="'+n+'"]').length>0&&(o=a.find('[data-validate="'+n+'"]').val()),o!==i?t.toString()==o.toString():!1},maxLength:function(e,t){return e!==i?e.length<=t:!1},not:function(e,t){return e="string"==typeof e?e.toLowerCase():e,t="string"==typeof t?t.toLowerCase():t,e!=t},notExactly:function(e,t){return e!=t},url:function(e){var t=/(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/;return t.test(e)}}}}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.accordion=function(n){{var o,a=e(this),r=(new Date).getTime(),s=[],c=arguments[0],l="string"==typeof c,u=[].slice.call(arguments,1);t.requestAnimationFrame||t.mozRequestAnimationFrame||t.webkitRequestAnimationFrame||t.msRequestAnimationFrame||function(e){setTimeout(e,0)}}return a.each(function(){var d,f,m=e.isPlainObject(n)?e.extend(!0,{},e.fn.accordion.settings,n):e.extend({},e.fn.accordion.settings),g=m.className,p=m.namespace,v=m.selector,h=m.error,b="."+p,y="module-"+p,x=a.selector||"",w=e(this),C=w.find(v.title),k=w.find(v.content),T=this,S=w.data(y);f={initialize:function(){f.debug("Initializing accordion with bound events",w),w.on("click"+b,v.title,f.event.click),f.observeChanges(),f.instantiate()},instantiate:function(){S=f,w.data(y,f)},destroy:function(){f.debug("Destroying previous accordion for",w),w.removeData(y),C.off(b)},refresh:function(){C=w.find(v.title),k=w.find(v.content)},observeChanges:function(){"MutationObserver"in t&&(d=new MutationObserver(function(){f.debug("DOM tree modified, updating selector cache"),f.refresh()}),d.observe(T,{childList:!0,subtree:!0}),f.debug("Setting up mutation observer",d))},event:{click:function(){f.toggle.call(this)}},toggle:function(t){var n=t!==i?"number"==typeof t?C.eq(t):e(t):e(this),o=n.next(k),a=o.is(":visible");f.debug("Toggling visibility of content",n),a?m.collapsible?f.close.call(n):f.debug("Cannot close accordion content collapsing is disabled"):f.open.call(n)},open:function(t){var n=t!==i?"number"==typeof t?C.eq(t):e(t):e(this),o=n.next(k),a=o.is(":animated"),r=o.hasClass(g.active);a||r||(f.debug("Opening accordion content",n),m.exclusive&&f.closeOthers.call(n),n.addClass(g.active),m.animateChildren&&(e.fn.transition!==i&&w.transition("is supported")?o.children().transition({animation:"fade in",useFailSafe:!0,debug:m.debug,verbose:m.verbose,duration:m.duration}):o.children().stop().animate({opacity:1},m.duration,f.resetOpacity)),o.stop().slideDown(m.duration,m.easing,function(){o.addClass(g.active),f.reset.display.call(this),m.onOpen.call(this),m.onChange.call(this)}))},close:function(t){var n=t!==i?"number"==typeof t?C.eq(t):e(t):e(this),o=n.next(k),a=o.hasClass(g.active);a&&(f.debug("Closing accordion content",o),n.removeClass(g.active),o.removeClass(g.active).show(),m.animateChildren&&(e.fn.transition!==i&&w.transition("is supported")?o.children().transition({animation:"fade out",useFailSafe:!0,debug:m.debug,verbose:m.verbose,duration:m.duration}):o.children().stop().animate({opacity:0},m.duration,f.resetOpacity)),o.stop().slideUp(m.duration,m.easing,function(){f.reset.display.call(this),m.onClose.call(this),m.onChange.call(this)}))},closeOthers:function(t){var n,o,a,r=t!==i?C.eq(t):e(this),s=r.parents(v.content).prev(v.title),c=r.closest(v.accordion),l=v.title+"."+g.active+":visible",u=v.content+"."+g.active+":visible";m.closeNested?(n=c.find(l).not(s),a=n.next(k)):(n=c.find(l).not(s),o=c.find(u).find(l).not(s),n=n.not(o),a=n.next(k)),n.length>0&&(f.debug("Exclusive enabled, closing other content",n),n.removeClass(g.active),m.animateChildren&&(e.fn.transition!==i&&w.transition("is supported")?a.children().transition({animation:"fade out",useFailSafe:!0,debug:m.debug,verbose:m.verbose,duration:m.duration}):a.children().stop().animate({opacity:0},m.duration,f.resetOpacity)),a.stop().slideUp(m.duration,m.easing,function(){e(this).removeClass(g.active),f.reset.display.call(this)}))},reset:{display:function(){f.verbose("Removing inline display from element",this),e(this).css("display",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")},opacity:function(){f.verbose("Removing inline opacity from element",this),e(this).css("opacity",""),""===e(this).attr("style")&&e(this).attr("style","").removeAttr("style")}},setting:function(t,n){if(f.debug("Changing setting",t,n),e.isPlainObject(t))e.extend(!0,m,t);else{if(n===i)return m[t];m[t]=n}},internal:function(t,n){return f.debug("Changing internal",t,n),n===i?f[t]:void(e.isPlainObject(t)?e.extend(!0,f,t):f[t]=n)},debug:function(){m.debug&&(m.performance?f.performance.log(arguments):(f.debug=Function.prototype.bind.call(console.info,console,m.name+":"),f.debug.apply(console,arguments)))},verbose:function(){m.verbose&&m.debug&&(m.performance?f.performance.log(arguments):(f.verbose=Function.prototype.bind.call(console.info,console,m.name+":"),f.verbose.apply(console,arguments)))},error:function(){f.error=Function.prototype.bind.call(console.error,console,m.name+":"),f.error.apply(console,arguments)},performance:{log:function(e){var t,n,i;m.performance&&(t=(new Date).getTime(),i=r||t,n=t-i,r=t,s.push({Name:e[0],Arguments:[].slice.call(e,1)||"",Element:T,"Execution Time":n})),clearTimeout(f.performance.timer),f.performance.timer=setTimeout(f.performance.display,100)},display:function(){var t=m.name+":",n=0;r=!1,clearTimeout(f.performance.timer),e.each(s,function(e,t){n+=t["Execution Time"]}),t+=" "+n+"ms",x&&(t+=" '"+x+"'"),(console.group!==i||console.table!==i)&&s.length>0&&(console.groupCollapsed(t),console.table?console.table(s):e.each(s,function(e,t){console.log(t.Name+": "+t["Execution Time"]+"ms")}),console.groupEnd()),s=[]}},invoke:function(t,n,a){var r,s,c,l=S;return n=n||u,a=T||a,"string"==typeof t&&l!==i&&(t=t.split(/[\. ]/),r=t.length-1,e.each(t,function(n,o){var a=n!=r?o+t[n+1].charAt(0).toUpperCase()+t[n+1].slice(1):t;if(e.isPlainObject(l[a])&&n!=r)l=l[a];else{if(l[a]!==i)return s=l[a],!1;if(!e.isPlainObject(l[o])||n==r)return l[o]!==i?(s=l[o],!1):(f.error(h.method,t),!1);l=l[o]}})),e.isFunction(s)?c=s.apply(a,n):s!==i&&(c=s),e.isArray(o)?o.push(c):o!==i?o=[o,c]:c!==i&&(o=c),s}},l?(S===i&&f.initialize(),f.invoke(c)):(S!==i&&S.invoke("destroy"),f.initialize())}),o!==i?o:this},e.fn.accordion.settings={name:"Accordion",namespace:"accordion",debug:!1,verbose:!0,performance:!0,exclusive:!0,collapsible:!0,closeNested:!1,animateChildren:!0,duration:500,easing:"easeOutQuint",onOpen:function(){},onClose:function(){},onChange:function(){},error:{method:"The method you called is not defined"},className:{active:"active"},selector:{accordion:".accordion",title:".title",content:".content"}},e.extend(e.easing,{easeOutQuint:function(e,t,n,i,o){return i*((t=t/o-1)*t*t*t*t+1)+n}})}(jQuery,window,document),function(e,t,n,i){"use strict";e.fn.checkbox=function(n){var o,a=e(this),r=a.selector||"",s=(new Date).getTime(),c=[],l=arguments[0],u="string"==typeof l,d=[].slice.call(arguments,1);return a.each(function(){var a,f,m=e.extend(!0,{},e.fn.checkbox.settings,n),g=m.className,p=m.namespace,v=m.selector,h=m.error,b="."+p,y="module-"+p,x=e(this),w=e(this).find(v.label).first(),C=e(this).find(v.input),k=x.data(y),T=this;f={initialize:function(){f.verbose("Initializing checkbox",m),f.create.label(),f.add.events(),f.is.checked()?(f.set.checked(),m.fireOnInit&&m.onChecked.call(C.get())):(f.remove.checked(),m.fireOnInit&&m.onUnchecked.call(C.get())),f.observeChanges(),f.instantiate()},instantiate:function(){f.verbose("Storing instance of module",f),k=f,x.data(y,f)},destroy:function(){f.verbose("Destroying module"),f.remove.events(),x.removeData(y)},refresh:function(){x=e(this),w=e(this).find(v.label).first(),C=e(this).find(v.input)},observeChanges:function(){"MutationObserver"in t&&(a=new MutationObserver(function(){f.debug("DOM tree modified, updating selector cache"),f.refresh()}),a.observe(T,{childList:!0,subtree:!0}),f.debug("Setting up mutation observer",a))},attachEvents:function(t,n){var i=e(t);n=e.isFunction(f[n])?f[n]:f.toggle,i.length>0?(f.debug("Attaching checkbox events to element",t,n),i.on("click"+b,n)):f.error(h.notFound)},event:{keydown:function(e){var t=e.which,n={enter:13,space:32,escape:27};t==n.escape&&(f.verbose("Escape key pressed blurring field"),x.blur()),e.ctrlKey||t!=n.enter&&t!=n.space||(f.verbose("Enter key pressed, toggling checkbox"),f.toggle.call(this),e.preventDefault())}},is:{radio:function(){return x.hasClass(g.radio)},checked:function(){return C.prop("checked")!==i&&C.prop("checked")},unchecked:function(){return!f.is.checked()}},can:{change:function(){return!(x.hasClass(g.disabled)||x.hasClass(g.readOnly)||C.prop("disabled"))},uncheck:function(){return"boolean"==typeof m.uncheckable?m.uncheckable:!f.is.radio()}},set:{checked:function(){x.addClass(g.checked)},tab:function(){C.attr("tabindex")===i&&C.attr("tabindex",0)}},create:{label:function(){C.prevAll(v.label).length>0?(C.prev(v.label).detach().insertAfter(C),f.debug("Moving existing label",w)):f.has.label()||(w=e("