123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238 |
- MWF.xApplication.ControlPanel.Main = new Class({
- Extends: MWF.xApplication.Common.Main,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "name": "ControlPanel",
- "icon": "icon.png",
- "width": "840",
- "isResize": false,
- "isMax": false,
- "height": "280",
- "title": MWF.xApplication.ControlPanel.LP.title
- },
- loadWindow: function(isCurrent){
- debugger;
- this.fireAppEvent("queryLoadWindow");
- this.window = new MWF.xDesktop.WindowTransparent(this, {"container": this.desktop.node});
- this.fireAppEvent("loadWindow");
- this.window.show();
- this.content = this.window.content;
- if (isCurrent) this.setCurrent();
- this.fireAppEvent("postLoadWindow");
- this.fireAppEvent("queryLoadApplication");
- this.loadApplication(function(){
- this.fireAppEvent("postLoadApplication");
- }.bind(this));
- },
- loadWindowFlat: function (isCurrent) {
- this.window = {
- "isHide": false,
- "isMax": true,
- "maxSize": function () { },
- "restore": function () { },
- "setCurrent": function () {
- //this.content.show();
- this.content.removeClass("layout_component_content_hide");
- this.content.addClass("layout_component_content_show");
- }.bind(this),
- "setUncurrent": function () {
- //this.content.hide();
- debugger;
- this.content.addClass("layout_component_content_hide");
- this.content.removeClass("layout_component_content_show");
- }.bind(this),
- "hide": function () { },
- "maxOrRestoreSize": function () { },
- "restoreSize": function () { },
- "close": function (callback) {
- this.content.destroy();
- if (callback) callback();
- }.bind(this)
- };
- this.window.content = new Element("div.layout_component_content").inject(layout.desktop.contentNode);
- this.content = this.window.content;
- layout.desktop.addEvent("resize", function () {
- this.fireAppEvent("resize");
- }.bind(this));
- if (isCurrent){
- this.setCurrent();
- }else{
- this.setUncurrent();
- }
- this.fireAppEvent("postLoadWindow");
- this.fireAppEvent("queryLoadApplication");
- //load css
- if (this.stylePath) this.content.loadCss(this.stylePath);
- this.setContentEvent();
- this.loadApplication(function () {
- this.fireAppEvent("postLoadApplication");
- }.bind(this));
- this.fireAppEvent("postLoad");
- },
- setNodeResize: function(){
- this.setNodePositionAndSizeFun = this.setNodePositionAndSize.bind(this);
- this.setNodePositionAndSizeFun();
- this.addEvent("resize", this.setNodePositionAndSizeFun);
- // $(window).addEvent("resize", this.setNodePositionAndSizeFun);
- // this.addEvent("queryClose", function(){
- // $(window).removeEvent("resize", this.setNodePositionAndSizeFun);
- // }.bind(this));
- },
- setNodePositionAndSize: function(){
- // if (this.status && this.status.size){
- // this.node.setStyles({
- // "top": this.status.size.y,
- // "left": this.status.size.x
- // });
- // }else{
- this.node.position({
- relativeTo: this.desktop.node,
- position: 'center',
- edge: 'center',
- "offset": {
- "y": "-120"
- }
- });
- // }
- },
- recordStatus: function(){
- return {"size": this.node.getPosition()};
- },
- onQueryLoad: function(){
- this.lp = MWF.xApplication.ControlPanel.LP;
- },
- loadApplication: function(callback){
- this.layout = this.desktop;
- this.apps = [];
- //this.loadTitle();
- //this.content.setStyle("background-color", "#555555");
- if (layout.viewMode==="Default") this.css.contentNode = this.css.contentNodeFlat;
- if (this.options.event){
- this.css.contentNode.left = this.options.event.page.x;
- this.css.contentNode.top = this.options.event.page.y;
- // options.fromTop = this.options.event.page.y;
- // options.fromLeft = this.options.event.page.x;
- }
- this.node = new Element("div", {"styles": this.css.contentNode}).inject(this.content);
- var morph = new Fx.Morph(this.node, {
- "duration": "100",
- "transition": Fx.Transitions.Sine.easeOut
- });
- debugger;
- morph.start(this.css.contentNodeTo).chain(function(){
- this.setNodeResize();
- this.node.addEvent("selectstart", function(e){e.target.setStyle("-webkit-user-select", "none")}.bind(this));
- if (layout.viewMode==="Layout"){
- this.titleAreaNode = new Element("div", {"styles": this.css.titleAreaNode}).inject(this.node);
- this.closeNode = new Element("div", {"styles": this.css.closeNode}).inject(this.titleAreaNode);
- this.closeNode.addEvent("click", function(){this.close();}.bind(this));
- this.titleNode = new Element("div", {"styles": this.css.titleAreaTextNode, "text": this.lp.titleInfor}).inject(this.titleAreaNode);
- }
- this.contentNode = new Element("div", {"styles": this.css.contentAreaNode}).inject(this.node);
- this.loadApplications();
- }.bind(this));
- },
- loadTitle: function(){
- this.titleBar = new Element("div", {"styles": this.css.titleBar}).inject(this.content);
- this.taskTitleTextNode = new Element("div", {"styles": this.css.titleTextNode,"text": this.lp.title}).inject(this.titleBar);
- },
- setContentSize: function(){
- var size = this.node.getSize();
- var w = size.x*0.9;
- var count = (w/120).toInt();
- w = Math.min(count, this.apps.length)*120;
- this.contentNode.setStyles({"width": ""+w+"px"});
- },
- loadApplications: function(){
- COMMON.JSON.get(this.path+"applications.json", function(catalog){
- var user = this.layout.session.user;
- var currentNames = [user.name, user.distinguishedName, user.id, user.unique];
- if (user.roleList){
- user.roleList.each(function(role){
- currentNames.push(MWF.name.cn(role));
- currentNames.push(role);
- });
- }
- //currentNames = currentNames.concat(user.roleList);
- if (user.groupList){
- user.groupList.each(function(group){
- currentNames.push(MWF.name.cn(group));
- currentNames.push(group);
- });
- }
- //currentNames = currentNames.concat(user.groupList);
- catalog.each(function(value, key){
- var isAllow = true;
- if (value.allowList) isAllow = (value.allowList.length) ? (value.allowList.isIntersect(currentNames)) : true;
- var isDeny = false;
- if (value.denyList) isDeny = (value.denyList.length) ? (value.denyList.isIntersect(currentNames)!==-1) : false;
- if ((!isDeny && isAllow)){
- this.apps.push({"value":value, "key":key});
- this.createApplicationMenu(value, key);
- }
- this.setContentSize();
- this.addEvent("resize", this.setContentSize);
- }.bind(this));
- }.bind(this));
- },
- createApplicationMenu: function(value, key){
- var applicationMenuNode = new Element("div", {
- "styles": this.css.applicationMenuNode,
- "title": value.title
- }).inject(this.contentNode);
- var applicationMenuIconNode = new Element("div", {
- "styles": this.css.applicationMenuIconNode
- }).inject(applicationMenuNode);
- var icon = "../x_component_"+value.path.replace(/\./g, "_")+"/$Main/"+value.iconPath;
- applicationMenuIconNode.setStyle("background-image", "url("+icon+")");
- new Element("div", {
- "styles": this.css.applicationMenuTextNode,
- "text": value.title
- }).inject(applicationMenuNode);
- applicationMenuNode.addEvent("click", function(e){
- this.layout.openApplication(e, value.path);
- //this.closeApplicationMenu();
- }.bind(this));
- applicationMenuNode.makeLnk({
- "par": {"icon": icon, "title": value.title, "par": value.path},
- "onStart": function(){
- this.applicationMenuAreaMark.fade("out");
- this.applicationMenuArea.fade("out");
- }.bind(this),
- "onComplete": function(){
- //this.showApplicationMenu();
- }.bind(this)
- });
- var appName = value.path;
- }
- });
|