calendarCtrl.js 1.8 KB

1
  1. "use strict";app.controller("CalendarCtrl",["$scope","$aside","moment","SweetAlert",function(e,t,n,a){function l(n,a){var l=t.open({templateUrl:"calendarEvent.html",placement:"right",size:"sm",backdrop:!0,controller:function(e,t){e.$modalInstance=t,e.action=n,e.event=a,e.cancel=function(){t.dismiss("cancel")},e.deleteEvent=function(){t.close(e.event,e.event)}}});l.result.then(function(t,n){e.eventDeleted(t)})}var o=new Date,s=o.getDate(),i=o.getMonth(),c=o.getFullYear();e.events=[{title:"Birthday Party",type:"home",starts_at:new Date(c,i,5,19,0),ends_at:new Date(c,i,5,22,30)},{title:"AngularJS Seminar",type:"off-site-work",starts_at:new Date(c,i,8,10,30),ends_at:new Date(c,i,9,18,30)},{title:"Event 1",type:"job",starts_at:new Date(c,i,s-5),ends_at:new Date(c,i,s-2)},{title:"Event 2",type:"cancelled",starts_at:new Date(c,i,s-3,16,0),ends_at:new Date(c,i,s-3,18,0)},{title:"This is a really long event title",type:"to-do",starts_at:new Date(c,i,s+1,19,0),ends_at:new Date(c,i,s+1,22,30)}],e.calendarView="month",e.calendarDay=new Date,e.eventClicked=function(e){l("Clicked",e)},e.addEvent=function(){e.events.push({title:"New Event",starts_at:new Date(c,i,s,10,0),ends_at:new Date(c,i,s,11,0),type:"job"}),e.eventEdited(e.events[e.events.length-1])},e.eventEdited=function(e){l("Edited",e)},e.eventDeleted=function(t){a.swal({title:"Are you sure?",text:"Your will not be able to recover this event!",type:"warning",showCancelButton:!0,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes, delete it!",cancelButtonText:"No, cancel plx!",closeOnConfirm:!1,closeOnCancel:!1},function(n){n?(e.events.splice(t.$id,1),a.swal("Deleted!","Event has been deleted.","success")):a.swal("Cancelled","Event is safe :)","error")})},e.setCalendarToToday=function(){e.calendarDay=new Date},e.toggle=function(e,t,n){e.preventDefault(),e.stopPropagation(),n[t]=!n[t]}}]);