var __bind=function(e,t){return function(){return e.apply(t,arguments)}},__hasProp={}.hasOwnProperty,__extends=function(e,t){function r(){this.constructor=e}for(var n in t)__hasProp.call(t,n)&&(e[n]=t[n]);return r.prototype=t.prototype,e.prototype=new r,e.__super__=t.prototype,e};define(["environ","mediator","jquery","underscore","backbone","serrano/channels"],function(e,t,n,r,i,s){var o;return o=function(e){function i(){return this.remove=__bind(this.remove,this),this.add=__bind(this.add,this),this.render=__bind(this.render,this),i.__super__.constructor.apply(this,arguments)}return __extends(i,e),i.prototype.template=r.template('            <div id=columns-modal class="modal fade">                <div class=modal-header>                    <a class=close data-dismiss=modal>×</a>                    <h3>Data Columns</h3>                </div>                <div class=modal-body>                    <ul class="available-columns span5"></ul>                    <ul class="selected-columns span5"></ul>                </div>                <div class=modal-footer>                    <button data-save class="btn btn-primary">Save</button>                    <button data-close class=btn>Close</button>                </div>            </div>        '),i.prototype.availableItemTemplate=r.template('            <li data-id={{ id }}>                {{ name }}                <span class=controls>                    <button class="btn btn-success btn-mini">+</button>                </span>            </li>        '),i.prototype.selectedItemTemplate=r.template('            <li data-id={{ id }}>                {{ name }}                <span class=controls>                    <button class="btn btn-danger btn-mini">-</button>                </span>            </li>        '),i.prototype.events={"click [data-close]":"hide","click [data-save]":"save","click .available-columns button":"clickAdd","click .selected-columns button":"clickRemove"},i.prototype.deferred={add:!1,remove:!1},i.prototype.initialize=function(){var e=this;return i.__super__.initialize.apply(this,arguments),this.setElement(this.template()),this.$available=this.$(".available-columns"),this.$selected=this.$(".selected-columns").sortable({cursor:"move",forcePlaceholderSize:!0,placeholder:"placeholder"}),this.$el.addClass("loading"),this.collection.when(function(){return e.$el.removeClass("loading"),e.render(),e.resolve()}),t.subscribe(s.DATAVIEW_SYNCED,function(t){var n,r,i,s,o;if(t.isSession()&&(r=t.get("json"))){o=r.columns;for(i=0,s=o.length;i<s;i++)n=o[i],e.add(n)}})},i.prototype.render=function(){var e,t,n,r,i,s;e=[],n=[],s=this.collection.filter(function(e){return e.get("formatter_name")});for(r=0,i=s.length;r<i;r++)t=s[r],e.push(this.availableItemTemplate(t.attributes)),n.push(this.selectedItemTemplate(t.attributes));return this.$available.html(e.join("")),this.$selected.html(n.join("")),this},i.prototype.show=function(){return this.$el.modal("show")},i.prototype.hide=function(){return this.$el.modal("hide")},i.prototype.save=function(){var e;return this.hide(),e=n.map(this.$selected.children(),function(e){var t;if((t=n(e).data()).selected&&t.id)return t.id}),t.publish(s.DATAVIEW_COLUMNS,e)},i.prototype.add=function(e){return this.$available.find("[data-id="+e+"]").closest("li").hide(),this.$selected.find("[data-id="+e+"]").appendTo(this.$selected).show().data("selected",!0)},i.prototype.remove=function(e){return this.$selected.find("[data-id="+e+"]").hide().data("selected",!1),this.$available.find("[data-id="+e+"]").closest("li").show()},i.prototype.clickAdd=function(e){return e.preventDefault(),this.add(n(e.target).closest("li").data("id"))},i.prototype.clickRemove=function(e){return e.preventDefault(),this.remove(n(e.target).closest("li").data("id"))},i}(i.View)})