Js: Extensible Calendar Examples
http://ext.ensible.com
https://github.com/bmoeskau/Extensible
https://github.com/TeamupCom/extensible
http://www.rahulsingla.com/sites/default/files/content/blog/extjs-calendar/dynamic-calendars.html
http://ext.ensible.com/deploy/dev/examples/
http://ext.ensible.com/products/calendar/download/choose.php
dynamic-calendars.js:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | Ext.ns( 'Ext.ensible.sample' ); Ext.ensible.sample.CalendarData = { "calendars" :[{ "id" :1, "title" : "Home" , "color" :2 },{ "id" :2, "title" : "Work" , "color" :22 },{ "id" :3, "title" : "School" , "color" :7 },{ "id" :4, "title" : "Sports" , //"hidden":true, // optionally init this calendar as hidden by default "color" :26 }] }; var today = new Date().clearTime(); Ext.ensible.sample.EventData = { "evts" :[{ "id" :1001, "cid" :1, "title" : "Vacation" , "start" :today.add(Date.DAY, -20).add(Date.HOUR, 10), "end" :today.add(Date.DAY, -10).add(Date.HOUR, 15), "notes" : "Have fun" },{ "id" :1002, "cid" :2, "title" : "Lunch with Matt" , "start" :today.add(Date.HOUR, 11).add(Date.MINUTE, 30), "end" :today.add(Date.HOUR, 13), "loc" : "Chuy's!" , "url" : "http://chuys.com" , "notes" : "Order the queso" , "rem" : "15" },{ "id" :1003, "cid" :3, "title" : "Project due" , "start" :today.add(Date.HOUR, 15), "end" :today.add(Date.HOUR, 15) },{ "id" :1004, "cid" :1, "title" : "Sarah's birthday" , "start" :today, "end" :today, "notes" : "Need to get a gift" , "ad" : true },{ "id" :1005, "cid" :2, "title" : "A long one..." , "start" :today.add(Date.DAY, -12), "end" :today.add(Date.DAY, 10).add(Date.SECOND, -1), "ad" : true },{ "id" :1006, "cid" :3, "title" : "School holiday" , "start" :today.add(Date.DAY, 5), "end" :today.add(Date.DAY, 7).add(Date.SECOND, -1), "ad" : true , "rem" : "2880" },{ "id" :1007, "cid" :1, "title" : "Haircut" , "start" :today.add(Date.HOUR, 9), "end" :today.add(Date.HOUR, 9).add(Date.MINUTE, 30), "notes" : "Get cash on the way" },{ "id" :1008, "cid" :3, "title" : "An old event" , "start" :today.add(Date.DAY, -30), "end" :today.add(Date.DAY, -28), "ad" : true },{ "id" :1009, "cid" :2, "title" : "Board meeting" , "start" :today.add(Date.DAY, -2).add(Date.HOUR, 13), "end" :today.add(Date.DAY, -2).add(Date.HOUR, 18), "loc" : "ABC Inc." , "rem" : "60" },{ "id" :1010, "cid" :3, "title" : "Jenny's final exams" , "start" :today.add(Date.DAY, -2), "end" :today.add(Date.DAY, 3).add(Date.SECOND, -1), "ad" : true },{ "id" :1011, "cid" :1, "title" : "Movie night" , "start" :today.add(Date.DAY, 2).add(Date.HOUR, 19), "end" :today.add(Date.DAY, 2).add(Date.HOUR, 23), "notes" : "Don't forget the tickets!" , "rem" : "60" },{ "id" :1012, "cid" :4, "title" : "Gina's basketball tournament" , "start" :today.add(Date.DAY, 8).add(Date.HOUR, 8), "end" :today.add(Date.DAY, 10).add(Date.HOUR, 17) },{ "id" :1013, "cid" :4, "title" : "Toby's soccer game" , "start" :today.add(Date.DAY, 5).add(Date.HOUR, 10), "end" :today.add(Date.DAY, 5).add(Date.HOUR, 12) }] }; /* * A simple reusable store that loads static calendar field definitions into memory * and can be bound to the CalendarCombo widget and used for calendar color selection. */ Ext.ensible.sample.CalendarStore = Ext.extend(Ext.data.Store, { constructor: function (config){ config = Ext.applyIf(config || {}, { storeId: 'calendarStore' , root: 'calendars' , idProperty: Ext.ensible.cal.CalendarMappings.CalendarId.mapping || 'id' , proxy: new Ext.data.MemoryProxy(), autoLoad: true , fields: Ext.ensible.cal.CalendarRecord.prototype.fields.getRange(), sortInfo: { field: Ext.ensible.cal.CalendarMappings.Title.name, direction: 'ASC' } }); this .reader = new Ext.data.JsonReader(config); Ext.ensible.sample.CalendarStore.superclass.constructor.call( this , config); } }); /* * This is a simple in-memory store implementation that is ONLY intended for use with * calendar samples running locally in the browser with no external data source. Under * normal circumstances, stores that use a MemoryProxy are read-only and intended only * for displaying data read from memory. In the case of the calendar, it's still quite * useful to be able to deal with in-memory data for sample purposes (as many people * may not have PHP set up to run locally), but by default, updates will not work since the * calendar fully expects all CRUD operations to be supported by the store (and in fact * will break, for example, if phantom records are not removed properly). This simple * class gives us a convenient way of loading and updating calendar event data in memory, * but should NOT be used outside of the local samples. * * For a real-world store implementation see the remote sample (remote.js). */ Ext.ensible.sample.MemoryEventStore = Ext.extend(Ext.data.Store, { constructor: function (config){ config = Ext.applyIf(config || {}, { storeId: 'eventStore ', root: ' evts ', proxy: new Ext.data.MemoryProxy(), writer: new Ext.data.DataWriter(), fields: Ext.ensible.cal.EventRecord.prototype.fields.getRange(), idProperty: Ext.ensible.cal.EventMappings.EventId.mapping || ' id ' }); this.reader = new Ext.data.JsonReader(config); Ext.ensible.sample.MemoryEventStore.superclass.constructor.call(this, config); }, // In real implementations the store is responsible for committing records // after a remote transaction has returned success = true. Since we never do // a real transaction, we never get any of the normal store callbacks telling // us that an edit occurred. This simple hack works around that for the purposes // of the local samples, but should NEVER actually be done in real code. afterEdit : function(rec){ rec.commit(); }, listeners: { // Since MemoeryProxy has no "create" implementation, added events // get stuck as phantoms without an EventId. The calendar does not support // batching transactions and expects records to be non-phantoms, so for // the purpose of local samples we can hack that into place. In real remote // scenarios this is handled automatically by the store, and so you should // NEVER actually do something like this. ' add ': function(store, rec){ var r = rec[0]; r.data[Ext.ensible.cal.EventMappings.EventId.name] = r.id; r.phantom = false; r.commit(); } } }); App = function() { return { init: function() { Ext.BLANK_IMAGE_URL = ' http: //extjs.cachefly.net/ext-3.1.0/resources/images/default/s.gif'; // This is an example calendar store that enables event color-coding this .calendarStore = new Ext.ensible.sample.CalendarStore({ // defined in data-calendars.js data: Ext.ensible.sample.CalendarData }); // A sample event store that loads static JSON from a local file. Obviously a real // implementation would likely be loading remote data via an HttpProxy, but the // underlying store functionality is the same. this .eventStore = new Ext.ensible.sample.MemoryEventStore({ // defined in data-events.js data: Ext.ensible.sample.EventData }); // This is the app UI layout code. All of the calendar views are subcomponents of // CalendarPanel, but the app title bar and sidebar/navigation calendar are separate // pieces that are composed in app-specific layout code since they could be omitted // or placed elsewhere within the application. new Ext.Viewport({ layout: 'border ', renderTo: ' calendar-ct ', items: [{ id: ' app-header ', region: ' north ', height: 35, border: false, contentEl: ' app-header-content ' }, { id: ' app-center ', title: ' ... ', // will be updated to the current view' s date range region: 'center' , layout: 'border' , listeners: { 'afterrender' : function () { Ext.getCmp( 'app-center' ).header.addClass( 'app-center-header' ); } }, items: [{ id: 'app-west' , region: 'west' , width: 176, border: false , items: [{ xtype: 'datepicker' , id: 'app-nav-picker' , cls: 'ext-cal-nav-picker' , listeners: { 'select' : { fn: function (dp, dt) { App.calendarPanel.setStartDate(dt); }, scope: this } } }, { xtype: 'extensible.calendarlist' , store: this .calendarStore, border: false , width: 175 }, { xtype: 'button' , text: 'Manage Calendars' , handler: function () { App.calendarWindow.show(); } }] }, { xtype: 'extensible.calendarpanel' , eventStore: this .eventStore, calendarStore: this .calendarStore, border: false , id: 'app-calendar' , region: 'center' , activeItem: 3, // month view // Any generic view options that should be applied to all sub views: viewConfig: { //enableFx: false }, // View options specific to a certain view (if the same options exist in viewConfig // they will be overridden by the view-specific config): monthViewCfg: { showHeader: true , showWeekLinks: true , showWeekNumbers: true }, multiWeekViewCfg: { //weekCount: 3 }, // Some optional CalendarPanel configs to experiment with: //readOnly: true, //showDayView: false, //showMultiDayView: true, //showWeekView: false, //showMultiWeekView: false, //showMonthView: false, //showNavBar: false, //showTodayText: false, //showTime: false, //editModal: true, //title: 'My Calendar', // the header of the calendar, could be a subtitle for the app // Once this component inits it will set a reference to itself as an application // member property for easy reference in other functions within App. initComponent: function () { App.calendarPanel = this ; this .constructor.prototype.initComponent.apply( this , arguments); }, // plugins: [{ // ptype: 'ext.ensible.cal.contextmenu' // }], listeners: { 'eventclick' : { fn: function (vw, rec, el) { this .clearMsg(); }, scope: this }, 'eventover' : function (vw, rec, el) { //console.log('Entered evt rec='+rec.data[Ext.ensible.cal.EventMappings.Title.name]', view='+ vw.id +', el='+el.id); }, 'eventout' : function (vw, rec, el) { //console.log('Leaving evt rec='+rec.data[Ext.ensible.cal.EventMappings.Title.name]+', view='+ vw.id +', el='+el.id); }, 'eventadd' : { fn: function (cp, rec) { this .showMsg( 'Event ' + rec.data[Ext.ensible.cal.EventMappings.Title.name] + ' was added' ); }, scope: this }, 'eventupdate' : { fn: function (cp, rec) { this .showMsg( 'Event ' + rec.data[Ext.ensible.cal.EventMappings.Title.name] + ' was updated' ); }, scope: this }, 'eventdelete' : { fn: function (cp, rec) { //this.eventStore.remove(rec); this .showMsg( 'Event ' + rec.data[Ext.ensible.cal.EventMappings.Title.name] + ' was deleted' ); }, scope: this }, 'eventcancel' : { fn: function (cp, rec) { // edit canceled }, scope: this }, 'viewchange' : { fn: function (p, vw, dateInfo) { if ( this .editWin) { this .editWin.hide(); }; if (dateInfo !== null ) { // will be null when switching to the event edit form so ignore Ext.getCmp( 'app-nav-picker' ).setValue(dateInfo.activeDate); this .updateTitle(dateInfo.viewStart, dateInfo.viewEnd); } }, scope: this }, 'dayclick' : { fn: function (vw, dt, ad, el) { this .clearMsg(); }, scope: this }, 'rangeselect' : { fn: function (vw, dates, onComplete) { this .clearMsg(); }, scope: this }, 'eventmove' : { fn: function (vw, rec) { rec.commit(); var time = rec.data[Ext.ensible.cal.EventMappings.IsAllDay.name] ? '' : ' \\a\\t g:i a' ; this .showMsg( 'Event ' + rec.data[Ext.ensible.cal.EventMappings.Title.name] + ' was moved to ' + rec.data[Ext.ensible.cal.EventMappings.StartDate.name].format( 'F jS' + time)); }, scope: this }, 'eventresize' : { fn: function (vw, rec) { rec.commit(); this .showMsg( 'Event ' + rec.data[Ext.ensible.cal.EventMappings.Title.name] + ' was updated' ); }, scope: this }, 'eventdelete' : { fn: function (win, rec) { this .eventStore.remove(rec); this .showMsg( 'Event ' + rec.data[Ext.ensible.cal.EventMappings.Title.name] + ' was deleted' ); }, scope: this }, 'initdrag' : { fn: function (vw) { if ( this .editWin && this .editWin.isVisible()) { this .editWin.hide(); } }, scope: this } } }] }] }); }, // The CalendarPanel itself supports the standard Panel title config, but that title // only spans the calendar views. For a title that spans the entire width of the app // we added a title to the layout's outer center region that is app-specific. This code // updates that outer title based on the currently-selected view range anytime the view changes. updateTitle: function (startDt, endDt) { var p = Ext.getCmp('app-center '); if (startDt.clearTime().getTime() == endDt.clearTime().getTime()) { p.setTitle(startDt.format(' F j, Y ')); } else if (startDt.getFullYear() == endDt.getFullYear()) { if (startDt.getMonth() == endDt.getMonth()) { p.setTitle(startDt.format(' F j ') + ' - ' + endDt.format(' j, Y ')); } else { p.setTitle(startDt.format(' F j ') + ' - ' + endDt.format(' F j, Y ')); } } else { p.setTitle(startDt.format(' F j, Y ') + ' - ' + endDt.format(' F j, Y ')); } }, // This is an application-specific way to communicate CalendarPanel event messages back to the user. // This could be replaced with a function to do "toast" style messages, growl messages, etc. This will // vary based on application requirements, which is why it' s not baked into the CalendarPanel. showMsg: function (msg) { Ext.fly( 'app-msg' ).update(msg).removeClass( 'x-hidden' ); }, clearMsg: function () { Ext.fly( 'app-msg' ).update( '' ).addClass( 'x-hidden' ); } } } (); Ext.onReady(App.init, App); /////////////////////////////////////////////////////////////////////////////////////////////////////////// //Dynamic Calendars support. Ext.onReady( function () { App.calendarWindowMenu = new Ext.menu.Menu({ cls: 'x-calendar-list-menu' , items: [ new Ext.ensible.cal.ColorPalette({ handler: function (palette, colorId) { var record = App.calendarPanel.calendarStore.getAt(App.calendarWindowMenu.recordIndex); record.set( 'ColorId' , colorId); App.calendarWindowMenu.hide(); App.calendarWindowDataView.refreshNode(App.calendarWindowMenu.recordIndex); } }), new Ext.menu.Item({ text: 'Delete' , iconCls: 'no-icon' , handler: function () { Ext.Msg.confirm( 'Action confirmation' , 'Please ensure no Event is associated to this Calendar. Continue with deletion?' , function (btn) { if (btn == 'yes' ) { App.calendarPanel.calendarStore.removeAt(App.calendarWindowMenu.recordIndex); } }); } })] }); App.calendarWindow = new Ext.Window({ title: 'Manage Calendars' , width: 325, height: 400, modal: true , layout: 'fit' , closeAction: 'hide' , bodyStyle: 'background-color: white' , items: [ new Ext.DataView({ store: App.calendarPanel.calendarStore, cls: 'x-combo-list' , style: 'background-color: white; padding: 5px' , itemSelector: '.x-combo-list-item' , selectedClass: 'x-combo-selected' , overClass: 'x-combo-selected' , autoScroll: true , tpl: new Ext.XTemplate( '<div>Click on a Calendar to change its color or remove it.</div>' , '<tpl for=".">' , '<div class="x-combo-list-item" style="vertical-align: middle">' , '<div class="x-cal-{ColorId}">' , '<div class="mail-calendar-cat-color ext-cal-picker-icon" onmouseover="Ext.get(this).addClass(\'mail-calendar-cat-color-over\');" onmouseout="Ext.get(this).removeClass(\'mail-calendar-cat-color-over\');"> </div>' , '</div>' , '<div>{Title}</div>' , '</div>' , '</tpl>' , '<div class="x-clear"></div>' ), multiSelect: false , listeners: { click: function (view, index, node, e) { App.calendarWindowMenu.recordIndex = index; App.calendarWindowMenu.show(Ext.get(node)); } } })], buttons: [{ text: 'Add Calendar' , handler: function () { Ext.Msg.prompt( 'Enter name' , 'Enter calendar name:' , function (btn, text) { if (btn != 'ok' ) return ; if (App.calendarPanel.calendarStore.findExact( 'Title' , text) != -1) { Ext.Msg.alert( 'Invalid input' , 'A Calendar with the same name already exists.' ); } else { App.calendarPanel.calendarStore.loadData({ calendars: [{ title: text, color: 1}] }, true ); } }); } }, { text: 'Save Changes' , handler: function () { Ext.Msg.alert( 'Save' , 'Save changes to the Calendars on the server here.' ); App.calendarPanel.calendarStore.commitChanges(); App.calendarWindow.hide(); } }, { text: 'Cancel' , handler: function () { App.calendarPanel.calendarStore.rejectAllChanges(); App.calendarWindowDataView.refresh(); App.calendarWindow.hide(); } } ] }); App.calendarWindowDataView = App.calendarWindow.items.items[0]; }); Ext.data.Store.prototype.rejectAllChanges = function () { this .rejectChanges(); for ( var i = this .data.length - 1; i >= 0; i--) { var rec = this .data.items[i]; if (rec.phantom) { this .remove(rec); if (Ext.isArray( this .deleted)) { this .deleted.remove(rec); } if (Ext.isArray( this .removed)) { this .removed.remove(rec); } } } } |
dynamic-calendars.html:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | <! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> < html xmlns="http://www.w3.org/1999/xhtml"> < title >Extensible Calendar - Dynamic Calendars</ title > <!-- Ext includes http://extjs.cachefly.net/--> < link rel="stylesheet" type="text/css" href="extjs3.2/resources/css/ext-all.css" /> < script type="text/javascript" src="extjs3.2/adapter/ext/ext-base-debug.js"></ script > < script type="text/javascript" src="extjs3.2/ext-all-debug.js"></ script > <!-- Extensible includes --> < link rel="stylesheet" type="text/css" href="calendar/css/extensible-all.css" /> < script type="text/javascript" src="calendar/extensible-all.js"></ script > <!-- Page-specific includes --> < link rel="stylesheet" type="text/css" href="test-app.css" /> < script type="text/javascript" src="dynamic-calendars.js"></ script > < style type="text/css"> .mail-calendar-cat-color { float: left; width: 10px; height: 10px; margin-right: 10px; } .mail-calendar-cat-color-over { width: 12px; height: 12px; } </ style > </ head > < body > < div style="display:none;"> < div id="app-header-content"> < div id="app-logo"> < div class="logo-top"> </ div > < div id="logo-body"> </ div > < div class="logo-bottom"> </ div > </ div > < h1 >Ext Calendar Pro < span >BETA</ span ></ h1 > < span id="app-msg" class="x-hidden"></ span > </ div > </ div > </ body > < script type="text/javascript"> var updateLogoDt = function () { document.getElementById('logo-body').innerHTML = new Date().getDate(); } updateLogoDt(); setInterval(updateLogoDt, 1000); </ script > </ html > |
哲学管理(学)人生, 文学艺术生活, 自动(计算机学)物理(学)工作, 生物(学)化学逆境, 历史(学)测绘(学)时间, 经济(学)数学金钱(理财), 心理(学)医学情绪, 诗词美容情感, 美学建筑(学)家园, 解构建构(分析)整合学习, 智商情商(IQ、EQ)运筹(学)生存.---Geovin Du(涂聚文)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!
2015-08-24 csharp: SDK:CAPICOM
2015-08-24 sql server:compare data from two tables