~ubuntu-branches/ubuntu/precise/lightning-extension/precise

« back to all changes in this revision

Viewing changes to calendar/base/content/calendar-clipboard.js

  • Committer: Package Import Robot
  • Author(s): Chris Coulson
  • Date: 2012-02-07 12:00:41 UTC
  • mfrom: (1.1.16)
  • Revision ID: package-import@ubuntu.com-20120207120041-qo3fapzsweii9cra
Tags: 1.3~b1+build1-0ubuntu1
* New upstream release from the beta channel (CALENDAR_1_3b1_BUILD1)
* Drop 02_fix_system_libxul_build.patch - this is fixed upstream
* Add mozilla/mfbt to tarball

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 *   Joey Minta <jminta@gmail.com>
23
23
 *   Philipp Kewisch <mozilla@kewis.ch>
24
24
 *   Martin Schroeder <mschroeder@mozilla.x-home.org>
 
25
 *   Matthew Mecca <matthew.mecca@gmail.com>
25
26
 *
26
27
 * Alternatively, the contents of this file may be used under the terms of
27
28
 * either the GNU General Public License Version 2 or later (the "GPL"), or
73
74
 * deletes the events on success
74
75
 */
75
76
function cutToClipboard() {
76
 
    let calendarItemArray = currentView().getSelectedItems({});
77
 
 
78
 
    if (copyToClipboard(calendarItemArray)) {
79
 
        deleteSelectedEvents();
 
77
    if (copyToClipboard()) {
 
78
        deleteSelectedItems();
80
79
    }
81
80
}
82
81
 
91
90
 */
92
91
function copyToClipboard(calendarItemArray) {
93
92
    if (!calendarItemArray) {
94
 
        calendarItemArray = currentView().getSelectedItems({});
 
93
        calendarItemArray = getSelectedItems();
95
94
    }
96
95
 
97
96
    if (!calendarItemArray.length) {
 
97
        cal.LOG("[calendar-clipboard] No items to copy.");
98
98
        return false;
99
99
    }
100
100
 
207
207
            }
208
208
            let firstDate = currentView().selectedDay;
209
209
 
210
 
            // Timezones and DT/DST time may differ between the earliest item
211
 
            // and the selected day. Determine the offset between the
212
 
            // earliestDate in local time and the selected day in whole days.
213
 
            earliestDate = earliestDate.getInTimezone(calendarDefaultTimezone());
214
 
            earliestDate.isDate = true;
215
 
            let offset = firstDate.subtractDate(earliestDate);
216
 
            let deltaDST = firstDate.timezoneOffset - earliestDate.timezoneOffset;
217
 
            offset.inSeconds += deltaDST;
 
210
            let offset = null;
 
211
            if (earliestDate) {
 
212
                // Timezones and DT/DST time may differ between the earliest item
 
213
                // and the selected day. Determine the offset between the
 
214
                // earliestDate in local time and the selected day in whole days.
 
215
                earliestDate = earliestDate.getInTimezone(calendarDefaultTimezone());
 
216
                earliestDate.isDate = true;
 
217
                offset = firstDate.subtractDate(earliestDate);
 
218
                let deltaDST = firstDate.timezoneOffset - earliestDate.timezoneOffset;
 
219
                offset.inSeconds += deltaDST;
 
220
            }
218
221
 
219
222
            startBatchTransaction();
220
223
            for each (let item in items) {
222
225
                // Set new UID to allow multiple paste actions of the same
223
226
                // clipboard content.
224
227
                newItem.id = cal.getUUID();
225
 
                cal.shiftItem(newItem, offset);
 
228
                if (offset) {
 
229
                    cal.shiftItem(newItem, offset);
 
230
                }
226
231
                doTransaction('add', newItem, destCal, null, null);
227
232
            }
228
233
            endBatchTransaction();