summaryrefslogtreecommitdiff
path: root/calendar/base/content/calendar-menus.xml
diff options
context:
space:
mode:
Diffstat (limited to 'calendar/base/content/calendar-menus.xml')
-rw-r--r--calendar/base/content/calendar-menus.xml149
1 files changed, 149 insertions, 0 deletions
diff --git a/calendar/base/content/calendar-menus.xml b/calendar/base/content/calendar-menus.xml
new file mode 100644
index 000000000..c210306fb
--- /dev/null
+++ b/calendar/base/content/calendar-menus.xml
@@ -0,0 +1,149 @@
+<?xml version="1.0"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+ - License, v. 2.0. If a copy of the MPL was not distributed with this
+ - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<!DOCTYPE bindings SYSTEM "chrome://calendar/locale/calendar.dtd">
+
+<bindings id="calendar-menu-bindings"
+ xmlns="http://www.mozilla.org/xbl"
+ xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
+ xmlns:xbl="http://www.mozilla.org/xbl">
+
+ <binding id="task-menupopup" extends="xul:menupopup">
+ <implementation>
+ <field name="mType">null</field>;
+ <field name="mPopupHandler">null</field>
+ <field name="mParentMenuPopup">null</field>
+
+ <constructor><![CDATA[
+ this.mPopupHandler = () => { this.schangeMenuByPropertyName(); };
+ this.mParentMenuPopup = getParentNodeOrThis(this, "menupopup");
+ this.mParentMenuPopup.addEventListener("popupshowing", this.mPopupHandler, true);
+ ]]></constructor>
+
+ <destructor><![CDATA[
+ this.mParentMenuPopup.removeEventListener("popupshowing", this.mPopupHandler, true);
+ ]]></destructor>
+
+ <!-- This method checks a command which naming follows
+ the notation 'calendar_' + mType + ' + '-' + propertyValue + 'command',
+ when its propertyValue part matches the propertyValue of the selected tasks
+ as long as the selected tasks share common propertyValues. -->
+ <method name="changeMenuByPropertyName">
+ <body><![CDATA[
+ let liveList = document.getAnonymousNodes(this);
+ for (let item of liveList) {
+ let commandName = item.getAttribute("command");
+ let command = document.getElementById(commandName);
+ if (command) {
+ command.setAttribute("checked", "false");
+ item.setAttribute("checked", "false");
+ }
+ }
+ let propertyValue;
+ if (gTabmail && gTabmail.currentTabInfo.mode.type == "calendarTask") {
+ // We are in a task tab (editing a single task).
+ propertyValue = gConfig[this.mType];
+ } else {
+ // We are in the Tasks tab.
+ let tasks = getSelectedTasks();
+ let tasksSelected = (tasks != null) && (tasks.length > 0);
+ if (tasksSelected) {
+ let task = tasks[0];
+ if (isPropertyValueSame(tasks, this.mType)) {
+ propertyValue = task[this.mType];
+ }
+ } else {
+ applyAttributeToMenuChildren(this, "disabled", !tasksSelected);
+ }
+ }
+ if (propertyValue || propertyValue == 0) {
+ let command = document.getElementById("calendar_" + this.mType + "-" + propertyValue + "_command");
+ if (command) {
+ command.setAttribute("checked", "true");
+ }
+ }
+ ]]></body>
+ </method>
+ </implementation>
+ </binding>
+
+ <binding id="task-progress-menupopup" extends="chrome://calendar/content/calendar-menus.xml#task-menupopup">
+ <content>
+ <xul:menuitem anonid="percent-0-menuitem"
+ type="checkbox"
+ label="&progress.level.0;"
+ accesskey="&progress.level.0.accesskey;"
+ observes="calendar_percentComplete-0_command"
+ command="calendar_percentComplete-0_command"/>
+ <xul:menuitem anonid="percent-25-menuitem"
+ type="checkbox"
+ label="&progress.level.25;"
+ accesskey="&progress.level.25.accesskey;"
+ observes="calendar_percentComplete-25_command"
+ command="calendar_percentComplete-25_command"/>
+ <xul:menuitem anonid="percent-50-menuitem"
+ type="checkbox"
+ label="&progress.level.50;"
+ accesskey="&progress.level.50.accesskey;"
+ observes="calendar_percentComplete-50_command"
+ command="calendar_percentComplete-50_command"/>
+ <xul:menuitem anonid="percent-75-menuitem"
+ type="checkbox"
+ label="&progress.level.75;"
+ accesskey="&progress.level.75.accesskey;"
+ observes="calendar_percentComplete-75_command"
+ command="calendar_percentComplete-75_command"/>
+ <xul:menuitem anonid="percent-100-menuitem"
+ type="checkbox"
+ label="&progress.level.100;"
+ accesskey="&progress.level.100.accesskey;"
+ observes="calendar_percentComplete-100_command"
+ command="calendar_percentComplete-100_command"/>
+ <children/>
+ </content>
+ <implementation>
+ <constructor><![CDATA[
+ this.mType = "percentComplete";
+ this.changeMenuByPropertyName();
+ ]]></constructor>
+ </implementation>
+ </binding>
+
+ <binding id="task-priority-menupopup" extends="chrome://calendar/content/calendar-menus.xml#task-menupopup">
+ <content>
+ <xul:menuitem id="priority-0-menuitem"
+ type="checkbox"
+ label="&priority.level.none;"
+ accesskey="&priority.level.none.accesskey;"
+ command="calendar_priority-0_command"
+ observes="calendar_priority-0_command"/>
+ <xul:menuitem id="priority-9-menuitem"
+ type="checkbox"
+ label="&priority.level.low;"
+ accesskey="&priority.level.low.accesskey;"
+ command="calendar_priority-9_command"
+ observes="calendar_priority-9_command"/>
+ <xul:menuitem id="priority-5-menuitem"
+ type="checkbox"
+ label="&priority.level.normal;"
+ accesskey="&priority.level.normal.accesskey;"
+ command="calendar_priority-5_command"
+ observes="calendar_priority-5_command"/>
+ <xul:menuitem id="priority-1-menuitem"
+ type="checkbox"
+ label="&priority.level.high;"
+ accesskey="&priority.level.high.accesskey;"
+ command="calendar_priority-1_command"
+ observes="calendar_priority-1_command"/>
+ <children/>
+ </content>
+ <implementation>
+ <constructor><![CDATA[
+ this.mType = "priority";
+ this.changeMenuByPropertyName();
+ ]]></constructor>
+ </implementation>
+ </binding>
+</bindings>