Initial dev repository
[kcls-web.git] / opac / extras / mobile / mobile / js / opac / ou_tree.js
diff --git a/opac/extras/mobile/mobile/js/opac/ou_tree.js b/opac/extras/mobile/mobile/js/opac/ou_tree.js
new file mode 100644 (file)
index 0000000..7e6ad15
--- /dev/null
@@ -0,0 +1,4 @@
+var __hasProp=Object.prototype.hasOwnProperty,__bind=function(o,f){return function(){return o.apply(f,arguments)}};
+module("opac.ou_tree",imports("eg.fieldmapper","eg.eg_api"),function(o,f){var p;p={name:"org_unit",all:true,selected:0,indent:". ",focus:false};return $.fn.ou_tree=function(r){var a;a=$.extend({},p,r);f.openils("actor.org_tree.retrieve",__bind(function(m){var k,l,g,q;if(typeof(k=window.query==null?undefined:window.query.ol)!=="undefined"&&k!==null){k=window.query.ol.toUpperCase();for(l in m)if(__hasProp.call(m,l)){g=m[l];if(g.shortname===k){q=Number(l);break}}}return this.parallel("organization list",
+{ouTypes:f.openils("actor.org_types.retrieve"),ouTree:f.openils("actor.org_tree.descendants.retrieve",q)},function(h){var i,b,d,e,c,n,j;this.append(i=$("<select>").attr("name",a.name));e=[];b=h.ouTree;for(d in b)if(__hasProp.call(b,d)){g=b[d];c=[];for(n=j=h.ouTypes[g.ou_type];j;){if(j.id===1)break;c.push(a.indent);j=h.ouTypes[j.parent]}c.push(g.name);c=c.join("");if(a.all)e.push($("<option>").val(d).text(c));else!n.can_have_users||n.can_have_users==="f"?e.push($("<optgroup>").attr("label",c)):e.push($("<option>").val(d).text(c))}b=
+0;for(d=e.length;b<d;b++){h=e[b];i.append(h)}if(a.selected)isNaN(a.selected)?i.children().first().text(a.selected):i.children().each(function(){if(Number($(this).val())===a.selected){$(this).attr("selected","selected");return false}});if(a.focus)return i.focus()})},this));return this}});