Initial dev repository
[kcls-web.git] / opac / extras / mobile / js / opac / search_bar.js
diff --git a/opac/extras/mobile/js/opac/search_bar.js b/opac/extras/mobile/js/opac/search_bar.js
new file mode 100644 (file)
index 0000000..e73ffba
--- /dev/null
@@ -0,0 +1,57 @@
+var __hasProp=Object.prototype.hasOwnProperty,__bind=function(g,j){return function(){return g.apply(j,arguments)}};
+module("opac.search_bar",imports("eg.eg_api","plugin","opac.ou_tree","opac.sort"),function(){var g,j,k,l,o,m;l={};j={default_class:{keyword:"Keyword",title:"Title",author:"Author",subject:"Subject",series:"Series"},search_term_verb:{" ":"Contains","-":"Does not contain","=":"Matches exactly"},item_type:{"":"All Item Types",at:"Books",i:"Audiobooks",g:"Video Recordings",j:"Music",m:"Electronic Resources"},language:{"":"All Languages",eng:"English",spa:"Spanish",fre:"French",ger:"German",ita:"Italian",
+chi:"Chinese",jpn:"Japanese",kor:"Korean",dut:"Dutch",gre:"Greek, Modern (1453- )",lat:"Latin",vie:"Vietnamese",rus:"Russian",nor:"Norwegian",wel:"Welsh",pau:"Palauan",swe:"Swedish",nav:"Navajo"},pub_year_verb:{is:"Is",before:"Before",after:"After",between:"Between"},refresh:""};g=function(){var c,h,a,b,d;if(!(b=l[$(this).attr("name")]))return null;if($(this).find("option").length)return null;h=[];for(d in b)if(__hasProp.call(b,d)){a=b[d];h.push(function(){c=$('<option value="'+d+'">'+a+"</option>");
+d||c.attr("selected","selected");return $(this).append(c)}.call(this))}return h};o=function(){var c;c=$(".search.term",this);c.hide().empty().
+append('<div class="search row advanced_search">\n\t\n\t'
+   + '<div class="search row buttons"><button type="button" title="Delete this search row" class="search row delete">-</button>'
+   + '<button type="button" title="Add new search row" class="search row add">+</button></div>\n'
+   + '<select name="default_class" class="default_class" />\n\t<select name="search_term_verb" />\n\t'
+   + '<input name="term" type="text" />\n\t</div>').
+append('<div class="search row advanced_search">\n\t\n\t'
+   + '<div class="search row buttons"><button type="button" title="Delete this search row" class="search row delete">-</button>'
+   + '<button type="button" title="Add new search row" class="search row add">+</button></div>\n'
+   + '<select name="default_class" class="default_class" />\n\t<select name="search_term_verb" />\n\t'
+   + '<input name="term" type="text" />\n\t</div>').
+append('<div class="search row advanced_search">\n\t\n\t'
+   + '<div class="search row buttons"><button type="button" title="Delete this search row" class="search row delete">-</button>'
+   + '<button type="button" title="Add new search row" class="search row add">+</button></div>\n'
+   + '<select name="default_class" class="default_class" />\n\t<select name="search_term_verb" />\n\t'
+   + '<input name="term" type="text" />\n\t</div>').find("select").each(function(){return g.call(this)});
+c.fadeIn(1E3);$(".search.advanced",this).fadeIn(1E3);$("select:[name=item_type]",this).hide().attr({multiple:true,size:4}).fadeIn(1E3);$("input[name=term]",this).first().focus();return false};m=function(){var c;c=$(".search.term",this);c.hide().empty().
+append('<div class="search row">\n\t<input name="term" type="text" />\n\t'
+   + '<select name="default_class" class="slim" />\n</div>').find("select").each(function(){return g.call(this)});c.fadeIn(1E3);$(".search.advanced",this).fadeOut(1E3);$("select:[name=item_type]",
+this).hide().attr({multiple:false,size:1}).fadeIn(1E3);$("input[name=term]",this).first().focus();return false};k=function(){$("input[type=text]",this).val("");$("input[type=checkbox]",this).attr("checked",false);$("select",this).val("");$(".sort select",this).change();return false};return $.fn.search_bar=function(c){var h;l=$.extend({},j,c);this.plugin("basic_search search_bar").
+html('<form class="search_form_advanced">\n\t<div class="search term" />\n\t'
+   + '<div>\n\t\t<span class="org_unit_selector" />\n\t\t<span class="advanced search org_unit_available">'
+   + '<div><input type="checkbox" name="available" value="1" /><label for="available">Limit to Available</label></div></span>\n\t</div>\n\t'
+   + '<div>\n\t\t<select name="item_type" title="Filter by item type"/>\n\t\t'
+   + '<select multiple size="4" class="advanced search" name="language" title="Filter by language"/>\n\t</div>\n\t'
+   + '<div class="advanced search publication year">\n\t\t<span>Publication Year</span>\n\t\t<select name="pub_year_verb" class="slim" />\n\t\t'
+   + '<input type="text" name="year_begin" maxlength="4" size="4" class="slim"/>\n\t\t'
+   + '<span class="year_end">and <input name="year_end" maxlength="4" size="4"/></span>\n\t</div>\n\t<div class="sort_chooser" />\n\t'
+   + '<input name="offset" value="0" type="hidden" />\n\t<input name="limit" value="10" type="hidden" />\n\t'
+   + '<input name="visibility_limit" value="1000" type="hidden" />\n\t<input name="type" value="advanced" type="hidden" />\n\t'
+   + '<button type="submit">Search</button>\n\t<button type="reset">Reset</button>\n\t<button type="button" class="search type" />\n</form>');
+$(".org_unit_selector",this).ou_tree({all:true,selected:typeof(h=window.query==null?undefined:window.query.ol)!=="undefined"&&h!==null?null:"Search all libraries",indent:"_ "});$(".sort_chooser",this).sort_chooser();$("select",this).each(function(){return g.call(this)});m.call(this);$(".search.type",this).text("Advanced").toggle(__bind(function(a){$(a.target).text("Simple").attr("title","Show simple search form");o.call(this);return k.call(this)},this),__bind(function(a){$(a.target).text("Advanced").attr("title",
+"Show advanced search form");m.call(this);return k.call(this)},this));this.delegate("button.search.row","click",__bind(function(a){var b;b=$(a.target);a=b.parent();if(b.hasClass("delete"))this.find("div.search.row").length!==1&&a.parent().remove();else if(b.hasClass("add")){a.
+parent().before('<div class="search row advanced_search">\n\t\n\t'
+   + '<div class="search row buttons"><button type="button" title="Delete this search row" class="search row delete">-</button>'
+   + '<button type="button" title="Add new search row" class="search row add">+</button></div>\n'
+   + '<select name="default_class" class="default_class" />\n\t<select name="search_term_verb" />\n\t'
+   + '<input name="term" type="text" />\n\t</div>');
+this.find("select",a).each(function(){return g.call(this)})}return false},this));$(".year_end",this).hide();this.delegate("select[name=pub_year_verb]","blur",__bind(function(a){var b;b=$(a.target).val();a=$(".year_end",this);b==="between"?a.show():a.hide();return false},this));this.keyup(__bind(function(a){switch(a.keyCode){case 27:$("button[type=reset]",this).click();break}return false},this));this.delegate("button[type=reset]","click",__bind(function(){return k.call(this)},this));return this.submit(function(){var a,
+b,d,i,e,n,f;n=false;$("input[name=term]",this).each(function(){if(this.value){n=true;return false}});if(!n)return false;e={};d=$(this).children("form").serializeArray();a=0;for(b=d.length;a<b;a++){f=d[a];if(typeof(i=e[f.name])!=="undefined"&&i!==null){$.isArray(e[f.name])||(e[f.name]=[e[f.name]]);e[f.name].push(f.value)}else e[f.name]=f.value}e.depth=(typeof(i=d=$("select[name=org_unit]",$(this)).find(":selected").text().match(/\_ /g))==="undefined"||i===null?undefined:i.length)||0;$(this).publish("search",
+[e]);return false})}});
+/*
+var __hasProp=Object.prototype.hasOwnProperty,__bind=function(f,g){return function(){return f.apply(g,arguments)}};
+module("opac.search_bar",imports("eg.eg_api","plugin","opac.ou_tree","opac.sort"),function(){var f;f={refresh:"",default_class:{keyword:"Keyword",title:"Title",author:"Author",subject:"Subject",series:"Series"},item_type:{"":"All Item Types",at:"Books",i:"Audiobooks",g:"Video Recordings",j:"Music",m:"Electronic Resources"}};return $.fn.search_bar=function(g){var j,k;k=$.extend({},f,g);this.plugin("basic_search search_bar").
+html('<form>\n\t<div>\n\t\t<input name="term" type="text" />\n\t\t<select name="default_class" class="slim"/>\n\t\t'
+   + '<!--select name="item_type" /-->\n\t\t<span class="org_unit_selector"></span>\n\t\t'
+   + '<div class="sort_chooser plugin sort"></div>'
+   + '<button type="submit">Search</button>\n\t\t<button type="reset">Reset</button>\n\t<input name="type" value="advanced" type="hidden"/>\n\t'
+   + '<input name="offset" value="0" type="hidden"/>\n</form>');
+//<form>\n\t<div>\n\t\t<input  name="term" type="text" />\n\t\t<select name="default_class" />\n\t\t<!--select name="item_type" /--\>\n\t\t<button type="submit">Search</button>\n\t\t<button type="reset">Reset</button>\n\t</div>\n\t<span class="org_unit_selector" />\n\t<div class="sort_chooser" />\n\t<input name="type" value="advanced" type="hidden" />\n\t<input name="offset" value="0" type="hidden" />\n</form>');
+$("input[name=term]",this).focus();this.find("select").each(function(){var a,e,b,c;if(!(b=k[$(this).attr("name")]))return null;return $(this).append(function(){a=[];for(c in b)if(__hasProp.call(b,c)){e=b[c];a.push('<option value="'+c+'">'+e+"</option>")}return a}().join(""))});$(".org_unit_selector",this).ou_tree({all:true,selected:typeof(j=window.query==null?undefined:window.query.ol)!=="undefined"&&j!==null?null:"Search all libraries",indent:"_ "});$(".sort_chooser",this).sort_chooser();this.keyup(__bind(function(a){a.keyCode===
+27&&$("button[type=reset]",this).click();return false},this));this.delegate("button[type=reset]","click",__bind(function(){$("input[name=term]",this).val("");$("select",this).val(0);$(".sort select",this).change();return false},this));this.submit(function(){var a,e,b,c,h,d,i;d={};e=$(this).children("form").serializeArray();a=0;for(b=e.length;a<b;a++){i=e[a];d[i.name]=i.value}if(typeof(c=d.item_type)!=="undefined"&&c!==null)d.item_type=d.item_type.split("");d.depth=(typeof(h=$("select[name=org_unit]",
+$(this)).find(":selected").text().match(/\_ /g))==="undefined"||h===null?undefined:h.length)||0;$(this).publish("search",[d]);return false});return this.subscribe("search",function(a){this.find(":input").each(function(){if(this.name==="search"||this.name==="offset"||this.name==="visibility_limit")return null;if(!a[this.name])return null;if(this.name==="item_type")a.item_type=a.item_type.join("");return $(this).val(a[this.name])});this.find(".sort select").change();return false})}});
+*/
\ No newline at end of file