calendar/base/content/calendar-item-bindings.xml
author Arshad Khan <arshdkhn1@gmail.com>
Sat, 08 Sep 2018 22:12:36 +0530
changeset 33167 d197d42b67d83e5991554fa300ddeff7d1be5203
parent 32866 7973e4623106e0a0360f416156ea872ded1d8c8e
child 33413 9d0f37068236caf4bed8a0773b0f70b35a58da12
permissions -rw-r--r--
Bug 1489791 - Remove calendar-caption binding. r=MakeMyDay

<?xml version="1.0" encoding="UTF-8"?>
<!-- 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-item-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="item-date-row" extends="xul:row">
    <content xbl:inherits="mode">
      <xul:label anonid="item-datetime-label"
                 class="headline"
                 xbl:inherits="align"/>
      <xul:textbox readonly="true"
                   class="selectable-label plain"
                   anonid="item-datetime-value"/>
    </content>
    <implementation>
      <field name="mItem">null</field>

      <property name="mode"
                readonly="true">
        <getter><![CDATA[
            if (this.hasAttribute("mode")) {
                return this.getAttribute("mode");
            } else {
                return "start";
            }
        ]]></getter>
      </property>
      <property name="Item">
        <getter><![CDATA[
            return mItem;
        ]]></getter>
        <setter><![CDATA[
            this.mItem = val;
            let headerLabel = document.getAnonymousElementByAttribute(this, "anonid", "item-datetime-label");
            let itemDateTimeLabel = document.getAnonymousElementByAttribute(this, "anonid", "item-datetime-value");
            let date;
            if (this.mode == "start") {
                date = this.mItem[cal.dtz.startDateProp(this.mItem)];
                if (date) {
                    let label;
                    if (cal.item.isToDo(this.mItem)) {
                        label = this.getAttribute("taskStartLabel");
                    } else {
                        label = this.getAttribute("eventStartLabel");
                    }
                    headerLabel.value = label;
                }
            } else {
                date = this.mItem[cal.dtz.endDateProp(this.mItem)];
                if (date) {
                    let label;
                    if (cal.item.isToDo(this.mItem)) {
                        label = this.getAttribute("taskDueLabel");
                    } else {
                        label = this.getAttribute("eventEndLabel");
                    }
                    headerLabel.value = label;
                }
            }
            let hideLabels = (date == null);
            if (hideLabels) {
                this.setAttribute("hidden", "true");
            } else {
                const kDefaultTimezone = cal.dtz.defaultTimezone;
                let localTime = date.getInTimezone(kDefaultTimezone);
                let formatter = cal.getDateFormatter();
                itemDateTimeLabel.value = formatter.formatDateTime(localTime);
                if (!date.timezone.isFloating && date.timezone.tzid != kDefaultTimezone.tzid) {
                    // we additionally display the original datetime with timezone
                    let orgTime = cal.l10n.getCalString("datetimeWithTimezone", [
                        formatter.formatDateTime(date),
                        date.timezone.tzid
                    ]);
                    itemDateTimeLabel.value += " (" + orgTime + ")";
                }
                this.removeAttribute("hidden");
            }
        ]]></setter>
      </property>
    </implementation>
  </binding>
</bindings>