diff options
Diffstat (limited to 'app/php/controls')
-rw-r--r-- | app/php/controls/CalendarGroupFilter.php | 21 | ||||
-rw-r--r-- | app/php/controls/CalendarGroupFilter.tpl | 16 | ||||
-rw-r--r-- | app/php/controls/scripts/CalendarGroupFilter.js | 29 |
3 files changed, 66 insertions, 0 deletions
diff --git a/app/php/controls/CalendarGroupFilter.php b/app/php/controls/CalendarGroupFilter.php new file mode 100644 index 0000000..6f19bcd --- /dev/null +++ b/app/php/controls/CalendarGroupFilter.php @@ -0,0 +1,21 @@ +<?php + +Prado::using('Application.web.FacadeTemplateControl'); + +Prado::using('Application.facades.CalendarFacade'); + +class CalendarGroupFilter extends FacadeTemplateControl { + + public function onPreRender($param) { + parent::onPreRender($param); + $this->Categories->DataSource = $this->Facade->getCategories(); + $this->Categories->dataBind(); + } + + public function getPradoScriptDependencies() { + return ['jquery']; + } + +} + +?> diff --git a/app/php/controls/CalendarGroupFilter.tpl b/app/php/controls/CalendarGroupFilter.tpl new file mode 100644 index 0000000..e9ae79a --- /dev/null +++ b/app/php/controls/CalendarGroupFilter.tpl @@ -0,0 +1,16 @@ +<com:TRepeater ID="Categories"> + <prop:HeaderTemplate> + <div class="selectAllGroups"> + All + <com:TCheckBox CssClass="box" Checked="True" /> + </div> + </prop:HeaderTemplate> + <prop:ItemTemplate> + <div class="selectGroup"> + <%# $this->Data->Name %> + <com:TCheckBox CssClass="box" Checked="True"> + <prop:Value><%# $this->Data->ID %></prop:Value> + </com:TCheckBox> + </div> + </prop:ItemTemplate> +</com:TRepeater> diff --git a/app/php/controls/scripts/CalendarGroupFilter.js b/app/php/controls/scripts/CalendarGroupFilter.js new file mode 100644 index 0000000..e6c1d73 --- /dev/null +++ b/app/php/controls/scripts/CalendarGroupFilter.js @@ -0,0 +1,29 @@ +$(document).on('ready', function() { + var selectBoxes = $('.selectGroup input.box'); + var selectAllBox = $('.selectAllGroups input.box'); + selectBoxes.on('change', function() { + var groups = []; + var allSelected = true; + $('.selectGroup input.box').each(function() { + var box = $(this); + if (box.is(':checked')) { + groups.push(box.val()); + } else { + allSelected = false; + } + }); + if (allSelected) { + selectAllBox.prop('checked', true); + } else { + selectAllBox.removeAttr('checked'); + } + $(document).trigger('Application.calendarGroupFilterChanged', {groups: groups}); + }); + selectAllBox.on('change', function() { + if ($(this).is(':checked')) { + selectBoxes.prop('checked', true).trigger('change'); + } else { + selectBoxes.removeAttr('checked').trigger('change'); + } + }); +}); |