text: "use strict";var isBrowser="undefined"!=typeof window,isNode="undefined"!=typeof module&&"undefined"!=typeof module.exports,Model=isNode?require("bimo").Model:bimo.Model,Format=isNode?require("./format.js"):tools.Format,PageModel=function(t){Model.call(this,t),this.counts=new Model(t.counts),this._format=new Format};PageModel.prototype=Object.create(Model.prototype),PageModel.constructor=Model,PageModel.prototype.formatCount=function(t){var o="na";return this.counts&&this.counts[t]&&(o=this._format.addSeparators(this.counts[t])),o},PageModel.prototype.userCount=function(){return this.formatCount("total")},PageModel.prototype.femaleCount=function(){return this.formatCount("female")},PageModel.prototype.maleCount=function(){return this.formatCount("male")},PageModel.prototype.countryCount=function(){return this.formatCount("country")},PageModel.prototype.regionCount=function(){return this.formatCount("region")},PageModel.prototype.cityCount=function(){return this.formatCount("city")},PageModel.prototype.divorcedPercent=function(){var t="na";return this.counts&&this.counts.total&&this.counts.divorced&&(t=(this.counts.divorced/this.counts.total*100).toFixed(1)+"%"),t},isBrowser?(window.models=window.models||{},window.models.PageModel=PageModel):isNode&&(module.exports=PageModel);var isBrowser="undefined"!=typeof window,isNode="undefined"!=typeof module&&"undefined"!=typeof module.exports,ContactsItemModel=function(t){t=t||{};for(var o in t)t.hasOwnProperty(o)&&(this[o]=t[o])};ContactsItemModel.prototype.initials=function(){var t="";return this.firstName&&(t+=this.firstName.substring(0,1).toUpperCase()),this.lastName&&(t+=this.lastName.substring(0,1).toUpperCase()),""===t&&(t="??"),t},ContactsItemModel.prototype.fullName=function(){var t="n/a";return this.firstName&&this.lastName&&(t=[this.firstName,this.lastName].join(" ")),t},ContactsItemModel.prototype.isInquiry=function(){return"INQUIRY"===this.mode},ContactsItemModel.prototype.isContact=function(){return"CONTACT"===this.mode},ContactsItemModel.prototype.displayDate=function(){var t;if(this.date){var o=new Date(this.date);t=o.toLocaleDateString()}return t},isBrowser?(window.move=window.move||{},window.move.ContactsItemModel=ContactsItemModel):isNode&&(module.exports=ContactsItemModel);var isBrowser="undefined"!=typeof window,isNode="undefined"!=typeof module&&"undefined"!=typeof module.exports,ContactsPagingModel=function(t){t=t||{},this.page=t.page?parseInt(t.page,10):0,this.size=t.size?parseInt(t.size,10):0,this.sort=t.sort||"",this.count=t.count||0};ContactsPagingModel.prototype.pageCount=function(){var t=this.count/this.size;if(this.count<=this.size)t=1;else{t=Math.floor(this.count/this.size);var o=this.count%this.size;o>0&&t++}return t},ContactsPagingModel.prototype.hasNext=function(){return this.page<this.count/this.size},ContactsPagingModel.prototype.hasPrev=function(){return this.page>1},ContactsPagingModel.prototype.next=function(){var t=!1;return this.page<this.pageCount()&&(this.page++,t=!0),t},ContactsPagingModel.prototype.prev=function(){var t=!1;return this.page>1&&(this.page--,t=!0),t},ContactsPagingModel.prototype.first=function(){return this.page=1,!0},ContactsPagingModel.prototype.last=function(){return this.page=this.pageCount(),!0},isBrowser?(window.move=window.move||{},window.move.ContactsPagingModel=ContactsPagingModel):isNode&&(module.exports=ContactsPagingModel);var isBrowser="undefined"!=typeof window,isNode="undefined"!=typeof module&&"undefined"!=typeof module.exports,ContactsItemModel=isNode?require("./contactsItemModel.js"):move.ContactsItemModel,ContactsDetailModel=function(t){ContactsItemModel.call(this,t),this.isDetail=!0};ContactsDetailModel.prototype=Object.create(ContactsItemModel.prototype),ContactsDetailModel.constructor=ContactsItemModel,ContactsDetailModel.prototype.addCommas=function(t){var o=/(\d+)(\d{3})/;for(t=void 0===t?0:t,t=t.toString();o.test(t);)t=t.replace(o,"$1,$2");return t},ContactsDetailModel.prototype.displayPrice=function(){var t="$n/a";return"number"==typeof this.price&&(t="$"+this.addCommas(this.price.toFixed(2))),t},ContactsDetailModel.prototype.displayBed=function(){var t="n/a";return"number"==typeof this.bed&&(t=this.bed.toString()),t},ContactsDetailModel.prototype.displayBath=function(){var t="n/a";return"number"==typeof this.bath&&(t=this.bath.toString()),t},ContactsDetailModel.prototype.displaySqft=function(){var t="n/a";return"number"==typeof this.sqft&&(t=this.addCommas(this.sqft)),t},isBrowser?(window.move=window.move||{},window.move.ContactsDetailModel=ContactsDetailModel):isNode&&(module.exports=ContactsDetailModel);var ContactsPage=function(t){var o,e,n,i,a,s,r,d,c,l,u,m,p,f,h,g,C,v,w=this,M=new move.RealAjax,y=null,P=null,N=new move.RealUrl,I=null,x={page:1,size:10,sort:"newest"};n=function(t){console&&console.error(t)},i=function(t){t.preventDefault(),t.stopPropagation(),alert("Not Implemented yet"),console&&console.log("Not Implemented yet")},a=function(){o="list",w.dom.detailContainer.hide(),w.dom.listContainer.show(),null!==y&&(N.update({},y),y=null),null!==I&&(w.dom.document.scrollTop(I),I=null)},s=function(){if(o="detail",I=w.dom.document.scrollTop(),"string"==typeof P){y=window.location.href;var t=N.host("/contact-detail/"+P);N.update({},t)}w.dom.listContainer.hide(),w.dom.detailContainer.show(),w.dom.document.scrollTop(0)},r=function(t,o){w.dom.menu=w.dom.menu||$("#widget--menu-widget"),null!==t?n(t):w.dom.menu.html("").append(o)},d=function(t,o){w.dom.contacts=w.dom.contacts||$("#contacts-items"),null!==t?n(t):w.dom.contacts.html("").append(o)},c=function(t,o){w.dom.detailContainer=w.dom.detailContainer||$("#detail-container"),null!==t?n(t):(w.dom.detailContainer.html("").append(o),s())},l=function(){N.update({page:e.page,size:e.size,sort:e.sort}),w.dom.sort.val(e.sort),w.dom.prev.hide(),e.hasPrev()&&w.dom.prev.show(),w.dom.next.hide(),e.hasNext()&&w.dom.next.show()},h=function(t,o){o=o||g;var e={page:t.page,size:t.size,sort:t.sort};M.post("/api/contacts/list",JSON.stringify(e),o,n)},g=function(t,o){if(t){e=null,e=new move.ContactsPagingModel(t.paging),w.cache.list=[];for(var n=0,i=t.contacts.length;i>n;n++)w.cache.list.push(new move.ContactsItemModel(t.contacts[n]));dust.render("contacts-list.dust",{contacts:w.cache.list},d),o?o():l()}else o&&o()},C=function(t,o){o=o||v,M.get("/api/contacts/detail/"+t,o,n)},v=function(t){if(t){var o=new move.ContactsDetailModel(t);w.cache.detail[o.id]=o,dust.render("contacts-detail.dust",o,c)}},u=function(){e.sort!==w.dom.sort.val()&&(e.sort=w.dom.sort.val(),h(e))},m=function(t){t.stopPropagation();var o=$(t.target),n=!1;o.hasClass("js-nav-next")?n=e.next():o.hasClass("js-nav-prev")&&(n=e.prev()),l(),n&&h(e)},p=function(t){t.stopPropagation();var o=$(t.target).parents("*[data-contact-id]").data("contact-id");void 0!==o&&""!==o&&(P=o,C(o))},f=function(t){t.preventDefault(),t.stopPropagation(),0===e.page&&0===e.size?h(x,function(t){g(t,function(){I=0,y=N.host("/contacts"),a(),l()})}):a()},w.options=t||{},w.dom={},w.cache={list:[],detail:{}},w.init=function(t){t=t||{},t.container=t.container||document,w.dom.container=w.dom.container||("string"==typeof t.container?$(t.container):t.container),dust.render("contacts-menu.dust",{},r),w.dom.document=w.dom.document||$(document),w.dom.container=w.dom.container||w.dom.document,w.dom.sort=w.dom.sort||$(".js-sort",w.dom.container),w.dom.next=w.dom.next||$(".js-nav-next",w.dom.container),w.dom.prev=w.dom.prev||$(".js-nav-prev",w.dom.container),w.dom.contacts=w.dom.contacts||$("#contacts-items",w.dom.container),w.dom.detailContainer=w.dom.detailContainer||$("#detail-container",w.dom.container),w.dom.listContainer=w.dom.listContainer||$("#list-container",w.dom.container),w.dom.sort.on("change",u),w.dom.next.on("click",m),w.dom.prev.on("click",m),w.dom.contacts.on("click","div",p),w.dom.document.on("click",".js-back-to-list",f),w.dom.document.on("click",".js-edit-contact",i),e=new move.ContactsPagingModel(t.paging),l()}};window.move=window.move||{},window.move.ContactsPage=ContactsPage;