MWF.xApplication.Meeting = MWF.xApplication.Meeting || {}; MWF.require("MWF.xDesktop.UserData", null, false); MWF.xDesktop.requireApp("Meeting", "MeetingView", null, false); MWF.xDesktop.requireApp("Meeting", "Common", null, false); MWF.xDesktop.requireApp("Template", "MDomItem", null, false); MWF.xApplication.Meeting.options.multitask = false; MWF.xApplication.Meeting.Main = new Class({ Extends: MWF.xApplication.Common.Main, Implements: [Options, Events], options: { "style": "default", "name": "Meeting", "icon": "icon.png", "width": "1000", "height": "600", "isResize": true, "isMax": true, "sideBarEnable" : true, "settingEnable" : true, "title": MWF.xApplication.Meeting.LP.title }, onQueryLoad: function(){ this.lp = MWF.xApplication.Meeting.LP; this.menuMode="show"; this.isManager = MWF.AC.isMeetingAdministrator(); this.actions = MWF.Actions.get("x_meeting_assemble_control"); this.personActions = MWF.Actions.get("x_organization_assemble_express"); //if (!this.actions) this.actions = new MWF.xApplication.Meeting.Actions.RestActions(); //if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions(); }, loadApplication: function(callback) { MWF.UD.getDataJson("meetingConfig", function(json){ this.meetingConfig = json || {}; o2.Actions.load("x_meeting_assemble_control").ConfigAction.getSystemConfig(function(json){ var jsonData = json.data; if (jsonData.process){ this.meetingConfig.process = jsonData.process; }else{ this.meetingConfig.process = null; } if( jsonData.weekBegin ){ this.meetingConfig.weekBegin = jsonData.weekBegin; } if( jsonData.meetingViewer ){ this.meetingConfig.meetingViewer = jsonData.meetingViewer; } for( var key in jsonData ){ if( key !== "process" && key !== "weekBegin" && key !== "meetingViewer" ){ this.meetingConfig[ key ] = jsonData[key]; } } if( !this.meetingConfig.disableViewList ) this.meetingConfig.disableViewList = []; if( !this.meetingConfig.typeList ){ this.meetingConfig.typeList = []; }else{ this.meetingConfig.typeList = this.meetingConfig.typeList.filter(function(t){return !!t}); } this.createNode(); if (!this.options.isRefresh) { this.maxSize(function () { this.loadLayout(); }.bind(this)); } else { this.loadLayout(); } if (callback) callback(); }.bind(this)); }.bind(this)); }, createNode: function(){ this.content.setStyle("overflow", "hidden"); this.node = new Element("div", { "styles": {"width": "100%", "height": "100%", "overflow": "hidden"} }).inject(this.content); }, loadLayout: function(){ this.content.loadCss("../x_component_Meeting/$Main/default/style.css"); if( this.status && this.status.action ){ this.defaultAction = this.status.action; }else if (this.meetingConfig.defaultView){ this.defaultAction = this.meetingConfig.defaultView; }else{ this.defaultAction = "toMyMeeting"; } if( this.meetingConfig.disableViewList.contains( this.defaultAction ) ){ this.defaultAction = ""; } this.topMenu = new Element("div", {"styles": this.css.topMenu}).inject(this.node); this.contentNode = new Element("div.contentNode", {"styles": this.inContainer ? this.css.contentNode_inContainer : this.css.contentNode}).inject(this.node); //this.bottomMenu = new Element("div", {"styles": this.css.bottomMenu}).inject(this.node); this.loadTopMenus(); if( this.options.sideBarEnable ){ this.loadSideBar(); } //this.loadBottomMenus(); //this.hideMenu(); // //this.node.addEvent("contextmenu", function(e){ // if (this.menuMode=="show"){ // this.hideMenu(); // }else{ // this.showMenu(); // } // e.preventDefault(); //}.bind(this)); this.setEvent(); }, isOnlineAvailable: function(){ return !!this.meetingConfig.enableOnline; }, isAutoCreateOnlineRoom: function(){ return this.meetingConfig.enableOnline && this.meetingConfig.onlineProduct === "好视通" }, isCopyEnable: function(){ return Promise.resolve(false); // if( typeOf(this.copyEnable) === "boolean" )return Promise.resolve(this.copyEnable); // var text = " "; // if (navigator.clipboard) { // return navigator.clipboard.writeText(text).then(function() { // this.copyEnable = true; // return this.copyEnable; // }.bind(this), function(err) { // this.copyEnable = false; // return this.copyEnable; // }); // }else{ // var textArea = document.createElement("textarea"); // textArea.value = text; // // Avoid scrolling to bottom // textArea.style.top = "0"; // textArea.style.left = "0"; // textArea.style.position = "fixed"; // document.body.appendChild(textArea); // textArea.focus(); // textArea.select(); // try { // var successful = document.execCommand('copy'); // this.copyEnable = successful; // } catch (err) { // this.copyEnable = false // } // document.body.removeChild(textArea); // return Promise.resolve(this.copyEnable); // } }, copyTextToClipboard: function(text) { if (!navigator.clipboard) { this.fallbackCopyTextToClipboard(text); return; } navigator.clipboard.writeText(text); }, fallbackCopyTextToClipboard: function(text) { var textArea = document.createElement("textarea"); textArea.value = text; // Avoid scrolling to bottom textArea.style.top = "0"; textArea.style.left = "0"; textArea.style.position = "fixed"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); try { var successful = document.execCommand('copy'); } catch (err) { } document.body.removeChild(textArea); }, setEvent: function(){ //this.topMenu.addEvent("mouseover", function(){this.showMenu();}.bind(this)); //this.topMenu.addEvent("mouseout", function(){this.hideMenu();}.bind(this)); //this.bottomMenu.addEvent("mouseover", function(){this.showMenu();}.bind(this)); //this.bottomMenu.addEvent("mouseout", function(){this.hideMenu();}.bind(this)); //this.contentNode.addEvent("click", function(){this.hideMenu();}.bind(this)); }, loadTopMenus_right: function(){ this.topMenuRight = new Element("div", {"styles": this.css.topMenuRight }).inject(this.topMenu); this.createTopMenu_right(this.lp.addMeeting, "o2icon-create", "addMeeting"); if (this.isManager)this.createTopMenu_right(this.lp.addRoom, "o2icon-icon_newhuiyishi", "addRoom"); //var refreshNode = this.createTopMenu_right(this.lp.refresh, "refresh", "refresh"); //refreshNode.setStyle("float", "right"); if( this.options.settingEnable ){ var configNode = this.createTopMenu_right(this.lp.setting, "o2icon-config", "config"); configNode.setStyle("float", "right"); } }, createTopMenu_right : function(text, icon, action){ var actionNode = new Element("div", {"styles": this.css.topMenuNode_right, "title" : text}).inject(this.topMenuRight); var actionIconNode = new Element("div."+icon, {"styles": this.css.topMenuIconNode}).inject(actionNode); var actionTextNode = new Element("div",{styles: this.css.topMenuTextNode, "text":text}).inject(actionNode); //actionIconNode.setStyle("background", "url(../x_component_Meeting/$Main/default/icon/"+icon+".png) no-repeat center center"); actionNode.store("icon",icon); actionNode.store("iconNode",actionIconNode); var _self = this; actionNode.addEvents({ "mouseover": function(){ this.node.setStyles(_self.css.topMenuNode_over); this.node.addClass("mainColor_color"); this.node.retrieve("iconNode").setStyles( _self.css.topMenuIconNode_over ).addClass("mainColor_color"); //this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" ); }.bind( { node : actionNode } ), "mouseout": function(){ this.node.setStyles(_self.css.topMenuNode_right); this.node.removeClass("mainColor_color"); this.node.retrieve("iconNode").setStyles( _self.css.topMenuIconNode ).removeClass("mainColor_color"); //this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+".png) no-repeat center center" ); }.bind({ node:actionNode }), "click": function(){ this.node.setStyles(_self.css.topMenuNode_down); //this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" ); if (_self[action]) _self[action].apply(_self); }.bind({ node : actionNode }) }); return actionNode; }, loadTopMenus: function(){ this.createTopMenu(this.lp.myMeeting, "o2icon-person", "toMyMeeting"); this.createTopMenu(this.lp.month, "o2icon-month", "toMonth"); this.createTopMenu(this.lp.week, "o2icon-week", "toWeek"); this.createTopMenu(this.lp.day, "o2icon-day", "toDay"); this.createTopMenu(this.lp.list, "o2icon-list", "toList"); this.createTopMenu(this.lp.room, "o2icon-home", "toRoom"); this.loadTopMenus_right(); }, isViewAvailable : function( action ){ return !this.meetingConfig.disableViewList.contains( action ); }, createTopMenu: function(text, icon, action){ if( this.meetingConfig.disableViewList.contains( action ) )return; if( this.meetingConfig[ action + "ViewName" ] ){ text = this.meetingConfig[ action + "ViewName" ]; } var actionNode = new Element("div", {"styles": this.css.topMenuNode}).inject(this.topMenu); var actionIconNode = new Element("div."+icon, {"styles": this.css.topMenuIconNode}).inject(actionNode); //actionIconNode.setStyle("background", "url(../x_component_Meeting/$Main/default/icon/"+icon+".png) no-repeat center center"); var actionTextNode = new Element("div", {"styles": this.css.topMenuTextNode, "text": text}).inject(actionNode); actionNode.store("icon",icon); actionNode.store("iconNode",actionIconNode); actionNode.store("action",action); var _self = this; actionNode.addEvents({ "mouseover": function(){ if( this.node != _self.currentTopMenuNode ){ this.node.setStyles(_self.css.topMenuNode_over); this.node.addClass("mainColor_color"); this.node.retrieve("iconNode").setStyles( _self.css.topMenuIconNode_over ).addClass("mainColor_color"); //this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" ); } }.bind( { node : actionNode } ), "mouseout": function(){ if(this.node != _self.currentTopMenuNode){ this.node.setStyles(_self.css.topMenuNode); this.node.removeClass("mainColor_color"); this.node.retrieve("iconNode").setStyles( _self.css.topMenuIconNode ).removeClass("mainColor_color"); //this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+".png) no-repeat center center" ); } }.bind({ node:actionNode }), //"mousedown": function(){this.setStyles(_self.css.topMenuNode_down);}, //"mouseup": function(){this.setStyles(_self.css.topMenuNode_over);}, "click": function(){ if( this.node != _self.currentTopMenuNode ){ this.node.setStyles( _self.css.topMenuNode_down ); this.node.addClass("mainColor_color"); this.node.retrieve("iconNode").setStyles( _self.css.topMenuIconNode_over ).addClass("mainColor_color"); //this.node.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+this.node.retrieve("icon")+"_click.png) no-repeat center center" ); } if( _self.currentTopMenuNode && this.node != _self.currentTopMenuNode){ _self.currentTopMenuNode.setStyles( _self.css.topMenuNode ); _self.currentTopMenuNode.removeClass("mainColor_color"); _self.currentTopMenuNode.retrieve("iconNode").setStyles( _self.css.topMenuIconNode ).removeClass("mainColor_color"); //_self.currentTopMenuNode.retrieve("iconNode").setStyle( "background","url(../x_component_Meeting/$Main/default/icon/"+_self.currentTopMenuNode.retrieve("icon")+".png) no-repeat center center" ); } _self.currentTopMenuNode = this.node; if (_self[action]) _self[action].apply(_self); }.bind({ node : actionNode }) }); if( this.defaultAction ){ if( this.defaultAction == action ){ actionNode.click(); } }else if( !this.loaded ){ actionNode.click(); this.loaded = true; } return actionNode; }, hideMenu: function(){ }, showMenu: function(){ if (this.menuMode!="show") { this.topMenu.set("tween", {duration: 100, transition: "bounce:out"}); //this.bottomMenu.set("tween", {duration: 100, transition: "bounce:out"}); this.topMenu.tween("top", "-50px", "0px"); //this.bottomMenu.tween("bottom", "-50px", "0px"); this.menuMode = "show"; if (this.topMenuPoint) this.topMenuPoint.setStyle("display", "none"); if (this.bottomMenuPoint) this.bottomMenuPoint.setStyle("display", "none"); } }, hideCurrentView: function(){ if (this.currentView){ this.currentView.hide(); this.currentView = null; } }, toMyMeeting: function(){ this.contentNode.setStyles(this.css.contentNode); //if ((!this.myMeetingView) || this.currentView!=this.myMeetingView){ // this.hideCurrentView(); // this.getMyMeetingView(function(){ // this.myMeetingView.show(); // this.currentView = this.myMeetingView; // }.bind(this)); //} if( this.currentView ){ this.currentView.destroy(); this.currentView = null; } this.myMeetingView = null; this.getMyMeetingView(function(){ this.myMeetingView.show(); this.currentView = this.myMeetingView; }.bind(this)); }, getMyMeetingView: function(callback){ if (!this.myMeetingView){ MWF.xDesktop.requireApp("Meeting", "MeetingView", function(){ var options; if( this.status && this.status.options ){ options = this.status.options } this.myMeetingView = new MWF.xApplication.Meeting.MeetingView(this.contentNode, this, options); if( options )this.status.options = null; if (callback) callback(); }.bind(this)); }else{ if (callback) callback(); } }, toList: function(){ this.contentNode.setStyle("background", "#EEE"); //if ((!this.listView) || this.currentView!=this.listView){ // this.hideCurrentView(); // this.getListView(function(){ // this.listView.show(); // this.currentView = this.listView; // }.bind(this)); //} if( this.currentView ){ this.currentView.destroy(); this.currentView = null; } this.listView = null; this.getListView(function(){ this.listView.show(); this.currentView = this.listView; }.bind(this)); }, getListView: function(callback){ if (!this.listView){ MWF.xDesktop.requireApp("Meeting", "ListView", function(){ var options; if( this.status && this.status.options ){ options = this.status.options } this.listView = new MWF.xApplication.Meeting.ListView(this.contentNode, this, options); if( options )this.status.options = null; if (callback) callback(); }.bind(this)); }else{ if (callback) callback(); } }, toMonth: function(){ this.contentNode.setStyle("background", "#EEE"); //if ((!this.monthView) || this.currentView!=this.monthView){ // this.hideCurrentView(); // this.getMonthView(function(){ // this.monthView.show(); // this.currentView = this.monthView; // }.bind(this)); //} if( this.currentView ){ this.currentView.destroy(); this.currentView = null; } this.monthView = null; this.getMonthView(function(){ this.monthView.show(); this.currentView = this.monthView; }.bind(this)); }, getMonthView: function(callback){ if (!this.monthView){ MWF.xDesktop.requireApp("Meeting", "MonthView", function(){ var options; if( this.status && this.status.options ){ options = this.status.options } this.monthView = new MWF.xApplication.Meeting.MonthView(this.contentNode, this, options); if( options )this.status.options = null; if (callback) callback(); }.bind(this)); }else{ if (callback) callback(); } }, toWeek: function(){ this.contentNode.setStyle("background", "#EEE"); //if ((!this.monthView) || this.currentView!=this.monthView){ // this.hideCurrentView(); // this.getMonthView(function(){ // this.monthView.show(); // this.currentView = this.monthView; // }.bind(this)); //} if( this.currentView ){ this.currentView.destroy(); this.currentView = null; } this.weekView = null; this.getWeekView(function(){ this.weekView.show(); this.currentView = this.weekView; }.bind(this)); }, getWeekView: function(callback){ if (!this.weekView){ MWF.xDesktop.requireApp("Meeting", "WeekView", function(){ var options; if( this.status && this.status.options ){ options = this.status.options } this.weekView = new MWF.xApplication.Meeting.WeekView(this.contentNode, this, options); if( options )this.status.options = null; if (callback) callback(); }.bind(this)); }else{ if (callback) callback(); } }, toDay: function(d){ this.contentNode.setStyle("background", "#EEE"); //if ((!this.dayView) || this.currentView!=this.dayView){ // this.hideCurrentView(); // this.getDayView(function(){ // this.dayView.show(); // this.currentView = this.dayView; // }.bind(this), d); //} if( this.currentView ){ this.currentView.destroy(); this.currentView = null; } this.dayView = null; this.getDayView(function(){ this.dayView.show(); this.currentView = this.dayView; }.bind(this), d); }, getDayView: function(callback, d){ if (!this.dayView){ MWF.xDesktop.requireApp("Meeting", "DayView", function(){ var options; if( this.status && this.status.options ){ options = this.status.options } this.dayView = new MWF.xApplication.Meeting.DayView(this.contentNode, this, options || {"date": d}); if(this.status)this.status.options = null; if (callback) callback(); }.bind(this)); }else{ this.dayView.toDay(d); if (callback) callback(); } }, toRoom: function(){ this.contentNode.setStyle("background", "#EEE"); //if ((!this.roomView) || this.currentView!=this.roomView){ // this.hideCurrentView(); // this.getRoomView(function(){ // this.roomView.show(); // this.currentView = this.roomView; // }.bind(this)); //} if( this.currentView ){ this.currentView.destroy(); this.currentView = null; } this.roomView = null; this.getRoomView(function(){ this.roomView.show(); this.currentView = this.roomView; }.bind(this)); }, getRoomView: function(callback){ if (!this.roomView){ MWF.xDesktop.requireApp("Meeting", "RoomView", function(){ var options; if( this.status && this.status.options ){ options = this.status.options } this.roomView = new MWF.xApplication.Meeting.RoomView(this.contentNode, this, options); if( options )this.status.options = null; if (callback) callback(); }.bind(this)); }else{ if (callback) callback(); } }, //refresh: function(){ // //this.hideMenu(); // if (this.currentView) this.currentView.reload(); //}, addMeeting: function(date, hour, minute, room, processData, latest){ o2.Actions.load("x_meeting_assemble_control").ConfigAction.getSystemConfig(function(json){ var jsonData = json.data; var process = (jsonData) ? jsonData.process : null; if (process){ this.loadMeetingProcess(process, processData, latest); }else{ //new MWF.xApplication.Meeting.Creator(this, date, hour, room); var form = new MWF.xApplication.Meeting.MeetingForm(this,{}, { date : date, hour : hour, minute : minute, room : room }, {app:this}); form.view = this; form.create(); //this.hideMenu(); } }.bind(this)); }, loadMeetingProcess: function(id, processData, latest){ this.getProcess(id, function(process){ MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){ var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(process, this, { "latest" : latest, "workData" : processData, "onStarted": function(data, title, processName){ this.afterStartProcess(data, title, processName); }.bind(this) }); starter.load(); }.bind(this)); }.bind(this)); }, afterStartProcess: function(data, title, processName){ if (data.work){ this.startProcessDraft(data, title, processName); }else{ this.startProcessInstance(data, title, processName); } }, startProcessDraft: function(data, title, processName){ var work = data.work; var options = {"draft": work, "appId": "process.Work"+(new o2.widget.UUID).toString(), "desktopReload": false, "onPostClose": function(){ }.bind(this) }; this.desktop.openApplication(null, "process.Work", options); }, startProcessInstance: function(data, title, processName){ var workInfors = []; var currentTask = []; data.each(function(work){ if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work); workInfors.push(this.getStartWorkInforObj(work)); }.bind(this)); if (currentTask.length===1){ var options = {"workId": currentTask[0], "appId": currentTask[0]}; this.desktop.openApplication(null, "process.Work", options); this.createStartWorkResault(workInfors, title, processName, false); }else{ this.createStartWorkResault(workInfors, title, processName, true); } }, createStartWorkResault: function(workInfors, title, processName, isopen){ var content = ""; workInfors.each(function(infor){ var users = []; infor.users.each(function(uname){ users.push(MWF.name.cn(uname)); }); content += "