-
Notifications
You must be signed in to change notification settings - Fork 0
/
jassa-ui-angular.min.js
9 lines (8 loc) · 32.5 KB
/
jassa-ui-angular.min.js
1
2
3
4
5
6
7
8
9
/*
* jassa-ui-angular
* https://github.com/GeoKnow/Jassa-UI-Angular
* Version: 0.9.0-SNAPSHOT - 2017-04-05
* License: MIT
*/
angular.module("ui.jassa",["ui.jassa.auto-focus","ui.jassa.blurify","ui.jassa.breadcrumb","ui.jassa.compile","ui.jassa.constraint-list","ui.jassa.dataset-browser","ui.jassa.facet-list","ui.jassa.facet-tree","ui.jassa.facet-typeahead","ui.jassa.facet-value-list","ui.jassa.jassa-list","ui.jassa.jassa-list-browser","ui.jassa.jassa-media-list","ui.jassa.lang-select","ui.jassa.list-search","ui.jassa.paging-model","ui.jassa.paging-style","ui.jassa.pointer-events-scroll-fix","ui.jassa.replace","ui.jassa.resizable","ui.jassa.scroll-glue-right","ui.jassa.sparql-grid","ui.jassa.template-list"]),angular.module("ui.jassa.auto-focus",[]).directive("autoFocus",function(a,b){return{link:function(c,d,e){var f=b(e.autoFocus);c.$watch(f,function(b){b===!0&&a(function(){d[0].focus()})}),d.bind("blur",function(){f.assign&&c.$apply(f.assign(c,!1))})}}}),angular.module("ui.jassa.blurify",[]).directive("blurify",["$parse",function(a){return{require:"ngModel",restrict:"A",link:function(b,c,d,e){c.on("focus",function(){e.$render()}),c.on("blur",function(){var e=a(d.ngModel)(b),f=a(d.blurify)(b);if(f){var g=f(e);g&&g.then?g.then(function(a){c.val(a)}):c.val(g)}})}}}]),angular.module("ui.jassa.breadcrumb",[]).controller("BreadcrumbCtrl",["$rootScope","$scope","$q","$timeout",function(a,b,c,d){b.slots=[],b.invert=function(){b.model.property=null;var a=b.model.pathHead;a&&(b.model.pathHead=new jassa.facete.PathHead(a.getPath(),!a.isInverse()))};var e=function(){var a=b.model.property,d=null==a||a===!0?null:jassa.rdf.NodeFactory.createUri(a),e=b.model.pathHead,f=e?e.getPath():null,g=b.lookupService;if(g&&f){var h=f.getSteps();g=new jassa.service.LookupServiceTransform(g,function(a){return a.displayLabel});var i=jassa.facete.PathUtils.getUris(f);null!=d&&i.push(d),c.when(g.lookup(i)).then(function(a){var b=h.map(function(b){var c=jassa.rdf.NodeFactory.createUri(b.getPropertyName()),d={property:c,labelInfo:{displayLabel:a.get(c)},isInverse:b.isInverse()};return d}),c=null;d&&(c={property:d,labelInfo:{displayLabel:a.get(d)}});var e={slots:b,value:c};return e}).then(function(a){b.state=a})}};b.$watch("[ObjectUtils.hashCode(facetTreeConfig), model.pathHead.hashCode(), model.property]",function(){e()},!0),b.$watch("lookupService",function(){e()}),b.setPath=function(a){b.model.property=null;var c=b.model.pathHead,d=c?c.getPath():null,e=c?c.isInverse():!1;if(null!=d){var f=d.getSteps(),g=f.slice(0,a),h=new jassa.facete.Path(g);b.model.pathHead=new jassa.facete.PathHead(h,e)}}}]).directive("breadcrumb",function(){return{restrict:"EA",replace:!0,templateUrl:"template/breadcrumb/breadcrumb.html",scope:{lookupService:"=",model:"=ngModel",maxSize:"=?",onSelect:"&select"},controller:"BreadcrumbCtrl",compile:function(a,b){return{pre:function(a,b,c,d){}}}}}),angular.module("ui.jassa.compile",[]).directive("compile",["$compile",function(a){return{scope:!0,terminal:!0,replace:!0,compile:function(b,c){return{post:function(b,c,d,e){b.$watch(function(a){return a.$eval(d.compile)},function(d){c.html(d),a(c.contents())(b)})}}}}}]),angular.module("ui.jassa.constraint-list",[]).controller("ConstraintListCtrl",["$scope","$q","$rootScope","$dddi",function(a,b,c,d){var e=d(a);e.register("constraintLabelsLookupService",["lookupService",function(a){var b=new jassa.facete.LookupServiceConstraintLabels(ls);return b}]),e.register("constraints",["=constraintManager.getConstraints()",function(a){return a}]),e.register("listService",["constraints","constraintLabelsLookupService",function(){}]);a.removeConstraint=function(b){a.constraintManager.removeConstraint(b.constraint)}}]).directive("constraintList",function(){return{restrict:"EA",replace:!0,templateUrl:"template/constraint-list/constraint-list.html",transclude:!1,require:"constraintList",scope:{lookupService:"=",constraintManager:"=",onSelect:"&select"},controller:"ConstraintListCtrl"}}),angular.module("ui.jassa.dataset-browser",["ui.jassa.replace"]).controller("DatasetBrowserCtrl",["$scope","$q",function(a,b){var c=function(a,b){var c=new jassa.sponate.StoreFacade(a,{rdf:"http://www.w3.org/1999/02/22-rdf-syntax-ns#","dbpedia-owl":"http://dbpedia.org/ontology/",foaf:"http://xmlns.com/foaf/0.1/",dcat:"http://www.w3.org/ns/dcat#",theme:"http://example.org/resource/theme/",o:"http://example.org/ontology/"}),d=function(){return jassa.sponate.MappedConceptUtils.createMappedConceptLiteralPreference(new jassa.sparql.LiteralPreference(b))},e=function(){return jassa.sponate.MappedConceptUtils.createMappedConceptLiteralPreference(new jassa.sparql.LiteralPreference(b,[jassa.vocab.rdfs.comment]))},f=[{id:"?s",label:{$ref:{target:d,attr:"displayLabel"}},comment:{$ref:{target:e,attr:"displayLabel"}},depiction:"?d",resources:[{label:'"Distributions"',type:'"dataset"',items:[{$ref:{target:"distributions",on:"?x"}}],template:"template/dataset-browser/distribution-list.html"},{label:'"Join Summaries"',type:"join-summary",items:[[{$ref:{target:"datasets",on:"?j"}}],function(a){var b=_(a).chain().map(function(a){return a.resources[0].items}).flatten(!0).value();return b}],template:"template/dataset-browser/distribution-list.html"}]}];c.addMap({name:"primaryDatasets",template:f,from:"?s a dcat:Dataset ; dcat:theme theme:primary . Optional { ?s foaf:depiction ?d } . Optional { ?x o:distributionOf ?s } Optional { ?j o:joinSummaryOf ?s }"}),c.addMap({name:"datasets",template:f,from:"?s a dcat:Dataset . Optional { ?s foaf:depiction ?d } . Optional { ?x o:distributionOf ?s } Optional { ?j o:joinSummaryOf ?s }"}),c.addMap({name:"distributions",template:[{id:"?s",accessUrl:"?a",graphs:["?g"]}],from:"?s a dcat:Distribution ; dcat:accessURL ?a . Optional { ?s o:graph ?g } "});var g=c.primaryDatasets.getListService();return g=new jassa.service.ListServiceTransformConceptMode(g,function(){var a=new jassa.sparql.LiteralPreference(b,[jassa.vocab.rdfs.comment,jassa.vocab.rdfs.label]),c=jassa.sparql.LabelUtils.createRelationLiteralPreference(a);return c}),g.fetchItems().then(function(a){console.log("DatasetBrowser - found items: ",a)}),g};a.$watch(function(){return a.sparqlService},function(b){a.listService=c(b,a.langs)}),a.langs=["de","en",""],a.searchModes=[{label:"regex",mode:"regex"},{label:"fulltext",mode:"fulltext"}],a.activeSearchMode=a.searchModes[0],a.availableLangs=["de","en","jp","ko"],a.offset=0,a.limit=10,a.totalItems=0,a.items=[],a.maxSize=7,a.doFilter=function(b){a.filter={searchString:b,mode:a.activeSearchMode.mode},a.offset=0},a.context={onSelect:function(){a.onSelect.apply(this,arguments)}},a.itemTemplate="template/dataset-browser/dataset-list-item.html"}]).directive("datasetBrowser",function(){return{restrict:"EA",replace:!0,templateUrl:"template/dataset-browser/dataset-browser.html",scope:{sparqlService:"=",maxSize:"=?",onSelect:"&?"},controller:"DatasetBrowserCtrl",compile:function(a,b){return{pre:function(a,b,c,d){}}}}}),angular.module("ui.jassa.facet-list",["ui.jassa.breadcrumb","ui.jassa.paging-style","ui.jassa.paging-model","ui.bootstrap","dddi"]).controller("FacetListCtrl",["$rootScope","$scope","$q","$dddi",function(a,b,c,d){b.facetPlugins=b.facetPlugins||[],b.showConstraints=!1;var e=new ListServiceWatcher(b,c);b.ls=e.watch("listService"),b.pagingStyle=b.pagingStyle||{},b.ObjectUtils=jassa.util.ObjectUtils,b.loading=b.loading||{data:!1,pageCount:!1},b.NodeUtils=jassa.rdf.NodeUtils,b.breadcrumb=b.breadcrumb||{},b.location=null,b.locationToFilter=new jassa.util.HashMap;var f={constraint:{type:"constraint",itemTemplate:"template/facet-list/facet-list-item-constraint.html",listServiceFn:function(){var a=b.constraintService;return a}},facet:{type:"facet",itemTemplate:"template/facet-list/facet-list-item-facet.html",listServiceFn:function(){var a=b.facetService?b.facetService.prepareListService(b.breadcrumb.pathHead):null;return a}},facetValue:{type:"facetValue",itemTemplate:"template/facet-list/facet-list-item-facet-value.html",listServiceFn:function(){var a=b.facetValueService?b.facetValueService.prepareTableService(b.facetValuePath,!0):null;return a}}},g={pathHead:new jassa.facete.PathHead(new jassa.facete.Path),property:null};_.defaults(b.breadcrumb,g),b.facetValuePath=null,b.descendFacet=function(a){var c=b.breadcrumb.pathHead,d=new jassa.facete.Step(a.getUri(),c.isInverse()),e=c.getPath().copyAppendStep(d);b.breadcrumb.pathHead=new jassa.facete.PathHead(e,c.isInverse())};var h=function(a,b){var c=a.getPath().copyAppendStep(new jassa.facete.Step(b,a.isInverse()));return c};b.toggleConstraint=function(a){var c=b.facetValuePath,d=b.constraintManager,e=new jassa.facete.ConstraintEquals(c,a);d.toggleConstraint(e)};var i=d(b);i.register("mode",["showConstraints","breadcrumb.pathHead.hashCode()","?breadcrumb.property",function(a){var c,d=b.breadcrumb;if(a===!0)c=f.constraint;else{var e=d.property;c=e===!0?f.facetValue:null==e?f.facet:f.facetValue}return c}]),i.register("facetValuePath",["breadcrumb.pathHead.hashCode()","breadcrumb.property",function(){var a,c=b.breadcrumb,d=c.property;return a=d===!0?b.breadcrumb.pathHead.getPath():null==d?null:h(b.breadcrumb.pathHead,d)}]),i.register("location",["mode","?facetValuePath.hashCode()","?breadcrumb.pathHead.hashCode()",function(){var a;return a="constraint"===b.mode.type?jassa.facete.Path.parse("constraint"):null!=b.facetValuePath?b.facetValuePath:b.breadcrumb.pathHead}]),i.register("listFilter",["location.hashCode()",function(a){var c=b.locationToFilter.get(b.location);return null==c&&(c={limit:10,offset:0,concept:null},b.locationToFilter.put(b.location,c)),c}]),i.register("filterModel",["listFilter.concept",function(a){return a}]),b.$watch("listFilter",function(a){a&&angular.copy(a,b.ls.ctrl.filter)}),i.register("listService",["mode","location","facetService","facetValueService","constraintService",function(a){var b=a.listServiceFn();return b}]),i.register("totalConstraints",["constraintManager.getConstraints().length",function(a){return a}])}]).directive("facetList",function(){return{restrict:"EA",replace:!0,templateUrl:"template/facet-list/facet-list.html",scope:{constraintManager:"=",lookupServiceNodeLabels:"=",facetService:"=",facetValueService:"=",constraintService:"=",listFilter:"=?",breadcrumb:"=?uiModel",pathHead:"=?",facetPlugins:"=?",pluginContext:"=?",pagingStyle:"=?",loading:"=?",onSelect:"&select"},controller:"FacetListCtrl",compile:function(a,b){return function(a,b,c,d){}}}}),angular.module("ui.jassa.facet-tree",[]).controller("FacetTreeDirContentCtrl",["$rootScope","$scope","$q",function(a,b,c){}]).directive("facetTreeDirContent",function(a){return{restrict:"EA",replace:!0,templateUrl:"template/facet-tree/facet-tree-content.html",transclude:!1,require:"facetTree",scope:{sparqlService:"=",facetTreeConfig:"=",plugins:"=",onSelect:"&select"},controller:"FacetTreeDirContentCtrl",compile:function(a,b){return function(a,b,c,d){}}}}),angular.module("ui.jassa.facet-tree",["ui.jassa.template-list"]).controller("FacetNodeCtrl",["$scope",function(a){a.$watchCollection("[facet.incoming, facet.outgoing]",function(){var b=a.facet;b&&(a.dirset=b.outgoing?b.outgoing:b.incoming)}),a.$watchCollection("[dirset, dirset.listFilter.getOffset(), dirset.listFilter.getLimit(), dirset.childCountInfo.count]",function(){var b=a.dirset;b&&(b.offset=b.listFilter.getOffset()||0,b.limit=b.listFilter.getLimit()||0,b.pageCount=b.limit?Math.floor(b.childCountInfo.count/b.limit):1,b.currentPage=b.limit?Math.floor(b.offset/b.limit)+1:1)})}]).controller("FacetTreeCtrl",["$rootScope","$scope","$q","$timeout",function(a,b,c,d){var e=this,f=function(){var a=b.sparqlService&&b.facetTreeConfig;b.facetTreeService=a?jassa.facete.FacetTreeServiceUtils.createFacetTreeService(b.sparqlService,b.facetTreeConfig):null},g=function(){f(),e.refresh()};b.itemsPerPage=[10,25,50,100],b.ObjectUtils=jassa.util.ObjectUtils,b.Math=Math,b.startPath=null;var h="[ObjectUtils.hashCode(facetTreeConfig), startPath]";b.$watch(h,function(){g()},!0),b.$watch("sparqlService",function(){g()}),b.doFilter=function(a,c){var d=b.facetTreeConfig.getFacetTreeState().getPathHeadToFilter(),e=d.get(a);e||(e=new jassa.facete.ListFilter(null,10,0),d.put(a,e)),e.setConcept(c),e.setOffset(0)},e.refresh=function(){if(b.facetTreeService){var a=b.facetTreeService.fetchFacetTree(b.startPath);c.when(a).then(function(a){b.facet=a})}else b.facet=null},b.toggleControls=function(a){var c=b.facetTreeConfig.getPathToTags(),d=c.get(a);d||(d={},c.put(a,d)),d.showControls=!d.showControls},b.toggleCollapsed=function(a){var c=b.facetTreeConfig.getFacetTreeState().getPathExpansions();jassa.util.CollectionUtils.toggleItem(c,a)},b.isEqual=function(a,b){var c=null==a?null==b:a.equals(b);return c},b.setStartPath=function(a){var c=null==a||b.isEqual(b.startPath,a);b.startPath=c?null:a},b.selectIncoming=function(a){if(b.facetTreeConfig){var c=b.facetTreeConfig.getFacetTreeState().getPathToDirection();c.put(a,-1)}},b.selectOutgoing=function(a){if(b.facetTreeConfig){var c=b.facetTreeConfig.getFacetTreeState().getPathToDirection();c.put(a,1)}},b.selectPage=function(a,c){var d=b.facetTreeConfig.getFacetTreeState().getPathHeadToFilter(),e=d.get(a);e||(e=new jassa.facete.ListFilter(null,10,0),d.put(a,e));var f=(c-1)*e.getLimit();e.setOffset(f)}}]).directive("facetTree",function(){return{restrict:"EA",replace:!0,templateUrl:"template/facet-tree/facet-tree-item.html",transclude:!1,require:"facetTree",scope:{sparqlService:"=",facetTreeConfig:"=",plugins:"=",pluginContext:"=",onSelect:"&select"},controller:"FacetTreeCtrl",compile:function(a,b){return function(a,b,c,d){}}}}),angular.module("ui.jassa.facet-typeahead",[]).directive("facetTypeahead",["$compile","$q","$parse",function(a,b,c){var d=jassa.sponate,e=jassa.facete,f=function(a){var b=a instanceof e.Path?a:e.Path.parse(a);return b},g=function(a,b){var c;if(!a)throw new Error("No specification for building a list service provided");if("[object String]"===Object.prototype.toString.call(a)){var e=b.store;if(c=e.getListService(a),!c)throw new Error("No collection with name "+a+" found")}else if(a instanceof d.MappedConcept){var f=b.sparqlService;c=jassa.sponate.ListServiceUtils.createListServiceMappedConcept(f,a)}else if(a instanceof d.MappedConceptSource){var g=a.getMappedConcept(),h=a.getSparqlService();c=jassa.sponate.ListServiceUtils.createListServiceMappedConcept(h,g)}else{if(!(a instanceof service.ListService))throw new Error("Unsupported list service type",a);c=a}return c},h=function(a,b,c){var d=[],e=Object.keys(a);return e.forEach(function(e){var g,h,i=a[e],j=i.scope,k=i.modelExpr(j),l=i.pathExpr(j),m=f(l);if(c||"[object String]"!==Object.prototype.toString.call(k)||""===(h=k.trim()))if(k&&k.id){var n=k.id,o=jassa.rdf.NodeFactory.createUri(n);g=new jassa.facete.ConstraintEquals(m,o)}else g=null;else if(b){var p=b(h);g=new jassa.facete.ConstraintConcept(m,p)}else g=new jassa.facete.ConstraintRegex(m,h);g&&d.push(g)}),d},i=function(a,b,c,d,e){this.$scope=a,this.$q=b,this.configExpr=c,this.id=d,this.listServiceExpr=e};return i.prototype.getSuggestions=function(a){var b=this.configExpr(this.$scope),c=b.idToModelPathMapping,d=c[this.id];if(!d)throw new Error("Cannot retrieve model-path mapping for facet-typeahead directive with id "+id);var e=d.pathExpr(this.$scope),i=f(e),j=this.listServiceExpr(this.$scope),k=g(j,b),l=b.facetConfig,m=l.getConstraintManager(),n=h(c,b.search);_(n).each(function(a){var b=a.getDeclaredPaths();b.forEach(function(a){var b=m.getConstraintsByPath(a);b.forEach(function(a){m.removeConstraint(a)})}),m.addConstraint(a)});var o=new jassa.facete.FacetValueConceptServiceExact(l),p=o.prepareConcept(i,!1).then(function(a){var b=k.fetchItems(a,10).then(function(a){var b=a.map(function(a){return a.val});return b});return b});return p},{restrict:"A",scope:!0,priority:1001,terminal:!0,compile:function(d,e){this.instanceId||(this.instanceId=0);var f="facetTypeAhead-"+this.instanceId++,g=e.ngModel,j=e.facetTypeahead,k=e.facetTypeaheadPath,l=e.facetTypeaheadSuggestions,m=e.facetTypeaheadLabel,n=e.facetTypeaheadModel;m=m||"id",n=n||"id",console.log("labelAttr",m),console.log("modelAttr",n),d.removeAttr("facet-typeahead"),d.removeAttr("facet-typeahead-path"),d.removeAttr("facet-typeahead-suggestions"),d.removeAttr("facet-typeahead-label"),d.removeAttr("facet-typeahead-model");var o=n?"."+n:"",p="item as item"+o+" for item in facetTypeAheadService.getSuggestions($viewValue)";return d.attr("typeahead",p),d.attr("blurify","labelFn"),{pre:function(a,d,e){var n=c(g),o=c(k),p=c(j),q=c(l);a.labelFn=function(b){var c=n(a),d=c?c[m]:null,e=d?d:b;return e},a.$watch(j,function(b,c){c&&c!=b&&c.modelToPathMapping&&delete c.idToModelPathMapping[f],b&&(b.idToModelPathMapping||(b.idToModelPathMapping={}),b.idToModelPathMapping[f]={modelExpr:n,modelExprStr:g,pathExprStr:k,pathExpr:o,scope:a},b.getConstraints=function(a){var c=h(b.idToModelPathMapping,b.search,a);return c})}),a.facetTypeAheadService=new i(a,b,p,f,q)},post:function(b,c,d){a(c)(b)}}}}}]),angular.module("ui.jassa.facet-value-list",[]).controller("FacetValueListCtrl",["$rootScope","$scope","$q",function(a,b,c){b.filterText="",b.pagination={totalItems:0,currentPage:1,maxSize:5},b.path=null;var d=null,e=function(){var a=b.sparqlService&&b.facetTreeConfig&&b.path;if(a){var c=b.facetTreeConfig.getFacetConfig();d=new facete.FacetValueService(b.sparqlService,c,5e6)}},f=function(){var a=b.path;return d&&a?void d.prepareTableService(b.path,!0).then(function(d){var e=null,f=10,g=(b.pagination.currentPage-1)*f,h=d.fetchCount(e),i=d.fetchItems(e,f,g);c.when(h).then(function(a){b.pagination.totalItems=a.count}),c.when(i).then(function(c){var d=c.map(function(a){return a.val}),e=b.facetTreeConfig.getFacetConfig().getConstraintManager(),f=e.getConstraintsByPath(a),g={};f.forEach(function(a){"equals"===a.getName()&&(g[a.getValue()]=!0)}),d.forEach(function(a){var b=g[""+a.node];a.tags=a.tags||{},a.tags.isConstrainedEqual=b}),b.facetValues=d})}):(b.totalItems=0,void(b.facetValues=[]))},g=function(){e(),f()};b.ObjectUtils=jassa.util.ObjectUtils;var h='[ObjectUtils.hashCode(facetTreeConfig), "" + path, pagination.currentPage]';b.$watch(h,function(){g()},!0),b.$watch("sparqlService",function(){g()}),b.toggleConstraint=function(a){var c=b.facetTreeConfig.getFacetConfig().getConstraintManager(),d=b.path,e=a.node,f=new jassa.facete.ConstraintEquals(d,e);c.toggleConstraint(f)},b.filterTable=function(a){b.filterText=a,g()}}]).directive("facetValueList",function(){return{restrict:"EA",replace:!0,templateUrl:"template/facet-value-list/facet-value-list.html",transclude:!1,require:"facetValueList",scope:{sparqlService:"=",facetTreeConfig:"=",path:"=",onSelect:"&select"},controller:"FacetValueListCtrl"}}),angular.module("ui.jassa.jassa-list",[]).controller("JassaListCtrl",["$scope","$q","$timeout",function(a,b,c){var d={listFilter:{concept:null,limit:10,offset:0},currentPage:1,items:[],totalItems:0,maxSize:7,context:{},listClass:"",paginationOptions:{cssClass:"pagination",maxSize:7,rotate:!0,boundaryLinks:!0,firstText:"<<",previousText:"<",nextText:">",lastText:">>"}};_.defaults(a,d),_.defaults(a.listFilter,d.listFilter),_.defaults(a.paginationOptions,d.paginationOptions),a.loading=a.loading||{data:!1,pageCount:!1},a.doRefresh=function(){a.loading.data=!0,a.loading.pageCount=!0;var d=a.listFilter,e=a.listService;angular.isFunction(e)&&(e=e()),null!=e&&b.when(e).then(function(e){b.when(e.fetchCount(d.concept)).then(function(b){c(function(){a.totalItems=b.count,a.loading.pageCount=!1})}),b.when(e.fetchItems(d.concept,d.limit,d.offset)).then(function(b){c(function(){a.items=b.map(function(a){return a.val}),a.loading.data=!1})})})},a.numPages=function(){var b=a.listFilter.limit,c=null==b?1:Math.ceil(a.totalItems/b);return c=Math.max(c,1)},a.$watch("listFilter.offset",function(){a.currentPage=Math.floor(a.listFilter.offset/a.listFilter.limit)+1}),a.$watch("currentPage",function(){a.listFilter.offset=(a.currentPage-1)*a.listFilter.limit}),a.$watch(function(){return a.rawListService},function(b){jassa.util.PromiseUtils.replaceService(a,"listService",b)}),a.$watch("[listFilter, refresh]",a.doRefresh,!0),a.$watch("listService",a.doRefresh)}]).directive("jassaList",[function(){return{restrict:"EA",templateUrl:"template/jassa-list/jassa-list.html",transclude:!0,scope:{rawListService:"=listService",listFilter:"=?",listClass:"=?",paginationOptions:"=?",totalItems:"=?",items:"=?",loading:"=?",refresh:"=?",context:"=?"},controller:"JassaListCtrl",link:function(a,b,c,d,e){e(a,function(a,c){var d=b.find("ng-transclude"),e=d.parent();d.remove(),e.append(a)})}}}]),angular.module("ui.jassa.jassa-list-browser",[]).controller("JassaListBrowserCtrl",["$scope",function(a){a.context=a.context||{}}]).directive("jassaListBrowser",function(){return{restrict:"EA",replace:!0,scope:{listService:"=",filter:"=",limit:"=",offset:"=",totalItems:"=",items:"=",maxSize:"=",langs:"=",availableLangs:"=",doFilter:"=",searchModes:"=",activeSearchMode:"=",itemTemplate:"=",context:"=?"},templateUrl:"template/jassa-list-browser/jassa-list-browser.html",controller:"JassaListBrowserCtrl"}}),angular.module("ui.jassa.jassa-media-list",["ui.jassa.replace"]).controller("JassaMediaListCtrl",["$scope","$q","$timeout",function(a,b,c){a.currentPage=1,a.limit=a.limit||10,a.offset=a.offset||0,a.items=a.items||[],a.maxSize=a.maxSize||6,a.doRefresh=function(){b.when(a.listService.fetchCount(a.filter)).then(function(b){c(function(){a.totalItems=b.count})}),b.when(a.listService.fetchItems(a.filter,a.limit,a.offset)).then(function(b){c(function(){a.items=b.map(function(a){return a.val})})})},a.$watch("offset",function(){a.currentPage=Math.floor(a.offset/a.limit)+1}),a.$watch("currentPage",function(){a.offset=(a.currentPage-1)*a.limit}),a.$watch("[filter, limit, offset, refresh]",a.doRefresh,!0),a.$watch("listService",a.doRefresh)}]).directive("jassaMediaList",[function(){return{restrict:"EA",templateUrl:"template/jassa-media-list/jassa-media-list.html",replace:!0,scope:{listService:"=",filter:"=?",limit:"=?",offset:"=?",totalItems:"=?",itemTemplate:"=",items:"=?",maxSize:"=?",refresh:"=?",context:"=?"},controller:"JassaMediaListCtrl",link:function(a,b,c,d,e){}}}]),angular.module("ui.jassa.lang-select",["ui.sortable","ngSanitize"]).controller("LangSelectCtrl",["$scope",function(a){a.newLang="",a.showLangInput=!1;var b=!1;a.sortConfig={placeholder:"lang-sortable-placeholder",receive:function(a,c){b=!1},over:function(a,c){b=!1},out:function(a,c){b=!0},beforeStop:function(c,d){if(b===!0){var e=d.item.context.textContent;if(e){e=e.trim();var f=a.langs.indexOf(e);a.langs.splice(f,1),d.item.remove()}}},stop:function(){a.$$phase||a.$apply()}},a.getLangSuggestions=function(){var b,c=a.availableLangs;return b=c?Array.isArray(c)?c:c instanceof Function?c():[]:[]},a.confirmAddLang=function(b){var c=a.langs.indexOf(b);0>c&&a.langs.push(b),a.showLangInput=!1,a.newLang=""}}]).directive("langSelect",function(){return{restrict:"EA",replace:!0,templateUrl:"template/lang-select/lang-select.html",scope:{langs:"=",availableLangs:"="},controller:"LangSelectCtrl"}}),angular.module("ui.jassa.list-search",[]).controller("ListSearchCtrl",["$scope",function(a){a.setActiveSearchMode=function(b){a.activeSearchMode=b}}]).directive("listSearch",function(){return{restrict:"EA",scope:{searchModes:"=",activeSearchMode:"=",ngModel:"=",onSubmit:"&submit"},controller:"ListSearchCtrl",templateUrl:"template/list-search/list-search.html"}}),angular.module("ui.jassa.paging-model",[]).directive("pagingModel",["$compile",function(a){return{priority:1050,restrict:"A",terminal:!0,scope:!1,compile:function(b,c){return{pre:function(b,c,d,e){var f=function(a,b){var d=c.attr(a);null==d&&c.attr(a,b)},g=d.pagingModel;if(null==g)throw new Error("Object needed as argument for paging-model");c.removeAttr("paging-model"),f("total-items",g+".state.paging.totalItems"),f("items-per-page",g+".state.filter.limit"),f("ng-model",g+".ctrl.paging.currentPage"),f("page",g+".ctrl.paging.currentPage"),a(c)(b)}}}}}]);var ListServiceWatcher=Jassa.ext.Class.create({initialize:function(a,b){this.$scope=a,this.$q=b},watch:function(a,b,c){var d=this.$scope,e=this.$q,f=function(a,b){var c;try{c=a()}catch(d){c=b||null}return c};c=c||{};var g=ListServiceWatcher.getDefaults();_.defaults(c,g),_.defaults(c.state,g.state),_.defaults(c.state.listService,g.state.listService),_.defaults(c.state.filter,g.state.filter),_.defaults(c.state.paging,g.state.paging),_.defaults(c.loading,g.loading),_.defaults(c.ctrl,g.ctrl),_.defaults(c.ctrl.listService,g.ctrl.listService),_.defaults(c.ctrl.filter,g.ctrl.filter),_.defaults(c.ctrl.paging,g.ctrl.paging),_.defaults(c.paginationOptions,g.paginationOptions);var h=function(){var a=f(function(){return c.state.filter.limit}),b=f(function(){return c.state.paging.totalItems},0),d=null==a?1:Math.ceil(b/a);return d=Math.max(d,1)};c.doRefresh=function(){var a=c.doRefreshCount(),b=c.doRefreshData(),d=jassa.util.PromiseUtils.all([a,b]);return d},c.doRefreshData=function(){c.loading.data=!0;var a,b=c.ctrl.filter,d=c.state.listService;return a=null!=d?Promise.resolve(d).then(function(a){e.when(a.fetchItems(b.concept,b.limit,b.offset)).then(function(a){c.state.entries=a,c.state.items=a.map(function(a){return a.val}),c.loading.data=!1,c.state.filter.limit=c.ctrl.filter.limit,c.state.filter.offset=c.ctrl.filter.offset})},function(){c.loading.data=!1}):Promise.resolve({})},c.doRefreshCount=function(){var a,b=c.ctrl.filter,d=c.state.listService;return null!=d?(c.loading.pageCount=!0,a=Promise.resolve(d).then(function(a){e.when(a.fetchCount(b.concept)).then(function(a){c.state.paging.totalItems=a.count,c.state.paging.numPages=h(),c.loading.pageCount=!1},function(){c.loading.pageCount=!1})})):a=Promise.resolve({}),a},c.unwatch=function(){c.watchers.forEach(function(a){a()}),jassa.util.ArrayUtils.clear(c.watchers)},c.cancelAll=function(){var a=c.state.listService;a&&a.cancelAll()},c.watchers=c.watchers||[];var i=function(){var a=d.$watch.apply(d,arguments);return c.watchers.push(a),a},j=function(){var a=d.$watchCollection.apply(d,arguments);return c.watchers.push(a),a};i(a,function(a){c.ctrl.listService=a}),i(function(){return c.ctrl.listService},function(a){c.cancelAll&&c.cancelAll(),jassa.util.PromiseUtils.replaceService(c.state,"listService",a)}),i(function(){return c.ctrl.paging.currentPage},function(a){var b=c.ctrl.filter.limit;c.ctrl.filter.offset=(a-1)*b}),i(function(){return c.ctrl.filter.offset},function(a){var b=c.ctrl.filter.limit;c.state.paging.currentPage=Math.max(Math.floor(a/b)+1,1)});var k=[null,null,null,null],l=function(){return k[0]=c.ctrl.listService,k[1]=c.ctrl.filter.concept,k[2]=c.ctrl.filter.limit,k[3]=c.ctrl.filter.offset,k};return j(l,function(a,b){a[0]!=b[1]||a[1]!=b[1]?c.doRefresh():c.doRefreshData()}),c}});ListServiceWatcher.getDefaults=function(){var a={state:{items:[],entries:[],filter:{concept:null,limit:10,offset:0},listService:null,paging:{currentPage:1,numPages:1,totalItems:0}},loading:{data:!1,pageCount:!1},ctrl:{listService:null,filter:{concept:null,limit:10,offset:0},paging:{currentPage:1}},watchers:[]};return a},angular.module("ui.jassa.paging-style",[]).directive("pagingStyle",["$compile","$parse",function(a,b){return{priority:1050,restrict:"A",terminal:!0,scope:!1,compile:function(c,d){return{pre:function(c,d,e,f){var g=function(){return{maxSize:6,rotate:!0,boundaryLinks:!0,directionLinks:!0,firstText:"<<",previousText:"<",nextText:">",lastText:">>"}},h=function(a,b,c){var e=d.attr(a);if(null==e){var f=c?"{{"+b+"}}":b;d.attr(a,f)}},i=e.pagingStyle;null==i&&(i="pagingStyle",c.pagingStyle={}),d.removeAttr("paging-style"),h("max-size",i+".maxSize",!0),h("rotate",i+".rotate",!0),h("boundary-links",i+".boundaryLinks",!0),h("first-text",i+".firstText",!0),h("previous-text",i+".previousText",!0),h("next-text",i+".nextText",!0),h("last-text",i+".lastText",!0),h("direction-links",i+".directionLinks",!0);var j=g(),k=e.pagingStyle,l=b(k),m=function(a){a=a||l(c),null!=a&&_.defaults(a,j)};c.$watch(function(){var a=l(c);return a},function(a){m(a)},!0),m(),a(d)(c)}}}}}]),angular.module("ui.jassa.pointer-events-scroll-fix",[]).directive("pointerEventsScrollFix",function(){return{restrict:"A",compile:function(){return{post:function(a,b,c){jQuery.fn.hasScrollBar||(jQuery.fn.hasScrollBar=function(){var a=this.get(0);if(!a)return console.log("Should not happen"),!1;var b=a.scrollHeight>a.clientHeight||a.scrollWidth>a.clientWidth;return b});var d=null;a.$watch(function(){return jQuery(b).hasScrollBar()},function(a){a?d||(d=b.css("pointer-events"),b.css("pointer-events","auto")):d&&(b.css("pointer-events",d),d=null)})}}}}}),angular.module("ui.jassa.replace",[]).directive("replace",function(){return{restrict:"A",link:function(a,b,c){b.replaceWith(b.children())}}}),angular.module("ui.jassa.resizable",[]).directive("resizable",function(){return{restrict:"A",scope:{resizable:"=",onResize:"&onResize",onResizeInit:"&onResizeInit",bounds:"="},compile:function(){return{post:function(a,b,c){a.bounds||(a.bounds={});var d=!1,e=function(a){d&&jQuery(b).resizable("destroy"),jQuery(b).resizable(a),d=!0},f=["top","bottom","width","height"],g=function(a){var c=b.prop("style"),d=_(c).pick(a);return d},h=function(a){_(a).each(function(a,c){b.css(c,a)})},i=g(f);angular.copy(i,a.bounds),a.onResizeInit&&a.onResizeInit({bounds:i});var j=function(a,b){h(a)};a.$watch("bounds",j,!0),jQuery(b).on("resizestop",function(b,c){var d=g(f);angular.copy(d,a.bounds),a.onResize&&a.onResize(b,c,d),a.$$phase||a.$apply()}),a.$watch("resizable",e)}}}}}),angular.module("ui.jassa.scroll-glue-right",[]).directive("scrollGlueRight",["$parse","$timeout",function(a,b){function c(a){var b=a;return{getValue:function(){return b},setValue:function(a){b=a}}}function d(a,b){return{getValue:function(){return a(b)},setValue:function(){}}}function e(a,b,c){return{getValue:function(){return a(c)},setValue:function(d){d!==a(c)&&c.$apply(function(){b(c,d)})}}}function f(b,f){if(""!==b){var g=a(b);return void 0!==g.assign?e(g,g.assign,f):d(g,f)}return c(!0)}return{priority:1,restrict:"A",link:function(a,b,c){function d(){i.scrollLeft=i.scrollWidth}function e(a){j.getValue()&&!g()&&d()}function g(){var a=i.scrollLeft+i.clientWidth+1>=i.scrollWidth;return a}function h(){j.setValue(g())}var i=b[0],j=f(c.scrollGlueRight,a);a.$watch(function(){return i.clientWidth},function(a){e()}),a.$watch(e),b.bind("scroll",h)}}}]),angular.module("ui.jassa.sparql-grid",[]).controller("SparqlGridCtrl",["$scope","$rootScope","$q",function(a,b,c){var d=(jassa.rdf,jassa.sparql,jassa.service),e=jassa.util,f=(jassa.sponate,jassas.facete),g=function(a,b){for(var c=[],d=0;d<a.fields.length;++d){var g=a.fields[d],h=a.directions[d],i=0;if("asc"===h?i=1:"desc"===h&&(i=-1),0!==i){var j=new f.SortCondition(g,i);c.push(j)}}var k=b.getSortConditions(),l=_(c).isEqual(k);l||e.ArrayUtils.replace(k,c)},h=function(){var b=a.config,c=a.sparqlService,e=b?b.queryFactory:null,f=e?e.createQuery():null,g=new d.SparqlTableService(c,f);return g};a.$watch("gridOptions.sortInfo",function(b){var c=a.config,d=c?c.tableMod:null;null!=d&&g(b,d),a.refreshData()},!0),a.$watch("[pagingOptions, filterOptions]",function(b,c){a.refreshData()},!0);var i=function(){a.refresh()};a.ObjectUtils=e.ObjectUtils,a.$watch("[ObjectUtils.hashCode(config), disableRequests]",function(a,b){i()},!0),a.$watch("sparqlService",function(){i()}),a.totalServerItems=0,a.pagingOptions={pageSizes:[10,50,100],pageSize:10,currentPage:1},a.refresh=function(){var b=h();return a.disableRequests?void e.ArrayUtils.clear(a.myData):(a.refreshSchema(b),a.refreshPageCount(b),void a.refreshData(b))},a.refreshSchema=function(b){b=b||h();var c=a.colDefs,d=b.getSchema(),e=_(d).isEqual(c);e||(a.colDefs=d)},a.refreshPageCount=function(b){b=b||h();var d=b.fetchCount();jassa.sponate.angular.bridgePromise(d,c.defer(),a,function(b){a.totalServerItems=b.count})},a.refreshData=function(b){b=b||h();var d=a.pagingOptions.currentPage,e=a.pagingOptions.pageSize,f=(d-1)*e,g=b.fetchData(e,f);jassa.sponate.angular.bridgePromise(g,c.defer(),a,function(b){var c=_(b).isEqual(a.myData);c||(a.myData=b)})};var j=[];if(ngGridFlexibleHeightPlugin){
var k=ngGridFlexibleHeightPlugin;j.push(new k(30))}a.myData=[],a.gridOptions={data:"myData",enablePaging:!0,useExternalSorting:!0,showFooter:!0,totalServerItems:"totalServerItems",enableHighlighting:!0,sortInfo:{fields:[],directions:[],columns:[]},pagingOptions:a.pagingOptions,filterOptions:a.filterOptions,plugins:j,columnDefs:"colDefs"}}]).directive("sparqlGrid",["$parse",function(a){return{restrict:"EA",replace:!0,templateUrl:"template/sparql-grid/sparql-grid.html",controller:"SparqlGridCtrl",scope:{sparqlService:"=",config:"=",disableRequests:"=",onSelect:"&select",onUnselect:"&unselect"},link:function(a,b,c){}}}]),angular.module("ui.jassa.template-list",[]).controller("TemplateListCtrl",["$scope",function(a){}]).directive("templateList",["$compile",function(a){return{restrict:"EA",replace:!0,templateUrl:"template/template-list/template-list.html",transclude:!0,scope:{templates:"=",data:"=",context:"="},controller:"TemplateListCtrl",compile:function(){return{pre:function(b,c,d){angular.forEach(b.templates,function(d){var e=a('<li style="display: inline;"></li>')(b),f=a(d)(b);e.append(f),c.append(e)})}}}}}]);