Advertisement
Guest User

Untitled

a guest
Jun 20th, 2013
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function showCalendar() {
  2.  
  3.     dojo.require("dojo.dnd.move");
  4.     dojo.require("dojox.layout.FloatingPane");
  5.  
  6.     require([
  7.                 'dojox/calendar/Calendar',
  8.                 'dojox/calendar/CalendarBase',
  9.                 'dojo/store/Memory',
  10.                 'dojo/store/Observable',
  11.                 'dojo/when',
  12.                 'dojo/parser',
  13.                 'dojo/domReady!'],
  14.            
  15.  
  16.             function(Calendar, CalendarBase, Memory, Observable, when) {
  17.                 var divA = document.getElementById('rcg');
  18.                 divA.style.display = 'block';
  19.                 divA.style.visibility = 'visible';
  20.  
  21.                 document.body.appendChild(divA);
  22.  
  23.                 var ParentConstrainedFloatingPane = dojo.declare(dojox.layout.FloatingPane, {
  24.                     postCreate: function () {
  25.                         this.close = function () {
  26.                             this.domNode.style.display = "none";
  27.                             this.domNode.style.visibility = "hidden";
  28.                         };
  29.                         this.inherited(arguments);
  30.                         this.moveable = new dojo.dnd.move.parentConstrainedMoveable(
  31.                             this.domNode, {
  32.                                 handle: this.focusNode,
  33.                                 area: "content",
  34.                                 within: true
  35.                             }
  36.                         );
  37.                     }
  38.                 });
  39.  
  40.                 var BoxConstrainedFloatingPane = dojo.declare(dojox.layout.FloatingPane, {
  41.  
  42.                     postCreate: function() {
  43.                         this.inherited(arguments);
  44.                         this.moveable = new dojo.dnd.move.boxConstrainedMoveable(
  45.                             this.domNode, {
  46.                                 handle: this.focusNode,
  47.                                 box: { l: 0, t: 0, w: 0, h: 0 },
  48.                                 within: false
  49.                             }
  50.                         );
  51.                     }
  52.                 });
  53.  
  54.                 var ConstrainedFloatingPane = dojo.declare(dojox.layout.FloatingPane, {
  55.                     postCreate: function() {
  56.                         this.inherited(arguments);
  57.                         this.close = function () {
  58.                             this.domNode.style.display = "none";
  59.                             this.domNode.style.visibility = "hidden";
  60.                         };
  61.                         this.moveable = new dojo.dnd.move.constrainedMoveable(
  62.                             this.domNode, {
  63.                                 handle: this.focusNode,
  64.                                
  65.                                 constraints: function() {
  66.                                     var coordsBody = dojo.coords(dojo.body());
  67.                                     // or
  68.                                     var coordsWindow = {
  69.                                         l: 0,
  70.                                         t: 0,
  71.  
  72.                                         w: window.innerWidth,
  73.                                         h: window.innerHeight
  74.                                     };
  75.                                     return coordsWindow;
  76.                                 },
  77.  
  78.                                 within: true
  79.                             }
  80.                         );
  81.                     }
  82.                 });
  83.  
  84.                
  85.                 var fpaner = new ParentConstrainedFloatingPane({
  86.                     title: "Koledar",
  87.                     resizable: true,
  88.                     maxable: true,
  89.                     dockable: true,
  90.                     closable: true,
  91.                     //constrainToContainer: true,
  92.                     style: "position:absolute;top:110px;left:335px;width:700px;height:650px;"
  93.                 }, "rcg");
  94.                
  95.                 var someData = [
  96.                     {
  97.                         id: 0,
  98.                         summary: "Event 1",
  99.                         startTime: new Date(2013, 5, 17, 10),
  100.                         endTime: new Date(2013, 5, 17, 12),
  101.                         calendar: "Calendar1"
  102.                     },
  103.                     {
  104.                         id: 1,
  105.                         summary: "Event 2",
  106.                         startTime: new Date(2013, 5, 17, 14),
  107.                         endTime: new Date(2013, 5, 17, 15),
  108.                         calendar: "Calendar2"
  109.                     }
  110.                 ];
  111.  
  112.                 var someData2 = [
  113.                     {
  114.                         id: 30,
  115.                         summary: "Event 3",
  116.                         startTime: new Date(2013, 6, 29, 10),
  117.                         endTime: new Date(2013, 6, 29, 12),
  118.                         calendar: "Calendar1"
  119.                     },
  120.                     {
  121.                         id: 40,
  122.                         summary: "Event 4",
  123.                         startTime: new Date(2013, 6, 27, 14),
  124.                         endTime: new Date(2013, 6, 27, 15),
  125.                         calendar: "Calendar2"
  126.                     }
  127.                 ];
  128.  
  129.                 var calendar = new Calendar({
  130.                     date: new Date(2013, 5, 17),
  131.                     dateInterval: "month",
  132.                     columnViewProps: { minHours: 0, maxHours: 24 },
  133.                     style: "position:relative;height:100%"
  134.                 });
  135.  
  136.                 calendar.on("timeIntervalChange", function(e) {
  137.                     var YYYY = e.startTime;
  138.                     var MM = e.startTime.getMonth() + 1;
  139.                     var DD = e.startTime.getDay();
  140.  
  141.                     var YYYYend = e.endTime.getFullYear();
  142.                     var MMend = e.endTime.getMonth() + 1;
  143.                     var DDend = e.startTime.getDay();
  144.  
  145.                     if (MM < 10)
  146.                     { MM = '0' + MM };
  147.  
  148.                     if (MMend < 10)
  149.                     { MMend = '0' + MMend };
  150.  
  151.                     if (MM == "06") {
  152.                         calendar.set('store', new Observable(new Memory({ data: someData })));
  153.                     }
  154.                     else if (MM == "07") {
  155.                         calendar.set('store', new Observable(new Memory({ data: someData2 })));
  156.                     }
  157.                 });
  158.  
  159.                     calendar.placeAt(fpaner);
  160.                     fpaner.startup();
  161.                     fpaner.show();
  162.             });
  163.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement