瀏覽代碼

active plugins when they are loaded

Adam Shaw 7 年之前
父節點
當前提交
8b4a9d486f
共有 6 個文件被更改,包括 13 次插入2 次删除
  1. 2 0
      plugins/luxon/main.ts
  2. 2 1
      plugins/moment-timezone/main.ts
  3. 1 0
      plugins/moment/main.ts
  4. 2 0
      src/exports.ts
  5. 2 1
      src/options.ts
  6. 4 0
      tests/automated/globals.js

+ 2 - 0
plugins/luxon/main.ts

@@ -38,6 +38,7 @@ class LuxonNamedTimeZone extends fc.NamedTimeZoneImpl {
 }
 }
 
 
 fc.registerNamedTimeZoneImpl('luxon', LuxonNamedTimeZone)
 fc.registerNamedTimeZoneImpl('luxon', LuxonNamedTimeZone)
+fc.globalDefaults.timeZoneImpl = 'luxon'
 
 
 
 
 fc.registerCmdFormatter('luxon', function(cmdStr: string, arg: fc.VerboseFormattingArg) {
 fc.registerCmdFormatter('luxon', function(cmdStr: string, arg: fc.VerboseFormattingArg) {
@@ -68,6 +69,7 @@ fc.registerCmdFormatter('luxon', function(cmdStr: string, arg: fc.VerboseFormatt
     arg.localeCodes[0]
     arg.localeCodes[0]
   ).toFormat(cmd.whole)
   ).toFormat(cmd.whole)
 })
 })
+fc.globalDefaults.cmdFormatter = 'luxon'
 
 
 
 
 function luxonToArray(datetime: DateTime): number[] {
 function luxonToArray(datetime: DateTime): number[] {

+ 2 - 1
plugins/moment-timezone/main.ts

@@ -1,6 +1,6 @@
 import * as moment from 'moment'
 import * as moment from 'moment'
 import 'moment-timezone'
 import 'moment-timezone'
-import { NamedTimeZoneImpl, registerNamedTimeZoneImpl } from 'fullcalendar'
+import { NamedTimeZoneImpl, registerNamedTimeZoneImpl, globalDefaults } from 'fullcalendar'
 
 
 
 
 class MomentNamedTimeZone extends NamedTimeZoneImpl {
 class MomentNamedTimeZone extends NamedTimeZoneImpl {
@@ -17,3 +17,4 @@ class MomentNamedTimeZone extends NamedTimeZoneImpl {
 
 
 
 
 registerNamedTimeZoneImpl('moment-timezone', MomentNamedTimeZone)
 registerNamedTimeZoneImpl('moment-timezone', MomentNamedTimeZone)
+globalDefaults.timeZoneImpl = 'moment-timezone'

+ 1 - 0
plugins/moment/main.ts

@@ -49,6 +49,7 @@ fc.registerCmdFormatter('moment', function(cmdStr: string, arg: fc.VerboseFormat
     arg.localeCodes[0]
     arg.localeCodes[0]
   ).format(cmd.whole) // TODO: test for this
   ).format(cmd.whole) // TODO: test for this
 })
 })
+fc.globalDefaults.cmdFormatter = 'moment'
 
 
 function createMomentFormatFunc(mom: moment.Moment) {
 function createMomentFormatFunc(mom: moment.Moment) {
   return function(cmdStr) {
   return function(cmdStr) {

+ 2 - 0
src/exports.ts

@@ -120,3 +120,5 @@ export { default as Draggable } from './interactions-external/ExternalDraggable'
 export { default as ThirdPartyDraggable } from './interactions-external/ThirdPartyDraggable'
 export { default as ThirdPartyDraggable } from './interactions-external/ThirdPartyDraggable'
 
 
 export { formatDate, formatRange } from './formatting-api'
 export { formatDate, formatRange } from './formatting-api'
+
+export { globalDefaults } from './options'

+ 2 - 1
src/options.ts

@@ -5,7 +5,7 @@ export const globalDefaults = {
 
 
   defaultRangeSeparator: ' - ',
   defaultRangeSeparator: ' - ',
   titleRangeSeparator: ' \u2013 ', // en dash
   titleRangeSeparator: ' \u2013 ', // en dash
-  //cmdFormatter: null,
+  cmdFormatter: null,
 
 
   defaultTimedEventDuration: '02:00:00',
   defaultTimedEventDuration: '02:00:00',
   defaultAllDayEventDuration: { day: 1 },
   defaultAllDayEventDuration: { day: 1 },
@@ -41,6 +41,7 @@ export const globalDefaults = {
   timeZoneParam: 'timeZone',
   timeZoneParam: 'timeZone',
 
 
   timeZone: 'UTC', // TODO: throw error if given falsy value?
   timeZone: 'UTC', // TODO: throw error if given falsy value?
+  timeZoneImpl: null,
 
 
   // allDayDefault: undefined,
   // allDayDefault: undefined,
 
 

+ 4 - 0
tests/automated/globals.js

@@ -235,3 +235,7 @@ window.spyCall = function(func) {
 window.pushOptions({
 window.pushOptions({
   timeZone: 'UTC'
   timeZone: 'UTC'
 })
 })
+
+// clear what plugins do. will take affect for all calendars, not just those via initCalendar()
+FullCalendar.globalDefaults.timeZoneImpl = null
+FullCalendar.globalDefaults.cmdFormatter = null