Skip to content

Instantly share code, notes, and snippets.

@maxchirkov
Created December 12, 2017 22:07
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save maxchirkov/12e21726eec6275db617b77c315e3bd1 to your computer and use it in GitHub Desktop.
Save maxchirkov/12e21726eec6275db617b77c315e3bd1 to your computer and use it in GitHub Desktop.
Lifestyle Widgets
/**
* All Area Widgets
*
* Parameters:
* @param data-init string widgets/area
* @param data-id string Area ID
* @param data-chooser boolean Render Chooser true|false
* @param data-chooser-limit number of items to be returned within the chooser
* @param data-widgets JSON Array '["age", "cost", "education", "employment",
* "occupancy", "summary", "weather", "details"]'
*
* Example:
* <div
* data-init="widgets/area"
* data-chooser="true"
* data-id="6e87e3e7bf04cda3ce8bdaecf473e2d8" // Paradise Valley AZ
* data-widgets='["age", "cost", "education", "employment", "occupancy", "summary", "weather", "details"]'
* >
* </div>
*
* Widget Object can be accessed in the DOM as follows:
* $('[data-init="widgets/area"]')[0].widget;
*
* Manipulating widget instance:
* // Re-setting widgets to only summary
* $('[data-init="widgets/area"]')[0].widget.options.widgets = ['summary'];
* // Setting new area ID
* $('[data-init="widgets/area"]')[0].widget.options.id = 'ac28dd4fdde34d4040931bca6459ceea';
* // Re-rendering the whole widget
* $('[data-init="widgets/area"]')[0].render();
*/
/**
* Area Details Widget
*
* Parameters:
* @param data-init string widgets/areaDetails
* @param data-id string Area ID
* @param data-chooser boolean Render Chooser true|false
* @param data-chooser-limit number of items to be returned within the chooser
*
* Example:
* <div data-init="widgets/areaDetails"></div>
*
* Widget Object can be accessed in the DOM as follows:
* $('[data-init="widgets/areaDetails"]')[0].widget;
*
* Manipulating widget instance:
* // Setting new area ID
* $('[data-init="widgets/areaDetails"]')[0].widget.options.id = 'ac28dd4fdde34d4040931bca6459ceea';
* // Re-rendering the whole widget
* $('[data-init="widgets/areaDetails"]')[0].render();
*/
/**
* Schools Widget
*
* Parameters:
* @param data-init string widgets/school
* @param data-parameters JSON Object supports all schools filters
*
* Filters (data-parameters):
* admission: Public | Private
* charter: true | false
* district: Name |ID
* grade: elementary, middle, high, pk, kg, 1, 2, 3, etc.
* magnet: true
* name: name of the school
* titlei: true to limit the search to only Title I schools.
*
* Note: adding area selector (data-chooser) to the front-end,
* will reset all pre-set filters/parameters just to the selected area/polygon.
*
*
* Example 1:
* Renders table of Magnet schools in Phoenix, AZ
* <div data-init="widgets/schools" data-parameters='{"city":"Phoenix", "magnet":"true"}'></div>
*
* Example 2:
* Renders table of high table in the Paradise Valley Unified District
* <div data-init="widgets/schools" data-parameters='{"district":"Paradise Valley Unified", "grade":"high"}' data-chooser="true"></div>
*
* Widget Object can be accessed in the DOM as follows:
* var widget = $('[data-init="widgets/schools"]')[0].widget;
*
* Manipulating widget instance:
* var widget = $('[data-init="widgets/schools"]')[0].widget;
* // Resetting search parameters to a polygon
* widget.options.parameters = {'polygon' : '$ac28dd4fdde34d4040931bca6459ceea'};
* // Re-rendering the whole widget
* widget.render();
*/
/**
* School Widget
*
* Parameters:
* @param data-init string widgets/school
* @param data-id string School ID
* @param data-widgets JSON Array '["details", "enrollment", "ethnicity", "gender", "summary"]'
*
* Example:
* Renders details view of the North Ranch Elementary School in Scottsdale, AZ
* <div data-init="widgets/school" data-id="040593001378"></div>
*
* Widget Object can be accessed in the DOM as follows:
* var widget = $('[data-init="widgets/school"]')[0].widget;
*
* Manipulating widget instance:
* var widget = $('[data-init="widgets/school"]')[0].widget;
* // Setting new school ID
* widget.options.id = '040593001084';
* // Re-rendering the whole widget
* widget.render();
*/
/**
* Sales Statistics Widget
*
* Parameters:
* @param data-init string widgets/sales/statistics
* @param data-widgets JSON Array ["sold-sale-price", "sold-count"]
* @param data-parameters JSON Object supports all sales filters
* @api https://slipstream.homejunction.com/docs/ws/sales#search
*
* Example:
* <div data-init="widgets/sales/statistics"
* data-parameters='{"polygon":"$6e87e3e7bf04cda3ce8bdaecf473e2d8"}'
* data-widgets='["sold-sale-price", "sold-count"]'></div>
*
*
* Widget Object can be accessed in the DOM as follows:
* $('[data-init="widgets/sales/statistics"]')[0].widget;
*
*/
/**
* Sales Catalogue Widget
*
* Renders list of sold properties and corresponding map representation with plotted markers.
* @source https://slipstream.homejunction.com/docs/js/1.3.3/sales/widget/catalogue
*
* @todo extract lookBack() method into sales parameters validation utility for re-usability
*
* Invocation Example:
* <div data-init="widgets/sales/catalogue" data-parameters='{"city":"San Diego"}'></div>
*
* Initialized component object can be accessed as follows:
* jQuery('[data-init="widgets/sales/catalogue"]')[0].widget;
*
* Supported data attributes:
*
* @param string data-init Initializes plugin by given namespace.
* @param object data-parameters JSON Object of sales search parameters.
* Note: all Sales Search web service parameters are supported:
* @api https://slipstream.homejunction.com/docs/ws/sales#search
*
* Dynamic Parameters:
* saleDate supports lookBack() method that generates correct query for the last number of days
* Example:
* data-parameters='{"saleDate":"lookBack(60)"}' - will return sales within the last 60 days
*
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment