FullCalendar.io

In this example below you will see how to do a FullCalendar.io with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by ptongalex, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright ptongalex ©

Technologies

  • HTML
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>FullCalendar.io</title>
  
  
  <link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'>
<link rel='stylesheet prefetch' href='https://cdn.rawgit.com/fullcalendar/fullcalendar/v3.2.0/dist/fullcalendar.min.css'>
<link rel='stylesheet prefetch' href='https://cdn.rawgit.com/likeastore/ngDialog/master/css/ngDialog.min.css'>
<link rel='stylesheet prefetch' href='https://cdn.rawgit.com/likeastore/ngDialog/master/css/ngDialog-theme-default.min.css'>

  
  
</head>

<body>

  <div ng-app='app' ng-controller='Main' class='container-fluid'>
  <p style='color:red'>{{eventSources[0].start}} - {{eventSources[0].end}}    -    {{eventSources[0].title}}</p>
  <div ui-calendar="calendarOptions.calendar" ng-model="eventSources" calendar="myCalendar">
    
  rdff
</div>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.6.1/angular.min.js'></script>
<script src='https://cdn.rawgit.com/moment/moment/develop/moment.js'></script>
<script src='https://cdn.rawgit.com/angular-ui/ui-calendar/master/src/calendar.js'></script>
<script src='https://cdn.rawgit.com/fullcalendar/fullcalendar/v3.2.0/dist/fullcalendar.min.js'></script>
<script src='https://cdn.rawgit.com/likeastore/ngDialog/master/js/ngDialog.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/ptongalex/fullcalendario-RKXJKe */
angular.module('app', ['ui.calendar', 'ngDialog'])
.controller('Main', function($scope, ngDialog, $timeout, $compile, uiCalendarConfig){
  $scope.eventSources = [
    {
      idx: 9,
      title: 'Happy Hour',
      start: '2017-02-20T02:30:00',
      end: '2017-02-20T04:30:00'
    }
  ];
   
  $scope.calendarOptions = 
    {
      calendar: {
        height: 450,
                eventOverlap: false,
                selectOverlap: false,
                slotEventOverlap: false,
                allDaySlot: false,
                theme: false,
                defaultView: 'agendaWeek',
                minTime: '00:00',
                maxTime: '24:00',
                timeFormat: 'H:mm',
                slotLabelFormat:"HH:mm",
                scrollTime: false,
                firstDay: 1, // Monday = 1
                lastDay: 7,  // Sunday = 7
                timezone: "local",
                ignoreTimezone: true,
                navLinks: true, // can click day/week names to navigate views
                selectable: true,
                selectHelper: true,
                editable: true,
                sticky: true,
                eventLimit: true, // allow "more" link when too many events
                header: {
                    left: '',
                    center: '',
                    right: ''
                },
                eventConstraint:{
                    start: '00:00',
                    end: '24:00'
                },
        eventClick: _eventClick,
        eventDrop: _eventDrop,
        eventResize: _eventDrop,
        select: _eventSelection
      }
      };
  
  $timeout(function () {
    var calendarThs = angular.element('.fc-head-container').find('th');
    
    var _tmpl = '<br><a href ng-click="copyTo()" style="color: red">Copy to <span class="glyphicon glyphicon-copy"></span></a>';
    angular.forEach(calendarThs, function (th, index) {
      if (index !== 0) {
        angular.element(th).append($compile(_tmpl)($scope));
      }
    });
  });
  
  $scope.copyTo = function () {
    console.log('copyTo');
  };
  
  var _editCellTemplate =
            `<input type="text" ng-model="editValue" style="width: 400px"/><br>
             <button class="btn btn-blue" ng-click="ok()">Ok</button>
            `;
  
  function _eventSelection (start, end) {
        let _hourStart = start._d.getHours();
        let _minStart  = start._d.getMinutes();

        let _hourEnd   = end._d.getHours();
        let _minEnd    = end._d.getMinutes();

        if (_minEnd === 30) {
            _minEnd = 29;
        } else if (_minEnd === 0) {
            _minEnd = 59;
            _hourEnd--;
        }

        let _newEvent = {
          start: start,
          end: end,
          employeeCount: 1,
          title: '1'
        };
      
    uiCalendarConfig.calendars.myCalendar.fullCalendar('addEvent', _newEvent);
    $scope.eventSources.push(_newEvent);
  }
  
  function _eventDrop (event, element) {
    $scope.eventSources[0].start = event.start;
    $scope.eventSources[0].end = event.end;
  }
  
  function _eventClick (event, element) {
    console.log('clicked');
    ngDialog.open({
                        template: _editCellTemplate,
                        preCloseCallback: function (editValue) {
                          $scope.eventSources[0].title = editValue;
                        
                          console.log('event', event);
                        },
                        controller: function ($scope, _editedValue) {
                            $scope.editValue = _editedValue.title;
                            $scope.ok = ok;

                            function ok() {
                                return $scope.closeThisDialog($scope.editValue);
                            }
                        },
                        resolve: {
                            _editedValue: function () {
                                return event;
                            }
                        },
                        plain: true
                    });
  }
});

Comments