main.js 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. var FC = $.fullCalendar = {
  2. version: "<%= version %>",
  3. // When introducing internal API incompatibilities (where fullcalendar plugins would break),
  4. // the minor version of the calendar should be upped (ex: 2.7.2 -> 2.8.0)
  5. // and the below integer should be incremented.
  6. internalApiVersion: 9
  7. };
  8. var fcViews = FC.views = {};
  9. $.fn.fullCalendar = function(options) {
  10. var args = Array.prototype.slice.call(arguments, 1); // for a possible method call
  11. var res = this; // what this function will return (this jQuery object by default)
  12. this.each(function(i, _element) { // loop each DOM element involved
  13. var element = $(_element);
  14. var calendar = element.data('fullCalendar'); // get the existing calendar object (if any)
  15. var singleRes; // the returned value of this single method call
  16. // a method call
  17. if (typeof options === 'string') {
  18. if (calendar && $.isFunction(calendar[options])) {
  19. singleRes = calendar[options].apply(calendar, args);
  20. if (!i) {
  21. res = singleRes; // record the first method call result
  22. }
  23. if (options === 'destroy') { // for the destroy method, must remove Calendar object data
  24. element.removeData('fullCalendar');
  25. }
  26. }
  27. }
  28. // a new calendar initialization
  29. else if (!calendar) { // don't initialize twice
  30. calendar = new Calendar(element, options);
  31. element.data('fullCalendar', calendar);
  32. calendar.render();
  33. }
  34. });
  35. return res;
  36. };
  37. var complexOptions = [ // names of options that are objects whose properties should be combined
  38. 'header',
  39. 'footer',
  40. 'buttonText',
  41. 'buttonIcons',
  42. 'themeButtonIcons'
  43. ];
  44. // Merges an array of option objects into a single object
  45. function mergeOptions(optionObjs) {
  46. return mergeProps(optionObjs, complexOptions);
  47. }