diff --git a/bower.json b/bower.json index 5b838bfb..b33d9f7a 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "cilantro", - "version": "2.3.2-beta", + "version": "2.3.2", "license": "BSD", "description": "Client library for Serrano-compatible APIs", "keywords": [ diff --git a/cdn/js/cilantro.js b/cdn/js/cilantro.js index 00e30457..1274475e 100644 --- a/cdn/js/cilantro.js +++ b/cdn/js/cilantro.js @@ -1,8 +1,8 @@ -define("cilantro/utils/numbers",[],function(){var e=[[3,"K"],[6,"million"],[9,"billion"],[12,"trillion"],[15,"quadrillion"],[18,"quintillion"],[21,"sextillion"],[24,"septillion"],[27,"octillion"],[30,"nonillion"],[33,"decillion"],[100,"googol"]],t=function(e){return!(void 0===e||null===e||""===e)},i=function(i,o){if(t(i)){if(1e3>i&&(null===o||void 0===o))return n(i);if(o>=i)return i;for(var s,r,a,l,c=0;ci)return l=Math.round(i/a*10)/10,""+l+" "+r}},n=function(e,i){if(t(e)){void 0===i&&(i=",");for(var n=e.toString().split("."),o=n[0],s=n[1],r=o.toString().split(""),a=r.length,l=a%3||3;a>l;)r.splice(l,0,i),l+=4;var c=r.join("");return s&&(c+="."+s),c}},o=function(e,n){if(t(e)){if(0!==e){if(Math.abs(e)<.01)return e.toExponential(2);Math.round(e)!==e&&(e=e.toPrecision(3))}return i(e,n)}};return{toSuffixedNumber:i,toDelimitedNumber:n,prettyNumber:o}}),define("cilantro/utils/url",["jquery"],function(e){var t=function(e){var t=document.createElement("a");return t.href=e,t},i=function(i,n){if(!n)return i;for(var o=t(i),s={},r=o.search.substr(1).split("&"),a=0;ao;o++)n[o]=n[o]||0;var s;if(!e.test(s=n.join(".")))throw new Error("Bad version string: "+t);return s},i=function(e){var i=t(e).split(".");return{major:parseInt(i[0],10),minor:parseInt(i[1],10),micro:parseInt(i[2],10)}},n=function(e,t){switch(e=i(e),t=i(t),!0){case e.major>t.major:return 1;case e.majort.minor:return 1;case e.minort.micro:return 1;case e.micro-1},a=function(e,t){return-1===n(e,t)},l=function(e,t){return n(e,t)<1},c=function(e,t,i){return r(e,t)&&l(e,i)};return{cleanVersionString:t,parseVersionString:i,compareVersions:n,versionIsEqual:o,versionIsGt:s,versionIsGte:r,versionIsLt:a,versionIsLte:l,versionInRange:c}}),define("cilantro/utils",["jquery","./utils/numbers","./utils/url","./utils/version"],function(e){var t=Array.prototype.slice.call(arguments,1),i=function(e,t){document.cookie=e+"="+window.escape(t)+"; path=/"},n=function(e){for(var t=e+"=",i=document.cookie.split(";"),n=0;n-1&&s.splice(e,1),[].unshift.call(arguments,"abort"),n.rejectWith(n,arguments)},s.push(l)}else t(i,n,a);return n}var o=e.ajax,s=[],r=!1;e.ajax=function(e,t){return"string"==typeof e&&(t.url=e,e=t),n(e)},e.hasPendingRequest=function(){return r}}),define("cilantro/core",["underscore","backbone","./config","./channels","./utils","plugins/js","plugins/jquery-ajax-queue",void 0===JSON?"json2":null],function(e,t,i,n,o){var s={version:"2.3.1",minSerranoVersion:"2.0.16",maxSerranoVersion:"2.3.6",getSerranoVersion:function(){return this.session?this.utils.cleanVersionString(this.session.version):void 0},isSupported:function(e){var t=this.minSerranoVersion,i=this.maxSerranoVersion,n=this.getSerranoVersion();return o.versionIsLt(n,i)&&(i=n),o.versionInRange(e,t,i)},config:new i.Config(this.cilantro),utils:o};return e.extend(s,t.Events,n),s}),define("cilantro/models/base",["underscore","backbone"],function(e,t){var i=t.Model.extend({constructor:function(i,n){n=e.defaults({parse:!0},n),this.links={},t.Model.prototype.constructor.call(this,i,n),this.on("change:_links",this._parseLinks)},url:function(){return this.isNew()?t.Model.prototype.url.call(this):this.links.self},_parseLinks:function(t,i){var n={};e.each(i,function(e,t){n[t]=e.href}),t.links=n},parse:function(e){return e&&e._links&&this._parseLinks(this,e._links),e}}),n=t.Collection.extend({model:i}),o=n.extend({initialize:function(){this.session=this.add({session:!0})},reset:function(e,i){i=i||{},e=e||[];for(var o,s,r=0;r=0&&n>=0?i-n:0>i&&0>n?e.key>t.key:i>=0?-1:1}),n}});return{StatModel:t,StatCollection:i}}),define("cilantro/models/field",["underscore","backbone","../core","./base","./stats"],function(e,t,i,n,o){var s=function(e){var t=i.config.get("fields.instances."+e.id+".type");return t?t:e.type?e.type:(t=e.simple_type,e.enumerable||"boolean"===t?"choice":t)},r=n.Model.extend({constructor:function(){n.Model.prototype.constructor.apply(this,arguments);var e=this;this.links.stats&&(this.stats=new o.StatCollection,this.stats.url=function(){return e.links.stats})},parse:function(){this._cache={};var e=n.Model.prototype.parse.apply(this,arguments);return e.type=s(e),e},distribution:function(e,i){if(i!==!1&&(i=!0),void 0===this.links.distribution)return void e();if(i&&void 0!==this._cache.distribution)e(this._cache.distribution);else{var n=this;t.ajax({url:this.links.distribution,dataType:"json",success:function(t){return i&&(n._cache.distribution=t),e(t)}})}},values:function(e,i,n){if(n!==!1&&(n=!0),"function"==typeof e?(i=e,n=i,e={}):e&&(n=!1,"string"==typeof e&&(e={query:e})),!this.links.values)return void i();var o=t.$.Deferred();if(i&&o.done(i),n&&void 0!==this._cache.values)o.resolve(this._cache.values);else{var s=this;t.ajax({url:this.links.values,data:e,dataType:"json",success:function(e){n&&(s._cache.values=e),o.resolve(e)},error:function(){o.reject()}})}return o.promise()}}),a=n.Collection.extend({model:r,search:function(i,n){t.ajax({url:e.result(this,"url"),data:{query:i},dataType:"json",success:function(e){n(e)}})}});return{FieldModel:r,FieldCollection:a}}),define("cilantro/models/concept",["underscore","backbone","../core","./base","./field"],function(e,t,i,n,o){var s=n.Model.extend({constructor:function(){this.fields=new o.FieldCollection,n.Model.prototype.constructor.apply(this,arguments)},initialize:function(){n.Model.prototype.initialize.call(this,arguments),i.on(i.CONCEPT_FOCUS,function(e){this.id===e&&0===this.fields.length&&this.fields.fetch({reset:!0})},this)},parse:function(e,t){n.Model.prototype.parse.call(this,e,t);var i=this;return this.fields.url=function(){return i.links.fields},e?(e.fields&&(this.fields.set(e.fields,t),delete e.fields),e):void 0}}),r=n.Collection.extend({model:s,search:function(i,n){return t.ajax({url:e.result(this,"url"),data:{query:i,brief:1},dataType:"json",success:function(e){n(e)}})}}),a=r.extend({constructor:function(){this.queryable=new r,this.viewable=new r;var t=this;this.queryable.url=function(){return e.result(t,"url")},this.viewable.url=function(){return e.result(t,"url")},r.prototype.constructor.apply(this,arguments)},initialize:function(){this.on("add remove reset",function(){this.queryable.reset(this.filter(function(e){return!!e.get("queryable")||!!e.get("queryview")})),this.viewable.reset(this.filter(function(e){return!!e.get("viewable")||!!e.get("formatter_name")}))})}});return{Concept:s,Concepts:a}}),define("cilantro/models/filters",["jquery","underscore","backbone"],function(e,t,i){var n=function(e){var t="";if(e.concept&&(t+="c"+e.concept),e.field&&(t+="f"+e.field),!t)throw new Error("Cannot generate id for filter");return t},o=i.Model.extend({constructor:function(e,t){e&&!e.id&&(e[this.idAttribute]=n(e)),i.Model.prototype.constructor.call(this,e,t)},generateId:function(e){return n(e)},clear:function(e){var i=t.clone(this.attributes);delete i.id,delete i.field,delete i.concept,t.each(i,function(e,t){i[t]=void 0}),this.set(i,t.defaults({unset:!0},e))},sync:function(){},apply:function(e){this.trigger("apply",this,e)},unapply:function(e){this.trigger("unapply",this,e)},toJSON:function(i){i=t.defaults(i||{},{id:!1});var n=e.extend(!0,{},this.attributes);return i.id||delete n[this.idAttribute],n},isEnabled:function(){return this.get("enabled")!==!1},toggleEnabled:function(){this.set("enabled",!this.isEnabled())}}),s=i.Collection.extend({model:o,constructor:function(e,n){n=t.defaults({parse:!0},n),i.Collection.prototype.constructor.call(this,e,n)},sync:function(){},apply:function(e){this.trigger("apply",this,e)},unapply:function(e){this.trigger("unapply",this,e)},parse:function(e){if(t.isArray(e))t.each(e,function(e){e.id||(e.id=this.model.prototype.generateId(e))});else{var i=e||{};if(e=[],i.field){var n=this.model.prototype.generateId(i);e.push(t.extend({id:n},i))}else if(i.children){var o=i.concept;t.each(i.children,function(i){void 0!==o&&(i=t.extend({concept:o},i)),e=e.concat(this.parse(i))},this)}}return e}});return{Filter:o,Filters:s}}),define("cilantro/models/context",["underscore","backbone","loglevel","../core","./base","./filters"],function(e,t,i,n,o,s){var r=function(){var t=[];e.each(n.config.get("filters.required"),function(e){t.push(e)});var o=n.config.get("query.concepts.required");return o&&(i.warn('The "query.concepts.required" option is deprecated, use "filters.required" instead with fully qualified lookups.'),e.each(o,function(e){t.push({concept:e})})),t},a=o.Model.extend({options:{saveDelay:300},initialize:function(t,i){t=t||{},this.requiredFilters=r(),this._filters=new s.Filters(t.json,e.defaults({parse:!0},i)),this.filters=new s.Filters(t.json,e.defaults({parse:!0},i)),this.listenTo(this._filters,{apply:this.apply,unapply:this.unapply}),this.listenTo(this.filters,{unapply:this.unapply,"change:enabled":function(){this._save()}}),this.on("change:json",function(t,i,n){this.filters.set(i,e.defaults({parse:!0},n)),n.reset&&this._filters.set(i,e.defaults({parse:!0,remove:!1},n)),this.filters.each(function(e){this.isFilterRequired(e.attributes)?e.set("required",!0):e.unset("required")},this)}),this.on("sync",function(e,t,i){i=i||{},this.validate(),i.silent!==!0&&n.trigger(n.CONTEXT_SYNCED,this,"success")}),this._save=e.debounce(this.save,this.options.saveDelay)},validate:function(){var t=[];return e.each(this.requiredFilters,function(i){var n,o=this.filters.findWhere(i);o?o.isEnabled()||(n="disabled"):n="undefined",n&&t.push(e.extend({reason:n},i))},this),t.length?(n.trigger(n.CONTEXT_INVALID,t),"One or more filters are invalid"):void 0},isFilterRequired:function(t){return e.any(this.requiredFilters,function(i){return e.isEqual(e.pick(t,e.keys(i)),i)})},_apply:function(e,t){var i=e.toJSON({id:!0});i.required=this.isFilterRequired(i);var n=this.filters.get(i.id);n?(n.clear({silent:!0}),n.set(i)):n=this.filters.add(i,t),n.set("enabled",!0,{silent:!0});var o=this._filters.get(n);o.trigger("applied",o,t),n.stopListening(this),n.listenToOnce(this,"request",function(e,t,i){this.trigger("request",this,t,i)}),n.listenToOnce(this,"sync",function(e,t,i){this.trigger("sync",this,this.toJSON(),i)})},apply:function(i,n){i instanceof t.Collection?i=i.slice():e.isArray(i)||(i=[i]),e.each(i,function(e){this._apply(e,n)},this),n&&n.save===!1||this._save()},_unapply:function(e,t){var n=e.toJSON({id:!0});if(this.isFilterRequired(n))return void i.debug("skipping unapplying required filter",n);var o=this.filters.remove(n,t);if(o){var s=this._filters.get(o);s.trigger("unapplied",s,t),o.stopListening(this)}},unapply:function(i,n){i instanceof t.Collection?i=i.slice():e.isArray(i)||(i=[i]),e.each(i,function(e){this._unapply(e,n)},this),n&&n.save===!1||this._save()},define:function(e){var t=this._filters.model.prototype.generateId(e),i=this._filters.get(t);return i||(i=this._filters.create(e)),i},toJSON:function(){var e=o.Model.prototype.toJSON.call(this),t=this.filters.toJSON();return e.json=t.length?{type:"and",children:t}:null,e},isSession:function(){return this.get("session")},isArchived:function(){return this.get("archived")},isFilterApplied:function(e){return void 0!==this.filters.get(e)},hasFilterChanged:function(t,i){var n=this.filters.get(t);if(n)return i||(i=e.keys(t.attributes)),e.any(i,function(i){return!e.isEqual(t.get(i),n.get(i))})}}),l=o.SessionCollection.extend({model:a});return{Context:a,ContextCollection:l}}),define("cilantro/models/view",["underscore","backbone","../core","./base"],function(e,t,i,n){var o=t.Model.extend({idAttribute:"concept"}),s=t.Collection.extend({model:o}),r=n.Model.extend({constructor:function(){this.facets=new s,this.on("change:json",function(e,t){return this.jsonToFacets(t)}),n.Model.prototype.constructor.apply(this,arguments)},initialize:function(){var e=this;return this.on("request",function(){return i.trigger(i.VIEW_SYNCING,this)}),this.on("sync",function(e,t,n){return n||(n={}),n.silent!==!0?i.trigger(i.VIEW_SYNCED,this,"success"):void 0}),this.on("error",function(){return i.trigger(i.VIEW_SYNCED,this,"error")}),this.on("change",function(){return i.trigger(i.VIEW_CHANGED,this)}),i.on(i.VIEW_SAVE,function(t){return e.id===t||!t&&e.isSession()?e.save():void 0})},isSession:function(){return this.get("session")},isArchived:function(){return this.get("archived")},toJSON:function(){var e=n.Model.prototype.toJSON.apply(this,arguments);return e.json=this.facetsToJSON(),e},parse:function(e){return n.Model.prototype.parse.apply(this,arguments),this.jsonToFacets(e.json),e},jsonToFacets:function(t){if(t||(t={}),e.isArray(t))return void this.facets.reset(t);for(var i,n,o,s=[],r=t.columns||[],a=t.ordering||[],l=0;l=1&&e<=this.numPages},hasNextPage:function(e){return e||(e=this.currentPageNum),e1},setCurrentPage:function(e){if(e!==this.currentPageNum){if(!this.hasPage(e))throw new Error("Cannot set the current page out of bounds");return this.previousPageNum=this.currentPageNum,this.currentPageNum=e,this.trigger.apply(this,["change:currentpage",this].concat([].slice.call(this.getCurrentPageStats())))}},getPage:function(e,t){if(t||(t={}),this.hasPage(e)){var i=this.get(e);return i||t.load===!1||(i=new this.model({page_num:e}),i.pending=!0,this.add(i),i.fetch().done(function(){delete i.pending})),i&&t.active!==!1&&this.setCurrentPage(e),i}},getCurrentPage:function(e){return this.getPage(this.currentPageNum,e)},getFirstPage:function(e){return this.getPage(1,e)},getLastPage:function(e){return this.getPage(this.numPages,e)},getNextPage:function(e,t){return e||(e=this.currentPageNum),this.getPage(e+1,t)},getPreviousPage:function(e,t){return e||(e=this.currentPageNum),this.getPage(e-1,t)},pageIsLoading:function(e){e||(e=this.currentPageNum);var t=this.getPage(e,{active:!1,load:!1});return t?!!t.pending:void 0},getPageCount:function(){return this.numPages},getCurrentPageStats:function(){return[this.currentPageNum,{previous:this.previousPageNum,first:1===this.currentPageNum,last:this.currentPageNum===this.numPages}]}},o=t.Model.extend({idAttribute:"page_num",url:function(){var t=e.result(this.collection,"url");return i.utils.alterUrlParams(t,{page:this.id,per_page:this.collection.perPage})}}),s=t.Collection.extend({model:o});return e.extend(s.prototype,n),{PaginatorMixin:n,Page:o,Paginator:s}}),define("cilantro/constants",{INPUT_DELAY:400,CLICK_DELAY:300,REQUEST_DELAY:250}),define("cilantro/structs",["underscore","backbone","./models/base"],function(e,t,i){var n=t.Model.extend({defaults:{visible:!0},show:function(){this.set({visible:!0})},hide:function(){this.set({visible:!1})}}),o=t.Collection.extend({model:n}),s=t.Model.extend({constructor:function(e,i,o){i instanceof n||(i=new n(i)),this.index=i,t.Model.prototype.constructor.call(this,e,o)},size:function(){return 1},width:function(){return 1}}),r=t.Collection.extend({constructor:function(i,n,o){this.indexes=n;var r=this;this.model=function(t,i){var n=r.indexes.at(e.keys(r._byId).length);s.prototype.constructor.call(this,{value:t},n,i)},this.model.prototype=s.prototype,t.Collection.prototype.constructor.call(this,i,o)}}),a=t.Model.extend({constructor:function(i,n,s){var a;s||(s={}),n instanceof o||(n=new o(n)),this.indexes=n,e.isArray(i)?(a=i,i=null):s.parse=!0,this.data=new r(a,n),t.Model.prototype.constructor.call(this,i,s)},parse:function(e,t){return this.data.reset(e.values,t),delete e.values,e},isColumn:function(){return 1===this.width()},isRow:function(){return!this.isColumn()},size:function(){return this.isColumn()?this.data.length:1},width:function(){return this.indexes.length}}),l=t.Collection.extend({constructor:function(e,i,n){this.indexes=i,t.Collection.prototype.constructor.call(this,e,n);var o=this;this.model=function(e,t){a.prototype.constructor.call(this,e,o.indexes,t)},this.model.prototype=a.prototype}}),c=i.Model.extend({constructor:function(t,n,s){var r;s||(s={}),n instanceof o||(n=new o(n)),this.indexes=n,e.isArray(t)?(r=t,t=null):s.parse=!0,this.series=new l(r,n),i.Model.prototype.constructor.call(this,t,s)},parse:function(e,t){return i.Model.prototype.parse.call(this,e,t),this.indexes.reset(e.keys,t),this.series.reset(e.objects,t),delete e.keys,delete e.objects,e},size:function(){return this.series.length},width:function(){return this.indexes.length},column:function(e){var t=this.series.map(function(t){return t.data.at(e)});return new a(t,this.indexes.at(e))}}),u=i.Collection.extend({model:c,constructor:function(e,t){this.indexes=new o,this.on("reset",function(e){var t=e.models[0];return t?this.indexes.reset(t.indexes.models):void 0}),this.on("add",function(e,t){return 1===t.length?this.indexes.reset(e.indexes.models):void 0}),i.Collection.prototype.constructor.call(this,e,t)}});return{Datum:s,Frame:c,FrameArray:u,Index:n,Indexes:o,Series:a}}),define("cilantro/models/results",["underscore","../core","../constants","../structs","./paginator"],function(e,t,i,n,o){var s=n.Frame.extend({idAttribute:"page_num",url:function(){var i=e.result(this.collection,"url");return t.utils.alterUrlParams(i,{page:this.id,per_page:this.collection.perPage})}}),r=n.FrameArray.extend({initialize:function(){e.bindAll(this,"fetch","markAsDirty","onWorkspaceUnload","onWorkspaceLoad","refresh"),this.isDirty=!0,this.isWorkspaceOpen=!1,this._refresh=e.debounce(this.refresh,i.CLICK_DELAY),t.on(t.VIEW_SYNCED,this.markAsDirty),t.on(t.CONTEXT_SYNCED,this.markAsDirty),this.on("workspace:load",this.onWorkspaceLoad),this.on("workspace:unload",this.onWorkspaceUnload)},onWorkspaceLoad:function(){this.isWorkspaceOpen=!0,this._refresh()},onWorkspaceUnload:function(){this.isWorkspaceOpen=!1},markAsDirty:function(){this.isDirty=!0,this._refresh()},fetch:function(e){e||(e={});var i;if((i=t.config.get("session.defaults.data.preview"))&&(e.type="POST",e.contentType="application/json",e.data=JSON.stringify(i)),this.isDirty&&this.isWorkspaceOpen)return this.isDirty=!1,void 0===e.cache&&(e.cache=!1),n.FrameArray.prototype.fetch.call(this,e);var o=this;return{done:function(){return delete o.pending}}}});return e.extend(r.prototype,o.PaginatorMixin),r.prototype.getPage=function(e,i){if(i||(i={}),this.hasPage(e)){var n=this.get(e);if(!n&&i.load!==!1){n=new this.model({page_num:e}),n.pending=!0,this.add(n);var o,s={};(o=t.config.get("session.defaults.data.preview"))&&(s.type="POST",s.contentType="application/json",s.data=JSON.stringify(o)),n.fetch(s).done(function(){delete n.pending})}return n&&i.active!==!1&&this.setCurrentPage(e),n}},r.prototype.model=s,{Results:r}}),define("cilantro/models/exporter",["underscore","./base"],function(e,t){var i=function(e){if(!e.href)return"Untitled";var t,i=e.href;return t="/"===i.charAt(i.length-1)?i.substr(0,i.length-1).split("/"):i.split("/"),t.length>0?t[t.length-1].toUpperCase():"Untitled "+i},n=t.Model.extend({idAttribute:"type"}),o=t.Collection.extend({model:n,parse:function(t){var n=[];return e.each(t._links,function(t,o){"self"!==o&&(t=e.extend({type:o},t),t.title||(t.title=i(t)),n.push(t))}),n}});return{ExporterModel:n,ExporterCollection:o}}),define("cilantro/models/query",["./base","../core","./context","./view"],function(e,t,i,n){var o=e.Model.extend({constructor:function(t,o){t=t||{},this.context=new i.Context({json:t.context_json}),this.view=new n.ViewModel({json:t.view_json}),e.Model.prototype.constructor.call(this,t,o)},parse:function(t,i){return t&&(t&&!t.shared_users&&(t.shared_users=[]),this.context.set({json:t.context_json}),this.view.set({json:t.view_json})),e.Model.prototype.parse.call(this,t,i)}}),s=e.Collection.extend({model:o});return{Query:o,Queries:s}}),define("cilantro/models/value",["underscore","backbone","../structs","../constants"],function(e,t,i,n){var o=t.Model.extend({idAttribute:"label",defaults:{valid:null,pending:!1},fetch:function(){},toJSON:function(e){return e&&e.flat?this.pluck("value"):this.pick("value","label")},destroy:function(e){this.trigger("destroy",this,this.collection,e)}}),s=t.Collection.extend({model:o,options:{check:!0},initialize:function(t,i){i=e.extend({},this.options,i||{}),i.check&&this.on("add reset",e.debounce(this.check,n.INPUT_DELAY))},fetch:function(){},create:function(e,t){this.add(e,t)},check:function(){var i=this.where({valid:null,pending:!1});if(i.length&&this.url){e.each(i,function(e){e.set("pending",!0)});var n=this;t.ajax({url:this.url(),type:"POST",data:JSON.stringify(i),contentType:"application/json",success:function(e){n.set(e,{add:!1,remove:!1})},complete:function(){e.each(i,function(e){e.set("pending",!1)})}})}}});return{Value:o,Values:s}}),define("cilantro/models",["underscore","./models/base","./models/field","./models/concept","./models/context","./models/filters","./models/view","./models/paginator","./models/results","./models/exporter","./models/query","./models/value"],function(e){var t=[].slice.call(arguments,1);return e.extend.apply(null,[{}].concat(t))}),define("cilantro/router",["backbone","underscore","loglevel"],function(e,t,i){var n=e.Router.extend({options:{main:"body",root:null},initialize:function(e){this.options=t.extend({},t.result(this,"options"),e),this._loaded=[],this._routes={},this._handlers={},this._registered={},t.bindAll(this,"_unloadAll","_loadAll","_unload","_load","_render")},_unloadAll:function(){var e=[].slice.call(arguments);t.each(this._loaded.slice(),function(t){this._unload.apply(this,[this._registered[t],!1].concat(e))},this)},_loadAll:function(e){var i=this._routes[e];if(i){var n=[].slice.call(arguments,1);t.each(i,function(e){this._load.apply(this,[this._registered[e]].concat(n))},this)}},_unload:function(t,i){void 0===i&&(i=!0);var n=this._loaded.indexOf(t.id);if((t.route||i&&n>=0)&&(this._loaded.splice(n,1),t._view)){t._view.$el.hide();var o=[].slice.call(arguments,2);t._view.trigger.apply(t._view,["router:unload",this,e.history.fragment].concat(o))}},_load:function(e){var n=[].slice.call(arguments,1);if(!e._view){if(t.isString(e.view)){var o=this;return void require([e.view],function(t){e._view=new t(e.options),o._render.apply(o,[e].concat(n)),o._loaded.push(e.id)},function(e){i.error(e)})}e._view=e.view}this._render.apply(this,[e].concat(n)),this._loaded.push(e.id)},_render:function(t){var i=[].slice.call(arguments,1),n=t._view;if(!n._rendered&&(n._rendered=!0,t.el!==!1)){var o;o=t.el?e.$(t.el,this.options.main):e.$(this.options.main),o.append(n.el),n.render()}n.$el.show(),n.trigger.apply(n,["router:load",this,e.history.fragment].concat(i))},_register:function(e){if(this._registered[e.id])throw new Error('Route "'+e.id+'" already registered');if(e=t.clone(e),e.route){if(!this._handlers[e.route]){this._routes[e.route]=[];var i=t.bind(function(){var t=[].slice.call(arguments);this._unloadAll.apply(this,t),this._loadAll.apply(this,[e.route].concat(t))},this);this._handlers[e.route]=i,this.route(e.route,e.id,i)}}else this._load(e);e.route&&this._routes[e.route].push(e.id),this._registered[e.id]=e},get:function(e){return this._registered[e]},isNavigable:function(e){var t=this.get(e);return t&&t.navigable!==!1},isCurrent:function(i){if(i===e.history.fragment)return!0;var n=this._routes[e.history.fragment]||[];return t.any(n,function(e){return i===e})},hasRoute:function(e){return this._routes.hasOwnProperty(e)},navigate:function(t,i){return this.isNavigable(t)&&(t=this.get(t).route),e.Router.prototype.navigate.call(this,t,i)},register:function(e){e&&(t.isArray(e)||(e=[e]),t.each(e,function(e){e.view&&this._register(e)},this))},unregister:function(e){if(void 0===e)return void t.each(this._registered,function(e,t){this.unregister(t)},this);var i=this._registered[e];if(!i)throw new Error('No route registered by id "'+e+'"');this._unload(i),delete this._registered[e];var n=this._routes[i.route];n&&n.indexOf(e)>=0&&this._routes[i.route].splice(n.indexOf(e),1)},start:function(i){if(!e.History.started){var n=this.options.root||"/";return"/"!==n.charAt(n.length-1)&&(n+="/"),i=t.extend({root:n,pushState:!0},i),e.history.start(i)}}});return{Router:n}}),define("cilantro/session",["jquery","underscore","backbone","./models","./utils","./router","./core"],function(e,t,i,n,o,s,r){var a={SESSION_OPENING:"session:opening",SESSION_ERROR:"session:error",SESSION_UNAUTHORIZED:"session:unauthorized",SESSION_OPENED:"session:opened",SESSION_CLOSED:"session:closed"},l={concepts:n.Concepts,fields:n.FieldCollection,contexts:n.ContextCollection,views:n.ViewCollection,preview:n.Results,exporter:n.ExporterCollection,queries:n.Queries,public_queries:n.Queries},c=n.Model.extend({idAttribute:"url",options:function(){return r.config.get("session.defaults")},initialize:function(e,i){this.options=t.extend({},t.result(this,"options"),i),this.opened=!1,this.started=!1,this.opening=!1,this.state={},t.bindAll(this,"ping","startPing","stopPing")},validate:function(e){return e&&e.url?void 0:"url is required"},startPing:function(){this.links.ping&&this.options.ping&&!this._ping&&(this.ping(),this._ping=setInterval(this.ping,this.options.ping))},stopPing:function(){clearTimeout(this._ping),delete this._ping},ping:function(){var e=this;i.ajax({type:"GET",url:this.links.ping,dataType:"json",success:function(t){"timeout"===t.status&&(e.stopPing(),e.timeout(t.location))},error:function(t,i,n){e.stopPing(),"FOUND"===n&&this.timeout(t.getResponseHeader("Location"))}})},timeout:function(e){var t;t=e?'Your session timed out. Please refresh the page.':"Your session timed out. Please refresh the page.",r.notify({header:"Session Timeout",message:t,dismissable:!1,timeout:!1,level:"warning"}),setTimeout(function(){e?window.location=location:window.location.reload(!0)},5e3)},parse:function(e){e=e||{},this.title=e.title,this.version=e.version,this.data={};var i;t.each(e._links,function(e,t){(i=l[t])&&(this.data[t]=new i,this.data[t].url=e.href,this.data[t].fetch({reset:!0}))},this),this.router=new s.Router({main:r.config.get("main"),root:r.config.get("root")});var n=this.get("routes");if(n)if("string"==typeof n){var o=this;require([n],function(e){o.router.register(e)})}else"function"==typeof n&&(n=n()),this.router.register(n);return e},open:function(){if(this.opened||this.opening)return this._opening.promise();if(!this.isValid())throw new Error(this.validationError);this.opening=!0,this._opening=e.Deferred();var t={url:this.get("url"),type:"GET",dataType:"json"},i=this.get("credentials");i&&e.extend(t,{type:"POST",contentType:"application/json",data:JSON.stringify(i)});var n=this;return this.fetch(t).always(function(){n.opening=!1 +define("cilantro/utils/numbers",[],function(){var e=[[3,"K"],[6,"million"],[9,"billion"],[12,"trillion"],[15,"quadrillion"],[18,"quintillion"],[21,"sextillion"],[24,"septillion"],[27,"octillion"],[30,"nonillion"],[33,"decillion"],[100,"googol"]],t=function(e){return!(void 0===e||null===e||""===e)},i=function(i,o){if(t(i)){if(1e3>i&&(null===o||void 0===o))return n(i);if(o>=i)return i;for(var s,r,a,l,c=0;ci)return l=Math.round(i/a*10)/10,""+l+" "+r}},n=function(e,i){if(t(e)){void 0===i&&(i=",");for(var n=e.toString().split("."),o=n[0],s=n[1],r=o.toString().split(""),a=r.length,l=a%3||3;a>l;)r.splice(l,0,i),l+=4;var c=r.join("");return s&&(c+="."+s),c}},o=function(e,n){if(t(e)){if(0!==e){if(Math.abs(e)<.01)return e.toExponential(2);Math.round(e)!==e&&(e=e.toPrecision(3))}return i(e,n)}};return{toSuffixedNumber:i,toDelimitedNumber:n,prettyNumber:o}}),define("cilantro/utils/url",["jquery"],function(e){var t=function(e){var t=document.createElement("a");return t.href=e,t},i=function(i,n){if(!n)return i;for(var o=t(i),s={},r=o.search.substr(1).split("&"),a=0;ao;o++)n[o]=n[o]||0;var s;if(!e.test(s=n.join(".")))throw new Error("Bad version string: "+t);return s},i=function(e){var i=t(e).split(".");return{major:parseInt(i[0],10),minor:parseInt(i[1],10),micro:parseInt(i[2],10)}},n=function(e,t){switch(e=i(e),t=i(t),!0){case e.major>t.major:return 1;case e.majort.minor:return 1;case e.minort.micro:return 1;case e.micro-1},a=function(e,t){return-1===n(e,t)},l=function(e,t){return n(e,t)<1},c=function(e,t,i){return r(e,t)&&l(e,i)};return{cleanVersionString:t,parseVersionString:i,compareVersions:n,versionIsEqual:o,versionIsGt:s,versionIsGte:r,versionIsLt:a,versionIsLte:l,versionInRange:c}}),define("cilantro/utils",["jquery","./utils/numbers","./utils/url","./utils/version"],function(e){var t=Array.prototype.slice.call(arguments,1),i=function(e,t){document.cookie=e+"="+window.escape(t)+"; path=/"},n=function(e){for(var t=e+"=",i=document.cookie.split(";"),n=0;n-1&&s.splice(e,1),[].unshift.call(arguments,"abort"),n.rejectWith(n,arguments)},s.push(l)}else t(i,n,a);return n}var o=e.ajax,s=[],r=!1;e.ajax=function(e,t){return"string"==typeof e&&(t.url=e,e=t),n(e)},e.hasPendingRequest=function(){return r}}),define("cilantro/core",["underscore","backbone","./config","./channels","./utils","plugins/js","plugins/jquery-ajax-queue",void 0===JSON?"json2":null],function(e,t,i,n,o){var s={version:"2.3.2",minSerranoVersion:"2.0.16",maxSerranoVersion:"2.3.6",getSerranoVersion:function(){return this.session?this.utils.cleanVersionString(this.session.version):void 0},isSupported:function(e){var t=this.minSerranoVersion,i=this.maxSerranoVersion,n=this.getSerranoVersion();return o.versionIsLt(n,i)&&(i=n),o.versionInRange(e,t,i)},config:new i.Config(this.cilantro),utils:o};return e.extend(s,t.Events,n),s}),define("cilantro/models/base",["underscore","backbone"],function(e,t){var i=t.Model.extend({constructor:function(i,n){n=e.defaults({parse:!0},n),this.links={},t.Model.prototype.constructor.call(this,i,n),this.on("change:_links",this._parseLinks)},url:function(){return this.isNew()?t.Model.prototype.url.call(this):this.links.self},_parseLinks:function(t,i){var n={};e.each(i,function(e,t){n[t]=e.href}),t.links=n},parse:function(e){return e&&e._links&&this._parseLinks(this,e._links),e}}),n=t.Collection.extend({model:i}),o=n.extend({initialize:function(){this.session=this.add({session:!0})},reset:function(e,i){i=i||{},e=e||[];for(var o,s,r=0;r=0&&n>=0?i-n:0>i&&0>n?e.key>t.key:i>=0?-1:1}),n}});return{StatModel:t,StatCollection:i}}),define("cilantro/models/field",["underscore","backbone","../core","./base","./stats"],function(e,t,i,n,o){var s=function(e){var t=i.config.get("fields.instances."+e.id+".type");return t?t:e.type?e.type:(t=e.simple_type,e.enumerable||"boolean"===t?"choice":t)},r=n.Model.extend({constructor:function(){n.Model.prototype.constructor.apply(this,arguments);var e=this;this.links.stats&&(this.stats=new o.StatCollection,this.stats.url=function(){return e.links.stats})},parse:function(){this._cache={};var e=n.Model.prototype.parse.apply(this,arguments);return e.type=s(e),e},distribution:function(e,i){if(i!==!1&&(i=!0),void 0===this.links.distribution)return void e();if(i&&void 0!==this._cache.distribution)e(this._cache.distribution);else{var n=this;t.ajax({url:this.links.distribution,dataType:"json",success:function(t){return i&&(n._cache.distribution=t),e(t)}})}},values:function(e,i,n){if(n!==!1&&(n=!0),"function"==typeof e?(i=e,n=i,e={}):e&&(n=!1,"string"==typeof e&&(e={query:e})),!this.links.values)return void i();var o=t.$.Deferred();if(i&&o.done(i),n&&void 0!==this._cache.values)o.resolve(this._cache.values);else{var s=this;t.ajax({url:this.links.values,data:e,dataType:"json",success:function(e){n&&(s._cache.values=e),o.resolve(e)},error:function(){o.reject()}})}return o.promise()}}),a=n.Collection.extend({model:r,search:function(i,n){t.ajax({url:e.result(this,"url"),data:{query:i},dataType:"json",success:function(e){n(e)}})}});return{FieldModel:r,FieldCollection:a}}),define("cilantro/models/concept",["underscore","backbone","../core","./base","./field"],function(e,t,i,n,o){var s=n.Model.extend({constructor:function(){this.fields=new o.FieldCollection,n.Model.prototype.constructor.apply(this,arguments)},initialize:function(){n.Model.prototype.initialize.call(this,arguments),i.on(i.CONCEPT_FOCUS,function(e){this.id===e&&0===this.fields.length&&this.fields.fetch({reset:!0})},this)},parse:function(e,t){n.Model.prototype.parse.call(this,e,t);var i=this;return this.fields.url=function(){return i.links.fields},e?(e.fields&&(this.fields.set(e.fields,t),delete e.fields),e):void 0}}),r=n.Collection.extend({model:s,search:function(i,n){return t.ajax({url:e.result(this,"url"),data:{query:i,brief:1},dataType:"json",success:function(e){n(e)}})}}),a=r.extend({constructor:function(){this.queryable=new r,this.viewable=new r;var t=this;this.queryable.url=function(){return e.result(t,"url")},this.viewable.url=function(){return e.result(t,"url")},r.prototype.constructor.apply(this,arguments)},initialize:function(){this.on("add remove reset",function(){this.queryable.reset(this.filter(function(e){return!!e.get("queryable")||!!e.get("queryview")})),this.viewable.reset(this.filter(function(e){return!!e.get("viewable")||!!e.get("formatter_name")}))})}});return{Concept:s,Concepts:a}}),define("cilantro/models/filters",["jquery","underscore","backbone"],function(e,t,i){var n=function(e){var t="";if(e.concept&&(t+="c"+e.concept),e.field&&(t+="f"+e.field),!t)throw new Error("Cannot generate id for filter");return t},o=i.Model.extend({constructor:function(e,t){e&&!e.id&&(e[this.idAttribute]=n(e)),i.Model.prototype.constructor.call(this,e,t)},generateId:function(e){return n(e)},clear:function(e){var i=t.clone(this.attributes);delete i.id,delete i.field,delete i.concept,t.each(i,function(e,t){i[t]=void 0}),this.set(i,t.defaults({unset:!0},e))},sync:function(){},apply:function(e){this.trigger("apply",this,e)},unapply:function(e){this.trigger("unapply",this,e)},toJSON:function(i){i=t.defaults(i||{},{id:!1});var n=e.extend(!0,{},this.attributes);return i.id||delete n[this.idAttribute],n},isEnabled:function(){return this.get("enabled")!==!1},toggleEnabled:function(){this.set("enabled",!this.isEnabled())}}),s=i.Collection.extend({model:o,constructor:function(e,n){n=t.defaults({parse:!0},n),i.Collection.prototype.constructor.call(this,e,n)},sync:function(){},apply:function(e){this.trigger("apply",this,e)},unapply:function(e){this.trigger("unapply",this,e)},parse:function(e){if(t.isArray(e))t.each(e,function(e){e.id||(e.id=this.model.prototype.generateId(e))});else{var i=e||{};if(e=[],i.field){var n=this.model.prototype.generateId(i);e.push(t.extend({id:n},i))}else if(i.children){var o=i.concept;t.each(i.children,function(i){void 0!==o&&(i=t.extend({concept:o},i)),e=e.concat(this.parse(i))},this)}}return e}});return{Filter:o,Filters:s}}),define("cilantro/models/context",["underscore","backbone","loglevel","../core","./base","./filters"],function(e,t,i,n,o,s){var r=function(){var t=[];e.each(n.config.get("filters.required"),function(e){t.push(e)});var o=n.config.get("query.concepts.required");return o&&(i.warn('The "query.concepts.required" option is deprecated, use "filters.required" instead with fully qualified lookups.'),e.each(o,function(e){t.push({concept:e})})),t},a=o.Model.extend({options:{saveDelay:300},initialize:function(t,i){t=t||{},this.requiredFilters=r(),this._filters=new s.Filters(t.json,e.defaults({parse:!0},i)),this.filters=new s.Filters(t.json,e.defaults({parse:!0},i)),this.listenTo(this._filters,{apply:this.apply,unapply:this.unapply}),this.listenTo(this.filters,{unapply:this.unapply,"change:enabled":function(){this._save()}}),this.on("change:json",function(t,i,n){this.filters.set(i,e.defaults({parse:!0},n)),n.reset&&this._filters.set(i,e.defaults({parse:!0,remove:!1},n)),this.filters.each(function(e){this.isFilterRequired(e.attributes)?e.set("required",!0):e.unset("required")},this)}),this.on("sync",function(e,t,i){i=i||{},this.validate(),i.silent!==!0&&n.trigger(n.CONTEXT_SYNCED,this,"success")}),this._save=e.debounce(this.save,this.options.saveDelay)},validate:function(){var t=[];return e.each(this.requiredFilters,function(i){var n,o=this.filters.findWhere(i);o?o.isEnabled()||(n="disabled"):n="undefined",n&&t.push(e.extend({reason:n},i))},this),t.length?(n.trigger(n.CONTEXT_INVALID,t),"One or more filters are invalid"):void 0},isFilterRequired:function(t){return e.any(this.requiredFilters,function(i){return e.isEqual(e.pick(t,e.keys(i)),i)})},_apply:function(e,t){var i=e.toJSON({id:!0});i.required=this.isFilterRequired(i);var n=this.filters.get(i.id);n?(n.clear({silent:!0}),n.set(i)):n=this.filters.add(i,t),n.set("enabled",!0,{silent:!0});var o=this._filters.get(n);o.trigger("applied",o,t),n.stopListening(this),n.listenToOnce(this,"request",function(e,t,i){this.trigger("request",this,t,i)}),n.listenToOnce(this,"sync",function(e,t,i){this.trigger("sync",this,this.toJSON(),i)})},apply:function(i,n){i instanceof t.Collection?i=i.slice():e.isArray(i)||(i=[i]),e.each(i,function(e){this._apply(e,n)},this),n&&n.save===!1||this._save()},_unapply:function(e,t){var n=e.toJSON({id:!0});if(this.isFilterRequired(n))return void i.debug("skipping unapplying required filter",n);var o=this.filters.remove(n,t);if(o){var s=this._filters.get(o);s.trigger("unapplied",s,t),o.stopListening(this)}},unapply:function(i,n){i instanceof t.Collection?i=i.slice():e.isArray(i)||(i=[i]),e.each(i,function(e){this._unapply(e,n)},this),n&&n.save===!1||this._save()},define:function(e){var t=this._filters.model.prototype.generateId(e),i=this._filters.get(t);return i||(i=this._filters.create(e)),i},toJSON:function(){var e=o.Model.prototype.toJSON.call(this),t=this.filters.toJSON();return e.json=t.length?{type:"and",children:t}:null,e},isSession:function(){return this.get("session")},isArchived:function(){return this.get("archived")},isFilterApplied:function(e){return void 0!==this.filters.get(e)},hasFilterChanged:function(t,i){var n=this.filters.get(t);if(n)return i||(i=e.keys(t.attributes)),e.any(i,function(i){return!e.isEqual(t.get(i),n.get(i))})}}),l=o.SessionCollection.extend({model:a});return{Context:a,ContextCollection:l}}),define("cilantro/models/view",["underscore","backbone","../core","./base"],function(e,t,i,n){var o=t.Model.extend({idAttribute:"concept"}),s=t.Collection.extend({model:o}),r=n.Model.extend({constructor:function(){this.facets=new s,this.on("change:json",function(e,t){return this.jsonToFacets(t)}),n.Model.prototype.constructor.apply(this,arguments)},initialize:function(){var e=this;return this.on("request",function(){return i.trigger(i.VIEW_SYNCING,this)}),this.on("sync",function(e,t,n){return n||(n={}),n.silent!==!0?i.trigger(i.VIEW_SYNCED,this,"success"):void 0}),this.on("error",function(){return i.trigger(i.VIEW_SYNCED,this,"error")}),this.on("change",function(){return i.trigger(i.VIEW_CHANGED,this)}),i.on(i.VIEW_SAVE,function(t){return e.id===t||!t&&e.isSession()?e.save():void 0})},isSession:function(){return this.get("session")},isArchived:function(){return this.get("archived")},toJSON:function(){var e=n.Model.prototype.toJSON.apply(this,arguments);return e.json=this.facetsToJSON(),e},parse:function(e){return n.Model.prototype.parse.apply(this,arguments),this.jsonToFacets(e.json),e},jsonToFacets:function(t){if(t||(t={}),e.isArray(t))return void this.facets.reset(t);for(var i,n,o,s=[],r=t.columns||[],a=t.ordering||[],l=0;l=1&&e<=this.numPages},hasNextPage:function(e){return e||(e=this.currentPageNum),e1},setCurrentPage:function(e){if(e!==this.currentPageNum){if(!this.hasPage(e))throw new Error("Cannot set the current page out of bounds");return this.previousPageNum=this.currentPageNum,this.currentPageNum=e,this.trigger.apply(this,["change:currentpage",this].concat([].slice.call(this.getCurrentPageStats())))}},getPage:function(e,t){if(t||(t={}),this.hasPage(e)){var i=this.get(e);return i||t.load===!1||(i=new this.model({page_num:e}),i.pending=!0,this.add(i),i.fetch().done(function(){delete i.pending})),i&&t.active!==!1&&this.setCurrentPage(e),i}},getCurrentPage:function(e){return this.getPage(this.currentPageNum,e)},getFirstPage:function(e){return this.getPage(1,e)},getLastPage:function(e){return this.getPage(this.numPages,e)},getNextPage:function(e,t){return e||(e=this.currentPageNum),this.getPage(e+1,t)},getPreviousPage:function(e,t){return e||(e=this.currentPageNum),this.getPage(e-1,t)},pageIsLoading:function(e){e||(e=this.currentPageNum);var t=this.getPage(e,{active:!1,load:!1});return t?!!t.pending:void 0},getPageCount:function(){return this.numPages},getCurrentPageStats:function(){return[this.currentPageNum,{previous:this.previousPageNum,first:1===this.currentPageNum,last:this.currentPageNum===this.numPages}]}},o=t.Model.extend({idAttribute:"page_num",url:function(){var t=e.result(this.collection,"url");return i.utils.alterUrlParams(t,{page:this.id,per_page:this.collection.perPage})}}),s=t.Collection.extend({model:o});return e.extend(s.prototype,n),{PaginatorMixin:n,Page:o,Paginator:s}}),define("cilantro/constants",{INPUT_DELAY:400,CLICK_DELAY:300,REQUEST_DELAY:250}),define("cilantro/structs",["underscore","backbone","./models/base"],function(e,t,i){var n=t.Model.extend({defaults:{visible:!0},show:function(){this.set({visible:!0})},hide:function(){this.set({visible:!1})}}),o=t.Collection.extend({model:n}),s=t.Model.extend({constructor:function(e,i,o){i instanceof n||(i=new n(i)),this.index=i,t.Model.prototype.constructor.call(this,e,o)},size:function(){return 1},width:function(){return 1}}),r=t.Collection.extend({constructor:function(i,n,o){this.indexes=n;var r=this;this.model=function(t,i){var n=r.indexes.at(e.keys(r._byId).length);s.prototype.constructor.call(this,{value:t},n,i)},this.model.prototype=s.prototype,t.Collection.prototype.constructor.call(this,i,o)}}),a=t.Model.extend({constructor:function(i,n,s){var a;s||(s={}),n instanceof o||(n=new o(n)),this.indexes=n,e.isArray(i)?(a=i,i=null):s.parse=!0,this.data=new r(a,n),t.Model.prototype.constructor.call(this,i,s)},parse:function(e,t){return this.data.reset(e.values,t),delete e.values,e},isColumn:function(){return 1===this.width()},isRow:function(){return!this.isColumn()},size:function(){return this.isColumn()?this.data.length:1},width:function(){return this.indexes.length}}),l=t.Collection.extend({constructor:function(e,i,n){this.indexes=i,t.Collection.prototype.constructor.call(this,e,n);var o=this;this.model=function(e,t){a.prototype.constructor.call(this,e,o.indexes,t)},this.model.prototype=a.prototype}}),c=i.Model.extend({constructor:function(t,n,s){var r;s||(s={}),n instanceof o||(n=new o(n)),this.indexes=n,e.isArray(t)?(r=t,t=null):s.parse=!0,this.series=new l(r,n),i.Model.prototype.constructor.call(this,t,s)},parse:function(e,t){return i.Model.prototype.parse.call(this,e,t),this.indexes.reset(e.keys,t),this.series.reset(e.objects,t),delete e.keys,delete e.objects,e},size:function(){return this.series.length},width:function(){return this.indexes.length},column:function(e){var t=this.series.map(function(t){return t.data.at(e)});return new a(t,this.indexes.at(e))}}),u=i.Collection.extend({model:c,constructor:function(e,t){this.indexes=new o,this.on("reset",function(e){var t=e.models[0];return t?this.indexes.reset(t.indexes.models):void 0}),this.on("add",function(e,t){return 1===t.length?this.indexes.reset(e.indexes.models):void 0}),i.Collection.prototype.constructor.call(this,e,t)}});return{Datum:s,Frame:c,FrameArray:u,Index:n,Indexes:o,Series:a}}),define("cilantro/models/results",["underscore","../core","../constants","../structs","./paginator"],function(e,t,i,n,o){var s=n.Frame.extend({idAttribute:"page_num",url:function(){var i=e.result(this.collection,"url");return t.utils.alterUrlParams(i,{page:this.id,per_page:this.collection.perPage})}}),r=n.FrameArray.extend({initialize:function(){e.bindAll(this,"fetch","markAsDirty","onWorkspaceUnload","onWorkspaceLoad","refresh"),this.isDirty=!0,this.isWorkspaceOpen=!1,this._refresh=e.debounce(this.refresh,i.CLICK_DELAY),t.on(t.VIEW_SYNCED,this.markAsDirty),t.on(t.CONTEXT_SYNCED,this.markAsDirty),this.on("workspace:load",this.onWorkspaceLoad),this.on("workspace:unload",this.onWorkspaceUnload)},onWorkspaceLoad:function(){this.isWorkspaceOpen=!0,this._refresh()},onWorkspaceUnload:function(){this.isWorkspaceOpen=!1},markAsDirty:function(){this.isDirty=!0,this._refresh()},fetch:function(e){e||(e={});var i;if((i=t.config.get("session.defaults.data.preview"))&&(e.type="POST",e.contentType="application/json",e.data=JSON.stringify(i)),this.isDirty&&this.isWorkspaceOpen)return this.isDirty=!1,void 0===e.cache&&(e.cache=!1),n.FrameArray.prototype.fetch.call(this,e);var o=this;return{done:function(){return delete o.pending}}}});return e.extend(r.prototype,o.PaginatorMixin),r.prototype.getPage=function(e,i){if(i||(i={}),this.hasPage(e)){var n=this.get(e);if(!n&&i.load!==!1){n=new this.model({page_num:e}),n.pending=!0,this.add(n);var o,s={};(o=t.config.get("session.defaults.data.preview"))&&(s.type="POST",s.contentType="application/json",s.data=JSON.stringify(o)),n.fetch(s).done(function(){delete n.pending})}return n&&i.active!==!1&&this.setCurrentPage(e),n}},r.prototype.model=s,{Results:r}}),define("cilantro/models/exporter",["underscore","./base"],function(e,t){var i=function(e){if(!e.href)return"Untitled";var t,i=e.href;return t="/"===i.charAt(i.length-1)?i.substr(0,i.length-1).split("/"):i.split("/"),t.length>0?t[t.length-1].toUpperCase():"Untitled "+i},n=t.Model.extend({idAttribute:"type"}),o=t.Collection.extend({model:n,parse:function(t){var n=[];return e.each(t._links,function(t,o){"self"!==o&&(t=e.extend({type:o},t),t.title||(t.title=i(t)),n.push(t))}),n}});return{ExporterModel:n,ExporterCollection:o}}),define("cilantro/models/query",["./base","../core","./context","./view"],function(e,t,i,n){var o=e.Model.extend({constructor:function(t,o){t=t||{},this.context=new i.Context({json:t.context_json}),this.view=new n.ViewModel({json:t.view_json}),e.Model.prototype.constructor.call(this,t,o)},parse:function(t,i){return t&&(t&&!t.shared_users&&(t.shared_users=[]),this.context.set({json:t.context_json}),this.view.set({json:t.view_json})),e.Model.prototype.parse.call(this,t,i)}}),s=e.Collection.extend({model:o});return{Query:o,Queries:s}}),define("cilantro/models/value",["underscore","backbone","../structs","../constants"],function(e,t,i,n){var o=t.Model.extend({idAttribute:"label",defaults:{valid:null,pending:!1},fetch:function(){},toJSON:function(e){return e&&e.flat?this.pluck("value"):this.pick("value","label")},destroy:function(e){this.trigger("destroy",this,this.collection,e)}}),s=t.Collection.extend({model:o,options:{check:!0},initialize:function(t,i){i=e.extend({},this.options,i||{}),i.check&&this.on("add reset",e.debounce(this.check,n.INPUT_DELAY))},fetch:function(){},create:function(e,t){this.add(e,t)},check:function(){var i=this.where({valid:null,pending:!1});if(i.length&&this.url){e.each(i,function(e){e.set("pending",!0)});var n=this;t.ajax({url:this.url(),type:"POST",data:JSON.stringify(i),contentType:"application/json",success:function(e){n.set(e,{add:!1,remove:!1})},complete:function(){e.each(i,function(e){e.set("pending",!1)})}})}}});return{Value:o,Values:s}}),define("cilantro/models",["underscore","./models/base","./models/field","./models/concept","./models/context","./models/filters","./models/view","./models/paginator","./models/results","./models/exporter","./models/query","./models/value"],function(e){var t=[].slice.call(arguments,1);return e.extend.apply(null,[{}].concat(t))}),define("cilantro/router",["backbone","underscore","loglevel"],function(e,t,i){var n=e.Router.extend({options:{main:"body",root:null},initialize:function(e){this.options=t.extend({},t.result(this,"options"),e),this._loaded=[],this._routes={},this._handlers={},this._registered={},t.bindAll(this,"_unloadAll","_loadAll","_unload","_load","_render")},_unloadAll:function(){var e=[].slice.call(arguments);t.each(this._loaded.slice(),function(t){this._unload.apply(this,[this._registered[t],!1].concat(e))},this)},_loadAll:function(e){var i=this._routes[e];if(i){var n=[].slice.call(arguments,1);t.each(i,function(e){this._load.apply(this,[this._registered[e]].concat(n))},this)}},_unload:function(t,i){void 0===i&&(i=!0);var n=this._loaded.indexOf(t.id);if((t.route||i&&n>=0)&&(this._loaded.splice(n,1),t._view)){t._view.$el.hide();var o=[].slice.call(arguments,2);t._view.trigger.apply(t._view,["router:unload",this,e.history.fragment].concat(o))}},_load:function(e){var n=[].slice.call(arguments,1);if(!e._view){if(t.isString(e.view)){var o=this;return void require([e.view],function(t){e._view=new t(e.options),o._render.apply(o,[e].concat(n)),o._loaded.push(e.id)},function(e){i.error(e)})}e._view=e.view}this._render.apply(this,[e].concat(n)),this._loaded.push(e.id)},_render:function(t){var i=[].slice.call(arguments,1),n=t._view;if(!n._rendered&&(n._rendered=!0,t.el!==!1)){var o;o=t.el?e.$(t.el,this.options.main):e.$(this.options.main),o.append(n.el),n.render()}n.$el.show(),n.trigger.apply(n,["router:load",this,e.history.fragment].concat(i))},_register:function(e){if(this._registered[e.id])throw new Error('Route "'+e.id+'" already registered');if(e=t.clone(e),e.route){if(!this._handlers[e.route]){this._routes[e.route]=[];var i=t.bind(function(){var t=[].slice.call(arguments);this._unloadAll.apply(this,t),this._loadAll.apply(this,[e.route].concat(t))},this);this._handlers[e.route]=i,this.route(e.route,e.id,i)}}else this._load(e);e.route&&this._routes[e.route].push(e.id),this._registered[e.id]=e},get:function(e){return this._registered[e]},isNavigable:function(e){var t=this.get(e);return t&&t.navigable!==!1},isCurrent:function(i){if(i===e.history.fragment)return!0;var n=this._routes[e.history.fragment]||[];return t.any(n,function(e){return i===e})},hasRoute:function(e){return this._routes.hasOwnProperty(e)},navigate:function(t,i){return this.isNavigable(t)&&(t=this.get(t).route),e.Router.prototype.navigate.call(this,t,i)},register:function(e){e&&(t.isArray(e)||(e=[e]),t.each(e,function(e){e.view&&this._register(e)},this))},unregister:function(e){if(void 0===e)return void t.each(this._registered,function(e,t){this.unregister(t)},this);var i=this._registered[e];if(!i)throw new Error('No route registered by id "'+e+'"');this._unload(i),delete this._registered[e];var n=this._routes[i.route];n&&n.indexOf(e)>=0&&this._routes[i.route].splice(n.indexOf(e),1)},start:function(i){if(!e.History.started){var n=this.options.root||"/";return"/"!==n.charAt(n.length-1)&&(n+="/"),i=t.extend({root:n,pushState:!0},i),e.history.start(i)}}});return{Router:n}}),define("cilantro/session",["jquery","underscore","backbone","./models","./utils","./router","./core"],function(e,t,i,n,o,s,r){var a={SESSION_OPENING:"session:opening",SESSION_ERROR:"session:error",SESSION_UNAUTHORIZED:"session:unauthorized",SESSION_OPENED:"session:opened",SESSION_CLOSED:"session:closed"},l={concepts:n.Concepts,fields:n.FieldCollection,contexts:n.ContextCollection,views:n.ViewCollection,preview:n.Results,exporter:n.ExporterCollection,queries:n.Queries,public_queries:n.Queries},c=n.Model.extend({idAttribute:"url",options:function(){return r.config.get("session.defaults")},initialize:function(e,i){this.options=t.extend({},t.result(this,"options"),i),this.opened=!1,this.started=!1,this.opening=!1,this.state={},t.bindAll(this,"ping","startPing","stopPing")},validate:function(e){return e&&e.url?void 0:"url is required"},startPing:function(){this.links.ping&&this.options.ping&&!this._ping&&(this.ping(),this._ping=setInterval(this.ping,this.options.ping))},stopPing:function(){clearTimeout(this._ping),delete this._ping},ping:function(){var e=this;i.ajax({type:"GET",url:this.links.ping,dataType:"json",success:function(t){"timeout"===t.status&&(e.stopPing(),e.timeout(t.location))},error:function(t,i,n){e.stopPing(),"FOUND"===n&&this.timeout(t.getResponseHeader("Location"))}})},timeout:function(e){var t;t=e?'Your session timed out. Please refresh the page.':"Your session timed out. Please refresh the page.",r.notify({header:"Session Timeout",message:t,dismissable:!1,timeout:!1,level:"warning"}),setTimeout(function(){e?window.location=location:window.location.reload(!0)},5e3)},parse:function(e){e=e||{},this.title=e.title,this.version=e.version,this.data={};var i;t.each(e._links,function(e,t){(i=l[t])&&(this.data[t]=new i,this.data[t].url=e.href,this.data[t].fetch({reset:!0}))},this),this.router=new s.Router({main:r.config.get("main"),root:r.config.get("root")});var n=this.get("routes");if(n)if("string"==typeof n){var o=this;require([n],function(e){o.router.register(e)})}else"function"==typeof n&&(n=n()),this.router.register(n);return e},open:function(){if(this.opened||this.opening)return this._opening.promise();if(!this.isValid())throw new Error(this.validationError);this.opening=!0,this._opening=e.Deferred();var t={url:this.get("url"),type:"GET",dataType:"json"},i=this.get("credentials");i&&e.extend(t,{type:"POST",contentType:"application/json",data:JSON.stringify(i)});var n=this;return this.fetch(t).always(function(){n.opening=!1 }).done(function(e,t,i){n.opened=!0,n._opening.resolveWith(n,[n,e,t,i])}).fail(function(e,t,i){n.error=i,n._opening.rejectWith(n,[this,e,t,i])}),this._opening.promise()},close:function(){this.end(),this.opening=this.opened=!1,t.each(this.data,function(e){e.reset(),delete e.url}),delete this._opening,delete this.data},start:function(e,t){if(this.started)return!1;if(!this.opened)throw new Error("Session must be opened before loaded");this.started=!0,e&&this.router.register(e),this.router.start(t),this.startPing(),this.listenTo(r,{visible:this.startPing,hidden:this.stopPing,focus:this.startPing,blur:this.stopPing}),r.isSupported(r.getSerranoVersion())||r.notify({header:"Serrano Version Unsupported",level:"warning",timeout:!1,message:"You are connecting to an unsupported version of Serrano. Some functionality may be broken or missing due to compatibility issues."})},end:function(){this.started=!1,this.stopPing(),this.stopListening(r,"visible hidden"),this.router.unregister()}}),u=i.Collection.extend({_switch:function(e){this.active!==e&&(delete this.pending,this.close(),this.active=e,this.trigger(a.SESSION_OPENED,e))},open:function(e,t){"object"==typeof e?t=e:(t=t||{},t.url=e);var i=this.get(t.url);i||(i=new c(t),this.add(i)),i!==this.active&&i!==this.pending&&(this.pending=i,this.trigger(a.SESSION_OPENING,i));var n=this;return i.open().done(function(){n.pending===i&&n._switch(i)}).fail(function(e,t,o,s){if(n.pending===i){n.pending=null;var r;r=401===t.statusCode||403===t.statusCode?a.SESSION_UNAUTHORIZED:a.SESSION_ERROR,n.trigger(r,i,s)}})},close:function(){if(this.active){var e=this.active;delete this.active,this.remove(e),e.close(),this.trigger(a.SESSION_CLOSED,e)}},clear:function(){this.close(),this.reset()}});return t.extend({SessionManager:u,Session:c,events:a})}),define("text",["module"],function(e){var t,i,n,o,s,r=["Msxml2.XMLHTTP","Microsoft.XMLHTTP","Msxml2.XMLHTTP.4.0"],a=/^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,l=/]*>\s*([\s\S]+)\s*<\/body>/im,c="undefined"!=typeof location&&location.href,u=c&&location.protocol&&location.protocol.replace(/\:/,""),h=c&&location.hostname,d=c&&(location.port||void 0),p={},f=e.config&&e.config()||{};return t={version:"2.0.12",strip:function(e){if(e){e=e.replace(a,"");var t=e.match(l);t&&(e=t[1])}else e="";return e},jsEscape:function(e){return e.replace(/(['\\])/g,"\\$1").replace(/[\f]/g,"\\f").replace(/[\b]/g,"\\b").replace(/[\n]/g,"\\n").replace(/[\t]/g,"\\t").replace(/[\r]/g,"\\r").replace(/[\u2028]/g,"\\u2028").replace(/[\u2029]/g,"\\u2029")},createXhr:f.createXhr||function(){var e,t,i;if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;if("undefined"!=typeof ActiveXObject)for(t=0;3>t;t+=1){i=r[t];try{e=new ActiveXObject(i)}catch(n){}if(e){r=[i];break}}return e},parseName:function(e){var t,i,n,o=!1,s=e.indexOf("."),r=0===e.indexOf("./")||0===e.indexOf("../");return-1!==s&&(!r||s>1)?(t=e.substring(0,s),i=e.substring(s+1,e.length)):t=e,n=i||t,s=n.indexOf("!"),-1!==s&&(o="strip"===n.substring(s+1),n=n.substring(0,s),i?i=n:t=n),{moduleName:t,ext:i,strip:o}},xdRegExp:/^((\w+)\:)?\/\/([^\/\\]+)/,useXhr:function(e,i,n,o){var s,r,a,l=t.xdRegExp.exec(e);return l?(s=l[2],r=l[3],r=r.split(":"),a=r[1],r=r[0],!(s&&s!==i||r&&r.toLowerCase()!==n.toLowerCase()||(a||r)&&a!==o)):!0},finishLoad:function(e,i,n,o){n=i?t.strip(n):n,f.isBuild&&(p[e]=n),o(n)},load:function(e,i,n,o){if(o&&o.isBuild&&!o.inlineText)return void n();f.isBuild=o&&o.isBuild;var s=t.parseName(e),r=s.moduleName+(s.ext?"."+s.ext:""),a=i.toUrl(r),l=f.useXhr||t.useXhr;return 0===a.indexOf("empty:")?void n():void(!c||l(a,u,h,d)?t.get(a,function(i){t.finishLoad(e,s.strip,i,n)},function(e){n.error&&n.error(e)}):i([r],function(e){t.finishLoad(s.moduleName+"."+s.ext,s.strip,e,n)}))},write:function(e,i,n){if(p.hasOwnProperty(i)){var o=t.jsEscape(p[i]);n.asModule(e+"!"+i,"define(function () { return '"+o+"';});\n")}},writeFile:function(e,i,n,o,s){var r=t.parseName(i),a=r.ext?"."+r.ext:"",l=r.moduleName+a,c=n.toUrl(r.moduleName+a)+".js";t.load(l,n,function(){var i=function(e){return o(c,e)};i.asModule=function(e,t){return o.asModule(e,c,t)},t.write(e,l,i,s)},s)}},"node"===f.env||!f.env&&"undefined"!=typeof process&&process.versions&&process.versions.node&&!process.versions["node-webkit"]?(i=require.nodeRequire("fs"),t.get=function(e,t,n){try{var o=i.readFileSync(e,"utf8");0===o.indexOf("")&&(o=o.substring(1)),t(o)}catch(s){n&&n(s)}}):"xhr"===f.env||!f.env&&t.createXhr()?t.get=function(e,i,n,o){var s,r=t.createXhr();if(r.open("GET",e,!0),o)for(s in o)o.hasOwnProperty(s)&&r.setRequestHeader(s.toLowerCase(),o[s]);f.onXhr&&f.onXhr(r,e),r.onreadystatechange=function(){var t,o;4===r.readyState&&(t=r.status||0,t>399&&600>t?(o=new Error(e+" HTTP status: "+t),o.xhr=r,n&&n(o)):i(r.responseText),f.onXhrComplete&&f.onXhrComplete(r,e))},r.send(null)}:"rhino"===f.env||!f.env&&"undefined"!=typeof Packages&&"undefined"!=typeof java?t.get=function(e,t){var i,n,o="utf-8",s=new java.io.File(e),r=java.lang.System.getProperty("line.separator"),a=new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(s),o)),l="";try{for(i=new java.lang.StringBuffer,n=a.readLine(),n&&n.length()&&65279===n.charAt(0)&&(n=n.substring(1)),null!==n&&i.append(n);null!==(n=a.readLine());)i.append(r),i.append(n);l=String(i.toString())}finally{a.close()}t(l)}:("xpconnect"===f.env||!f.env&&"undefined"!=typeof Components&&Components.classes&&Components.interfaces)&&(n=Components.classes,o=Components.interfaces,Components.utils["import"]("resource://gre/modules/FileUtils.jsm"),s="@mozilla.org/windows-registry-key;1"in n,t.get=function(e,t){var i,r,a,l={};s&&(e=e.replace(/\//g,"\\")),a=new FileUtils.File(e);try{i=n["@mozilla.org/network/file-input-stream;1"].createInstance(o.nsIFileInputStream),i.init(a,1,0,!1),r=n["@mozilla.org/intl/converter-input-stream;1"].createInstance(o.nsIConverterInputStream),r.init(i,"utf-8",i.available(),o.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER),r.readString(i.available(),l),r.close(),i.close(),t(l.value)}catch(c){throw new Error((a&&a.path||"")+": "+c)}}),t}),define("tpl",["module","text","underscore"],function(module,text,_){var settings=module.config()||{};return{load:function(e,t,i,n){return n.isBuild?void text.load.call(text,e,t,i,n):void t(["text!"+e],function(t){var n=t?_.template(t,void 0,settings):function(){return""};n._moduleName=e,i(n)})},write:function(pluginName,moduleName,write,config){text.write.call(text,pluginName,moduleName,{asModule:function(name,contents){contents=contents.substr(contents.indexOf("return")+7),contents=contents.substr(0,contents.lastIndexOf(";")-3);try{var template=_.template(eval(contents),void 0,settings);write.asModule(pluginName+"!"+moduleName,"define(function() { var func = "+template.source+"; func._moduleName = '"+moduleName+"'; return func; });")}catch(err){throw console.error("~~~~~"),console.error("FAILED TO COMPILE "+pluginName+"!"+moduleName),console.error("Error: "+String(err)),console.error("\n"),err&&err.source&&(console.error("Error Source:\n"),console.error(err.source),console.error("\n\n")),console.error("Original Contents:\n"),console.error(contents),console.error("\n\n"),err}}},config)}}}),define("tpl!templates/count.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="\n\n"};return e._moduleName="templates/count.html",e}),define("tpl!templates/notification.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+='\n'+(null==(t=e.header)?"":t)+"\n"+(null==(t=e.message)?"":t)+"\n"};return e._moduleName="templates/notification.html",e}),define("tpl!templates/paginator.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="\n\n\n\n\n page - / -\n\n"};return e._moduleName="templates/paginator.html",e}),define("tpl!templates/panel.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='
\n
\n'};return e._moduleName="templates/panel.html",e}),define("tpl!templates/search.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='\n'};return e._moduleName="templates/search.html",e}),define("tpl!templates/welcome.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="

Welcome!

\n\n
\n

Welcome to your data discovery and query workspace.

\n\n

Get started by searching or browsing\n something you are curious about on the left side. We've broken up the \n various data you are interested into (hopefully) intuitive categories.

\n\n

When you select one of the items on the left to view, you will be\n presented with some description information,\n distribution charts (for numerical data), and various\n statistics about the data.

\n
\n\n
\n

Welcome back. You can find your existing filters on the right and you\n can create new filters by selecting items on the left. Clicking on a filter\n on the right will open that item so you can edit it and see further \n information associated with that filter.

\n
\n"};return e._moduleName="templates/welcome.html",e}),define("tpl!templates/accordion/group.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+='
\n \n \n '+(null==(t=e.name)?"":t)+'\n
\n
\n
\n
\n'};return e._moduleName="templates/accordion/group.html",e}),define("tpl!templates/accordion/section.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+="
"+(null==(t=e.name)?"":t)+'
\n\n'};return e._moduleName="templates/accordion/section.html",e}),define("tpl!templates/accordion/item.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+=""+(null==(t=e.name)?"":t)+"\n"};return e._moduleName="templates/accordion/item.html",e}),define("tpl!templates/base/error-overlay.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='

Whoops, sorry.

\n\n

There was a problem syncing with the server.\n Don\'t worry only the last change you made will have to be repeated.\n Please refresh your browser and give it another try.

\n'};return e._moduleName="templates/base/error-overlay.html",e}),define("tpl!templates/button/select-option.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+=''+(null==(t=e.label)?"":t)+"\n"};return e._moduleName="templates/button/select-option.html",e}),define("tpl!templates/button/select.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='\n \n \n\n\n'};return e._moduleName="templates/button/select.html",e}),define("tpl!templates/charts/chart.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="
\n \n \n
\n
\n"};return e._moduleName="templates/charts/chart.html",e}),define("tpl!templates/charts/editable-chart.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='
\n
\n \n \n
\n
\n \n
\n
\n \n
\n
\n
\n \n \n
\n
\n
\n
\n \n \n \n \n
\n
\n
\n
\n'};return e._moduleName="templates/charts/editable-chart.html",e}),define("tpl!templates/concept/columns/available-group.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+="
\n "+(null==(t=e.name)?"":t)+'\n \n
\n
\n
\n
\n'};return e._moduleName="templates/concept/columns/available-group.html",e}),define("tpl!templates/concept/columns/available-section.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+="
\n "+(null==(t=e.name)?"":t)+'\n \n
\n\n'};return e._moduleName="templates/concept/columns/available-section.html",e}),define("tpl!templates/concept/columns/available-item.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+=""+(null==(t=e.name)?"":t)+'\n\n'};return e._moduleName="templates/concept/columns/available-item.html",e}),define("tpl!templates/concept/columns/selected-item.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+=""+(null==(t=e.name)?"":t)+'\n\n'};return e._moduleName="templates/concept/columns/selected-item.html",e}),define("tpl!templates/concept/columns/layout.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='
\n
\n
\n
\n\n
\n
\n \n Click, drag and drop to change the order.\n
\n
\n
\n'};return e._moduleName="templates/concept/columns/layout.html",e}),define("tpl!templates/concept/columns/dialog.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="\n\n\n\n\n"};return e._moduleName="templates/concept/columns/dialog.html",e}),define("tpl!templates/concept/error.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+='

Whoops, sorry.

\n\nThere was a problem loading "'+(null==(t=e.name)?"":t)+'"\n'};return e._moduleName="templates/concept/error.html",e}),define("tpl!templates/concept/form.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="
\n\n
\n"};return e._moduleName="templates/concept/form.html",e}),define("tpl!templates/concept/info.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+="",e.category&&(i+="\n

\n ",e.category.parent&&(i+="\n "+(null==(t=e.category.parent.name)?"":t)+"\n \n "),i+="\n "+(null==(t=e.category.name)?"":t)+"\n

\n"),i+="\n\n

\n "+(null==(t=e.name)?"":t)+"\n ",e.unit&&(i+="\n "+(null==(t=e.unit)?"":t)+"\n "),i+="\n

\n\n",e.description&&(i+='\n
\n
'+(null==(t=e.description)?"":t)+"
\n read more\n
\n"),i+="\n"};return e._moduleName="templates/concept/info.html",e}),define("tpl!templates/concept/panel.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="
\n
\n
\n
\n"};return e._moduleName="templates/concept/panel.html",e}),define("tpl!templates/concept/workspace.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='
\n'};return e._moduleName="templates/concept/workspace.html",e}),define("tpl!templates/concept/popover.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+='
\n

'+(null==(t=e.name)?"":t)+'

\n
\n

'+(null==(t=e.description)?"":t)+"

\n ",e.fields&&(i+="\n

Included fields: "+(null==(t=e.fields)?"":t)+"

\n "),i+="\n
\n"};return e._moduleName="templates/concept/popover.html",e}),define("tpl!templates/export/dialog.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='\n\n\n\n\n'};return e._moduleName="templates/export/dialog.html",e}),define("tpl!templates/export/option.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+=' '+(null==(t=e.title)?"":t)+"\n"};return e._moduleName="templates/export/option.html",e}),define("tpl!templates/export/batch.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="

Downloads

\n"};return e._moduleName="templates/export/batch.html",e}),define("tpl!templates/export/progress.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+="
\n
\n "+(null==(t=e.title)?"":t)+'\n
\n
\n Pending...\n
\n
\n Cancel\n
\n
\n\n'};return e._moduleName="templates/export/progress.html",e}),define("tpl!templates/context/panel.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='
\n
\n
\n
\n
\n'};return e._moduleName="templates/context/panel.html",e}),define("tpl!templates/context/actions.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+="
\n \n
\n\n
\n Calculating...\n ",i+=null==e.count?"\n All\n ":"\n "+(null==(t=e.prettyCount)?"":t)+"\n ",i+="\n \n ",i+=1==e.count?"\n "+(null==(t=e.object_name)?"":t)+"\n ":"\n "+(null==(t=e.object_name_plural)?"":t)+"\n ",i+="\n \n
\n"};return e._moduleName="templates/context/actions.html",e}),define("tpl!templates/context/info.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='\n\n'};return e._moduleName="templates/context/info.html",e}),define("tpl!templates/context/empty.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="

No filters are applied

\n\n

Explore the available filters on the left side or click \"View Results\"\nto immediately preview some data.

\n

Browse the data in the table to the left or click \"Refine Query\"\nto create and add filters.

\n"};return e._moduleName="templates/context/empty.html",e}),define("tpl!templates/context/filter.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+='
\n \n
\n\n\n
'+(null==(t=e.language)?"":t)+'
\n
\n'};return e._moduleName="templates/context/filter.html",e}),define("tpl!templates/controls/infograph/bar.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+='
\n
\n '+(null==(t=e.label)?"":t)+"\n \n "+(null==(t=e.count)?"":t)+"\n ("+(null==(t=e.percentage)?"":t)+"%)\n \n
\n"};return e._moduleName="templates/controls/infograph/bar.html",e}),define("tpl!templates/controls/infograph/layout.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="
\n
\n Loading values...\n
\n
\n"};return e._moduleName="templates/controls/infograph/layout.html",e}),define("tpl!templates/controls/infograph/toolbar.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="\n
\n Value Count \n
\n"};return e._moduleName="templates/controls/infograph/toolbar.html",e}),define("tpl!templates/controls/range/layout.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='\n and \n\n\nEntering a value on the left while leaving the right empty represents a filter matching all values greater than or equal to the supplied value. Conversely, entering a value on the right and leaving the left empty represents a filter matching all values less than or equal to the supplied value. Entering values in both boxes will match all values within the range specified. The opposite applies when not between is selected from the choices above.\n'};return e._moduleName="templates/controls/range/layout.html",e}),define("tpl!templates/controls/select/layout.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="
\n"};return e._moduleName="templates/controls/select/layout.html",e}),define("tpl!templates/controls/select/list.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="\n"};return e._moduleName="templates/controls/select/list.html",e}),define("tpl!templates/controls/search/layout.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="
\n
\n
\n \n
\n
\n
\n
\n
\n
\n
\n"};return e._moduleName="templates/controls/search/layout.html",e}),define("tpl!templates/controls/search/item.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+='
\n \n \n
\n'+(null==(t=e.label)?"":t)+"\n"};return e._moduleName="templates/controls/search/item.html",e}),define("tpl!templates/controls/null/layout.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="\n"};return e._moduleName="templates/controls/null/layout.html",e}),define("tpl!templates/controls/text/layout.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="
\n

Wrap two or more words with quotes to match explicitly. Prefix a single keyword or quoted text with a \"+\" (plus sign) to require matching on the keyword or \"-\" (minus sign) to prevent matching on the keyword.

\n
\n"};return e._moduleName="templates/controls/text/layout.html",e}),define("tpl!templates/controls/text/preview-list.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="

Preview

\n\n

Note, these preview texts may not be in your final query results depending on the other filters applied.

\n\n
\n"};return e._moduleName="templates/controls/text/preview-list.html",e}),define("tpl!templates/controls/text/preview-item.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+=""+(null==(t=e.label)?"":t)+"\n"};return e._moduleName="templates/controls/text/preview-item.html",e}),define("tpl!templates/controls/vocab/layout.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n
\n"};return e._moduleName="templates/controls/vocab/layout.html",e}),define("tpl!templates/controls/vocab/path.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+="
\n
\n"};return e._moduleName="templates/controls/vocab/path.html",e}),define("tpl!templates/controls/vocab/item.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+="
\n \n \n
\n",i+=e.url?"\n "+(null==(t=e.label)?"":t)+"\n":"\n "+(null==(t=e.label)?"":t)+"\n",i+="\n" };return e._moduleName="templates/controls/vocab/item.html",e}),define("tpl!templates/controls/vocab/bucket.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+=""+(null==(t=e.name)?"":t)+"\n
\n"};return e._moduleName="templates/controls/vocab/bucket.html",e}),define("tpl!templates/controls/vocab/bucket-item.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+="
\n \n
\n"+(null==(t=e.label)?"":t)+"\n"};return e._moduleName="templates/controls/vocab/bucket-item.html",e}),define("tpl!templates/field/form-condensed.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="
\n
\n
\n
\n
\n
\n
\n
\n
\n"};return e._moduleName="templates/field/form-condensed.html",e}),define("tpl!templates/field/form.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='
\n
\n
\n
\n\n
\n \n \n
\n
\n'};return e._moduleName="templates/field/form.html",e}),define("tpl!templates/field/info.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+="

\n "+(null==(t=e.alt_name||e.name)?"":t)+"\n ",e.unit&&(i+="\n "+(null==(t=e.unit)?"":t)+"\n "),i+="\n

\n\n",e.description&&(i+="\n

"+(null==(t=e.description)?"":t)+"

\n"),i+="\n"};return e._moduleName="templates/field/info.html",e}),define("tpl!templates/field/stats.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="
\n
\n"};return e._moduleName="templates/field/stats.html",e}),define("tpl!templates/field/links.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='Jump to: \n'};return e._moduleName="templates/field/links.html",e}),define("tpl!templates/field/link.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+=""+(null==(t=e.name)?"":t)+"\n"};return e._moduleName="templates/field/link.html",e}),define("tpl!templates/query/delete-dialog.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='\n\n\n\n\n'};return e._moduleName="templates/query/delete-dialog.html",e}),define("tpl!templates/query/edit-dialog.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='\n\n\n\n\n'};return e._moduleName="templates/query/edit-dialog.html",e}),define("tpl!templates/query/item.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+="\n \n \n \n \n\n\n\n shared by "+(null==(t=e.user.username)?"":t)+"\n\n\n\n "+(null==(t=e.name)?"":t)+"\n Show details\n\n\n
\n"};return e._moduleName="templates/query/item.html",e}),define("tpl!templates/query/list.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='
\n
\n

\n
\n
\n
\n Loading...\n
\n
There was a problem retrieving the queries. Please reload the page to try to reload the queries.
\n
\n
\n'};return e._moduleName="templates/query/list.html",e}),define("tpl!templates/query/loader.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+="
\n Loading Query...\n
\n
\n Uh oh. There was an error opening the query. Your filters and view have not been changed. It is possible that this query has been removed. To try opening this query again, please navigate to the Workspace page and clicking on the query from the list shown on that page.\n
\n"};return e._moduleName="templates/query/loader.html",e}),define("tpl!templates/values/item.html",[],function(){var e=function(e){{var t,i="";Array.prototype.join}return i+=""+(null==(t=e.label)?"":t)+"\n"};return e._moduleName="templates/values/item.html",e}),define("tpl!templates/values/list.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='\n'};return e._moduleName="templates/values/list.html",e}),define("tpl!templates/workflows/query.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='
\n'};return e._moduleName="templates/workflows/query.html",e}),define("tpl!templates/workflows/results.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='\n\n
\n

Loading Results

\n
\n\n
\n'};return e._moduleName="templates/workflows/results.html",e}),define("tpl!templates/workflows/workspace.html",[],function(){var e=function(){{var e="";Array.prototype.join}return e+='
\n
\n
\n
\n'};return e._moduleName="templates/workflows/workspace.html",e}),define("cilantro/ui/templates",["underscore","loglevel","tpl!templates/count.html","tpl!templates/notification.html","tpl!templates/paginator.html","tpl!templates/panel.html","tpl!templates/search.html","tpl!templates/welcome.html","tpl!templates/accordion/group.html","tpl!templates/accordion/section.html","tpl!templates/accordion/item.html","tpl!templates/base/error-overlay.html","tpl!templates/button/select-option.html","tpl!templates/button/select.html","tpl!templates/charts/chart.html","tpl!templates/charts/editable-chart.html","tpl!templates/concept/columns/available-group.html","tpl!templates/concept/columns/available-section.html","tpl!templates/concept/columns/available-item.html","tpl!templates/concept/columns/selected-item.html","tpl!templates/concept/columns/layout.html","tpl!templates/concept/columns/dialog.html","tpl!templates/concept/error.html","tpl!templates/concept/form.html","tpl!templates/concept/info.html","tpl!templates/concept/panel.html","tpl!templates/concept/workspace.html","tpl!templates/concept/popover.html","tpl!templates/export/dialog.html","tpl!templates/export/option.html","tpl!templates/export/batch.html","tpl!templates/export/progress.html","tpl!templates/context/panel.html","tpl!templates/context/actions.html","tpl!templates/context/info.html","tpl!templates/context/empty.html","tpl!templates/context/filter.html","tpl!templates/controls/infograph/bar.html","tpl!templates/controls/infograph/layout.html","tpl!templates/controls/infograph/toolbar.html","tpl!templates/controls/range/layout.html","tpl!templates/controls/select/layout.html","tpl!templates/controls/select/list.html","tpl!templates/controls/search/layout.html","tpl!templates/controls/search/item.html","tpl!templates/controls/null/layout.html","tpl!templates/controls/text/layout.html","tpl!templates/controls/text/preview-list.html","tpl!templates/controls/text/preview-item.html","tpl!templates/controls/vocab/layout.html","tpl!templates/controls/vocab/path.html","tpl!templates/controls/vocab/item.html","tpl!templates/controls/vocab/bucket.html","tpl!templates/controls/vocab/bucket-item.html","tpl!templates/field/form-condensed.html","tpl!templates/field/form.html","tpl!templates/field/info.html","tpl!templates/field/stats.html","tpl!templates/field/links.html","tpl!templates/field/link.html","tpl!templates/query/delete-dialog.html","tpl!templates/query/edit-dialog.html","tpl!templates/query/item.html","tpl!templates/query/list.html","tpl!templates/query/loader.html","tpl!templates/values/item.html","tpl!templates/values/list.html","tpl!templates/workflows/query.html","tpl!templates/workflows/results.html","tpl!templates/workflows/workspace.html"],function(e,t){var i={},n={},o=function(e){return"/"===e.charAt(0)&&(e=e.substr(1)),e=e.replace(/\.\.\//g,""),e.replace(/templates\//,"").replace(/\.html$/,"")},s=[].slice.call(arguments,2);e.each(s,function(e){e.templateId=o(e._moduleName),i[e.templateId]=e});var r=0,a=function(e,i){r++,require([i],function(t){e||(e=t,t=null),l(e,t),r--},function(e){t.debug(e),r--})},l=function(e,t){if("function"==typeof e){if(t=e,!t._moduleName)throw new Error("cannot register anonymous template");e=o(t._moduleName)}else t||(t=e,e=null);switch(typeof t){case"function":n[e]=t;break;case"string":a(e,t);break;default:throw new Error("template must be a function or AMD module")}};return{get:function(e){return n[e]||i[e]},set:function(t,i){e.isArray(t)?e.each(t,function(e){this.set(e)},this):e.isFunction(t)?l(t):e.isObject(t)?e.each(t,function(e,t){this.set(t,e)},this):l(t,i)},ready:function(){return 0===r},clear:function(){n={}}}}),define("cilantro/ui/controls/base",["jquery","underscore","backbone","marionette","../../core"],function(e,t,i,n,o){var s=function(){},r={className:"control",attrNames:["concept","field","operator","value"],attrGetters:{concept:"getConcept",field:"getField",operator:"getOperator",value:"getValue"},attrSetters:{concept:"setConcept",field:"setField",operator:"setOperator",value:"setValue"},_get:function(e,t){var i,n;if(i=this.attrGetters[e]){if(n=this[i])return n.call(this,t);throw new Error("Getter declared, but not defined for "+e)}},_set:function(e,t,i){var n,o;if(n=this.attrSetters[e]){if(o=this[n])return o.call(this,t,i);throw new Error("Setter declared, but not defined for "+e)}},wait:function(){if(!this._waiting){this._waiting=!0;var e=this,t=setTimeout(function(){e.trigger("error")},o.config.get("timeouts.control"));this.on("beforeready error",function(){clearTimeout(t)})}},ready:function(e){e&&this._waiting||(delete this._waiting,this.trigger("beforeready"),this.trigger("ready"))},get:function(e,i){if(t.isObject(e)&&(i=e,e=null),e)return this._get(e,i);for(var n,o={},s=0;st.value[1]?"The lower bound cannot be greater than the upper":void 0}});return{RangeControl:o}}),define("cilantro/ui/controls/date",["underscore","./range"],function(e,t){var i=t.RangeControl.extend({events:function(){return e.extend({"changeDate .range-lower,.range-upper":"_change"},t.RangeControl.prototype.events)},onRender:function(){t.RangeControl.prototype.onRender.apply(this,arguments),this.ui.lowerBound.datepicker({autoclose:!0}),this.ui.upperBound.datepicker({autoclose:!0})},_setPlaceholder:function(e,t){var i=t.replace(/T.*$/,""),n=i.split("-");3===n.length&&(i=""+n[1]+"/"+n[2]+"/"+n[0],e.attr("placeholder",i))},setLowerBoundPlaceholder:function(e){this._setPlaceholder(this.ui.lowerBound,e)},setUpperBoundPlaceholder:function(e){this._setPlaceholder(this.ui.upperBound,e)}});return{DateControl:i}}),define("cilantro/ui/controls/number",["./range"],function(e){var t=e.RangeControl.extend({getLowerBoundValue:function(){var e=this.ui.lowerBound.val().trim();return e?parseFloat(e):void 0},getUpperBoundValue:function(){var e=this.ui.upperBound.val().trim();return e?parseFloat(e):void 0}});return{NumberControl:t}}),define("cilantro/ui/base",["jquery","underscore","marionette"],function(e,t,i){var n=i.ItemView.extend({align:"center",constructor:function(e){if(i.ItemView.prototype.constructor.call(this,e),!this.template)if(this.options.template)this.template=this.options.template;else{var n=[],o=t.result(this.options,"icon")||t.result(this,"icon"),s=t.result(this.options,"message")||t.result(this,"message");o&&n.push(o),s&&n.push(s),this.template=function(){return n.join(" ")}}this.align&&this.$el.css("text-align",this.align)}}),o=n.extend({className:"empty-view",icon:'',message:"No data available"}),s=o.extend({className:"empty-search-view",icon:'',message:"We could not find anything related to your search"}),r=n.extend({className:"error-view",icon:'',message:"Something went awry.."}),a=r.extend({className:"error-overlay-view",template:"base/error-overlay",onRender:function(){e(this.options.target).append(this.$el)}}),l=n.extend({className:"load-view",icon:'',message:"Loading..."});return{EmptyView:o,EmptySearchView:s,ErrorView:r,ErrorOverlayView:a,LoadView:l}}),define("cilantro/ui/paginator",["jquery","underscore","marionette","./base","../constants"],function(e,t,i,n,o){var s=n.EmptyView.extend({message:"No page results"}),r=n.LoadView.extend({message:"Loading page..."}),a=i.ItemView.extend({template:"paginator",className:"paginator",ui:{first:"[data-page=first]",prev:"[data-page=prev]",next:"[data-page=next]",last:"[data-page=last]",pageCount:".page-count",currentPage:".current-page",buttons:"[data-toggle=tooltip]"},modelEvents:{"change:pagecount":"renderPageCount","change:currentpage":"renderCurrentPage"},events:{"click [data-page]":"requestChangePage"},initialize:function(){this._changePage=t.debounce(this.changePage,o.REQUEST_DELAY)},onRender:function(){if(this.ui.buttons.tooltip({animation:!1,placement:"bottom"}),!this.model.pageIsLoading()){this.renderPageCount(this.model,this.model.getPageCount());var e=[this.model].concat(this.model.getCurrentPageStats());this.renderCurrentPage.apply(this,e)}},renderPageCount:function(e,t){this.ui.pageCount.text(t)},renderCurrentPage:function(e,t,i){this.ui.currentPage.text(t),this.ui.first.prop("disabled",!!i.first),this.ui.prev.prop("disabled",!!i.first),this.ui.next.prop("disabled",!!i.last),this.ui.last.prop("disabled",!!i.last),i.first&&(this.ui.first.tooltip("hide"),this.ui.prev.tooltip("hide")),i.last&&(this.ui.next.tooltip("hide"),this.ui.last.tooltip("hide"))},changePage:function(e){switch(e){case"first":return this.model.getFirstPage();case"prev":return this.model.getPreviousPage();case"next":return this.model.getNextPage();case"last":return this.model.getLastPage();default:throw new Error("Unknown paginator direction: "+e)}},requestChangePage:function(t){this._changePage(e(t.currentTarget).data("page"))}}),l=i.ItemView.extend({}),c=i.CollectionView.extend({itemView:l,emptyPage:s,itemViewOptions:function(e,i){return t.defaults({model:e,index:i},this.options)}}),u=i.CollectionView.extend({options:{list:!0},itemView:l,listView:c,emptyView:r,collectionEvents:{"change:currentpage":"showCurrentPage"},getItemView:function(){return this.options.list?this.listView:this.itemView},listViewOptions:function(e){return{collection:e.items}},itemViewOptions:function(e,i){var n={model:e,index:i};return this.options.list&&t.extend(n,this.listViewOptions(e,i)),t.defaults(n,this.options)},showCurrentPage:function(e,t){this.children.each(function(e){e.$el.toggle(e.model.id===t)})}});return{Paginator:a,Page:l,ListingPage:c,PageRoll:u}}),define("cilantro/ui/values",["jquery","underscore","marionette","loglevel","./base","../core","../models","../constants"],function(e,t,i,n,o,s,r,a){var l=i.ItemView.extend({className:"value-item",template:"values/item"}),c=i.ItemView.extend({className:"value-list",template:"values/list",collectionEvents:{add:"reloadText",remove:"reloadText",reset:"reloadText"},ui:{textarea:"textarea"},initialize:function(){t.bindAll(this,"parseText","reloadText"),this._parseText=t.debounce(this.parseText,a.INPUT_DELAY)},reloadText:function(){this.ui.textarea.val(this.collection.pluck("label").join("\n"))},parseText:function(){var i=[],o=this.ui.textarea.val().split("\n");t.each(o,function(t){if(t=e.trim(t)){var o=this.collection.get(t);o||(s.isSupported("2.3.2")?o={label:t}:(o={value:t},n.warn("Serrano 2.3.2+ is required for proper validation of search values"))),i.push(o)}},this),this.collection.reset(i)},onRender:function(){this.ui.textarea.on("input propertychange",this._parseText)}});return{ValueItem:l,ValueList:c}}),define("cilantro/ui/search",["underscore","marionette","../constants"],function(e,t,i){var n=t.ItemView.extend({className:"search",template:"search",options:{placeholder:"Search...",delay:i.INPUT_DELAY},ui:{input:"input"},events:{"input @ui.input":"_triggerSearch"},constructor:function(i){i=i||{};var n=i.delay||e.result(this,"options").delay;this._triggerSearch=e.debounce(this.triggerSearch,n),t.ItemView.prototype.constructor.call(this,i),this.on("search",this.renderInputValue),this.search&&this.on("search",this.search)},onRender:function(){this.ui.input.attr("placeholder",this.options.placeholder);var t=this;e.defer(function(){t._isRendered&&!t.isClosed&&t.ui.input.focus()})},renderInputValue:function(e){this._triggering||this.ui.input.val(e)},triggerSearch:function(){var e=this.ui.input.val();this._triggering=!0,this.trigger("search",e),this._triggering=!1}});return{Search:n}}),define("cilantro/ui/controls/search",["jquery","underscore","marionette","./base","../../models","../../constants","../paginator","../values","../search"],function(e,t,i,n,o,s,r,a,l){var c=o.Page.extend({constructor:function(e,t){(t=t||{}).parse=!0,this.items=new o.Values,o.Page.prototype.constructor.call(this,e,t)},parse:function(e,t){return this.items.reset(e.values,t),delete e.values,e}}),u=o.Paginator.extend({model:c,initialize:function(e,t){t=t||{},this.field=t.field,this.currentUrl=null,o.Paginator.prototype.initialize.call(this,e,t)},url:function(){var t=this.currentUrl||this.field.links.values;return this.urlParams&&(t=t+"?"+e.param(this.urlParams)),t}}),h=i.ItemView.extend({className:"value-item",template:"controls/search/item",ui:{actions:".actions",addButton:".add-item-button",removeButton:".remove-item-button",label:".value-label"},events:{"click .add-item-button":"addItem","click .remove-item-button":"removeItem"},constructor:function(e){e=e||{},(this.values=e.values)&&(this.listenTo(this.values,"add",this.setState),this.listenTo(this.values,"remove",this.setState),this.listenTo(this.values,"reset",this.setState)),i.ItemView.prototype.constructor.call(this,e)},addItem:function(){var e=t.extend(this.model.toJSON(),{valid:!0});this.values.add(e)},removeItem:function(){this.values.remove(this.model)},setState:function(){this.values.get(this.model)?(this.ui.addButton.hide(),this.ui.removeButton.show()):(this.ui.addButton.show(),this.ui.removeButton.hide())},onRender:function(){this.setState(),""===this.ui.label.html()?this.ui.label.html("(empty)"):"null"===this.ui.label.html()&&this.ui.label.html("(null)")}}),d=r.ListingPage.extend({className:"search-value-list",itemView:h}),p=r.PageRoll.extend({listView:d}),f=n.ControlLayout.extend({className:"field-value-search",template:"controls/search/layout",searchPaginator:u,events:{"click [data-action=clear]":"clearValues"},regions:{search:".search-region",paginator:".paginator-region",browse:".browse-region",values:".values-region"},regionViews:{search:l.Search,paginator:r.Paginator,browse:p,values:a.ValueList},initialize:function(){if(!this.collection){this.collection=new o.Values;var e=this;this.collection.url=function(){return e.model.links.values}}this.listenTo(this.collection,"all",this.change),this.valuesPaginator=new this.searchPaginator(null,{field:this.model}),this.valuesPaginator.refresh()},onRender:function(){var e=new this.regionViews.search({model:this.model,placeholder:"Search "+this.model.get("plural_name")+"..."});this.listenTo(e,"search",this.handleSearch);var t=new this.regionViews.browse({collection:this.valuesPaginator,values:this.collection}),i=new this.regionViews.paginator({className:"paginator mini",model:this.valuesPaginator}),n=new this.regionViews.values({collection:this.collection});this.search.show(e),this.browse.show(t),this.paginator.show(i),this.values.show(n)},handleSearch:function(e){this.valuesPaginator.urlParams=e?{query:e}:null,this.valuesPaginator.refresh()},clearValues:function(){this.collection.reset()},getField:function(){return this.model?this.model.id:void 0},getOperator:function(){return"in"},getValue:function(){return this.collection.toJSON()},setValue:function(e){this.collection.set(e,{merge:!1})},validate:function(e){var t=this.collection.any(function(e){return e.get("pending")===!0});if(t)return"The entered "+this.model.get("plural_name")+" are being validated.";var i=[];return this.collection.each(function(e){e.get("valid")===!1&&i.push(e.get("label"))}),i.length?"The following "+this.model.get("plural_name")+" are invalid:
"+i.join("\n")+"
":!e||e.value&&e.value.length?void 0:"At least one value must be selected"}});return{SearchControl:f,SearchItem:h,SearchPage:d,SearchPageRoll:p,SearchPaginator:u}}),define("cilantro/ui/controls/infograph",["jquery","underscore","backbone","marionette","./base"],function(e,t,i,n,o){var s=function(e){return function(i){var n=i.get(e);return t.isString(n)&&(n=n.toLowerCase()),n}},r=i.Model.extend({}),a=i.Collection.extend({model:r,comparator:function(e){return-e.get("count")},sortModelsBy:function(e){var t=e.chartAt(0);"-"===t&&(e=e.slice(1)),this.models=this.sortBy(s(e)),"-"===t&&this.models.reverse(),this.trigger("sort",this)}}),l=n.ItemView.extend({className:"info-bar",template:"controls/infograph/bar",options:{total:null},ui:{bar:".bar",barLabel:".bar-label"},events:{click:"toggleSelected"},modelEvents:{"change:selected":"setSelected","change:visible":"setVisible"},initialize:function(){t.bindAll(this,"onExcludedChange"),this.listenTo(this.model.collection,"change:excluded",this.onExcludedChange) },serializeData:function(){var e=this.model.toJSON(),t=this.getPercentage();return e.width=t,e.percentage=1>t?"<1":parseInt(t),e},onRender:function(){this.setSelected(this.model,!!this.model.get("selected")),""===this.ui.barLabel.html()&&this.ui.barLabel.html("(empty)"),"null"===this.ui.barLabel.html()&&this.ui.barLabel.html("(null)")},getPercentage:function(){return this.model.get("count")/this.options.total*100},toggleSelected:function(){this.model.set("selected",!this.model.get("selected"))},onExcludedChange:function(){this.$el.toggleClass("excluded",this.model.get("excluded"))},setSelected:function(e,t){this.$el.toggleClass("selected",t),t||e.get("visible")!==!1||this.$el.removeClass("filtered").hide()},setVisible:function(e,t){t?this.$el.removeClass("filtered").show():e.get("selected")?this.$el.addClass("filtered"):this.$el.hide()}}),c=o.ControlCollectionView.extend({className:"info-bar-chart",itemView:l,itemViewOptions:function(e){return{model:e,total:this.calcTotal()}},collectionEvents:{change:"change",sort:"sortChildren"},initialize:function(){this.wait();var e=this;this.model.distribution(function(i){e.model.values({limit:0},function(n){var o={};t.each(n.values,function(e){o[e.value]=e.label});var s=t.map(i.data,function(e){var t=e.values[0];return{count:e.count,value:t,label:o[t]}});e.collection.reset(s),e.ready()})})},calcTotal:function(){for(var e=0,t=this.collection.pluck("count"),i=0;i0?"-in":"in"},getValue:function(){return t.map(this.collection.where({selected:!0}),function(e){return e.get("value")})},setValue:function(e){e||(e=[]),this.collection.each(function(t){var i=t.get("value");t.set("selected",e.indexOf(i)>=0)})},setOperator:function(t){"-in"===t&&(this.collection.each(function(e){e.set("excluded",!0)}),e("input[name=exclude]").attr("checked",!0))}}),u=n.ItemView.extend({className:"navbar navbar-toolbar",template:"controls/infograph/toolbar",events:{"keyup [name=filter]":"filterBars","click [name=invert]":"invertSelection","click .sort-value-header, .sort-count-header":"sortBy","change [name=exclude]":"excludeCheckboxChanged"},ui:{toolbar:".btn-toolbar",filterInput:"[name=filter]",invertButton:"[name=invert]",sortValueHeader:".sort-value-header",sortCountHeader:".sort-count-header",excludeCheckbox:"[name=exclude]"},initialize:function(){this.sortDirection="-count"},sortBy:function(e){switch(this.sortDirection="sort-value-header"===e.currentTarget.className?"-value"===this.sortDirection?"value":"-value":"-count"===this.sortDirection?"count":"-count",this.sortDirection){case"-count":this.ui.sortValueHeader.html("Value "),this.ui.sortCountHeader.html("Count ");break;case"count":this.ui.sortValueHeader.html("Value "),this.ui.sortCountHeader.html("Count ");break;case"-value":this.ui.sortValueHeader.html("Value "),this.ui.sortCountHeader.html("Count ");break;case"value":this.ui.sortValueHeader.html("Value "),this.ui.sortCountHeader.html("Count ")}this.collection.sortModelsBy(this.sortDirection)},toggle:function(e){this.ui.filterInput.toggle(e),this.ui.invertButton.toggle(e),this.ui.sortValueHeader.toggle(e),this.ui.sortCountHeader.toggle(e)},filterBars:function(e){var i;t.isString(e)?i=e:(null!==e&&e.stopPropagation(),i=this.ui.filterInput.val());var n=new RegExp(i,"i");this.collection.each(function(e){e.set("visible",!i||n.test(e.get("value")))})},invertSelection:function(){this.collection.each(function(e){(e.get("visible")!==!1||e.get("selected"))&&e.set("selected",!e.get("selected"))}),this.collection.trigger("change")},excludeCheckboxChanged:function(){var e=this.ui.excludeCheckbox.prop("checked");this.collection.each(function(t){t.set("excluded",e,{silent:!0})}),this.collection.trigger("change:excluded")}}),h=o.ControlLayout.extend({template:"controls/infograph/layout",events:{change:"change"},options:{minValuesForToolbar:10},regions:{bars:".bars-region",toolbar:".toolbar-region"},ui:{loading:"[data-target=loading-indicator]"},collectionEvents:{reset:"toggleToolbar"},initialize:function(){t.bindAll(this,"toggleToolbar")},constructor:function(e){e.collection||(e.collection=new a),o.ControlLayout.prototype.constructor.apply(this,arguments),this.barsControl=new c({model:this.model,collection:this.collection});var i=this,n=["set","get","when","ready","wait"],s=function(e){return i[e]=function(){var t=i.barsControl;return t[e].call(t,arguments)},i[e]};t.each(n,function(e){s(e)}),this.listenTo(this.barsControl,"all",function(){var e=arguments[0];("change"===e||"beforeready"===e||"ready"===e)&&this.trigger.apply(this,arguments),"ready"===e&&this.ui.loading.hide()})},toggleToolbar:function(){this.toolbar.currentView&&this.toolbar.currentView.toggle(this.collection.length>=this.options.minValuesForToolbar)},onRender:function(){this.bars.show(this.barsControl),this.toolbar.show(new u({collection:this.collection})),this.toggleToolbar()},validate:function(e){return t.isUndefined(e.value)||0===e.value.length?"Select at least one value":void 0}});return{InfographControl:h}}),define("cilantro/ui/controls/select",["underscore","backbone","marionette","../../core","./base"],function(e,t,i,n,o){var s=i.ItemView.extend({template:function(){},tagName:"option",modelEvents:{"change:selected":"render"},onRender:function(){var e=this.model.get("label");this.$el.text(""===e?"(empty)":"null"===e?"(null)":e),this.$el.attr("value",this.model.get("value")),this.$el.attr("selected",this.model.get("selected"))}}),r=o.ControlCompositeView.extend({className:"selection-list",template:"controls/select/list",itemView:s,itemViewOptions:function(e){return{model:e}},itemViewContainer:".items",ui:{items:".items"},events:{"change .items":"onSelectionChange"},collectionEvents:{reset:"onCollectionSync"},initialize:function(){var e;if(this.wait(),!this.collection){this.collection=new t.Collection,e=n.isSupported("2.3.1")?0:1e3;var i=this;this.model.values({limit:e}).done(function(e){return i.collection.reset(e.values),i.ready()})}this.on("ready",function(){this.change()})},onCollectionSync:function(){this.render()},onSelectionChange:function(){this.change()},getField:function(){return this.model.id},getOperator:function(){return"exact"},getValue:function(){return this.ui.items.val()},setValue:function(e){this.ui.items.val(e)},validate:function(t){return e.isNull(t.value)||e.isUndefined(t.value)?"An option must be selected":void 0}}),a=r.extend({onCollectionSync:function(){this.render()},onSelectionChange:function(){var e=this;this.ui.items.children().each(function(t,i){e.collection.models[t].set("selected",i.selected)}),this.change()},onRender:function(){this.ui.items.attr("multiple",!0)},getOperator:function(){return"in"},getValue:function(){return e.map(this.collection.where({selected:!0}),function(e){return e.get("value")})},setValue:function(e){e||(e=[]),this.collection.each(function(t){t.set("selected",e.indexOf(t.get("value"))>=0)})},validate:function(e){return e.value&&e.value.length?void 0:"At least one option must be selected"}});return{SingleSelectionList:r,MultiSelectionList:a}}),define("cilantro/ui/controls/null",["./base"],function(e){var t=e.Control.extend({template:"controls/null/layout",ui:{select:"[data-target=null-selector]",nullOption:"[data-target=null-option]",notNullOption:"[data-target=not-null-option]"},events:{"change [data-target=null-selector]":"change"},initialize:function(){this.on("ready",this.change)},onRender:function(){this.options.isNullLabel&&this.ui.nullOption.text(this.options.isNullLabel),this.options.isNotNullLabel&&this.ui.notNullOption.text(this.options.isNotNullLabel)},getOperator:function(){return"isnull"},getValue:function(){return"true"===this.ui.select.val()},setValue:function(e){this.ui.select.val(e.toString())}});return{NullSelector:t}}),define("cilantro/ui/controls/text",["underscore","backbone","marionette","../../core","../search","../base","./base"],function(e,t,i,n,o,s,r){var a={a:!0,about:!0,above:!0,across:!0,after:!0,afterwards:!0,again:!0,against:!0,all:!0,almost:!0,alone:!0,along:!0,already:!0,also:!0,although:!0,always:!0,am:!0,among:!0,amongst:!0,amoungst:!0,amount:!0,an:!0,and:!0,another:!0,any:!0,anyhow:!0,anyone:!0,anything:!0,anyway:!0,anywhere:!0,are:!0,around:!0,as:!0,at:!0,back:!0,be:!0,became:!0,because:!0,become:!0,becomes:!0,becoming:!0,been:!0,before:!0,beforehand:!0,behind:!0,being:!0,below:!0,beside:!0,besides:!0,between:!0,beyond:!0,bill:!0,both:!0,bottom:!0,but:!0,by:!0,call:!0,can:!0,cannot:!0,cant:!0,co:!0,con:!0,could:!0,couldnt:!0,cry:!0,de:!0,describe:!0,detail:!0,"do":!0,does:!0,done:!0,down:!0,due:!0,during:!0,each:!0,eg:!0,eight:!0,either:!0,eleven:!0,"else":!0,elsewhere:!0,empty:!0,enough:!0,etc:!0,even:!0,ever:!0,every:!0,everyone:!0,everything:!0,everywhere:!0,except:!0,few:!0,fifteen:!0,fify:!0,fill:!0,find:!0,fire:!0,first:!0,five:!0,"for":!0,former:!0,formerly:!0,forty:!0,found:!0,four:!0,from:!0,front:!0,full:!0,further:!0,get:!0,give:!0,go:!0,had:!0,has:!0,hasnt:!0,have:!0,he:!0,hence:!0,her:!0,here:!0,hereafter:!0,hereby:!0,herein:!0,hereupon:!0,hers:!0,herself:!0,him:!0,himself:!0,his:!0,how:!0,however:!0,hundred:!0,ie:!0,"if":!0,"in":!0,inc:!0,indeed:!0,interest:!0,into:!0,is:!0,it:!0,its:!0,itself:!0,keep:!0,last:!0,latter:!0,latterly:!0,least:!0,less:!0,ltd:!0,made:!0,many:!0,may:!0,me:!0,meanwhile:!0,might:!0,mill:!0,mine:!0,more:!0,moreover:!0,most:!0,mostly:!0,move:!0,much:!0,must:!0,my:!0,myself:!0,name:!0,namely:!0,neither:!0,never:!0,nevertheless:!0,next:!0,nine:!0,no:!0,nobody:!0,none:!0,noone:!0,nor:!0,not:!0,nothing:!0,now:!0,nowhere:!0,of:!0,off:!0,often:!0,on:!0,once:!0,one:!0,only:!0,onto:!0,or:!0,other:!0,others:!0,otherwise:!0,our:!0,ours:!0,ourselves:!0,out:!0,over:!0,own:!0,part:!0,per:!0,perhaps:!0,please:!0,put:!0,rather:!0,re:!0,same:!0,see:!0,seem:!0,seemed:!0,seeming:!0,seems:!0,serious:!0,several:!0,she:!0,should:!0,show:!0,side:!0,since:!0,sincere:!0,six:!0,sixty:!0,so:!0,some:!0,somehow:!0,someone:!0,something:!0,sometime:!0,sometimes:!0,somewhere:!0,still:!0,such:!0,system:!0,take:!0,ten:!0,than:!0,that:!0,the:!0,their:!0,them:!0,themselves:!0,then:!0,thence:!0,there:!0,thereafter:!0,thereby:!0,therefore:!0,therein:!0,thereupon:!0,these:!0,they:!0,thickv:!0,thin:!0,third:!0,"this":!0,those:!0,though:!0,three:!0,through:!0,throughout:!0,thru:!0,thus:!0,to:!0,together:!0,too:!0,top:!0,toward:!0,towards:!0,twelve:!0,twenty:!0,two:!0,un:!0,under:!0,until:!0,up:!0,upon:!0,us:!0,very:!0,via:!0,was:!0,way:!0,we:!0,well:!0,were:!0,what:!0,whatever:!0,when:!0,whence:!0,whenever:!0,where:!0,whereafter:!0,whereas:!0,whereby:!0,wherein:!0,whereupon:!0,wherever:!0,whether:!0,which:!0,"while":!0,whither:!0,who:!0,whoever:!0,whole:!0,whom:!0,whose:!0,why:!0,will:!0,"with":!0,within:!0,without:!0,would:!0,yet:!0,you:!0,your:!0,yours:!0,yourself:!0,yourselves:!0,didnt:!0,doesnt:!0,dont:!0,isnt:!0,wasnt:!0,youre:!0,hes:!0,ive:!0,theyll:!0,whos:!0,wheres:!0,whens:!0,whys:!0,hows:!0,whats:!0,shes:!0,im:!0,thats:!0},l=function(e){for(var t,i=[],n=0;n=0&&e.data.length>0){var o=e.data.match(t),s=document.createElement("span"),r=e.splitText(n);return r.splitText(o[0].length),s.appendChild(r.cloneNode(!0)),s.className=i,r.parentNode.replaceChild(s,r),!0}}else if(e.nodeType===d&&e.childNodes&&!/(script|style)/i.test(e.tagName))for(var a=0;a1&&o.children.push({field:n,type:"and",children:e.map(s,function(e){return{field:n,operator:"icontains",value:e}})}),1===r.length?o.children.push({field:n,operator:"-icontains",value:r[0]}):r.length>1&&o.children.push({field:n,type:"and",children:e.map(r,function(e){return{field:n,operator:"-icontains",value:e}})}),1===a.length?o.children.push({field:n,operator:"icontains",value:a[0]}):a.length>1&&o.children.push({field:n,operator:"iregex",value:"("+a.join("|")+")"}),1===o.children.length&&(o=o.children[0]),o.query=t,o}},set:function(e){this._changing||e.query&&this.search.currentView.ui.input.val(e.query)}});return{TextControl:y}}),define("cilantro/ui/controls/vocab",["jquery","underscore","backbone","marionette","./base","./search","../search","../values","../paginator","../../models"],function(e,t,i,n,o,s,r,a,l,c){var u=i.Collection.extend({_matches:function(e){var t=e.attributes||e;return this.matcher(t)},initialize:function(e,i){this.matcher=i.matcher,this.values=i.collection,this.listenTo(this.values,{change:function(e,t){this._matches(e)?this.add(e,t):this.remove(e,t)},add:function(e,t,i){this._matches(e)&&this.add(e,i)},remove:function(e,t,i){this._matches(e)&&this.remove(e,i)},reset:function(e,i,n){var o=null;o=e&&e.length?t.filter(e,this._matches):[],o&&this.reset(o,n)}})}}),h=c.Value.extend({defaults:{operator:"in"}}),d=c.Values.extend({model:h}),p=a.ValueItem.extend({template:"controls/vocab/bucket-item",ui:{remove:"[data-target=remove]"},events:{"click @ui.remove":"removeItem"},removeItem:function(){this.model.destroy()}}),f=n.CompositeView.extend({className:"vocab-bucket",template:"controls/vocab/bucket",itemView:p,itemViewContainer:"[data-target=items]",options:{name:"Bucket"},ui:{items:"[data-target=items]"},events:{"sortreceive [data-target=items]":"receiveItem"},collectionEvents:{"add remove reset":"renderListState"},serializeData:function(){return{name:this.options.name}},receiveItem:function(e,t){var i=t.item.find("[data-value]").data("value"),n=this.collection.values.findWhere({value:parseInt(i,10)});n.set("operator",this.options.operator)},onRender:function(){this.ui.items.sortable({forcePlaceholderSize:!0,forceHelperSize:!0,placeholder:"placeholder",scroll:!1,opacity:.7,cursor:"move",connectWith:".vocab-bucket [data-target=items]"}),this.renderListState()},renderListState:function(){this.$el.toggleClass("empty",0===this.collection.length)}}),m=n.View.extend({initialize:function(){var e=this.model.get("alt_name").toLowerCase(),t=this.model.get("alt_plural_name").toLowerCase();this.buckets=[{name:"At least one "+e+" must match",operator:"in",collection:new u(null,{collection:this.collection,matcher:function(e){return"in"===e.operator}})},{name:"All the "+t+" must match",operator:"all",collection:new u(null,{collection:this.collection,matcher:function(e){return"all"===e.operator}})},{name:"The combination of "+t+" cannot match",operator:"-all",collection:new u(null,{collection:this.collection,matcher:function(e){return"-all"===e.operator}})},{name:"None of the "+t+" can match",operator:"-in",collection:new u(null,{collection:this.collection,matcher:function(e){return"-in"===e.operator}})}]},render:function(){for(var e=0;et&&(t=Math.max(0,o+1+t)),e.append(i),o>t&&n.eq(t).before(n.last()),e};return{insertAt:e}}),define("plugins/bootstrap-datepicker",["jquery"],function(e){var t=function(t,n){if(this.element=e(t),this.format=i.parseFormat(n.format||this.element.data("date-format")||"mm/dd/yyyy"),this.picker=e(i.template).appendTo("body").on({click:e.proxy(this.click,this)}),this.isInput=this.element.is("input"),this.component=this.element.is(".date")?this.element.find(".add-on"):!1,this.isInput?this.element.on({focus:e.proxy(this.show,this),keyup:e.proxy(this.update,this)}):this.component?this.component.on("click",e.proxy(this.show,this)):this.element.on("click",e.proxy(this.show,this)),this.minViewMode=n.minViewMode||this.element.data("date-minviewmode")||0,"string"==typeof this.minViewMode)switch(this.minViewMode){case"months":this.minViewMode=1;break;case"years":this.minViewMode=2;break;default:this.minViewMode=0}if(this.viewMode=n.viewMode||this.element.data("date-viewmode")||0,"string"==typeof this.viewMode)switch(this.viewMode){case"months":this.viewMode=1;break;case"years":this.viewMode=2;break;default:this.viewMode=0}this.startViewMode=this.viewMode,this.weekStart=n.weekStart||this.element.data("date-weekstart")||0,this.weekEnd=0===this.weekStart?6:this.weekStart-1,this.onRender=n.onRender,this.fillDow(),this.fillMonths(),this.update(),this.showMode()};t.prototype={constructor:t,show:function(t){this.picker.show(),this.height=this.component?this.component.outerHeight():this.element.outerHeight(),this.place(),e(window).on("resize",e.proxy(this.place,this)),t&&(t.stopPropagation(),t.preventDefault()),!this.isInput;var i=this;e(document).on("mousedown",function(t){0==e(t.target).closest(".datepicker").length&&i.hide()}),this.element.trigger({type:"show",date:this.date})},hide:function(){this.picker.hide(),e(window).off("resize",this.place),this.viewMode=this.startViewMode,this.showMode(),this.isInput||e(document).off("mousedown",this.hide),this.element.trigger({type:"hide",date:this.date})},set:function(){var e=i.formatDate(this.date,this.format);this.isInput?this.element.prop("value",e):(this.component&&this.element.find("input").prop("value",e),this.element.data("date",e))},setValue:function(e){this.date="string"==typeof e?i.parseDate(e,this.format):new Date(e),this.set(),this.viewDate=new Date(this.date.getFullYear(),this.date.getMonth(),1,0,0,0,0),this.fill()},place:function(){var e=this.component?this.component.offset():this.element.offset();this.picker.css({top:e.top+this.height,left:e.left})},update:function(e){this.date=i.parseDate("string"==typeof e?e:this.isInput?this.element.prop("value"):this.element.data("date"),this.format),this.viewDate=new Date(this.date.getFullYear(),this.date.getMonth(),1,0,0,0,0),this.fill()},fillDow:function(){for(var e=this.weekStart,t="";e'+i.dates.daysMin[e++%7]+"";t+="",this.picker.find(".datepicker-days thead").append(t)},fillMonths:function(){for(var e="",t=0;12>t;)e+=''+i.dates.monthsShort[t++]+"";this.picker.find(".datepicker-months td").append(e)},fill:function(){var e=new Date(this.viewDate),t=e.getFullYear(),n=e.getMonth(),o=this.date.valueOf();this.picker.find(".datepicker-days th:eq(1)").text(i.dates.months[n]+" "+t);var s=new Date(t,n-1,28,0,0,0,0),r=i.getDaysInMonth(s.getFullYear(),s.getMonth());s.setDate(r),s.setDate(r-(s.getDay()-this.weekStart+7)%7);var a=new Date(s);a.setDate(a.getDate()+42),a=a.valueOf();for(var l,c,u,h=[];s.valueOf()"),l=this.onRender(s),c=s.getFullYear(),u=s.getMonth(),n>u&&c===t||t>c?l+=" old":(u>n&&c===t||c>t)&&(l+=" new"),s.valueOf()===o&&(l+=" active"),h.push(''+s.getDate()+""),s.getDay()===this.weekEnd&&h.push(""),s.setDate(s.getDate()+1);this.picker.find(".datepicker-days tbody").empty().append(h.join(""));var d=this.date.getFullYear(),p=this.picker.find(".datepicker-months").find("th:eq(1)").text(t).end().find("span").removeClass("active");d===t&&p.eq(this.date.getMonth()).addClass("active"),h="",t=10*parseInt(t/10,10);var f=this.picker.find(".datepicker-years").find("th:eq(1)").text(t+"-"+(t+9)).end().find("td");t-=1;for(var m=-1;11>m;m++)h+=''+t+"",t+=1;f.html(h)},click:function(t){t.stopPropagation(),t.preventDefault();var n=e(t.target).closest("span, td, th");if(1===n.length)switch(n[0].nodeName.toLowerCase()){case"th":switch(n[0].className){case"switch":this.showMode(1);break;case"prev":case"next":this.viewDate["set"+i.modes[this.viewMode].navFnc].call(this.viewDate,this.viewDate["get"+i.modes[this.viewMode].navFnc].call(this.viewDate)+i.modes[this.viewMode].navStep*("prev"===n[0].className?-1:1)),this.fill(),this.set()}break;case"span":if(n.is(".month")){var o=n.parent().find("span").index(n);this.viewDate.setMonth(o)}else{var s=parseInt(n.text(),10)||0;this.viewDate.setFullYear(s)}0!==this.viewMode&&(this.date=new Date(this.viewDate),this.element.trigger({type:"changeDate",date:this.date,viewMode:i.modes[this.viewMode].clsName})),this.showMode(-1),this.fill(),this.set();break;case"td":if(n.is(".day")&&!n.is(".disabled")){var r=parseInt(n.text(),10)||1,o=this.viewDate.getMonth();n.is(".old")?o-=1:n.is(".new")&&(o+=1);var s=this.viewDate.getFullYear();this.date=new Date(s,o,r,0,0,0,0),this.viewDate=new Date(s,o,Math.min(28,r),0,0,0,0),this.fill(),this.set(),this.element.trigger({type:"changeDate",date:this.date,viewMode:i.modes[this.viewMode].clsName})}}},mousedown:function(e){e.stopPropagation(),e.preventDefault()},showMode:function(e){e&&(this.viewMode=Math.max(this.minViewMode,Math.min(2,this.viewMode+e))),this.picker.find(">div").hide().filter(".datepicker-"+i.modes[this.viewMode].clsName).show()}},e.fn.datepicker=function(i,n){return this.each(function(){var o=e(this),s=o.data("datepicker"),r="object"==typeof i&&i;s||o.data("datepicker",s=new t(this,e.extend({},e.fn.datepicker.defaults,r))),"string"==typeof i&&s[i](n)})},e.fn.datepicker.defaults={onRender:function(){return""}},e.fn.datepicker.Constructor=t;var i={modes:[{clsName:"days",navFnc:"Month",navStep:1},{clsName:"months",navFnc:"FullYear",navStep:1},{clsName:"years",navFnc:"FullYear",navStep:10}],dates:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sun"],daysMin:["Su","Mo","Tu","We","Th","Fr","Sa","Su"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]},isLeapYear:function(e){return e%4===0&&e%100!==0||e%400===0},getDaysInMonth:function(e,t){return[31,i.isLeapYear(e)?29:28,31,30,31,30,31,31,30,31,30,31][t]},parseFormat:function(e){var t=e.match(/[.\/\-\s].*?/),i=e.split(/\W+/);if(!t||!i||0===i.length)throw new Error("Invalid date format.");return{separator:t,parts:i}},parseDate:function(e,t){var i,n=e.split(t.separator),e=new Date;if(e.setHours(0),e.setMinutes(0),e.setSeconds(0),e.setMilliseconds(0),n.length===t.parts.length){for(var o=e.getFullYear(),s=e.getDate(),r=e.getMonth(),a=0,l=t.parts.length;l>a;a++)switch(i=parseInt(n[a],10)||1,t.parts[a]){case"dd":case"d":s=i,e.setDate(i);break;case"mm":case"m":r=i-1,e.setMonth(i-1);break;case"yy":o=2e3+i,e.setFullYear(2e3+i);break;case"yyyy":o=i,e.setFullYear(i)}e=new Date(o,r,s,0,0,0)}return e},formatDate:function(e,t){var i={d:e.getDate(),m:e.getMonth()+1,yy:e.getFullYear().toString().substring(2),yyyy:e.getFullYear()};i.dd=(i.d<10?"0":"")+i.d,i.mm=(i.m<10?"0":"")+i.m;for(var e=[],n=0,o=t.parts.length;o>n;n++)e.push(i[t.parts[n]]);return e.join(t.separator)},headTemplate:'‹›',contTemplate:''};i.template='"}),define("plugins/jquery-ui",["jquery"],function(e){!function(e,t){function i(t,i){var o,s,r,a=t.nodeName.toLowerCase();return"area"===a?(o=t.parentNode,s=o.name,t.href&&s&&"map"===o.nodeName.toLowerCase()?(r=e("img[usemap=#"+s+"]")[0],!!r&&n(r)):!1):(/input|select|textarea|button|object/.test(a)?!t.disabled:"a"===a?t.href||i:i)&&n(t)}function n(t){return e.expr.filters.visible(t)&&!e(t).parents().addBack().filter(function(){return"hidden"===e.css(this,"visibility")}).length}var o=0,s=/^ui-id-\d+$/;e.ui=e.ui||{},e.extend(e.ui,{version:"1.10.3",keyCode:{BACKSPACE:8,COMMA:188,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,LEFT:37,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SPACE:32,TAB:9,UP:38}}),e.fn.extend({focus:function(t){return function(i,n){return"number"==typeof i?this.each(function(){var t=this; setTimeout(function(){e(t).focus(),n&&n.call(t)},i)}):t.apply(this,arguments)}}(e.fn.focus),scrollParent:function(){var t;return t=e.ui.ie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(e.css(this,"position"))&&/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(e.css(this,"overflow")+e.css(this,"overflow-y")+e.css(this,"overflow-x"))}).eq(0),/fixed/.test(this.css("position"))||!t.length?e(document):t},zIndex:function(i){if(i!==t)return this.css("zIndex",i);if(this.length)for(var n,o,s=e(this[0]);s.length&&s[0]!==document;){if(n=s.css("position"),("absolute"===n||"relative"===n||"fixed"===n)&&(o=parseInt(s.css("zIndex"),10),!isNaN(o)&&0!==o))return o;s=s.parent()}return 0},uniqueId:function(){return this.each(function(){this.id||(this.id="ui-id-"+ ++o)})},removeUniqueId:function(){return this.each(function(){s.test(this.id)&&e(this).removeAttr("id")})}}),e.extend(e.expr[":"],{data:e.expr.createPseudo?e.expr.createPseudo(function(t){return function(i){return!!e.data(i,t)}}):function(t,i,n){return!!e.data(t,n[3])},focusable:function(t){return i(t,!isNaN(e.attr(t,"tabindex")))},tabbable:function(t){var n=e.attr(t,"tabindex"),o=isNaN(n);return(o||n>=0)&&i(t,!o)}}),e("").outerWidth(1).jquery||e.each(["Width","Height"],function(i,n){function o(t,i,n,o){return e.each(s,function(){i-=parseFloat(e.css(t,"padding"+this))||0,n&&(i-=parseFloat(e.css(t,"border"+this+"Width"))||0),o&&(i-=parseFloat(e.css(t,"margin"+this))||0)}),i}var s="Width"===n?["Left","Right"]:["Top","Bottom"],r=n.toLowerCase(),a={innerWidth:e.fn.innerWidth,innerHeight:e.fn.innerHeight,outerWidth:e.fn.outerWidth,outerHeight:e.fn.outerHeight};e.fn["inner"+n]=function(i){return i===t?a["inner"+n].call(this):this.each(function(){e(this).css(r,o(this,i)+"px")})},e.fn["outer"+n]=function(t,i){return"number"!=typeof t?a["outer"+n].call(this,t):this.each(function(){e(this).css(r,o(this,t,!0,i)+"px")})}}),e.fn.addBack||(e.fn.addBack=function(e){return this.add(null==e?this.prevObject:this.prevObject.filter(e))}),e("").data("a-b","a").removeData("a-b").data("a-b")&&(e.fn.removeData=function(t){return function(i){return arguments.length?t.call(this,e.camelCase(i)):t.call(this)}}(e.fn.removeData)),e.ui.ie=!!/msie [\w.]+/.exec(navigator.userAgent.toLowerCase()),e.support.selectstart="onselectstart"in document.createElement("div"),e.fn.extend({disableSelection:function(){return this.bind((e.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(e){e.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}}),e.extend(e.ui,{plugin:{add:function(t,i,n){var o,s=e.ui[t].prototype;for(o in n)s.plugins[o]=s.plugins[o]||[],s.plugins[o].push([i,n[o]])},call:function(e,t,i){var n,o=e.plugins[t];if(o&&e.element[0].parentNode&&11!==e.element[0].parentNode.nodeType)for(n=0;n0?!0:(t[n]=1,o=t[n]>0,t[n]=0,o)}})}(e),function(e,t){var i=0,n=Array.prototype.slice,o=e.cleanData;e.cleanData=function(t){for(var i,n=0;null!=(i=t[n]);n++)try{e(i).triggerHandler("remove")}catch(s){}o(t)},e.widget=function(t,i,n){var o,s,r,a,l={},c=t.split(".")[0];t=t.split(".")[1],o=c+"-"+t,n||(n=i,i=e.Widget),e.expr[":"][o.toLowerCase()]=function(t){return!!e.data(t,o)},e[c]=e[c]||{},s=e[c][t],r=e[c][t]=function(e,t){return this._createWidget?void(arguments.length&&this._createWidget(e,t)):new r(e,t)},e.extend(r,s,{version:n.version,_proto:e.extend({},n),_childConstructors:[]}),a=new i,a.options=e.widget.extend({},a.options),e.each(n,function(t,n){return e.isFunction(n)?void(l[t]=function(){var e=function(){return i.prototype[t].apply(this,arguments)},o=function(e){return i.prototype[t].apply(this,e)};return function(){var t,i=this._super,s=this._superApply;return this._super=e,this._superApply=o,t=n.apply(this,arguments),this._super=i,this._superApply=s,t}}()):void(l[t]=n)}),r.prototype=e.widget.extend(a,{widgetEventPrefix:s?a.widgetEventPrefix:t},l,{constructor:r,namespace:c,widgetName:t,widgetFullName:o}),s?(e.each(s._childConstructors,function(t,i){var n=i.prototype;e.widget(n.namespace+"."+n.widgetName,r,i._proto)}),delete s._childConstructors):i._childConstructors.push(r),e.widget.bridge(t,r)},e.widget.extend=function(i){for(var o,s,r=n.call(arguments,1),a=0,l=r.length;l>a;a++)for(o in r[a])s=r[a][o],r[a].hasOwnProperty(o)&&s!==t&&(i[o]=e.isPlainObject(s)?e.isPlainObject(i[o])?e.widget.extend({},i[o],s):e.widget.extend({},s):s);return i},e.widget.bridge=function(i,o){var s=o.prototype.widgetFullName||i;e.fn[i]=function(r){var a="string"==typeof r,l=n.call(arguments,1),c=this;return r=!a&&l.length?e.widget.extend.apply(null,[r].concat(l)):r,this.each(a?function(){var n,o=e.data(this,s);return o?e.isFunction(o[r])&&"_"!==r.charAt(0)?(n=o[r].apply(o,l),n!==o&&n!==t?(c=n&&n.jquery?c.pushStack(n.get()):n,!1):void 0):e.error("no such method '"+r+"' for "+i+" widget instance"):e.error("cannot call methods on "+i+" prior to initialization; attempted to call method '"+r+"'")}:function(){var t=e.data(this,s);t?t.option(r||{})._init():e.data(this,s,new o(r,this))}),c}},e.Widget=function(){},e.Widget._childConstructors=[],e.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"
",options:{disabled:!1,create:null},_createWidget:function(t,n){n=e(n||this.defaultElement||this)[0],this.element=e(n),this.uuid=i++,this.eventNamespace="."+this.widgetName+this.uuid,this.options=e.widget.extend({},this.options,this._getCreateOptions(),t),this.bindings=e(),this.hoverable=e(),this.focusable=e(),n!==this&&(e.data(n,this.widgetFullName,this),this._on(!0,this.element,{remove:function(e){e.target===n&&this.destroy()}}),this.document=e(n.style?n.ownerDocument:n.document||n),this.window=e(this.document[0].defaultView||this.document[0].parentWindow)),this._create(),this._trigger("create",null,this._getCreateEventData()),this._init()},_getCreateOptions:e.noop,_getCreateEventData:e.noop,_create:e.noop,_init:e.noop,destroy:function(){this._destroy(),this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(e.camelCase(this.widgetFullName)),this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled"),this.bindings.unbind(this.eventNamespace),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus")},_destroy:e.noop,widget:function(){return this.element},option:function(i,n){var o,s,r,a=i;if(0===arguments.length)return e.widget.extend({},this.options);if("string"==typeof i)if(a={},o=i.split("."),i=o.shift(),o.length){for(s=a[i]=e.widget.extend({},this.options[i]),r=0;r=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return!0}})}(e),function(e){function t(e,t,i){return e>t&&t+i>e}function i(e){return/left|right/.test(e.css("float"))||/inline|table-cell/.test(e.css("display"))}e.widget("ui.sortable",e.ui.mouse,{version:"1.10.3",widgetEventPrefix:"sort",ready:!1,options:{appendTo:"parent",axis:!1,connectWith:!1,containment:!1,cursor:"auto",cursorAt:!1,dropOnEmpty:!0,forcePlaceholderSize:!1,forceHelperSize:!1,grid:!1,handle:!1,helper:"original",items:"> *",opacity:!1,placeholder:!1,revert:!1,scroll:!0,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1e3,activate:null,beforeStop:null,change:null,deactivate:null,out:null,over:null,receive:null,remove:null,sort:null,start:null,stop:null,update:null},_create:function(){var e=this.options;this.containerCache={},this.element.addClass("ui-sortable"),this.refresh(),this.floating=this.items.length?"x"===e.axis||i(this.items[0].item):!1,this.offset=this.element.offset(),this._mouseInit(),this.ready=!0},_destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled"),this._mouseDestroy();for(var e=this.items.length-1;e>=0;e--)this.items[e].item.removeData(this.widgetName+"-item");return this},_setOption:function(t,i){"disabled"===t?(this.options[t]=i,this.widget().toggleClass("ui-sortable-disabled",!!i)):e.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(t,i){var n=null,o=!1,s=this;return this.reverting?!1:this.options.disabled||"static"===this.options.type?!1:(this._refreshItems(t),e(t.target).parents().each(function(){return e.data(this,s.widgetName+"-item")===s?(n=e(this),!1):void 0}),e.data(t.target,s.widgetName+"-item")===s&&(n=e(t.target)),n&&(!this.options.handle||i||(e(this.options.handle,n).find("*").addBack().each(function(){this===t.target&&(o=!0)}),o))?(this.currentItem=n,this._removeCurrentsFromItems(),!0):!1)},_mouseStart:function(t,i,n){var o,s,r=this.options;if(this.currentContainer=this,this.refreshPositions(),this.helper=this._createHelper(t),this._cacheHelperProportions(),this._cacheMargins(),this.scrollParent=this.helper.scrollParent(),this.offset=this.currentItem.offset(),this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left},e.extend(this.offset,{click:{left:t.pageX-this.offset.left,top:t.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}),this.helper.css("position","absolute"),this.cssPosition=this.helper.css("position"),this.originalPosition=this._generatePosition(t),this.originalPageX=t.pageX,this.originalPageY=t.pageY,r.cursorAt&&this._adjustOffsetFromHelper(r.cursorAt),this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]},this.helper[0]!==this.currentItem[0]&&this.currentItem.hide(),this._createPlaceholder(),r.containment&&this._setContainment(),r.cursor&&"auto"!==r.cursor&&(s=this.document.find("body"),this.storedCursor=s.css("cursor"),s.css("cursor",r.cursor),this.storedStylesheet=e("").appendTo(s)),r.opacity&&(this.helper.css("opacity")&&(this._storedOpacity=this.helper.css("opacity")),this.helper.css("opacity",r.opacity)),r.zIndex&&(this.helper.css("zIndex")&&(this._storedZIndex=this.helper.css("zIndex")),this.helper.css("zIndex",r.zIndex)),this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName&&(this.overflowOffset=this.scrollParent.offset()),this._trigger("start",t,this._uiHash()),this._preserveHelperProportions||this._cacheHelperProportions(),!n)for(o=this.containers.length-1;o>=0;o--)this.containers[o]._trigger("activate",t,this._uiHash(this));return e.ui.ddmanager&&(e.ui.ddmanager.current=this),e.ui.ddmanager&&!r.dropBehaviour&&e.ui.ddmanager.prepareOffsets(this,t),this.dragging=!0,this.helper.addClass("ui-sortable-helper"),this._mouseDrag(t),!0},_mouseDrag:function(t){var i,n,o,s,r=this.options,a=!1;for(this.position=this._generatePosition(t),this.positionAbs=this._convertPositionTo("absolute"),this.lastPositionAbs||(this.lastPositionAbs=this.positionAbs),this.options.scroll&&(this.scrollParent[0]!==document&&"HTML"!==this.scrollParent[0].tagName?(this.overflowOffset.top+this.scrollParent[0].offsetHeight-t.pageY=0;i--)if(n=this.items[i],o=n.item[0],s=this._intersectsWithPointer(n),s&&n.instance===this.currentContainer&&o!==this.currentItem[0]&&this.placeholder[1===s?"next":"prev"]()[0]!==o&&!e.contains(this.placeholder[0],o)&&("semi-dynamic"===this.options.type?!e.contains(this.element[0],o):!0)){if(this.direction=1===s?"down":"up","pointer"!==this.options.tolerance&&!this._intersectsWithSides(n))break;this._rearrange(t,n),this._trigger("change",t,this._uiHash());break}return this._contactContainers(t),e.ui.ddmanager&&e.ui.ddmanager.drag(this,t),this._trigger("sort",t,this._uiHash()),this.lastPositionAbs=this.positionAbs,!1},_mouseStop:function(t,i){if(t){if(e.ui.ddmanager&&!this.options.dropBehaviour&&e.ui.ddmanager.drop(this,t),this.options.revert){var n=this,o=this.placeholder.offset(),s=this.options.axis,r={};s&&"x"!==s||(r.left=o.left-this.offset.parent.left-this.margins.left+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollLeft)),s&&"y"!==s||(r.top=o.top-this.offset.parent.top-this.margins.top+(this.offsetParent[0]===document.body?0:this.offsetParent[0].scrollTop)),this.reverting=!0,e(this.helper).animate(r,parseInt(this.options.revert,10)||500,function(){n._clear(t)})}else this._clear(t,i);return!1}},cancel:function(){if(this.dragging){this._mouseUp({target:null}),"original"===this.options.helper?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"):this.currentItem.show();for(var t=this.containers.length-1;t>=0;t--)this.containers[t]._trigger("deactivate",null,this._uiHash(this)),this.containers[t].containerCache.over&&(this.containers[t]._trigger("out",null,this._uiHash(this)),this.containers[t].containerCache.over=0)}return this.placeholder&&(this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]),"original"!==this.options.helper&&this.helper&&this.helper[0].parentNode&&this.helper.remove(),e.extend(this,{helper:null,dragging:!1,reverting:!1,_noFinalSort:null}),this.domPosition.prev?e(this.domPosition.prev).after(this.currentItem):e(this.domPosition.parent).prepend(this.currentItem)),this},serialize:function(t){var i=this._getItemsAsjQuery(t&&t.connected),n=[];return t=t||{},e(i).each(function(){var i=(e(t.item||this).attr(t.attribute||"id")||"").match(t.expression||/(.+)[\-=_](.+)/);i&&n.push((t.key||i[1]+"[]")+"="+(t.key&&t.expression?i[1]:i[2]))}),!n.length&&t.key&&n.push(t.key+"="),n.join("&")},toArray:function(t){var i=this._getItemsAsjQuery(t&&t.connected),n=[];return t=t||{},i.each(function(){n.push(e(t.item||this).attr(t.attribute||"id")||"")}),n},_intersectsWith:function(e){var t=this.positionAbs.left,i=t+this.helperProportions.width,n=this.positionAbs.top,o=n+this.helperProportions.height,s=e.left,r=s+e.width,a=e.top,l=a+e.height,c=this.offset.click.top,u=this.offset.click.left,h="x"===this.options.axis||n+c>a&&l>n+c,d="y"===this.options.axis||t+u>s&&r>t+u,p=h&&d;return"pointer"===this.options.tolerance||this.options.forcePointerForContainers||"pointer"!==this.options.tolerance&&this.helperProportions[this.floating?"width":"height"]>e[this.floating?"width":"height"]?p:s0?"down":"up")},_getDragHorizontalDirection:function(){var e=this.positionAbs.left-this.lastPositionAbs.left;return 0!==e&&(e>0?"right":"left")},refresh:function(e){return this._refreshItems(e),this.refreshPositions(),this},_connectWith:function(){var e=this.options;return e.connectWith.constructor===String?[e.connectWith]:e.connectWith},_getItemsAsjQuery:function(t){var i,n,o,s,r=[],a=[],l=this._connectWith();if(l&&t)for(i=l.length-1;i>=0;i--)for(o=e(l[i]),n=o.length-1;n>=0;n--)s=e.data(o[n],this.widgetFullName),s&&s!==this&&!s.options.disabled&&a.push([e.isFunction(s.options.items)?s.options.items.call(s.element):e(s.options.items,s.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),s]);for(a.push([e.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):e(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),this]),i=a.length-1;i>=0;i--)a[i][0].each(function(){r.push(this)});return e(r)},_removeCurrentsFromItems:function(){var t=this.currentItem.find(":data("+this.widgetName+"-item)");this.items=e.grep(this.items,function(e){for(var i=0;i=0;i--)for(o=e(d[i]),n=o.length-1;n>=0;n--)s=e.data(o[n],this.widgetFullName),s&&s!==this&&!s.options.disabled&&(h.push([e.isFunction(s.options.items)?s.options.items.call(s.element[0],t,{item:this.currentItem}):e(s.options.items,s.element),s]),this.containers.push(s));for(i=h.length-1;i>=0;i--)for(r=h[i][1],a=h[i][0],n=0,c=a.length;c>n;n++)l=e(a[n]),l.data(this.widgetName+"-item",r),u.push({item:l,instance:r,width:0,height:0,left:0,top:0})},refreshPositions:function(t){this.offsetParent&&this.helper&&(this.offset.parent=this._getParentOffset());var i,n,o,s;for(i=this.items.length-1;i>=0;i--)n=this.items[i],n.instance!==this.currentContainer&&this.currentContainer&&n.item[0]!==this.currentItem[0]||(o=this.options.toleranceElement?e(this.options.toleranceElement,n.item):n.item,t||(n.width=o.outerWidth(),n.height=o.outerHeight()),s=o.offset(),n.left=s.left,n.top=s.top);if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(i=this.containers.length-1;i>=0;i--)s=this.containers[i].element.offset(),this.containers[i].containerCache.left=s.left,this.containers[i].containerCache.top=s.top,this.containers[i].containerCache.width=this.containers[i].element.outerWidth(),this.containers[i].containerCache.height=this.containers[i].element.outerHeight();return this},_createPlaceholder:function(t){t=t||this;var i,n=t.options;n.placeholder&&n.placeholder.constructor!==String||(i=n.placeholder,n.placeholder={element:function(){var n=t.currentItem[0].nodeName.toLowerCase(),o=e("<"+n+">",t.document[0]).addClass(i||t.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper");return"tr"===n?t.currentItem.children().each(function(){e(" ",t.document[0]).attr("colspan",e(this).attr("colspan")||1).appendTo(o)}):"img"===n&&o.attr("src",t.currentItem.attr("src")),i||o.css("visibility","hidden"),o},update:function(e,o){(!i||n.forcePlaceholderSize)&&(o.height()||o.height(t.currentItem.innerHeight()-parseInt(t.currentItem.css("paddingTop")||0,10)-parseInt(t.currentItem.css("paddingBottom")||0,10)),o.width()||o.width(t.currentItem.innerWidth()-parseInt(t.currentItem.css("paddingLeft")||0,10)-parseInt(t.currentItem.css("paddingRight")||0,10)))}}),t.placeholder=e(n.placeholder.element.call(t.element,t.currentItem)),t.currentItem.after(t.placeholder),n.placeholder.update(t,t.placeholder)},_contactContainers:function(n){var o,s,r,a,l,c,u,h,d,p,f=null,m=null;for(o=this.containers.length-1;o>=0;o--)if(!e.contains(this.currentItem[0],this.containers[o].element[0]))if(this._intersectsWith(this.containers[o].containerCache)){if(f&&e.contains(this.containers[o].element[0],f.element[0]))continue;f=this.containers[o],m=o}else this.containers[o].containerCache.over&&(this.containers[o]._trigger("out",n,this._uiHash(this)),this.containers[o].containerCache.over=0);if(f)if(1===this.containers.length)this.containers[m].containerCache.over||(this.containers[m]._trigger("over",n,this._uiHash(this)),this.containers[m].containerCache.over=1);else{for(r=1e4,a=null,p=f.floating||i(this.currentItem),l=p?"left":"top",c=p?"width":"height",u=this.positionAbs[l]+this.offset.click[l],s=this.items.length-1;s>=0;s--)e.contains(this.containers[m].element[0],this.items[s].item[0])&&this.items[s].item[0]!==this.currentItem[0]&&(!p||t(this.positionAbs.top+this.offset.click.top,this.items[s].top,this.items[s].height))&&(h=this.items[s].item.offset()[l],d=!1,Math.abs(h-u)>Math.abs(h+this.items[s][c]-u)&&(d=!0,h+=this.items[s][c]),Math.abs(h-u)this.containment[2]&&(s=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3]&&(r=this.containment[3]+this.offset.click.top)),o.grid&&(i=this.originalPageY+Math.round((r-this.originalPageY)/o.grid[1])*o.grid[1],r=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-o.grid[1]:i+o.grid[1]:i,n=this.originalPageX+Math.round((s-this.originalPageX)/o.grid[0])*o.grid[0],s=this.containment?n-this.offset.click.left>=this.containment[0]&&n-this.offset.click.left<=this.containment[2]?n:n-this.offset.click.left>=this.containment[0]?n-o.grid[0]:n+o.grid[0]:n)),{top:r-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():l?0:a.scrollTop()),left:s-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():l?0:a.scrollLeft())}},_rearrange:function(e,t,i,n){i?i[0].appendChild(this.placeholder[0]):t.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?t.item[0]:t.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var o=this.counter;this._delay(function(){o===this.counter&&this.refreshPositions(!n)})},_clear:function(e,t){this.reverting=!1;var i,n=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(i in this._storedCSS)("auto"===this._storedCSS[i]||"static"===this._storedCSS[i])&&(this._storedCSS[i]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!t&&n.push(function(e){this._trigger("receive",e,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||t||n.push(function(e){this._trigger("update",e,this._uiHash())}),this!==this.currentContainer&&(t||(n.push(function(e){this._trigger("remove",e,this._uiHash())}),n.push(function(e){return function(t){e._trigger("receive",t,this._uiHash(this))}}.call(this,this.currentContainer)),n.push(function(e){return function(t){e._trigger("update",t,this._uiHash(this))}}.call(this,this.currentContainer)))),i=this.containers.length-1;i>=0;i--)t||n.push(function(e){return function(t){e._trigger("deactivate",t,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over&&(n.push(function(e){return function(t){e._trigger("out",t,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!t){for(this._trigger("beforeStop",e,this._uiHash()),i=0;it?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(t*o-s)*Math.PI/r)+i:a*Math.pow(2,-10*(t-=1))*Math.sin(2*(t*o-s)*Math.PI/r)*.5+n+i},easeInBack:function(e,t,i,n,o,s){return void 0==s&&(s=1.70158),n*(t/=o)*t*((s+1)*t-s)+i},easeOutBack:function(e,t,i,n,o,s){return void 0==s&&(s=1.70158),n*((t=t/o-1)*t*((s+1)*t+s)+1)+i},easeInOutBack:function(e,t,i,n,o,s){return void 0==s&&(s=1.70158),(t/=o/2)<1?n/2*t*t*(((s*=1.525)+1)*t-s)+i:n/2*((t-=2)*t*(((s*=1.525)+1)*t+s)+2)+i},easeInBounce:function(t,i,n,o,s){return o-e.easing.easeOutBounce(t,s-i,0,o,s)+n},easeOutBounce:function(e,t,i,n,o){return(t/=o)<1/2.75?7.5625*n*t*t+i:2/2.75>t?n*(7.5625*(t-=1.5/2.75)*t+.75)+i:2.5/2.75>t?n*(7.5625*(t-=2.25/2.75)*t+.9375)+i:n*(7.5625*(t-=2.625/2.75)*t+.984375)+i},easeInOutBounce:function(t,i,n,o,s){return s/2>i?.5*e.easing.easeInBounce(t,2*i,0,o,s)+n:.5*e.easing.easeOutBounce(t,2*i-s,0,o,s)+.5*o+n}})}),define("plugins/jquery-panels",["jquery"],function(e){var t=function(e,t){t=t||{};var i=e.outerWidth(),n=e.children(".panel-toggle");return t.full!==!1&&n[0]?i-n.outerWidth():i},i=function(t,i){this.element=e(t),this.options=e.extend({side:"left",closed:!1},i),this.opened=!0,this.side="right"===this.options.side||this.element.hasClass("panel-right")?"right":"left",this.element.addClass("panel-"+this.side),(this.options.closed===!0||this.element.hasClass("closed"))&&(this.opened=!1,this.element.addClass("closed").hide());var n=this;return this.element.on("click",".panel-toggle",function(){n.toggle()}),this};i.prototype={constructor:i,open:function(e){if(!this.opened){e=e||{},this.opened=!0;var i={},n={};i[this.side]=-t(this.element,e),n[this.side]=0,this.element.css(i).show().stop(),e.animate!==!1?this.element.animate(n,300):this.element.css(n),this.element.removeClass("closed")}},close:function(e){if(this.opened){e=e||{},this.opened=!1;var i={},n=t(this.element,e);i[this.side]=-n,this.element.stop(),e.animate!==!1?this.element.animate(i,300):this.element.css(i),this.element.addClass("closed")}},toggle:function(){this.opened?this.close():this.open()},isOpen:function(){return this.opened},isClosed:function(){return!this.opened}},e.fn.panel=function(t,n){"object"==typeof t&&(n=t),this.each(function(){var o=e(this),s=o.data("panel");s||(s=new i(this,n),o.data("panel",s)),"string"==typeof t&&s[t](n)})},e.fn.panel.Constructor=i,e(function(){e(".panel").panel(),e("[data-toggle*=panel]").each(function(){var t=e(this);t.on("click",function(){var i;i=t.data("target")?e(t.data("target")):t.parent(),i.panel("toggle")})})})}),define("plugins/jquery-scroller",["jquery","underscore"],function(e,t){var i={container:window,threshold:.75,autofill:!1,resize:!0,trigger:null},n=function(n,o){this.element=e(n),this.options=e.extend({},i,o),this.container=e(o.container);var s=this;return this.options.resize&&e(window).on("resize",t.debounce(function(){s.reset()},100)),this.container.on("scroll",t.debounce(function(){var e=s.container.scrollTop(),t=(this.element.height()-this.container.height())*this.options.threshold;!this.reached&&e>=t&&(this.reached=!0,this.element.trigger("scroller"))},100)),this.options.trigger&&this.element.on("scroller",this.options.trigger),this};n.prototype={constructor:n,reset:function(){this.reached=!1;var e=this.element.height()-this.container.height();return this.options.autofill&&0>e&&this.element.trigger("scroller"),this}},e.fn.scroller=function(t,i){"object"==typeof t&&(i=t),this.each(function(){var o=e(this),s=o.data("scroller");s||(s=new n(this,i),o.data("scroller",s)),"string"==typeof t&&s[t](i)})},e.fn.scroller.Constructor=n}),define("cilantro/ui/core",["../core","./templates","./controls","./dom","bootstrap","plugins/bootstrap-datepicker","plugins/jquery-ui","plugins/jquery-easing","plugins/jquery-panels","plugins/jquery-scroller"],function(e,t,i,n){return e.templates=t,e.controls=i,e.dom=n,e}),define("cilantro/ui/accordion",["underscore","marionette","./base"],function(e,t,i){var n=t.ItemView.extend({tagName:"li",template:"accordion/item"}),o=t.CompositeView.extend({className:"section",itemView:n,template:"accordion/section",itemViewContainer:".items",ui:{heading:".heading"},isEmpty:function(){return 0===this.collection.length},onCompositeCollectionRendered:function(){this.$el.toggle(!this.isEmpty())}}),s=t.CompositeView.extend({className:"group",template:"accordion/group",itemView:o,itemViewContainer:".sections",itemSectionItems:"items",options:{collapsable:!0,collapsed:!0},ui:{heading:".heading",icon:".heading [data-toggle]",inner:".inner"},events:{"click > .heading":"toggleCollapse"},itemViewOptions:function(e,t){return{model:e,index:t,collection:e[this.itemSectionItems]}},initialize:function(){this.collapsed=this.options.collapsed},onRender:function(){this.options.collapsable?this.collapsed&&this.renderCollapsed():(this.renderExpanded(),this.ui.icon.hide())},isEmpty:function(){if(this.collection.length>0)return!1;for(var e=0;e0)return!1;return!0},onCompositeCollectionRendered:function(){if(this.$el.toggle(!this.isEmpty()),this.collection.length>0){var e=this.collection.at(0),t=this.children.findByModel(e);t.ui.heading.toggle(this.collection.length>1||e.id>-1)}},collapse:function(e){this.options.collapsable&&(this.collapsed=!0,this.renderCollapsed(e))},expand:function(e){this.options.collapsable&&(this.collapsed=!1,this.renderExpanded(e))},toggleCollapse:function(e){e.preventDefault(),this.options.collapsable&&(this.collapsed?this.expand({animate:!0}):this.collapse({animate:!0}))},renderState:function(e){this.collapsed&&this.options.collapsable?this.renderCollapsed(e):this.renderExpanded(e)},renderExpanded:function(e){e=e||{},this.$el.removeClass("collapsed"),e.animate?this.ui.inner.collapse("show"):this.ui.inner.addClass("in")},renderCollapsed:function(e){e=e||{},this.$el.addClass("collapsed"),e.animate?this.ui.inner.collapse("hide"):this.ui.inner.removeClass("in")}}),r=t.CollectionView.extend({className:"accordion",itemView:s,emptyView:i.EmptyView,itemGroupSections:"sections",options:{collapsable:!0},itemViewOptions:function(e,t){return{model:e,index:t,collection:e[this.itemGroupSections],collapsable:this.options.collapsable}}});return{Accordion:r,AccordionGroup:s,AccordionSection:o,AccordionItem:n}}),define("cilantro/ui/charts/options",[],function(){var e={chart:{style:{fontFamily:'"Helvetica Neue", Helvetica, Arial, sans-serif'}},title:{text:"",align:"right"},subtitle:{align:"right"},exporting:{enabled:!1},credits:{enabled:!1},tooltip:{formatter:function(){if(this.point.values){var e=[];return e.push(""+this.series.xAxis.axisTitle.text+":"),e.push(this.point.values[0]+"
"),e.push(""+this.series.yAxis.axisTitle.text+":"),e.push(this.y),e.join("")}return this.key},snap:1,useHTML:!0,borderWidth:1,borderRadius:3},plotOptions:{series:{cursor:"pointer",shadow:!1,borderWidth:0,borderColor:"#4b8cf7",turboThreshold:0,animation:{duration:400},color:"#777",states:{select:{color:"#0088cc"},hover:{enabled:!1}}},area:{lineWidth:1,shadow:!1,stacking:"normal",states:{hover:{lineWidth:1}},marker:{enabled:!1,states:{hover:{enabled:!0,radius:5}}},fillOpacity:.1},areaspline:{lineWidth:1,shadow:!1,states:{hover:{lineWidth:1}},marker:{enabled:!1,states:{hover:{enabled:!0}}},fillOpacity:.1},bar:{borderWidth:0,minPointLength:2},column:{borderWidth:0,minPointLength:2},pie:{allowPointSelect:!0,cursor:"pointer",showInLegend:!0},scatter:{marker:{radius:5,states:{hover:{enabled:!1}}},states:{hover:{marker:{enabled:!1}}}}}},t={chart:{defaultSeriesType:"areaspline",margin:[0,0,0,0],height:40},title:{text:"",align:"left",y:0,x:0,style:{fontSize:"8px",color:"#333333"}},credits:{enabled:!1},legend:{enabled:!1},tooltip:{enabled:!1},xAxis:{startOnTick:!0,labels:{enabled:!1}},yAxis:{endOnTick:!0,labels:{enabled:!1}},plotOptions:{series:{lineWidth:1,shadow:!1,states:{hover:{enabled:!1}},marker:{enabled:!1}},areaspline:{fillOpacity:.1},area:{fillOpacity:.1}}};return{defaults:e,sparkline:t}}),define("cilantro/ui/charts/core",["jquery","underscore","backbone","highcharts","../base","../controls","./options"],function(e,t,i,n,o,s,r){var a={el:"chart.renderTo",type:"chart.type",height:"chart.height",width:"chart.width",labelFormatter:"plotOptions.series.dataLabels.formatter",tooltipFormatter:"tooltip.formatter",animate:"plotOptions.series.animation",categories:"xAxis.categories",title:"title.text",subtitle:"subtitle.text",xAxis:"xAxis.title.text",yAxis:"yAxis.title.text",stacking:"plotOptions.series.stacking",legend:"legend.enabled",suffix:"tooltip.valueSuffix",prefix:"tooltip.valuePrefix",series:"series"},l=s.Control.extend({template:function(){},emptyView:o.EmptyView,loadView:o.LoadView,chartOptions:r.defaults,constructor:function(i){t.bindAll(this,"onChartLoaded");var n=t.extend({},i.chart);if(null!==n){var o;for(var r in n)o=n[r],a[r]&&(this.setOption(a[r],o),delete n[r]);this.chartOptions=e.extend(!0,{},this.chartOptions,n)}("undefined"==typeof this.chartOptions.el||null===typeof this.chartOptions.el)&&(this.chartOptions.el=this.el),s.Control.prototype.constructor.call(this,i)},setOption:function(e,t){for(var i,n=this.chartOptions,o=e.split("."),s=o.pop(),r=0;r2)throw new Error("3-dimensional charts are not supported.Specify which field the series applies to.");if(!o)throw new Error("The field instances must be supplied");var r,a,l,c,u,h,d,p=[],f=[],m=o[0],g=o[1];r=m.get("name"),a=m.get("enumerable")||"boolean"===m.get("simple_type"),l="date"===m.get("simple_type")?"datetime":"linear",g?(c=g.get("name"),u=g.get("enumerable")||"boolean"===g.get("simple_type"),h="date"===g.get("simple_type")?"datetime":"linear"):(c="Frequency",u=!1,h="linear"),a&&u?(d="scatter",p.push(" "),f.push(" ")):d=!g||a||u?u?"scatter":"column":"scatter";for(var v,w,b,y={},x=e.clustered,C=e.data,_=0;_"+this.series.name+"
"+r+":"+this.series.xAxis.categories[this.point.x]+"
"+c+":"+this.series.yAxis.categories[this.point.y]}:function(){return""+r+":"+this.series.xAxis.categories[this.point.x]+"
"+c+":"+this.series.yAxis.categories[this.point.y]}:"column"===d&&a?V[1]?function(){return"
"+this.series.name+"

"+r+":"+this.series.xAxis.categories[this.point.x]+"
"+c+":"+t.numberFormat(parseFloat(this.y))}:function(){return""+r+":"+this.series.xAxis.categories[this.point.x]+"
"+c+":"+t.numberFormat(parseFloat(this.y))}:V[1]?function(){return"
"+this.series.name+"

"+r+":"+t.numberFormat(parseFloat(this.x))+"
"+c+":"+t.numberFormat(parseFloat(this.y))}:function(){return""+r+":"+t.numberFormat(parseFloat(this.x))+"
"+c+":"+t.numberFormat(parseFloat(this.y))};var M={clustered:x,chart:{type:d},title:{text:g?""+r+" vs. "+c:""+r+" "+c},series:V,xAxis:{title:{text:r},type:l},yAxis:{title:{text:c},type:h},tooltip:{formatter:D}};return p.length&&(M.xAxis.categories=p),f.length&&(M.yAxis.categories=f),V[1]||(M.legend={enabled:!1}),"scatter"===d&&(M.yAxis.gridLineWidth=0,a||(M.chart.zoomType="xy")),M},s=function(t){for(var i,n,o=[],s=0;s---");for(var e,t=0;t'+e.get("name")+"");return this.$el},getSelected:function(){return this.collection.get(parseInt(this.$el.val()))}});return{FieldAxis:i}}),define("cilantro/ui/charts/editable",["jquery","underscore","./dist","./axis"],function(e,t,i,n){var o=i.FieldChart.extend({template:"charts/editable-chart",toolbarAnimationTime:200,formAnimationTime:300,events:t.extend({"click .fullsize":"toggleExpanded"},i.FieldChart.prototype.events),ui:t.extend({toolbar:".btn-toolbar",fullsizeToggle:".fullsize",form:".editable",xAxis:"[name=x-Axis]",yAxis:"[name=y-Axis]",series:"[name=series]"},i.FieldChart.prototype.ui),onRender:function(){this.options.editable===!1?(this.ui.form.detach(),this.ui.toolbar.detach()):(this.xAxis=new n.FieldAxis({el:this.ui.xAxis,collection:this.collection}),this.yAxis=new n.FieldAxis({el:this.ui.yAxis,collection:this.collection}),this.series=new n.FieldAxis({el:this.ui.series,enumerableOnly:!0,collection:this.collection}),this.model&&(this.model.get("xAxis")&&this.ui.form.hide(),this.model.get("expanded")?this.expand():this.contract()))},customizeOptions:function(t){if(this.ui.status.detach(),this.ui.heading.text(t.title.text),t.title.text="",!t.series[0])return void this.ui.chart.html("

Unfortunately, there is no data to graph here.

");this.ui.form.hide();var i=[];return t.clustered&&i.push("Clustered"),i[0]&&(this.ui.status.text(i.join(", ")).show(),this.ui.heading.append(this.$status)),this.interactive(t)&&this.enableChartEvents(),e.extend(!0,t,this.chartOptions),t.chart.renderTo=this.ui.chart[0],t},changeChart:function(e){e&&e.preventDefault();var t=this;this.collection.when(function(){var i,n,o,s;if((null===e||"undefined"==typeof e)&&(i=t.model.get("xAxis"),i&&t.xAxis.$el.val(i.toString()),n=t.model.get("yAxis"),n&&t.yAxis.$el.val(n.toString()),o=t.model.get("series"),o&&this.series.$el.val(o.toString())),i=t.xAxis.getSelected(),n=t.yAxis.getSelected(),o=t.series.getSelected(),i){var r=t.model.get("_links").distribution.href,a=[i],l="dimension="+i.id;n&&(a.push(n),l=l+"&dimension="+n.id),o&&(s=n?2:1,l=l+"&dimension="+o.id),e&&t.model&&t.model.set({xAxis:i.id,yAxis:n?n.id:null,series:o?o.id:null}),t.update(r,l,a,s)}})},disableSelected:function(t){var i=e(t.target);this.xAxis.el===t.target?(this.yAxis.$("option").prop("disabled",!1),this.series.$("option").prop("disabled",!1)):this.yAxis.el===t.target?(this.xAxis.$("option").prop("disabled",!1),this.series.$("option").prop("disabled",!1)):(this.xAxis.$("option").prop("disabled",!1),this.yAxis.$("option").prop("disabled",!1));var n=i.val();""!==n&&(this.xAxis.el===t.target?(this.yAxis.$("option[value="+n+"]").prop("disabled",!0).val(""),this.series.$("option[value="+n+"]").prop("disabled",!0).val("")):this.yAxis.el===t.target?(this.xAxis.$("option[value="+n+"]").prop("disable",!0).val(""),this.series.$("option[value="+n+"]").prop("disable",!0).val("")):(this.xAxis.$("option[value="+n+"]").prop("disable",!0).val(""),this.yAxis.$("option[value="+n+"]").prop("disable",!0).val("")))},toggleExpanded:function(){var e=this.model.get("expanded");e?this.contract():this.expand(),this.model.save({expanded:!e})},resize:function(){var e=this.ui.chart.width();this.chart&&this.chart.setSize(e,null,!1)},expand:function(){this.$fullsizeToggle.children("i").removeClass("icon-resize-small").addClass("icon-resize-full"),this.$el.addClass("expanded"),this.resize()},contract:function(){this.$fullsizeToggle.children("i").removeClass("icon-resize-full").addClass("icon-resize-small"),this.$el.removeClass("expanded"),this.resize()},hideToolbar:function(){this.ui.toolbar.fadeOut(this.toolbarAnimationTime)},showToolbar:function(){this.ui.toolbar.fadeIn(this.toolbarAnimationTime)},toggleEdit:function(){this.ui.form.is(":visible")?this.ui.form.fadeOut(this.formAnimationTime):this.ui.form.fadeIn(this.formAnimationTime)}});return{EditableFieldChart:o}}),define("cilantro/ui/charts",["underscore","./charts/dist","./charts/axis","./charts/editable"],function(e){var t=Array.prototype.slice.call(arguments,1);return e.extend.apply(e,[{}].concat(t))}),define("cilantro/ui/concept/info",["jquery","underscore","marionette","../core"],function(e,t,i,n){var o=i.ItemView.extend({className:"concept-info",template:"concept/info",ui:{name:".name",category:".category",description:".description",descriptionText:".description .text",descriptionToggle:".description .toggle"},events:{"click .category-link":"onCategoryLinkClick","click @ui.descriptionToggle":"toggleDescription"},initialize:function(){t.bindAll(this,"renderDescriptionToggle"),0===this.model.fields.length&&this.listenToOnce(this.model.fields,"reset",function(){this.render()})},onCategoryLinkClick:function(t){var i=e(t.target);n.panels.concept.triggerSearch(i.text())},serializeData:function(){var e=this.model.toJSON();if(1===this.model.fields.length){var t=this.model.fields.at(0);e.description||(e.description=t.get("description")),e.unit||(e.unit=t.get("unit"))}return e},onRender:function(){t.defer(this.renderDescriptionToggle),e(window).on("resize",this.renderDescriptionToggle)},onClose:function(){e(window).off("resize",this.renderDescriptionToggle)},descriptionOverflows:function(){var e=this.ui.descriptionText.prop("scrollWidth"),t=this.ui.descriptionText.prop("offsetWidth");return e>t},renderDescriptionToggle:function(){var e=this.ui.description.hasClass("ellipsis");this.ui.description.addClass("ellipsis"),this.descriptionOverflows()?(this.ui.descriptionToggle.show(),this.ui.description.toggleClass("ellipsis",e)):(this.ui.descriptionToggle.hide(),this.ui.description.addClass("ellipsis"))},toggleDescription:function(){if(this.ui.description.hasClass("ellipsis")){if(!this.descriptionOverflows())return;this.ui.descriptionToggle.text("read less"),this.ui.description.removeClass("ellipsis")}else this.ui.descriptionToggle.text("read more"),this.ui.description.addClass("ellipsis")}});return{ConceptInfo:o}}),define("cilantro/ui/concept/search",["underscore","../search"],function(e,t){var i=t.Search.extend({className:"concept-search search",options:function(){return e.extend({},t.Search.prototype.options,{placeholder:"Search by name, description, or data..."})},initialize:function(){if(this._request=null,!this.options.handler)throw new Error("no search handler defined")},search:function(e){this._request&&this._request.abort();var t=this.options.handler;e?this._request=this.collection.search(e,function(i){t(e,i)}):t(null,[])}});return{ConceptSearch:i}}),define("cilantro/ui/concept/index",["backbone","../core","../base","../accordion"],function(e,t,i,n){var o=n.AccordionItem.extend({events:{"click a":"click"},initialize:function(){this.listenTo(t,t.CONCEPT_FOCUS,this.toggleFocus)},click:function(e){e.preventDefault(),t.trigger(t.CONCEPT_FOCUS,this.model.id)},toggleFocus:function(e){this.$el.toggleClass("active",e===this.model.id)}}),s=n.AccordionSection.extend({itemView:o,filter:function(e,t){var i=!1;return this.children.each(function(n){!e||t[n.model.id]?(n.$el.show(),i=!0):n.$el.hide()}),this.$el.toggle(i),i}}),r=n.AccordionGroup.extend({itemView:s,filter:function(e,t){var i=!1;return this.children.each(function(n){n.filter(e,t)&&(i=!0)}),e?i?(this.$el.show(),this.expand()):this.$el.hide():(this.$el.show(),this.renderState()),i},find:function(e){var t,i,n;for(t in this.children._views)if(i=this.children._views[t],i.children&&(n=i.children.findByModel(e)))return n}}),a=n.Accordion.extend({className:"concept-index accordion",itemView:r,emptySearchView:i.EmptySearchView,showCollection:function(){this.resetGroups();var e=this;this.groups.each(function(t,i){e.addItemView(t,e.getItemView(t),i)})},getGroup:function(e){if(e.category){for(var t=e.category;t.parent;)t=t.parent;return t}return{id:-1,name:"Other"}},getSection:function(e){return e.category&&e.category.parent?e.category:{id:-1,name:"Other"}},resetGroups:function(){this.groups?this.groups.reset():this.groups=new e.Collection(null,{comparator:"order"});var t=this;this.collection.each(function(e){t.groupModel(e)})},groupModel:function(t){var i=this.getGroup(t.attributes),n=this.getSection(t.attributes),o=this.groups.get(i.id);o||(o=new e.Model(i),o.sections=new e.Collection(null,{comparator:"order"}),this.groups.add(o));var s=o.sections.get(n.id);s||(s=new e.Model(n),s.items=new e.Collection(null,{comparator:"order"}),o.sections.add(s)),s.items.add(t)},filter:function(e,t){var i={};if(e){var n,o,s;for(n=0;nWe could not find anything related to "'+e+'"

'}),this.$el.append(this._emptyView.render().el) +return"relative"!==this.cssPosition||this.scrollParent[0]!==document&&this.scrollParent[0]!==this.offsetParent[0]||(this.offset.relative=this._getRelativeOffset()),this.originalPosition&&(this.containment&&(t.pageX-this.offset.click.leftthis.containment[2]&&(s=this.containment[2]+this.offset.click.left),t.pageY-this.offset.click.top>this.containment[3]&&(r=this.containment[3]+this.offset.click.top)),o.grid&&(i=this.originalPageY+Math.round((r-this.originalPageY)/o.grid[1])*o.grid[1],r=this.containment?i-this.offset.click.top>=this.containment[1]&&i-this.offset.click.top<=this.containment[3]?i:i-this.offset.click.top>=this.containment[1]?i-o.grid[1]:i+o.grid[1]:i,n=this.originalPageX+Math.round((s-this.originalPageX)/o.grid[0])*o.grid[0],s=this.containment?n-this.offset.click.left>=this.containment[0]&&n-this.offset.click.left<=this.containment[2]?n:n-this.offset.click.left>=this.containment[0]?n-o.grid[0]:n+o.grid[0]:n)),{top:r-this.offset.click.top-this.offset.relative.top-this.offset.parent.top+("fixed"===this.cssPosition?-this.scrollParent.scrollTop():l?0:a.scrollTop()),left:s-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+("fixed"===this.cssPosition?-this.scrollParent.scrollLeft():l?0:a.scrollLeft())}},_rearrange:function(e,t,i,n){i?i[0].appendChild(this.placeholder[0]):t.item[0].parentNode.insertBefore(this.placeholder[0],"down"===this.direction?t.item[0]:t.item[0].nextSibling),this.counter=this.counter?++this.counter:1;var o=this.counter;this._delay(function(){o===this.counter&&this.refreshPositions(!n)})},_clear:function(e,t){this.reverting=!1;var i,n=[];if(!this._noFinalSort&&this.currentItem.parent().length&&this.placeholder.before(this.currentItem),this._noFinalSort=null,this.helper[0]===this.currentItem[0]){for(i in this._storedCSS)("auto"===this._storedCSS[i]||"static"===this._storedCSS[i])&&(this._storedCSS[i]="");this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper")}else this.currentItem.show();for(this.fromOutside&&!t&&n.push(function(e){this._trigger("receive",e,this._uiHash(this.fromOutside))}),!this.fromOutside&&this.domPosition.prev===this.currentItem.prev().not(".ui-sortable-helper")[0]&&this.domPosition.parent===this.currentItem.parent()[0]||t||n.push(function(e){this._trigger("update",e,this._uiHash())}),this!==this.currentContainer&&(t||(n.push(function(e){this._trigger("remove",e,this._uiHash())}),n.push(function(e){return function(t){e._trigger("receive",t,this._uiHash(this))}}.call(this,this.currentContainer)),n.push(function(e){return function(t){e._trigger("update",t,this._uiHash(this))}}.call(this,this.currentContainer)))),i=this.containers.length-1;i>=0;i--)t||n.push(function(e){return function(t){e._trigger("deactivate",t,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over&&(n.push(function(e){return function(t){e._trigger("out",t,this._uiHash(this))}}.call(this,this.containers[i])),this.containers[i].containerCache.over=0);if(this.storedCursor&&(this.document.find("body").css("cursor",this.storedCursor),this.storedStylesheet.remove()),this._storedOpacity&&this.helper.css("opacity",this._storedOpacity),this._storedZIndex&&this.helper.css("zIndex","auto"===this._storedZIndex?"":this._storedZIndex),this.dragging=!1,this.cancelHelperRemoval){if(!t){for(this._trigger("beforeStop",e,this._uiHash()),i=0;it?-.5*a*Math.pow(2,10*(t-=1))*Math.sin(2*(t*o-s)*Math.PI/r)+i:a*Math.pow(2,-10*(t-=1))*Math.sin(2*(t*o-s)*Math.PI/r)*.5+n+i},easeInBack:function(e,t,i,n,o,s){return void 0==s&&(s=1.70158),n*(t/=o)*t*((s+1)*t-s)+i},easeOutBack:function(e,t,i,n,o,s){return void 0==s&&(s=1.70158),n*((t=t/o-1)*t*((s+1)*t+s)+1)+i},easeInOutBack:function(e,t,i,n,o,s){return void 0==s&&(s=1.70158),(t/=o/2)<1?n/2*t*t*(((s*=1.525)+1)*t-s)+i:n/2*((t-=2)*t*(((s*=1.525)+1)*t+s)+2)+i},easeInBounce:function(t,i,n,o,s){return o-e.easing.easeOutBounce(t,s-i,0,o,s)+n},easeOutBounce:function(e,t,i,n,o){return(t/=o)<1/2.75?7.5625*n*t*t+i:2/2.75>t?n*(7.5625*(t-=1.5/2.75)*t+.75)+i:2.5/2.75>t?n*(7.5625*(t-=2.25/2.75)*t+.9375)+i:n*(7.5625*(t-=2.625/2.75)*t+.984375)+i},easeInOutBounce:function(t,i,n,o,s){return s/2>i?.5*e.easing.easeInBounce(t,2*i,0,o,s)+n:.5*e.easing.easeOutBounce(t,2*i-s,0,o,s)+.5*o+n}})}),define("plugins/jquery-panels",["jquery"],function(e){var t=function(e,t){t=t||{};var i=e.outerWidth(),n=e.children(".panel-toggle");return t.full!==!1&&n[0]?i-n.outerWidth():i},i=function(t,i){this.element=e(t),this.options=e.extend({side:"left",closed:!1},i),this.opened=!0,this.side="right"===this.options.side||this.element.hasClass("panel-right")?"right":"left",this.element.addClass("panel-"+this.side),(this.options.closed===!0||this.element.hasClass("closed"))&&(this.opened=!1,this.element.addClass("closed").hide());var n=this;return this.element.on("click",".panel-toggle",function(){n.toggle()}),this};i.prototype={constructor:i,open:function(e){if(!this.opened){e=e||{},this.opened=!0;var i={},n={};i[this.side]=-t(this.element,e),n[this.side]=0,this.element.css(i).show().stop(),e.animate!==!1?this.element.animate(n,300):this.element.css(n),this.element.removeClass("closed")}},close:function(e){if(this.opened){e=e||{},this.opened=!1;var i={},n=t(this.element,e);i[this.side]=-n,this.element.stop(),e.animate!==!1?this.element.animate(i,300):this.element.css(i),this.element.addClass("closed")}},toggle:function(){this.opened?this.close():this.open()},isOpen:function(){return this.opened},isClosed:function(){return!this.opened}},e.fn.panel=function(t,n){"object"==typeof t&&(n=t),this.each(function(){var o=e(this),s=o.data("panel");s||(s=new i(this,n),o.data("panel",s)),"string"==typeof t&&s[t](n)})},e.fn.panel.Constructor=i,e(function(){e(".panel").panel(),e("[data-toggle*=panel]").each(function(){var t=e(this);t.on("click",function(){var i;i=t.data("target")?e(t.data("target")):t.parent(),i.panel("toggle")})})})}),define("plugins/jquery-scroller",["jquery","underscore"],function(e,t){var i={container:window,threshold:.75,autofill:!1,resize:!0,trigger:null},n=function(n,o){this.element=e(n),this.options=e.extend({},i,o),this.container=e(o.container);var s=this;return this.options.resize&&e(window).on("resize",t.debounce(function(){s.reset()},100)),this.container.on("scroll",t.debounce(function(){var e=s.container.scrollTop(),t=(this.element.height()-this.container.height())*this.options.threshold;!this.reached&&e>=t&&(this.reached=!0,this.element.trigger("scroller"))},100)),this.options.trigger&&this.element.on("scroller",this.options.trigger),this};n.prototype={constructor:n,reset:function(){this.reached=!1;var e=this.element.height()-this.container.height();return this.options.autofill&&0>e&&this.element.trigger("scroller"),this}},e.fn.scroller=function(t,i){"object"==typeof t&&(i=t),this.each(function(){var o=e(this),s=o.data("scroller");s||(s=new n(this,i),o.data("scroller",s)),"string"==typeof t&&s[t](i)})},e.fn.scroller.Constructor=n}),define("cilantro/ui/core",["../core","./templates","./controls","./dom","bootstrap","plugins/bootstrap-datepicker","plugins/jquery-ui","plugins/jquery-easing","plugins/jquery-panels","plugins/jquery-scroller"],function(e,t,i,n){return e.templates=t,e.controls=i,e.dom=n,e}),define("cilantro/ui/accordion",["underscore","marionette","./base"],function(e,t,i){var n=t.ItemView.extend({tagName:"li",template:"accordion/item"}),o=t.CompositeView.extend({className:"section",itemView:n,template:"accordion/section",itemViewContainer:".items",ui:{heading:".heading"},isEmpty:function(){return 0===this.collection.length},onCompositeCollectionRendered:function(){this.$el.toggle(!this.isEmpty())}}),s=t.CompositeView.extend({className:"group",template:"accordion/group",itemView:o,itemViewContainer:".sections",itemSectionItems:"items",options:{collapsable:!0,collapsed:!0},ui:{heading:".heading",icon:".heading [data-toggle]",inner:".inner"},events:{"click > .heading":"toggleCollapse"},itemViewOptions:function(e,t){return{model:e,index:t,collection:e[this.itemSectionItems]}},initialize:function(){this.collapsed=this.options.collapsed},onRender:function(){this.options.collapsable?this.collapsed&&this.renderCollapsed():(this.renderExpanded(),this.ui.icon.hide())},isEmpty:function(){if(this.collection.length>0)return!1;for(var e=0;e0)return!1;return!0},onCompositeCollectionRendered:function(){if(this.$el.toggle(!this.isEmpty()),this.collection.length>0){var e=this.collection.at(0),t=this.children.findByModel(e);t.ui.heading.toggle(this.collection.length>1||e.id>-1)}},collapse:function(e){this.options.collapsable&&(this.collapsed=!0,this.renderCollapsed(e))},expand:function(e){this.options.collapsable&&(this.collapsed=!1,this.renderExpanded(e))},toggleCollapse:function(e){e.preventDefault(),this.options.collapsable&&(this.collapsed?this.expand({animate:!0}):this.collapse({animate:!0}))},renderState:function(e){this.collapsed&&this.options.collapsable?this.renderCollapsed(e):this.renderExpanded(e)},renderExpanded:function(e){e=e||{},this.$el.removeClass("collapsed"),e.animate?this.ui.inner.collapse("show"):this.ui.inner.addClass("in")},renderCollapsed:function(e){e=e||{},this.$el.addClass("collapsed"),e.animate?this.ui.inner.collapse("hide"):this.ui.inner.removeClass("in")}}),r=t.CollectionView.extend({className:"accordion",itemView:s,emptyView:i.EmptyView,itemGroupSections:"sections",options:{collapsable:!0},itemViewOptions:function(e,t){return{model:e,index:t,collection:e[this.itemGroupSections],collapsable:this.options.collapsable}}});return{Accordion:r,AccordionGroup:s,AccordionSection:o,AccordionItem:n}}),define("cilantro/ui/charts/options",[],function(){var e={chart:{style:{fontFamily:'"Helvetica Neue", Helvetica, Arial, sans-serif'}},title:{text:"",align:"right"},subtitle:{align:"right"},exporting:{enabled:!1},credits:{enabled:!1},tooltip:{formatter:function(){if(this.point.values){var e=[];return e.push(""+this.series.xAxis.axisTitle.text+":"),e.push(this.point.values[0]+"
"),e.push(""+this.series.yAxis.axisTitle.text+":"),e.push(this.y),e.join("")}return this.key},snap:1,useHTML:!0,borderWidth:1,borderRadius:3},plotOptions:{series:{cursor:"pointer",shadow:!1,borderWidth:0,borderColor:"#4b8cf7",turboThreshold:0,animation:{duration:400},color:"#777",states:{select:{color:"#0088cc"},hover:{enabled:!1}}},area:{lineWidth:1,shadow:!1,stacking:"normal",states:{hover:{lineWidth:1}},marker:{enabled:!1,states:{hover:{enabled:!0,radius:5}}},fillOpacity:.1},areaspline:{lineWidth:1,shadow:!1,states:{hover:{lineWidth:1}},marker:{enabled:!1,states:{hover:{enabled:!0}}},fillOpacity:.1},bar:{borderWidth:0,minPointLength:2},column:{borderWidth:0,minPointLength:2},pie:{allowPointSelect:!0,cursor:"pointer",showInLegend:!0},scatter:{marker:{radius:5,states:{hover:{enabled:!1}}},states:{hover:{marker:{enabled:!1}}}}}},t={chart:{defaultSeriesType:"areaspline",margin:[0,0,0,0],height:40},title:{text:"",align:"left",y:0,x:0,style:{fontSize:"8px",color:"#333333"}},credits:{enabled:!1},legend:{enabled:!1},tooltip:{enabled:!1},xAxis:{startOnTick:!0,labels:{enabled:!1}},yAxis:{endOnTick:!0,labels:{enabled:!1}},plotOptions:{series:{lineWidth:1,shadow:!1,states:{hover:{enabled:!1}},marker:{enabled:!1}},areaspline:{fillOpacity:.1},area:{fillOpacity:.1}}};return{defaults:e,sparkline:t}}),define("cilantro/ui/charts/core",["jquery","underscore","backbone","highcharts","../base","../controls","./options"],function(e,t,i,n,o,s,r){var a={el:"chart.renderTo",type:"chart.type",height:"chart.height",width:"chart.width",labelFormatter:"plotOptions.series.dataLabels.formatter",tooltipFormatter:"tooltip.formatter",animate:"plotOptions.series.animation",categories:"xAxis.categories",title:"title.text",subtitle:"subtitle.text",xAxis:"xAxis.title.text",yAxis:"yAxis.title.text",stacking:"plotOptions.series.stacking",legend:"legend.enabled",suffix:"tooltip.valueSuffix",prefix:"tooltip.valuePrefix",series:"series"},l=s.Control.extend({template:function(){},emptyView:o.EmptyView,loadView:o.LoadView,chartOptions:r.defaults,constructor:function(i){t.bindAll(this,"onChartLoaded");var n=t.extend({},i.chart);if(null!==n){var o;for(var r in n)o=n[r],a[r]&&(this.setOption(a[r],o),delete n[r]);this.chartOptions=e.extend(!0,{},this.chartOptions,n)}("undefined"==typeof this.chartOptions.el||null===typeof this.chartOptions.el)&&(this.chartOptions.el=this.el),s.Control.prototype.constructor.call(this,i)},setOption:function(e,t){for(var i,n=this.chartOptions,o=e.split("."),s=o.pop(),r=0;r2)throw new Error("3-dimensional charts are not supported.Specify which field the series applies to.");if(!o)throw new Error("The field instances must be supplied");var r,a,l,c,u,h,d,p=[],f=[],m=o[0],g=o[1];r=m.get("name"),a=m.get("enumerable")||"boolean"===m.get("simple_type"),l="date"===m.get("simple_type")?"datetime":"linear",g?(c=g.get("name"),u=g.get("enumerable")||"boolean"===g.get("simple_type"),h="date"===g.get("simple_type")?"datetime":"linear"):(c="Frequency",u=!1,h="linear"),a&&u?(d="scatter",p.push(" "),f.push(" ")):d=!g||a||u?u?"scatter":"column":"scatter";for(var v,w,b,y={},x=e.clustered,C=e.data,_=0;_"+this.series.name+"
"+r+":"+this.series.xAxis.categories[this.point.x]+"
"+c+":"+this.series.yAxis.categories[this.point.y]}:function(){return""+r+":"+this.series.xAxis.categories[this.point.x]+"
"+c+":"+this.series.yAxis.categories[this.point.y]}:"column"===d&&a?V[1]?function(){return"
"+this.series.name+"

"+r+":"+this.series.xAxis.categories[this.point.x]+"
"+c+":"+t.numberFormat(parseFloat(this.y))}:function(){return""+r+":"+this.series.xAxis.categories[this.point.x]+"
"+c+":"+t.numberFormat(parseFloat(this.y))}:V[1]?function(){return"
"+this.series.name+"

"+r+":"+t.numberFormat(parseFloat(this.x))+"
"+c+":"+t.numberFormat(parseFloat(this.y))}:function(){return""+r+":"+t.numberFormat(parseFloat(this.x))+"
"+c+":"+t.numberFormat(parseFloat(this.y))};var M={clustered:x,chart:{type:d},title:{text:g?""+r+" vs. "+c:""+r+" "+c},series:V,xAxis:{title:{text:r},type:l},yAxis:{title:{text:c},type:h},tooltip:{formatter:D}};return p.length&&(M.xAxis.categories=p),f.length&&(M.yAxis.categories=f),V[1]||(M.legend={enabled:!1}),"scatter"===d&&(M.yAxis.gridLineWidth=0,a||(M.chart.zoomType="xy")),M},s=function(t){for(var i,n,o=[],s=0;s---");for(var e,t=0;t'+e.get("name")+"");return this.$el},getSelected:function(){return this.collection.get(parseInt(this.$el.val()))}});return{FieldAxis:i}}),define("cilantro/ui/charts/editable",["jquery","underscore","./dist","./axis"],function(e,t,i,n){var o=i.FieldChart.extend({template:"charts/editable-chart",toolbarAnimationTime:200,formAnimationTime:300,events:t.extend({"click .fullsize":"toggleExpanded"},i.FieldChart.prototype.events),ui:t.extend({toolbar:".btn-toolbar",fullsizeToggle:".fullsize",form:".editable",xAxis:"[name=x-Axis]",yAxis:"[name=y-Axis]",series:"[name=series]"},i.FieldChart.prototype.ui),onRender:function(){this.options.editable===!1?(this.ui.form.detach(),this.ui.toolbar.detach()):(this.xAxis=new n.FieldAxis({el:this.ui.xAxis,collection:this.collection}),this.yAxis=new n.FieldAxis({el:this.ui.yAxis,collection:this.collection}),this.series=new n.FieldAxis({el:this.ui.series,enumerableOnly:!0,collection:this.collection}),this.model&&(this.model.get("xAxis")&&this.ui.form.hide(),this.model.get("expanded")?this.expand():this.contract()))},customizeOptions:function(t){if(this.ui.status.detach(),this.ui.heading.text(t.title.text),t.title.text="",!t.series[0])return void this.ui.chart.html("

Unfortunately, there is no data to graph here.

");this.ui.form.hide();var i=[];return t.clustered&&i.push("Clustered"),i[0]&&(this.ui.status.text(i.join(", ")).show(),this.ui.heading.append(this.$status)),this.interactive(t)&&this.enableChartEvents(),e.extend(!0,t,this.chartOptions),t.chart.renderTo=this.ui.chart[0],t},changeChart:function(e){e&&e.preventDefault();var t=this;this.collection.when(function(){var i,n,o,s;if((null===e||"undefined"==typeof e)&&(i=t.model.get("xAxis"),i&&t.xAxis.$el.val(i.toString()),n=t.model.get("yAxis"),n&&t.yAxis.$el.val(n.toString()),o=t.model.get("series"),o&&this.series.$el.val(o.toString())),i=t.xAxis.getSelected(),n=t.yAxis.getSelected(),o=t.series.getSelected(),i){var r=t.model.get("_links").distribution.href,a=[i],l="dimension="+i.id;n&&(a.push(n),l=l+"&dimension="+n.id),o&&(s=n?2:1,l=l+"&dimension="+o.id),e&&t.model&&t.model.set({xAxis:i.id,yAxis:n?n.id:null,series:o?o.id:null}),t.update(r,l,a,s)}})},disableSelected:function(t){var i=e(t.target);this.xAxis.el===t.target?(this.yAxis.$("option").prop("disabled",!1),this.series.$("option").prop("disabled",!1)):this.yAxis.el===t.target?(this.xAxis.$("option").prop("disabled",!1),this.series.$("option").prop("disabled",!1)):(this.xAxis.$("option").prop("disabled",!1),this.yAxis.$("option").prop("disabled",!1));var n=i.val();""!==n&&(this.xAxis.el===t.target?(this.yAxis.$("option[value="+n+"]").prop("disabled",!0).val(""),this.series.$("option[value="+n+"]").prop("disabled",!0).val("")):this.yAxis.el===t.target?(this.xAxis.$("option[value="+n+"]").prop("disable",!0).val(""),this.series.$("option[value="+n+"]").prop("disable",!0).val("")):(this.xAxis.$("option[value="+n+"]").prop("disable",!0).val(""),this.yAxis.$("option[value="+n+"]").prop("disable",!0).val("")))},toggleExpanded:function(){var e=this.model.get("expanded");e?this.contract():this.expand(),this.model.save({expanded:!e})},resize:function(){var e=this.ui.chart.width();this.chart&&this.chart.setSize(e,null,!1)},expand:function(){this.$fullsizeToggle.children("i").removeClass("icon-resize-small").addClass("icon-resize-full"),this.$el.addClass("expanded"),this.resize()},contract:function(){this.$fullsizeToggle.children("i").removeClass("icon-resize-full").addClass("icon-resize-small"),this.$el.removeClass("expanded"),this.resize()},hideToolbar:function(){this.ui.toolbar.fadeOut(this.toolbarAnimationTime)},showToolbar:function(){this.ui.toolbar.fadeIn(this.toolbarAnimationTime)},toggleEdit:function(){this.ui.form.is(":visible")?this.ui.form.fadeOut(this.formAnimationTime):this.ui.form.fadeIn(this.formAnimationTime)}});return{EditableFieldChart:o}}),define("cilantro/ui/charts",["underscore","./charts/dist","./charts/axis","./charts/editable"],function(e){var t=Array.prototype.slice.call(arguments,1);return e.extend.apply(e,[{}].concat(t))}),define("cilantro/ui/concept/info",["jquery","underscore","marionette","../core"],function(e,t,i,n){var o=i.ItemView.extend({className:"concept-info",template:"concept/info",ui:{name:".name",category:".category",description:".description",descriptionText:".description .text",descriptionToggle:".description .toggle"},events:{"click .category-link":"onCategoryLinkClick","click @ui.descriptionToggle":"toggleDescription"},initialize:function(){t.bindAll(this,"renderDescriptionToggle"),0===this.model.fields.length&&this.listenToOnce(this.model.fields,"reset",function(){this.render()})},onCategoryLinkClick:function(t){var i=e(t.target);n.panels.concept.triggerSearch(i.text())},serializeData:function(){var e=this.model.toJSON();if(1===this.model.fields.length){var t=this.model.fields.at(0);e.description||(e.description=t.get("description")),e.unit||(e.unit=t.get("unit"))}return e},onRender:function(){t.defer(this.renderDescriptionToggle),e(window).on("resize",this.renderDescriptionToggle)},onClose:function(){e(window).off("resize",this.renderDescriptionToggle)},descriptionOverflows:function(){var e=this.ui.descriptionText.prop("scrollWidth"),t=this.ui.descriptionText.prop("offsetWidth");return e>t},renderDescriptionToggle:function(){var e=this.ui.description.hasClass("ellipsis");this.ui.description.addClass("ellipsis"),this.descriptionOverflows()?(this.ui.descriptionToggle.show(),this.ui.description.toggleClass("ellipsis",e)):(this.ui.descriptionToggle.hide(),this.ui.description.addClass("ellipsis"))},toggleDescription:function(){if(this.ui.description.hasClass("ellipsis")){if(!this.descriptionOverflows())return;this.ui.descriptionToggle.text("read less"),this.ui.description.removeClass("ellipsis")}else this.ui.descriptionToggle.text("read more"),this.ui.description.addClass("ellipsis")}});return{ConceptInfo:o}}),define("cilantro/ui/concept/search",["underscore","../search"],function(e,t){var i=t.Search.extend({className:"concept-search search",options:function(){return e.extend({},t.Search.prototype.options,{placeholder:"Search by name, description, or data..."})},initialize:function(){if(this._request=null,!this.options.handler)throw new Error("no search handler defined")},search:function(e){this._request&&this._request.abort();var t=this.options.handler;e?this._request=this.collection.search(e,function(i){t(e,i)}):t(null,[])}});return{ConceptSearch:i}}),define("cilantro/ui/concept/index",["backbone","../core","../base","../accordion"],function(e,t,i,n){var o=n.AccordionItem.extend({events:{"click a":"click"},initialize:function(){this.listenTo(t,t.CONCEPT_FOCUS,this.toggleFocus)},click:function(e){e.preventDefault(),t.trigger(t.CONCEPT_FOCUS,this.model.id)},toggleFocus:function(e){this.$el.toggleClass("active",e===this.model.id)}}),s=n.AccordionSection.extend({itemView:o,filter:function(e,t){var i=!1;return this.children.each(function(n){!e||t[n.model.id]?(n.$el.show(),i=!0):n.$el.hide()}),this.$el.toggle(i),i}}),r=n.AccordionGroup.extend({itemView:s,filter:function(e,t){var i=!1;return this.children.each(function(n){n.filter(e,t)&&(i=!0)}),e?i?(this.$el.show(),this.expand()):this.$el.hide():(this.$el.show(),this.renderState()),i},find:function(e){var t,i,n;for(t in this.children._views)if(i=this.children._views[t],i.children&&(n=i.children.findByModel(e)))return n}}),a=n.Accordion.extend({className:"concept-index accordion",itemView:r,emptySearchView:i.EmptySearchView,showCollection:function(){this.resetGroups();var e=this;this.groups.each(function(t,i){e.addItemView(t,e.getItemView(t),i)})},getGroup:function(e){if(e.category){for(var t=e.category;t.parent;)t=t.parent;return t}return{id:-1,name:"Other"}},getSection:function(e){return e.category&&e.category.parent?e.category:{id:-1,name:"Other"}},resetGroups:function(){this.groups?this.groups.reset():this.groups=new e.Collection(null,{comparator:"order"});var t=this;this.collection.each(function(e){t.groupModel(e)})},groupModel:function(t){var i=this.getGroup(t.attributes),n=this.getSection(t.attributes),o=this.groups.get(i.id);o||(o=new e.Model(i),o.sections=new e.Collection(null,{comparator:"order"}),this.groups.add(o));var s=o.sections.get(n.id);s||(s=new e.Model(n),s.items=new e.Collection(null,{comparator:"order"}),o.sections.add(s)),s.items.add(t)},filter:function(e,t){var i={};if(e){var n,o,s;for(n=0;nWe could not find anything related to "'+e+'"

'}),this.$el.append(this._emptyView.render().el) },closeEmptySearchView:function(){this._emptyView&&(this._emptyView.remove(),delete this._emptyView)}});return{ConceptIndex:a,ConceptGroup:r,ConceptSection:s,ConceptItem:o}}),define("cilantro/ui/concept/panel",["underscore","marionette","./index","./search"],function(e,t,i,n){var o=t.Layout.extend({id:"concept-panel",className:"panel panel-left closed",template:"concept/panel",regions:{search:".search-region",index:".index-region"},regionViews:{search:n.ConceptSearch,index:i.ConceptIndex},onRender:function(){this.$el.panel();var e=new this.regionViews.index({collection:this.collection}),t=new this.regionViews.search({collection:this.collection,handler:function(t,i){e.filter(t,i)}});this.search.show(t),this.index.show(e)},triggerSearch:function(e){this.search.currentView.trigger("search",e)},openPanel:function(e){this.$el.panel("open",e)},closePanel:function(e){this.$el.panel("close",e)},isPanelOpen:function(e){return this.$el.data("panel").isOpen(e)},isPanelClosed:function(e){this.$el.data("panel").isClosed(e)}});return{ConceptPanel:o}}),define("cilantro/ui/field/info",["underscore","marionette"],function(e,t){var i=t.ItemView.extend({className:"field-info",template:"field/info"});return{FieldInfo:i}}),define("cilantro/ui/config",["underscore","./core"],function(e,t){var i=function(i,n){var o,s,r=[{}],a=t.config.get(n+".instances."+i.id+".form");e.isFunction(a)?o=a:e.isString(a)?s=a:e.isObject(a)&&r.push(a);var l=t.config.get(n+".types."+i.get("type")+".form");!o&&e.isFunction(l)?o=l:!s&&e.isString(l)?s=l:r.push(l);var c=t.config.get(n+".defaults.form");return!o&&e.isFunction(c)?o=c:!s&&e.isString(c)?s=c:r.push(c),r=e.defaults.apply(null,r),{view:o,module:s,options:r}};return{resolveFormOptions:i}}),define("cilantro/ui/field/stats",["jquery","underscore","backbone","marionette","../core","../base","../charts","../charts/utils"],function(e,t,i,n,o,s,r,a){var l=function(e){return t.isNumber(e)?o.utils.prettyNumber(e):e},c=n.ItemView.extend({tagName:"li",template:function(e){var t={min:"Min",max:"Max",avg:"Average",count:"Count",distinct_count:"Unique values"};return""+(t[e.key]||e.key)+' '+l(e.value)+""}}),u=n.CollectionView.extend({tagName:"ul",itemView:c}),h=(r.FieldChart.extend({className:"sparkline",chartOptions:i.Sparkline.prototype.chartOptions,getChartOptions:function(t){var i={series:[a.getSeries(t.data)]};return e.extend(!0,i,this.chartOptions),i.chart.renderTo=this.ui.chart[0],i}}),n.Layout.extend({className:"field-stats",template:"field/stats",regions:{values:".stats-values",chart:".stats-chart"},onRender:function(){this.model.stats&&(this.values.show(new u({collection:this.model.stats})),this.model.stats.length||this.model.stats.fetch({reset:!0}))}}));return{FieldStats:h}}),define("cilantro/ui/field/controls",["underscore","marionette","loglevel","../../core","../base","../controls"],function(e,t,i,n,o,s){var r=function(e,t){t&&(t.listenTo(e,"change",function(e,i){t.clear(),t.set(i)}),e.listenTo(t,"change",function(t){e.set(t.toJSON())}))},a=function(e,t){t.stopListening(e),e.stopListening(t)},l=o.ErrorView.extend({message:"Error rendering field control"}),c=o.LoadView.extend({message:"Loading and rendering field controls..."}),u=t.ItemView.extend({errorView:l,template:function(){},initialize:function(){var t=this.model.get("control");if(t=s.get(t)||t,e.isFunction(t))this.viewClass=t;else{var n=this;require([t],function(e){n.viewClass=e,n.render()},function(e){n.showErrorView(),i.debug(e)})}},onRender:function(){this.viewClass&&(this.view=new this.viewClass(this.model.toJSON()),this.view.render(),this.$el.html(this.view.el),this.listenTo(this.view,{beforeready:this.onControlBeforeReady,error:this.onControlError}),this.view.ready(!0))},onBeforeClose:function(){if(this.view){var e=this.model.get("filter");a(this.view,e),this.view.close()}},onControlBeforeReady:function(){var e=this.model.get("filter");this.view.set(e.toJSON()),r(this.view,e)},onControlError:function(){this.showErrorView()},showErrorView:function(){this.view=new this.errorView(this.model.toJSON()),this.view.render(),this.$el.html(this.view.el)}}),h=t.CollectionView.extend({itemView:u,emptyView:c});return{FieldControls:h}}),define("cilantro/ui/field/form",["underscore","backbone","marionette","loglevel","../../core","../base","../charts","../config","./info","./stats","./controls"],function(e,t,i,n,o,s,r,a,l,c,u){var h=s.LoadView.extend({message:"Loading fields..."}),d=i.Layout.extend({className:"field-form",getTemplate:function(){return this.options.condensed?"field/form-condensed":"field/form"},options:{info:!0,chart:!1,stats:!0,controls:!0,condensed:!1},ui:{apply:"[data-action=apply]",update:"[data-action=update]",state:"[data-target=state]"},events:{"click @ui.apply":"applyFilter","click @ui.update":"applyFilter"},filterEvents:{applied:"validateFilter",unapplied:"validateFilter",change:"validateFilter"},regions:{info:".info-region",stats:".stats-region",chart:".chart-region",controls:".controls-region"},regionViews:{info:l.FieldInfo,stats:c.FieldStats,chart:r.FieldChart,controls:u.FieldControls},initialize:function(e){if(this.data={},!(this.data.concept=e.concept))throw new Error("concept required");if(!(this.data.context=e.context))throw new Error("context required");e.filter||(e.filter=this.data.context.define({concept:this.data.concept.id,field:this.model.id})),this.data.filter=e.filter},onRender:function(){this.$el.attr("id",this.data.filter.id),this.options.condensed&&this.$el.addClass("condensed"),this.options.info&&this.renderInfo(),this.options.stats&&this.model.stats&&this.renderStats(),this.options.controls&&this.renderControls(),this.options.chart&&this.model.links.distribution&&this.renderChart(),this.validateFilter(),i.bindEntityEvents(this,this.data.filter,i.getOption(this,"filterEvents"))},renderInfo:function(){var t={model:this.model};e.isObject(this.options.info)&&e.extend(t,this.options.info),this.info.show(new this.regionViews.info(t))},renderStats:function(){var t={model:this.model,collection:this.model.stats};e.isObject(this.options.stats)&&e.extend(t,this.options.stats),this.stats.show(new this.regionViews.stats(t))},renderControls:function(){var i=[];if(e.each(this.options.controls,function(t){var n={model:this.model,filter:this.data.filter};e.isObject(t)?e.extend(n,t):n.control=t,i.push(n)},this),i.length>0){var n=new this.regionViews.controls({collection:new t.Collection(i)});this.controls.show(n)}},renderChart:function(){var t;t=this.options.condensed?{chart:{height:100}}:{chart:{height:200}},t.context=this.context,t.model=this.model,e.isObject(this.options.chart)&&e.extend(t,this.options.chart),this.chart.show(new this.regionViews.chart(t))},renderFilter:function(){this.ui.state.hide(),this.ui.apply.prop("disabled",!0),this.ui.update.prop("disabled",!0);var t=this.data.context.isFilterApplied(this.data.filter),i=!this.isEmpty&&!this.validationErrors;if(t){this.ui.apply.hide(),this.ui.update.show();var n=[];this.controls.currentView.children.each(function(t){t.view&&(n=n.concat(e.keys(t.view.get())))}),this.data.context.hasFilterChanged(this.data.filter,n)&&(i?this.ui.update.prop("disabled",!1):this.validationErrors&&this.ui.state.html(this.validationErrors.join("
")).show())}else this.ui.apply.show(),this.ui.update.hide(),i?this.ui.apply.prop("disabled",!1):!this.isEmpty&&this.validationErrors&&this.ui.state.html(this.validationErrors.join("
")).show()},validateFilter:function(){var e,t,i=[],n=this.data.filter.toJSON();return this.controls.currentView.children.each(function(o){o.view&&(t=o.view.validate(n),t&&i.push(t),e=o.view.isEmpty(n))}),this.isEmpty=e,this.validationErrors=i.length?i:null,this.renderFilter(),!this.validationErrors&&!this.isEmpty},applyFilter:function(e){e.preventDefault(),this.validateFilter()&&this.data.filter.apply()}}),p=s.ErrorView.extend({}),f=i.View.extend({itemView:d,emptyView:h,errorView:p,collectionEvents:{reset:"render"},initialize:function(){if(this.data={},!(this.data.concept=this.options.concept))throw new Error("concept required");if(!(this.data.context=this.options.context))throw new Error("context required");this._children=[]},render:function(){if(this.collection.length){var e=this;this.collection.each(function(t,i){e.renderItem(t,i)})}return this},close:function(){if(!this.isClosed){for(var e;e=this._children.pop();)e.close();i.View.prototype.close.call(this)}},renderItem:function(t,i){var o=e.extend({},this.options,{model:t,context:this.data.context,concept:this.data.concept,index:i});this.collection.length<2?o.info=!1:i>0&&this.options.condense&&(o.condensed=!0);var s=a.resolveFormOptions(t,"fields");if(e.extend(o,s.options),s.module){var r=this;require([s.module],function(e){r.createView(e,o)},function(e){r.showErrorView(t),n.debug(e)})}else this.createView(s.view||this.itemView,o)},createView:function(e,t){try{var i=new e(t);i.render(),this._children.push(i),o.dom.insertAt(this.$el,t.index,i.el)}catch(n){if(this.showErrorView(t.model),o.config.get("debug"))throw n}},showErrorView:function(e){var t=new this.errorView({model:e});t.render(),this._children.push(t),this.$el.html(t.el)}}),m=i.ItemView.extend({tagName:"li",template:"field/link",ui:{anchor:"a"},serializeData:function(){return{name:this.model.get("alt_name")||this.model.get("name")}}}),g=i.CompositeView.extend({template:"field/links",itemView:m,itemViewContainer:"[data-target=links]",onAfterItemAdded:function(e){var t=this.options.concept,i="c"+t.id+"f"+e.model.id;e.ui.anchor.attr("href","#"+i)}});return{FieldForm:d,FieldFormCollection:f,FieldLinkCollection:g}}),define("cilantro/ui/field",["underscore","./field/info","./field/form","./field/stats","./field/controls"],function(e){var t=[].slice.call(arguments,1);return e.extend.apply(null,[{}].concat(t))}),define("cilantro/ui/concept/form",["jquery","underscore","marionette","../../core","../field","../charts","./info"],function(e,t,i,n,o,s,r){var a=i.Layout.extend({className:"concept-form",template:"concept/form",options:{condense:!1,linksMinFields:2},events:{"click [data-target=links] a":"jumpToField"},regions:{info:".info-region",links:".links-region",fields:".fields-region"},regionViews:{info:r.ConceptInfo,links:o.FieldLinkCollection,fields:o.FieldFormCollection},constructor:function(e){if(e=e||{},!e.model)throw new Error("concept model required");i.Layout.prototype.constructor.call(this,e)},initialize:function(){if(this.data={},!(this.data.context=this.options.context))throw new Error("context required")},onRender:function(){var e=new this.regionViews.info({model:this.model}),i=new o.FieldFormCollection(t.defaults({context:this.data.context,concept:this.model,collection:this.model.fields},this.options));this.info.show(e),this.fields.show(i);var n=this.options.linksMinFields;n!==!1&&(0===this.model.fields.length?this.listenToOnce(this.model.fields,"reset",function(e){e.length>=n&&this._renderLinks()}):this.model.fields.length>this.options.linksMinFields&&this._renderLinks())},_renderLinks:function(){var e=new this.regionViews.links({concept:this.model,collection:this.model.fields});this.links.show(e)},jumpToField:function(t){t.preventDefault();var i=e(t.target.hash).offset().top-20;e("html,body").animate({scrollTop:i})}});return{ConceptForm:a}}),define("cilantro/ui/welcome",["underscore","marionette"],function(e,t){var i=t.ItemView.extend({className:"welcome",template:"welcome",ui:{firstTime:"[data-target=first-time]",welcomeBack:"[data-target=welcome-back]"},initialize:function(){if(this.data={},!(this.data.context=this.options.context))throw new Error("context model required");this.listenTo(this.data.context,"change",this.renderWelcomeMessage)},renderWelcomeMessage:function(){var t=!1;this.data.context.get("session")===!0&&this.data.context.get("created")&&!e.isEmpty(this.data.context.get("json"))&&(t=!0),t?(this.ui.firstTime.hide(),this.ui.welcomeBack.show()):(this.ui.firstTime.show(),this.ui.welcomeBack.hide())}});return{Welcome:i}}),define("cilantro/ui/concept/workspace",["underscore","marionette","loglevel","../core","../base","../welcome","../config","./form"],function(e,t,i,n,o,s,r,a){var l=o.ErrorView.extend({template:"concept/error"}),c=t.Layout.extend({className:"concept-workspace",template:"concept/workspace",itemView:a.ConceptForm,errorView:l,regions:{main:".main-region"},regionViews:{main:s.Welcome},initialize:function(){if(this.data={},!(this.data.concepts=this.options.concepts))throw new Error("concept collection required");if(!(this.data.context=this.options.context))throw new Error("context model required");this.listenTo(n,n.CONCEPT_FOCUS,this.showItem)},_ensureModel:function(e){return e instanceof n.models.Concept||(e=this.data.concepts.get(e)),e},showItem:function(t){var o=this._ensureModel(t);if(!o)return void i.debug("unknown workspace concept: "+(t.id||t));if(n.router.navigate("query",{trigger:!0}),!this.currentView.model||this.currentView.model.id!==o.id){var s={model:o,context:this.data.context},a=r.resolveFormOptions(o,"concepts");if(s=e.extend(s,a.options),a.module){var l=this;require([a.module],function(e){l.createView(e,s)},function(e){l.showErrorView(o),i.debug(e)})}else this.createView(a.view||this.itemView,s)}},createView:function(e,t){try{var i=new e(t);this.setView(i)}catch(o){if(this.showErrorView(t.model),n.config.get("debug"))throw o}},showErrorView:function(e){var t=new this.errorView({model:e});this.setView(t)},setView:function(e){this.currentView=e,this.main.show(e)},onRender:function(){var e=new this.regionViews.main({context:this.data.context});this.setView(e)}});return{ConceptWorkspace:c}}),define("cilantro/ui/concept/columns/available",["../index"],function(e){var t=e.ConceptItem.extend({template:"concept/columns/available-item",events:{mouseover:"triggerDetails",mouseout:"triggerDetails","click [data-action=add]":"triggerAdd"},modelEvents:{"columns:add":"disable","columns:remove":"enable"},triggerAdd:function(e){e.preventDefault(),this.model.trigger("columns:add",this.model)},triggerDetails:function(e){e.preventDefault(),e.stopPropagation(),this.model.trigger("columns:detail",this.model,e)},enable:function(){this.$el.removeClass("disabled")},disable:function(){this.$el.addClass("disabled")}}),i=e.ConceptSection.extend({template:"concept/columns/available-section",itemView:t,events:{"click [data-action=add-section]":"triggerAdd"},triggerAdd:function(e){e.preventDefault(),this.model.items.each(function(e){e.trigger("columns:add",e)})}}),n=e.ConceptGroup.extend({template:"concept/columns/available-group",itemView:i,events:{"click [data-action=add-group]":"triggerAdd"},triggerAdd:function(e){e.preventDefault(),this.model.sections.each(function(e){e.items.each(function(e){e.trigger("columns:add",e)})})}}),o=e.ConceptIndex.extend({itemView:n,className:"available-columns accordion"});return{AvailableItem:t,AvailableSection:i,AvailableGroup:n,AvailableColumns:o}}),define("cilantro/ui/concept/columns/selected",["marionette","../../base"],function(e,t){var i=e.ItemView.extend({tagName:"li",template:"concept/columns/selected-item",events:{"click [data-action=remove]":"triggerRemove",sortupdate:"updateIndex"},modelEvents:{"columns:remove":"remove"},triggerRemove:function(e){e.preventDefault(),this.model.trigger("columns:remove",this.model)},updateIndex:function(e,t){e.stopPropagation(),this.collection.remove(this.model,{silent:!0}),this.collection.add(this.model,{at:t,silent:!0})}}),n=t.EmptyView.extend({message:"No columns selected."}),o=e.CollectionView.extend({tagName:"ul",className:"selected-columns",itemView:i,emptyView:n,events:{sortupdate:"triggerItemSort"},itemViewOptions:function(e,t){return{model:e,index:t,collection:this.collection}},onRender:function(){this.$el.sortable({cursor:"move",forcePlaceholderSize:!0,placeholder:"placeholder"})},triggerItemSort:function(e,t){t.item.trigger(e,[t.item.index()])}});return{SelectedItem:i,SelectedColumns:o}}),define("cilantro/ui/concept/columns/layout",["jquery","underscore","backbone","marionette","../search","./available","./selected"],function(e,t,i,n,o,s,r){var a=n.ItemView.extend({className:"popover right",template:"concept/popover",initialize:function(){this.$el.css({position:"fixed",zIndex:1200,minWidth:300,minHeight:100}).hide()},serializeData:function(){var e=this.model.toJSON(),t=this.model.fields;return 0===t.length?e.description||(e.description=''):1===t.length?e.description||(e.description=t.models[0].get("description")):e.fields=t.map(function(e){return e.get("name")}).join(", "),e.description||e.fields||(e.description="No description is available"),e},onRender:function(){0===this.model.fields.length&&(this.listenTo(this.model.fields,"reset",this.show),this.model.fields.fetch({reset:!0}))},update:function(e){this.stopListening(),this.options=e,this.model=e.model,this.show()},show:function(){this.render(),this.shown()?this.$el.stop().animate({left:this.options.left,top:this.options.top-this.$el.outerHeight()/2},200):this.$el.show().css({left:this.options.left,top:this.options.top-this.$el.outerHeight()/2}).fadeIn(200)},shown:function(){return this.$el.is(":visible")},hide:function(){this.$el.fadeOut(200)}}),l=n.Layout.extend({className:"concept-columns",template:"concept/columns/layout",events:{click:"hideDetailsPopover","click [data-action=clear]":"triggerRemoveAll"},regions:{search:".search-region",available:".available-region",selected:".selected-region"},regionViews:{search:o.ConceptSearch,available:s.AvailableColumns,selected:r.SelectedColumns},initialize:function(){if(this.data={},!(this.data.view=this.options.view))throw new Error("view required");if(!(this.data.concepts=this.options.concepts))throw new Error("concepts collection required");this.listenTo(this.data.concepts,"columns:detail",this.handleDetailsPopover),this.data.selected=new i.Collection,this.data.selected.listenTo(this.data.concepts,"columns:add",function(e){this.add(e)}),this.data.selected.on("columns:remove",function(e){this.remove(e)})},handleDetailsPopover:function(i,n){var o=this,s=e(n.currentTarget);if(clearTimeout(this._detailsDelay),"mouseover"===n.type){var r=this.popover.shown()?100:500;this._detailsDelay=t.delay(function(){o.showDetailsPopover(i,s)},r)}else"mouseout"===n.type&&(this._detailsDelay=t.delay(function(){o.hideDetailsPopover(i,s)},200))},showDetailsPopover:function(t,i){i=e(i);var n=i.offset();this.popover.update({model:t,top:n.top+i.outerHeight()/2,left:n.left+i.outerWidth()})},hideDetailsPopover:function(){this.popover&&this.popover.hide()},resetSelected:function(){this.data.selected.reset();var e=this.data.concepts;this.data.view.facets.each(function(t){var i=e.get(t.get("concept"));i&&i.trigger("columns:add",i)})},selectedToFacets:function(){var e=this;return this.data.selected.map(function(t){var i=e.data.view.facets.get(t.id);return i?i.toJSON():{concept:t.id}})},onRender:function(){this.$el.modal({show:!1});var e=new this.regionViews.search({placeholder:"Search available columns by name, description, or data value...",collection:this.data.concepts,handler:function(e,i){t.filter(e,i)}}),t=new this.regionViews.available({collapsable:!1,collection:this.data.concepts}),i=new this.regionViews.selected({collection:this.data.selected});this.search.show(e),this.available.show(t),this.selected.show(i),this.popover=new a,this.$el.append(this.popover.el),this.data.view.facets.length>0&&this.data.concepts.length?this.resetSelected():(this.listenToOnce(this.data.view.facets,"reset",this.resetSelected),this.listenToOnce(this.data.concepts,"reset",this.resetSelected))},triggerRemoveAll:function(){var e=this.data.selected.slice(0);t.each(e,function(e){e.trigger("columns:remove",e)})}});return{ConceptColumnsLayout:l}}),define("cilantro/ui/concept/columns/dialog",["underscore","marionette","./layout"],function(e,t,i){var n=t.Layout.extend({className:"columns-modal modal hide full",template:"concept/columns/dialog",events:{"click [data-save]":"save","click [data-dismiss]":"cancel"},ui:{error:"[data-target=error]"},regions:{body:".concept-columns-region"},regionViews:{body:i.ConceptColumnsLayout},initialize:function(){if(this.data={},!(this.data.view=this.options.view))throw new Error("view required");if(!(this.data.concepts=this.options.concepts))throw new Error("concepts collection required")},onRender:function(){this.$el.modal({show:!1,keyboard:!1,backdrop:"static"}),this.columns=new this.regionViews.body({view:this.data.view,concepts:this.data.concepts}),this.body.show(this.columns)},cancel:function(){var t=this;e.delay(function(){t.columns.resetSelected()},25),this.render()},save:function(){this.ui.error.hide();var e=this.columns.selectedToFacets();return 0===e.length?void this.ui.error.html("

You must select one or more columns.

").show():(this.data.view.facets.reset(e),this.data.view.save(),void this.close())},open:function(){this.ui.error.hide(),this.$el.modal("show")},close:function(){this.$el.modal("hide")}});return{ConceptColumnsDialog:n}}),define("cilantro/ui/concept/columns",["underscore","./columns/dialog"],function(e){var t=[].slice.call(arguments,1);return e.extend.apply(e,[{}].concat(t))}),define("cilantro/ui/concept",["underscore","./concept/info","./concept/search","./concept/index","./concept/panel","./concept/form","./concept/workspace","./concept/columns"],function(e){var t=[].slice.call(arguments,1);return e.extend.apply(e,[{}].concat(t))}),define("cilantro/ui/context/filters",["underscore","marionette","../base","../core","../../utils/numbers"],function(e,t,i,n,o){var s=function(t,i,n,o){return t?(i||(i=[]),o!==!1&&(o=!0),o&&i.push("
    "),t.language?i.push("
  • "+t.language+"
  • "):t.type&&t.children.length&&(n&&i.push("
  • "+t.type.toUpperCase()+"
      "),e.each(t.children,function(e){s(e,i,n,!1)}),n&&i.push("
  • ")),o&&i.push("
"),i.join("")):""},r=t.ItemView.extend({className:"context-filter",template:"context/filter",ui:{actions:"[data-target=actions]",loader:"[data-target=loader]",remove:"[data-action=remove]",enable:"[data-action=enable]",description:"[data-target=description]",required:"[data-target=required]"},events:{click:"clickShow","click @ui.remove":"clickRemove","click @ui.enable":"toggleEnabled"},modelEvents:{request:"showLoadView",sync:"hideLoadView",error:"hideLoadView",change:"render"},simpleLanguage:{"in":["is","is"],"-in":["not","is not"],exact:["is","is"],range:["between","is between"],"-range":["not between","is not between"],isnull:["is","is"],gt:[">","is greater"],gte:[">=","is greater than or equal to"],lt:["<","is less"],lte:["<=","is less than or equal to"]},clickShow:function(){n.trigger(n.CONCEPT_FOCUS,this.model.get("concept"))},clickRemove:function(e){e.stopPropagation(),this.model.unapply()},toggleEnabled:function(e){e.stopPropagation(),this.model.toggleEnabled()},renderEnabled:function(){this.$el.removeClass("disabled"),this.ui.enable.attr("title","Disable"),this.ui.enable.prop("checked",!0)},renderDisabled:function(){this.$el.addClass("disabled"),this.ui.enable.attr("title","Enable"),this.ui.enable.prop("checked",!1)},renderState:function(){this.model.get("enabled")!==!1?this.renderEnabled():this.renderDisabled()},parseValue:function(t,i){var o,s=[];if(!e.isArray(t))return"undefined"!=typeof t.label&&(t=t.label),""+t+"";var r=n.config.get("maxFilterDisplayValues");if("object"==typeof t[0]&&(t=e.pluck(t,"label")),1===t.length)return""+t[0]+"";if(t.length"+t[o]+",");s.push("-"===i.charAt(0)?"nor":"or"),s.push(""+t[t.length-1]+"")}else{s.push(""+t[0]+","),s.push(""+t[1]+",");var a=t.length-r;s.push(i.indexOf("-")<0?"...("+a+" more) or":"...("+a+" more) nor"),s.push(""+t[t.length-1]+"")}return s.join(" ")},renderDescription:function(){var t=this.model.toJSON();if(!n.config.get("styleFilters"))return void this.ui.description.html(s(t));var i=t.cleaned_value,r=[],a=t.value,l=t.operator,c="";if("undefined"==typeof i&&(i=a),c=n.data.fields.get(t.field)?n.data.fields.get(t.field).get("name"):t.language.split(this.simpleLanguage[l][1])[0],c=c.replace(/[!?]$/g,""),r.push("
  • "),r.push(""+c+""),"range"===l||"-range"===l){r.push(this.simpleLanguage[l][0]);var u=a[0],h=a[1];e.isNumber(u)&&e.isNumber(h)&&(u=o.toDelimitedNumber(u),h=o.toDelimitedNumber(h)),r.push(""+u+" and "+h+"")}else"in"===l||"-in"===l?(r.push(this.simpleLanguage[l][0]),r.push(this.parseValue(i,l))):(r.push(this.simpleLanguage[l][0]),r.push(this.parseValue(i,l)));r.push("
"),this.ui.description.html(r.join(" "))},showLoadView:function(){this.ui.loader.show(),this.ui.description.hide()},hideLoadView:function(){this.ui.loader.hide(),this.ui.description.show()},onRender:function(){this.ui.actions.toggle(!this.model.get("required")),this.ui.enable.toggle(!this.model.get("required")),this.ui.required.toggle(this.model.get("required")===!0),this.ui.required.tooltip({container:"body",placement:"left",delay:500}),this.renderDescription(),this.renderState()}}),a=i.EmptyView.extend({template:"context/empty",ui:{noFiltersResultsMessage:".no-filters-results-workspace",noFiltersQueryMessage:".no-filters-query-workspace"},onRender:function(){this.listenTo(n.router,"route",this.toggleMessage),this.toggleMessage()},onClose:function(){this.stopListening(n.router)},toggleMessage:function(){n.router.isCurrent("results")?(this.ui.noFiltersQueryMessage.hide(),this.ui.noFiltersResultsMessage.show()):n.router.isCurrent("query")&&(this.ui.noFiltersQueryMessage.show(),this.ui.noFiltersResultsMessage.hide())}}),l=t.CollectionView.extend({itemView:r,emptyView:a});return{ContextFilter:r,ContextFilters:l,ContextNoFilters:a,flattenLanguage:s}}),define("cilantro/ui/context/info",["underscore","marionette","../core"],function(e,t,i){var n=t.ItemView.extend({template:"context/info",ui:{query:"[data-route=query]",results:"[data-route=results]"},initialize:function(){e.bindAll(this,"toggleButton"),i.router.on("route",this.toggleButton)},toggleButton:function(){this.ui.query.toggle(i.router.isCurrent("results")),this.ui.results.toggle(i.router.isCurrent("query"))},onRender:function(){this.toggleButton()}});return{ContextInfo:n}}),define("cilantro/ui/context/actions",["underscore","marionette","../core"],function(e,t,i){var n=t.ItemView.extend({template:"context/actions",ui:{removeAll:"[data-action=remove]",count:"[data-target=count]",units:"[data-target=units]",loading:"[data-target=loading-message]"},events:{"click @ui.removeAll":"clickRemoveAll"},modelEvents:{"change:count":"render",sync:"showCount",request:"showLoad"},collectionEvents:{"add remove reset":"renderRemoveAll"},serializeData:function(){var t=e.clone(this.model.attributes);return t.prettyCount=i.utils.prettyNumber(t.count,i.config.get("threshold")),t},clickRemoveAll:function(){this.collection.unapply()},onRender:function(){this.renderRemoveAll()},showLoad:function(){this.ui.count.hide(),this.ui.units.hide(),this.ui.loading.show()},showCount:function(){this.ui.count.show(),this.ui.units.show(),this.ui.loading.hide()},renderRemoveAll:function(){var e=this.collection.reject(function(e){return e.get("required")===!0});this.ui.removeAll.prop("disabled",!e.length)}});return{ContextActions:n}}),define("cilantro/ui/context/panel",["underscore","marionette","../base","../core","./filters","./info","./actions"],function(e,t,i,n,o,s,r){var a=t.Layout.extend({id:"context-panel",className:"panel panel-right closed",template:"context/panel",errorView:i.ErrorOverlayView,modelEvents:{sync:"hideLoadView",error:"showErrorView",request:"showLoadView"},regions:{info:".info-region",filters:".filters-region",actions:".actions-region"},regionViews:{info:s.ContextInfo,filters:o.ContextFilters,actions:r.ContextActions},showLoadView:function(){this._errorView&&(this._errorView.remove(),delete this._errorView),this.$el.addClass("loading")},hideLoadView:function(){this.$el.removeClass("loading")},showErrorView:function(){this._errorView||(this._errorView=new this.errorView({target:this.$el}),this._errorView.render())},onRender:function(){this.$el.panel();var e=new this.regionViews.info({model:this.model}),t=new this.regionViews.actions({model:this.model,collection:this.model.filters}),i=new this.regionViews.filters({model:this.model,collection:this.model.filters});this.info.show(e),this.actions.show(t),this.filters.show(i)},openPanel:function(e){this.$el.panel("open",e)},closePanel:function(e){this.$el.panel("close",e)},isPanelOpen:function(e){return this.$el.data("panel").isOpen(e)},isPanelClosed:function(e){return this.$el.data("panel").isClosed(e)}});return{ContextPanel:a}}),define("cilantro/ui/context",["underscore","./context/panel"],function(e){var t=[].slice.call(arguments,1);return e.extend.apply(e,[{}].concat(t))}),define("cilantro/ui/exporter",["jquery","underscore","backbone","marionette","./base","./core"],function(e,t,i,n,o,s){var r=n.ItemView.extend({tagName:"label",className:"checkbox",template:"export/option"}),a=o.EmptyView.extend({message:"No exporters available."}),l=n.CollectionView.extend({itemView:r,emptyView:a}),c=n.ItemView.extend({template:"export/progress",ui:{status:"[data-target=status]",cancel:"[data-target=cancel]"},events:{"click @ui.cancel":"cancel"},modelEvents:{"change:status":"renderStatus"},getCookieName:function(){return"export-type-"+this.model.get("type")},getExportUrl:function(){var e=this.model.get("href");return"/"!==e.charAt(e.length-1)&&(e+="/"),e+(this.model.get("pages")||"")},initialize:function(){var t=this.getCookieName(),i=this.getExportUrl();this.iframe=e("