{"version":3,"sources":["IndicatorSelectionButtonsView.js","IndicatorSelectionCheckboxView.js","IndicatorSelectionCreateProfileView.js","IndicatorSelectionModel.js","IndicatorSelectionRouter.js","IndicatorSelectionTreeView.js"],"names":["$","_","window","nspace","IndicatorSelectionButtonsView","Backbone","View","extend","initialize","bindAll","this","model","once","render","on","events","click .location-type-link","click button","toggleLocations","e","$self","preventDefault","currentTarget","hasClass","hideLocations","showLocations","dataLayer","push","event","eventCategory","eventAction","text","trim","eventLabel","location","pathname","$el","next","stop","slideUp","Math","min","height","removeClass","slideDown","addClass","setLocation","set","data","locationType","locationSlug","renderLocation","$button","$toggleButton","get","parent","parents","prev","jQuery","IndicatorSelectionCheckboxView","click .subtopic-list input","toggleIndicator","$input","indicatorId","indicators","getSingleIndicator","getMultipleIndicators","length","checked","temp","replace","split","splice","formattedIndicators","join","childIndicators","clone","find","map","prop","union","reject","indicator","any","childIndicator","shouldKeepIndicatorInCollection","expandChildIndicators","self","each","$ul","css","checkIndicators","object","checkIndicatorGroups","$inputs","indicatorCount","checkedIndicatorCount","filter","children","toggleIndicatorDisabledStatus","locTypeIdsRaw","locTypeIds","locTypeId","IndicatorSelectionCreateProfileView","click","shouldPreventDefault","which","trigger","writeProfileUrl","locationTypeSlug","url","silent","attr","IndicatorSelectionModel","Model","defaults","categories","ns","IndicatorSelectionRouter","ccc","shared","ArraySerializationRouterBase","routes","",":selectedLocationType",":selectedLocationType/:selectedLocation",":selectedLocationType/:selectedLocation/:selectedCategories",":selectedLocationType/:selectedLocation/:selectedCategories/:selectedIndicators","initializeViews","selectedLocationType","selectedLocation","selectedCategories","selectedIndicators","getArrayFromModelProperty","updateUrl","selectorsView","el","tableView","IndicatorSelectionTreeView","checkboxView","customizeProfileView","urlParts","getStringFromArrayProperty","navigate","click .indicator-tree-toggle","click li[data-top-category] .indicator-list-link:not(.disabled)","toggleIndicators","$catNode","id","closest","category","$topLevelCategories","allApplicableCategoriesAreExpanded","toggleAll","newIds","suppressLPIndicatorExpansion","toggleCategoryDisabledStatus","elementsToDisable","elementsToEnable","str","toString","indexOf","expandSelectedCategories","shouldBeExpanded","$indicatorListLink","categoryName","toggleExpandAll","$toggle"],"mappings":"cAGA,SAAUA,EAAGC,GAGNC,OAAOC,OAAO,wBAKhBC,8BAAgCC,SAASC,KAAKC,OAAO,CACtDC,WAAY,WACVP,EAAEQ,QAAQC,MAGVA,KAAKC,MAAMC,KAAK,SAAUF,KAAKG,QAC/BH,KAAKC,MAAMG,GAAG,kBAAmBJ,KAAKG,SAGxCE,OAAQ,CACNC,4BAA6B,kBAC7BC,eAAgB,eAMlBC,gBAAiB,SAASC,GACxB,IAAIC,EAEJD,EAAEE,kBAEFD,EAAQpB,EAAEmB,EAAEG,gBAEFC,SAAS,UACjBb,KAAKc,cAAcJ,IAIrBV,KAAKe,cAAcL,GAGnBM,UAAUC,KAAK,CACbC,MAAO,wBACPC,cAAe,qBACfC,YAAa,sBAAwBV,EAAMW,OAAOC,OAClDC,WAAY/B,OAAOgC,SAASC,aAGhCX,cAAe,SAASY,GACtBA,EACGC,OACAC,MAAK,GAAM,GACXC,QAAQC,KAAKC,IAAI,IAAK,IAAML,EAAIC,OAAOK,WAC1CN,EAAIO,YAAY,WAElBlB,cAAe,SAASW,GACtBA,EACGC,OACAC,MAAK,GAAM,GACXM,UAAUJ,KAAKC,IAAI,IAAK,IAAML,EAAIC,OAAOK,WAC5CN,EAAIS,SAAS,WAMfC,YAAa,SAAS3B,GACpB,IAAIC,EAEJA,EAAQpB,EAAEmB,EAAEG,eACZZ,KAAKC,MAAMoC,IAAI,CACbb,SAAUd,EAAM4B,KAAK,UACrBC,aAAc7B,EAAM4B,KAAK,cACzBE,aAAc9B,EAAM4B,KAAK,cAI3BtB,UAAUC,KAAK,CACbC,MAAO,wBACPC,cAAe,qBACfC,YAAa,sBAAwBV,EAAMW,OAAOC,OAClDC,WAAY/B,OAAOgC,SAASC,YAOhCtB,OAAQ,WACNH,KAAKyC,kBAMPA,eAAgB,WACd,IA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GCF,KAAK,wBACLhC,SAAS,YACTF,YAAY,UACZN,OACAE,QAAQ,OAGbvC,EAAE8J,GAAkBtE,KAAK,WAGfxF,EAAEU,MAAMqE,KAAK,QAAS,IACxBF,KAAK,wBAAwBlC,YAAY,gBAOnDuH,yBAA0B,WACxB,IAAI9C,EACA7B,EAAO7E,KAEX0G,EAAa1G,KAAKC,MAAM2C,IAAI,cAE5B5C,KAAKV,EAAE,yBAAyBwF,KAAK,WACnC,IAAIpE,EAAO+I,EAIX,KAFA/I,EAAQpB,EAAEU,OAEAwF,SAAS,mBAAmB/B,SAItCgG,EAAmBlK,EAAEkF,IAAIiC,EAAY,SAASkC,GAC5C,OAAQA,IAAclI,EAAM4B,KAAK,qBAMX,SAHtB5B,EACG8E,SAAS,OACT5D,MAAK,GAAM,GACXoD,IAAI,YAMT,GAAIyE,EAAJ,CACE,IAAIC,EAAqBhJ,EAAMyD,KAAK,wBAOpC,GANAuF,EACGvH,SAAS,UACTR,OACAC,MAAK,GAAM,GACXM,UAAU,MAER2C,EAAKoE,6BAA8B,CAEtC,IAAIU,EAAeD,EAAmBrI,OAAOC,OAC7CN,UAAUC,KAAK,CACbC,MAAO,yBACPC,cAAe,qBACfC,YAAa,uBAAyBuI,EACtCpI,WAAY/B,OAAOgC,SAASC,iBAMlCf,EACGyD,KAAK,wBACLlC,YAAY,UACZN,OACAC,MAAK,GAAM,GACXC,QAAQ,QAOf+H,gBAAiB,WACf,IAAIC,EAEJA,EAAU7J,KAAKV,EAAE,0BACbU,KAAK8I,qCACPe,EAAQxI,KAAK,gBAIfwI,EAAQxI,KAAK,eAGflB,OAAQ,WACNH,KAAKkJ,+BACLlJ,KAAKwJ,2BACLxJ,KAAK4J,qBArQX,CAwQG5G,OAAQzD","file":"profile-selection-generated.js","sourcesContent":["/// \r\n/// \r\n\r\n(function($, _) {\r\n var ns;\r\n\r\n ns = window.nspace(\"ccc.profileSelection\");\r\n\r\n /**\r\n * Renders the display of the location type dropdowns and location buttons.\r\n */\r\n ns.IndicatorSelectionButtonsView = Backbone.View.extend({\r\n initialize: function(options) {\r\n _.bindAll(this);\r\n\r\n // Re-render on model changes\r\n this.model.once(\"change\", this.render);\r\n this.model.on(\"change:location\", this.render);\r\n },\r\n\r\n events: {\r\n \"click .location-type-link\": \"toggleLocations\",\r\n \"click button\": \"setLocation\"\r\n },\r\n\r\n /**\r\n * Toggles the display state of the location type dropdowns.\r\n */\r\n toggleLocations: function(e) {\r\n var $self;\r\n\r\n e.preventDefault();\r\n\r\n $self = $(e.currentTarget);\r\n\r\n if ($self.hasClass(\"active\")) {\r\n this.hideLocations($self);\r\n return;\r\n }\r\n\r\n this.showLocations($self);\r\n\r\n // Tracks clicks on location expansion (City, Boroughs, Community Districts, etc) on the \"Location Profile\" page\r\n dataLayer.push({\r\n event: \"LP Location Expansion\",\r\n eventCategory: \"Interactive Clicks\",\r\n eventAction: \"Location Expansion|\" + $self.text().trim(),\r\n eventLabel: window.location.pathname\r\n });\r\n },\r\n hideLocations: function($el) {\r\n $el\r\n .next()\r\n .stop(true, true)\r\n .slideUp(Math.min(700, 1.1 * $el.next().height()));\r\n $el.removeClass(\"active\");\r\n },\r\n showLocations: function($el) {\r\n $el\r\n .next()\r\n .stop(true, true)\r\n .slideDown(Math.min(700, 1.1 * $el.next().height()));\r\n $el.addClass(\"active\");\r\n },\r\n\r\n /**\r\n * Sets the model's location in response to a DOM event.\r\n */\r\n setLocation: function(e) {\r\n var $self;\r\n\r\n $self = $(e.currentTarget);\r\n this.model.set({\r\n location: $self.data(\"loc-id\"),\r\n locationType: $self.data(\"loctype-id\"),\r\n locationSlug: $self.data(\"loc-slug\")\r\n });\r\n\r\n // Tracks clicks on a location (Ex: University Heights (B05)) on the \"Create Location Profiles\" page\r\n dataLayer.push({\r\n event: \"LP Location Selection\",\r\n eventCategory: \"Interactive Clicks\",\r\n eventAction: \"Location Selection|\" + $self.text().trim(),\r\n eventLabel: window.location.pathname\r\n });\r\n },\r\n\r\n /**\r\n * A controlling method that renders everything relevant to this view's context.\r\n */\r\n render: function() {\r\n this.renderLocation();\r\n },\r\n\r\n /**\r\n * Renders the location buttons according to the model state.\r\n */\r\n renderLocation: function() {\r\n var $button, $toggleButton;\r\n\r\n if (!this.model.get(\"location\")) {\r\n return;\r\n }\r\n\r\n this.$(\"button,li\").removeClass(\"active\");\r\n $button = this.$(\r\n \"button[data-loc-id=\" + this.model.get(\"location\") + \"]\"\r\n ).addClass(\"active\");\r\n $button.parent().addClass(\"active\");\r\n\r\n // Make sure that the current location's list is expanded.\r\n $toggleButton = $button.parents(\"div:first\").prev();\r\n if ($toggleButton.hasClass(\"active\")) {\r\n return;\r\n }\r\n\r\n this.showLocations($toggleButton);\r\n }\r\n });\r\n})(jQuery, _);\r\n","/// \r\n/// \r\n/// \r\n\r\n(function($, _) {\r\n var ns;\r\n\r\n ns = window.nspace(\"ccc.profileSelection\");\r\n\r\n /**\r\n * Renders the display of the indicator checkboxes.\r\n */\r\n ns.IndicatorSelectionCheckboxView = Backbone.View.extend({\r\n initialize: function() {\r\n _.bindAll(this);\r\n\r\n this.model.once(\"change\", this.render);\r\n this.model.on(\"change:locationType change:indicators\", this.render);\r\n },\r\n\r\n events: {\r\n \"click .subtopic-list input\": \"toggleIndicator\"\r\n },\r\n\r\n /**\r\n * Set's the model's indicator property in response to DOM events.\r\n */\r\n toggleIndicator: function(e) {\r\n var $input, $self, indicatorId, indicators;\r\n\r\n $input = $(e.currentTarget);\r\n $self = $input.parents(\"li:first\");\r\n indicatorId = +$self.data(\"indicator-id\");\r\n\r\n indicators = indicatorId\r\n ? this.getSingleIndicator(indicatorId)\r\n : this.getMultipleIndicators($self, $input);\r\n\r\n this.model.set(\"indicators\", indicators);\r\n\r\n // Tracks clicks on an indicator or subindicator checkbox (Ex: Total Population) on the \"Create Location Profiles\" page\r\n if (indicators && indicators.length) {\r\n if (indicatorId && !$(\"input[type=checkbox]\", $self)[0].checked) {\r\n return; // Indicator was de-selected\r\n }\r\n\r\n // Get the names of the selected indicators\r\n // Remove excess whitespace, and separate indicators with a pipe\r\n var regex = /[\\t\\r\\n]+/gi;\r\n var rawText = $self.text().trim();\r\n var temp = rawText.replace(regex, \"|\").split(\"|\");\r\n if (temp.length > 1) {\r\n // Remove duplicated root indicator name\r\n temp.splice(0, 1);\r\n }\r\n var formattedIndicators = temp.join(\"|\");\r\n dataLayer.push({\r\n event: \"LP Indicator Selection\",\r\n eventCategory: \"Interactive Clicks\",\r\n eventAction: \"Indicator Selection|\" + formattedIndicators,\r\n eventLabel: window.location.pathname\r\n });\r\n }\r\n },\r\n\r\n /**\r\n * Toggles the children of the checked indicator group from the model's indicator collection.\r\n */\r\n getMultipleIndicators: function($el, $input) {\r\n var indicators, childIndicators;\r\n\r\n indicators = _.clone(this.model.get(\"indicators\"));\r\n childIndicators = $el\r\n .find(\".child li\")\r\n .map(function() {\r\n return +$(this).data(\"indicator-id\");\r\n })\r\n .get();\r\n\r\n if ($input.prop(\"checked\")) {\r\n indicators = _.union(indicators, childIndicators);\r\n }\r\n else {\r\n indicators = _.reject(indicators, function(indicator) {\r\n return _.any(childIndicators, function(childIndicator) {\r\n return childIndicator === +indicator;\r\n });\r\n });\r\n }\r\n\r\n return indicators;\r\n },\r\n\r\n /**\r\n * Toggles the checked indicator from the model's indicator collection.\r\n */\r\n getSingleIndicator: function(indicatorId, shouldKeepIndicatorInCollection) {\r\n var indicators, indicatorInCollection;\r\n\r\n indicators = _.clone(this.model.get(\"indicators\"));\r\n\r\n indicatorInCollection = _.any(indicators, function(indicator) {\r\n return +indicator === indicatorId;\r\n });\r\n\r\n if (indicatorInCollection) {\r\n if (shouldKeepIndicatorInCollection) {\r\n return indicators;\r\n }\r\n indicators = _.reject(indicators, function(indicator) {\r\n return +indicator === indicatorId;\r\n });\r\n }\r\n else {\r\n indicators.push(indicatorId);\r\n }\r\n\r\n return indicators;\r\n },\r\n\r\n /**\r\n * Makes the child indicator ul expand on initial click. Per Teresa, these uls expand once on initial click, then stay expanded no matter what.\r\n */\r\n expandChildIndicators: function() {\r\n var self;\r\n\r\n self = this;\r\n _.each(this.model.get(\"indicators\"), function(indicator) {\r\n var $ul;\r\n\r\n $ul = self\r\n .$(\"li[data-indicator-id=\" + indicator + \"]\")\r\n .parent(\".child\");\r\n\r\n if (!$ul.length) {\r\n // This is a loose indicator, so need to slide anything down.\r\n return;\r\n }\r\n\r\n if ($ul.css(\"display\") === \"block\") {\r\n // slideDown sets the display to block, so if we're there already, no need to repeat.\r\n return;\r\n }\r\n\r\n $ul.slideDown(700);\r\n });\r\n },\r\n\r\n /**\r\n * Checks the indicator boxes in response to changes to the model's indicator property.\r\n */\r\n checkIndicators: function() {\r\n var indicators;\r\n\r\n // Making our indicator array to an object for faster lookup.\r\n indicators = _.object(\r\n _.map(this.model.get(\"indicators\"), function(indicator) {\r\n return [indicator, true];\r\n })\r\n );\r\n\r\n this.$(\"li[data-indicator-id]\").each(function() {\r\n var $self, $input;\r\n\r\n $self = $(this);\r\n $input = $self.find(\"input\");\r\n if (indicators[$self.data(\"indicator-id\")]) {\r\n $input.prop(\"checked\", true);\r\n return;\r\n }\r\n $input.prop(\"checked\", false);\r\n });\r\n },\r\n\r\n /**\r\n * Makes sure the indicator group checkbox matches the state of the checked indicators in the model.\r\n */\r\n checkIndicatorGroups: function() {\r\n this.$(\"ul.subtopic-list.child\").each(function() {\r\n var $self, $inputs, indicatorCount, checkedIndicatorCount;\r\n\r\n $self = $(this);\r\n $inputs = $self.find(\"li input:checkbox\");\r\n indicatorCount = $inputs.length;\r\n checkedIndicatorCount = $inputs.filter(\":checked\").length;\r\n\r\n $self\r\n .prev()\r\n .children(\"input\")\r\n .prop(\"checked\", indicatorCount === checkedIndicatorCount);\r\n });\r\n },\r\n\r\n /**\r\n * Makes the indicator checkboxes disabled if they aren't valid for the currently selected location.\r\n */\r\n toggleIndicatorDisabledStatus: function() {\r\n var locationType;\r\n\r\n locationType = +this.model.get(\"locationType\");\r\n\r\n if (!locationType) {\r\n return;\r\n }\r\n\r\n this.$(\"li[data-loctype-ids][data-indicator-id]\").each(function() {\r\n var $self,\r\n locTypeIdsRaw,\r\n areLocTypeIdsMultiple,\r\n locTypeIds,\r\n shouldBeEnabled;\r\n\r\n $self = $(this);\r\n\r\n locTypeIdsRaw = $self.data(\"loctype-ids\");\r\n // We may get into a situation where we only have one location type defined for a category/indicator.\r\n // In this case, if there's only one location, .data will return an int, which doesn't have a split\r\n // function. So checking for the existing of that function will tells us to either split the location\r\n // type id or wrap it in an array.\r\n areLocTypeIdsMultiple = !!locTypeIdsRaw.split;\r\n locTypeIds = areLocTypeIdsMultiple\r\n ? locTypeIdsRaw.split(\",\")\r\n : [locTypeIdsRaw];\r\n\r\n shouldBeEnabled = _.any(locTypeIds, function(locTypeId) {\r\n return +locTypeId === locationType;\r\n });\r\n\r\n if (shouldBeEnabled) {\r\n $self.prop(\"title\", \"\");\r\n $self.find(\"input\").prop(\"disabled\", false);\r\n $self.find(\"label\").removeClass(\"disabled\");\r\n return;\r\n }\r\n\r\n $self.prop(\"title\", \"Not available for the selected location\");\r\n $self.find(\"input\").prop(\"disabled\", true);\r\n $self.find(\"label\").addClass(\"disabled\");\r\n });\r\n },\r\n\r\n /**\r\n * A parent render method.\r\n */\r\n render: function() {\r\n this.expandChildIndicators();\r\n this.toggleIndicatorDisabledStatus();\r\n this.checkIndicators();\r\n this.checkIndicatorGroups();\r\n }\r\n });\r\n})(jQuery, _);\r\n","/// \r\n/// \r\n\r\n(function($, _) {\r\n var ns;\r\n\r\n ns = window.nspace(\"ccc.profileSelection\");\r\n\r\n /**\r\n * Renders the display of the location type dropdowns and location buttons.\r\n */\r\n ns.IndicatorSelectionCreateProfileView = Backbone.View.extend({\r\n initialize: function(options) {\r\n _.bindAll(this);\r\n\r\n // Re-render on model changes\r\n this.model.on(\"change\", this.render);\r\n },\r\n\r\n events: {\r\n click: \"shouldPreventDefault\"\r\n },\r\n\r\n shouldPreventDefault: function(e) {\r\n if (this.$(\".disabled:first\").length) {\r\n e.preventDefault();\r\n return;\r\n }\r\n\r\n // Let's ignore middle button clicks. This should open the link in a new tab\r\n // *without* closing the windowshade, which is probably the user's intention.\r\n if (e.which === 2) {\r\n return;\r\n }\r\n\r\n this.model.trigger(\"hrefChanged\");\r\n },\r\n\r\n /**\r\n * A controlling method that renders everything relevant to this view's context.\r\n */\r\n render: function() {\r\n this.writeProfileUrl();\r\n },\r\n\r\n /**\r\n * Renders the customize profile anchor link according to the model state.\r\n */\r\n writeProfileUrl: function() {\r\n var location,\r\n locationType,\r\n locationTypeSlug,\r\n locationSlug,\r\n indicators,\r\n url;\r\n\r\n location = this.model.get(\"location\");\r\n indicators = this.model.get(\"indicators\");\r\n\r\n if (!location || !indicators || location === \"n\" || !indicators.length) {\r\n this.$(\"input\").addClass(\"disabled\");\r\n return;\r\n }\r\n\r\n locationType = this.model.get(\"locationType\");\r\n locationTypeSlug = $(\r\n \"a.location-type-link[data-loctype-id=\" + locationType + \"]:first\"\r\n ).data(\"loctype-slug\");\r\n\r\n locationSlug = this.model.get(\"locationSlug\");\r\n if (!locationSlug) {\r\n this.model.set(\r\n \"locationSlug\",\r\n $(\r\n \".location-lists-container .subtopic-list button[data-loc-id=\" +\r\n location +\r\n \"]\"\r\n ).data(\"loc-slug\"),\r\n { silent: true }\r\n );\r\n locationSlug = this.model.get(\"locationSlug\");\r\n }\r\n\r\n this.$(\"input\").removeClass(\"disabled\");\r\n\r\n url =\r\n \"/profile/location/\" +\r\n locationType +\r\n \"/\" +\r\n locationTypeSlug +\r\n \"#\" +\r\n location +\r\n \"/\" +\r\n locationSlug +\r\n \"/\" +\r\n locationType +\r\n \"/\" +\r\n indicators;\r\n this.$el.attr(\"href\", url);\r\n }\r\n });\r\n})(jQuery, _);\r\n","/// \r\n/// \r\n\r\n(function() {\r\n var ns;\r\n\r\n ns = window.nspace(\"ccc.profileSelection\");\r\n\r\n /**\r\n * A simple model for expressing the app's model state.\r\n */\r\n ns.IndicatorSelectionModel = Backbone.Model.extend({\r\n defaults: {\r\n locationType: \"n\",\r\n location: \"n\",\r\n categories: [],\r\n indicators: []\r\n }\r\n });\r\n})(jQuery);\r\n","/// \r\n/// \r\n/// \r\n/// \r\n/// \r\n/// \r\n/// \r\n\r\n(function(_) {\r\n var ns;\r\n\r\n ns = window.nspace(\"ccc.profileSelection\");\r\n\r\n /**\r\n * The router for our app.\r\n */\r\n ns.IndicatorSelectionRouter = window.ccc.shared.ArraySerializationRouterBase.extend(\r\n {\r\n initialize: function() {\r\n _.bindAll(this);\r\n },\r\n\r\n routes: {\r\n \"\": \"initializeViews\",\r\n \":selectedLocationType\": \"initializeViews\",\r\n \":selectedLocationType/:selectedLocation\": \"initializeViews\",\r\n \":selectedLocationType/:selectedLocation/:selectedCategories\":\r\n \"initializeViews\",\r\n \":selectedLocationType/:selectedLocation/:selectedCategories/:selectedIndicators\":\r\n \"initializeViews\"\r\n },\r\n\r\n /**\r\n * Receives and routes our route data.\r\n */\r\n initializeViews: function(\r\n selectedLocationType,\r\n selectedLocation,\r\n selectedCategories,\r\n selectedIndicators\r\n ) {\r\n // This method will only ever be invoked a single time, so use\r\n // it to initialize the model/view classes and trigger the initial rendering\r\n this.model = new ns.IndicatorSelectionModel({\r\n locationType: selectedLocationType,\r\n location: selectedLocation,\r\n categories: this.getArrayFromModelProperty(selectedCategories),\r\n indicators: this.getArrayFromModelProperty(selectedIndicators)\r\n });\r\n\r\n // Listen for changes to the model and update our URL\r\n this.model.on(\"change\", this.updateUrl);\r\n\r\n // Apply the model to the views\r\n this.selectorsView = new ns.IndicatorSelectionButtonsView({\r\n model: this.model,\r\n el: \".location-lists-container\"\r\n });\r\n this.tableView = new ns.IndicatorSelectionTreeView({\r\n model: this.model,\r\n el: \".indicator-container\"\r\n });\r\n this.checkboxView = new ns.IndicatorSelectionCheckboxView({\r\n model: this.model,\r\n el: \".indicator-container\"\r\n });\r\n this.customizeProfileView = new ns.IndicatorSelectionCreateProfileView({\r\n model: this.model,\r\n el: \"a.customize-profile\"\r\n });\r\n\r\n // Trigger a change notification on the model now that all of the selectors have finished initializing\r\n // so that other components can update themselves to reflect the current app state\r\n this.model.trigger(\"change\");\r\n },\r\n\r\n /**\r\n * Writes our model's state to the URL.\r\n */\r\n updateUrl: function() {\r\n var urlParts;\r\n\r\n urlParts = [\r\n this.model.get(\"locationType\") || \"n\",\r\n this.model.get(\"location\") || \"n\",\r\n this.getStringFromArrayProperty(this.model.get(\"categories\")),\r\n this.getStringFromArrayProperty(this.model.get(\"indicators\"))\r\n ];\r\n\r\n this.navigate(urlParts.join(\"/\"), { replace: true });\r\n }\r\n }\r\n );\r\n})(_);\r\n","/// \r\n/// \r\n\r\n(function($, _) {\r\n var ns;\r\n\r\n ns = window.nspace(\"ccc.profileSelection\");\r\n\r\n /**\r\n * Renders the page's categories expanded/collapsed state.\r\n */\r\n ns.IndicatorSelectionTreeView = Backbone.View.extend({\r\n initialize: function() {\r\n _.bindAll(this);\r\n\r\n this.model.once(\"change\", this.render);\r\n this.model.on(\"change:locationType change:categories\", this.render);\r\n },\r\n\r\n events: {\r\n \"click .indicator-tree-toggle\": \"toggleAll\",\r\n \"click li[data-top-category] .indicator-list-link:not(.disabled)\":\r\n \"toggleIndicators\"\r\n },\r\n\r\n /**\r\n * Toggles the expand/collapse state of the category/indicator dropdowns.\r\n */\r\n toggleIndicators: function(e) {\r\n var $self, $catNode, id, categories, categoryInCollection;\r\n\r\n $self = $(e.currentTarget);\r\n $catNode = $self.closest(\"li[data-top-category]\");\r\n id = +$catNode.data(\"category-id\");\r\n\r\n categories = _.clone(this.model.get(\"categories\"));\r\n categoryInCollection = _.any(categories, function(category) {\r\n return +category === id;\r\n });\r\n\r\n if (categoryInCollection) {\r\n categories = _.reject(categories, function(category) {\r\n return +category === id;\r\n });\r\n }\n else {\r\n categories.push(id);\r\n }\r\n\r\n this.model.set(\"categories\", categories);\r\n },\r\n\r\n /**\r\n * Gets the top level category links.\r\n */\r\n $topLevelCategories: function() {\r\n return this.$(\r\n \"li[data-top-category]:has(.indicator-list-link:first:not(.disabled))\"\r\n );\r\n },\r\n\r\n /**\r\n * Determines whether all categories are already expanded.\r\n */\r\n allApplicableCategoriesAreExpanded: function() {\r\n var $topLevelCategories, categories;\r\n\r\n $topLevelCategories = this.$topLevelCategories();\r\n categories = _.clone(this.model.get(\"categories\"));\r\n\r\n return $topLevelCategories.length === categories.length;\r\n },\r\n\r\n /**\r\n * Toggles expand/collapse for all category dropdowns.\r\n */\r\n toggleAll: function(e) {\r\n var newIds;\r\n var self = this;\r\n // if the number of selectedCategories in the model is equal to the\r\n // number of li's in the view, collapse; otherwise, expand\r\n if (this.allApplicableCategoriesAreExpanded()) {\r\n // collapse\r\n this.model.set(\"categories\", []);\r\n }\n else {\r\n self.suppressLPIndicatorExpansion = true;\r\n\r\n // Tracks when a user clicks the \"Expand All\" button on the \"Create Location Profiles\" page\r\n dataLayer.push({\r\n event: \"LP Expand All\",\r\n eventCategory: \"Interactive Clicks\",\r\n eventAction: \"LP Expand All\",\r\n eventLabel: window.location.pathname\r\n });\r\n\r\n newIds = this.$topLevelCategories()\r\n .map(function() {\r\n var $self;\r\n\r\n $self = $(this);\r\n return +$self.data(\"category-id\");\r\n })\r\n .get();\r\n this.model.set(\"categories\", newIds);\r\n\r\n self.suppressLPIndicatorExpansion = false;\r\n }\r\n },\r\n\r\n /**\r\n * Toggles the disabled status of each category.\r\n */\r\n toggleCategoryDisabledStatus: function() {\r\n var self, locationType, elementsToDisable, elementsToEnable;\r\n\r\n self = this;\r\n elementsToDisable = [];\r\n elementsToEnable = [];\r\n\r\n locationType = self.model.get(\"locationType\");\r\n\r\n if (!locationType || locationType === \"n\") {\r\n return;\r\n }\r\n\r\n this.$(\"li[data-top-category]\").each(function() {\r\n var $self, locTypeIds, isCategoryApplicableToLocationType;\r\n\r\n $self = $(this);\r\n var str = $self.data(\"loctype-ids\").toString();\r\n if (str.indexOf(\",\") > -1) {\r\n locTypeIds = str.split(\",\");\r\n }\n else {\r\n locTypeIds = str;\r\n }\r\n\r\n isCategoryApplicableToLocationType = _.any(locTypeIds, function(\r\n locTypeId\r\n ) {\r\n return +locTypeId === +self.model.get(\"locationType\");\r\n });\r\n\r\n if (isCategoryApplicableToLocationType) {\r\n elementsToEnable.push(this);\r\n return;\r\n }\r\n\r\n if ($self.children(\".disabled:first\").length) {\r\n return;\r\n }\r\n\r\n elementsToDisable.push(this);\r\n });\r\n\r\n // If any elements should be disabled, reset our indicator collection\r\n // so that an invalid combination of locations/indicators aren't selected.\r\n if (elementsToDisable.length) {\r\n self.model.set(\"indicators\", []);\r\n }\r\n\r\n $(elementsToDisable).each(function() {\r\n var $self;\r\n\r\n $self = $(this).prop(\r\n \"title\",\r\n \"Not available for the selected location\"\r\n );\r\n $self\r\n .find(\".indicator-list-link\")\r\n .addClass(\"disabled\")\r\n .removeClass(\"active\")\r\n .next()\r\n .slideUp(700);\r\n });\r\n\r\n $(elementsToEnable).each(function() {\r\n var $self;\r\n\r\n $self = $(this).prop(\"title\", \"\");\r\n $self.find(\".indicator-list-link\").removeClass(\"disabled\");\r\n });\r\n },\r\n\r\n /**\r\n * Renders the expansion/collapsing of any selected categories.\r\n */\r\n expandSelectedCategories: function() {\r\n var categories;\r\n var self = this;\r\n\r\n categories = this.model.get(\"categories\");\r\n\r\n this.$(\"li[data-top-category]\").each(function() {\r\n var $self, shouldBeExpanded, isExpanded;\r\n\r\n $self = $(this);\r\n\r\n if ($self.children(\".disabled:first\").length) {\r\n return;\r\n }\r\n\r\n shouldBeExpanded = _.any(categories, function(category) {\r\n return +category === +$self.data(\"category-id\");\r\n });\r\n isExpanded =\r\n $self\r\n .children(\"div\")\r\n .stop(true, true)\r\n .css(\"display\") !== \"none\";\r\n\r\n if (shouldBeExpanded === isExpanded) {\r\n return;\r\n }\r\n\r\n if (shouldBeExpanded) {\r\n var $indicatorListLink = $self.find(\".indicator-list-link\");\r\n $indicatorListLink\r\n .addClass(\"active\")\r\n .next()\r\n .stop(true, true)\r\n .slideDown(700);\r\n\r\n if (!self.suppressLPIndicatorExpansion) {\r\n // Tracks clicks on indicator expansion (Demographics, Economic Conditions, etc) on the \"Location Profile\" page\r\n var categoryName = $indicatorListLink.text().trim();\r\n dataLayer.push({\r\n event: \"LP Indicator Expansion\",\r\n eventCategory: \"Interactive Clicks\",\r\n eventAction: \"Indicator Expansion|\" + categoryName,\r\n eventLabel: window.location.pathname\r\n });\r\n }\r\n return;\r\n }\r\n\r\n $self\r\n .find(\".indicator-list-link\")\r\n .removeClass(\"active\")\r\n .next()\r\n .stop(true, true)\r\n .slideUp(700);\r\n });\r\n },\r\n\r\n /**\r\n * Makes sure the text of the Expand All button is in sync with the expanded categories.\r\n */\r\n toggleExpandAll: function() {\r\n var $toggle;\r\n\r\n $toggle = this.$(\".indicator-tree-toggle\");\r\n if (this.allApplicableCategoriesAreExpanded()) {\r\n $toggle.text(\"Collapse All\");\r\n return;\r\n }\r\n\r\n $toggle.text(\"Expand All\");\r\n },\r\n\r\n render: function() {\r\n this.toggleCategoryDisabledStatus();\r\n this.expandSelectedCategories();\r\n this.toggleExpandAll();\r\n }\r\n });\r\n})(jQuery, _);\r\n"]}