Main.js 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411
  1. MWF.xDesktop.requireApp("Setting", "Document", null, false);
  2. MWF.xDesktop.requireApp("Setting", "SettingBase", null, false);
  3. MWF.xDesktop.requireApp("Setting", "SettingMobile", null, false);
  4. MWF.xDesktop.requireApp("Setting", "SettingLoginUI", null, false);
  5. MWF.xDesktop.requireApp("Setting", "SettingIndexUI", null, false);
  6. MWF.xDesktop.requireApp("Setting", "SettingModuleUI", null, false);
  7. MWF.xApplication.Setting.Main = new Class({
  8. Extends: MWF.xApplication.Common.Main,
  9. Implements: [Options, Events],
  10. options: {
  11. "style": "default",
  12. "name": "Setting",
  13. "icon": "icon.png",
  14. "width": "1020",
  15. "height": "660",
  16. "title": MWF.xApplication.Setting.LP.title
  17. },
  18. onQueryLoad: function(){
  19. this.lp = MWF.xApplication.Setting.LP;
  20. this.actions = MWF.Actions.get("x_program_center");
  21. //this.actions = new MWF.xApplication.Setting.Actions.RestActions();
  22. },
  23. loadApplication: function(callback){
  24. this.baseAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  25. this.uiAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  26. this.mobileAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  27. // this.serverAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  28. // this.applicationAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  29. // this.resourceAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  30. // this.mobileAreaNode = new Element("div", {"styles": this.css.tabAreaNode}).inject(this.content);
  31. MWF.require("MWF.widget.Tab", function(){
  32. this.tab = new MWF.widget.Tab(this.content, {"style": "administrator"});
  33. this.tab.load();
  34. this.basePage = this.tab.addTab(this.baseAreaNode, this.lp.tab_base, false);
  35. this.uiPage = this.tab.addTab(this.uiAreaNode, this.lp.tab_ui, false);
  36. this.mobilePage = this.tab.addTab(this.mobileAreaNode, this.lp.tab_mobile, false);
  37. this.basePage.addEvent("postShow", function(){
  38. if (!this.baseExplorer) this.baseExplorer = new MWF.xApplication.Setting.BaseExplorer(this, this.baseAreaNode);
  39. }.bind(this));
  40. this.uiPage.addEvent("postShow", function(){
  41. if (!this.uiExplorer) this.uiExplorer = new MWF.xApplication.Setting.UIExplorer(this, this.uiAreaNode);
  42. }.bind(this));
  43. this.mobilePage.addEvent("postShow", function(){
  44. if (!this.mobileExplorer) this.mobileExplorer = new MWF.xApplication.Setting.MobileExplorer(this, this.mobileAreaNode);
  45. }.bind(this));
  46. // this.serverPage = this.tab.addTab(this.serverAreaNode, this.lp.tab_Server, false);
  47. // this.applicationPage = this.tab.addTab(this.applicationAreaNode, this.lp.tab_Application, false);
  48. // this.resourcePage = this.tab.addTab(this.resourceAreaNode, this.lp.tab_Resource, false);
  49. // this.mobilePage = this.tab.addTab(this.mobileAreaNode, this.lp.tab_Mobile, false);
  50. // this.serverPage.addEvent("postShow", function(){
  51. // if (!this.serversExplorer) this.serversExplorer = new MWF.xApplication.Setting.ServersExplorer(this);
  52. // }.bind(this));
  53. //
  54. // this.applicationPage.addEvent("postShow", function(){
  55. // if (!this.applicationExplorer) this.applicationExplorer = new MWF.xApplication.Setting.ApplicationsExplorer(this);
  56. // }.bind(this));
  57. //
  58. // this.resourcePage.addEvent("postShow", function(){
  59. // if (!this.resourceExplorer) this.resourceExplorer = new MWF.xApplication.Setting.ResourceExplorer(this);
  60. // }.bind(this));
  61. //
  62. // this.mobilePage.addEvent("postShow", function(){
  63. // if (!this.mobileExplorer) this.mobileExplorer = new MWF.xApplication.Setting.MobileExplorer(this);
  64. // }.bind(this));
  65. this.basePage.showIm();
  66. //this.loadServers();
  67. this.setContentHeight();
  68. this.addEvent("resize", function(){this.setContentHeight();}.bind(this));
  69. }.bind(this));
  70. //MWF.xDesktop.requireApp("Setting", "ApplicationServers", function(){
  71. // this.applicationServerList = new MWF.xApplication.Setting.ApplicationServers(this);
  72. //}.bind(this));
  73. //this.loadApplicationServers();
  74. },
  75. loadTitle: function(){
  76. this.titleBar = new Element("div", {"styles": this.css.titleBar}).inject(this.content);
  77. this.taskTitleTextNode = new Element("div", {"styles": this.css.titleTextNode,"text": this.lp.title}).inject(this.titleBar);
  78. },
  79. setContentHeight: function(node){
  80. var size = this.content.getSize();
  81. //var titleSize = this.titleBar.getSize();
  82. var tabSize = this.tab.tabNodeContainer.getSize();
  83. //var height = size.y-tabSize.y-titleSize.y;
  84. var height = size.y-tabSize.y;
  85. this.tab.pages.each(function(page){
  86. page.contentNodeArea.setStyles({"height": ""+height+"px", "overflow": "auto"})
  87. });
  88. //this.appDeploymentContent.setStyle("height", height);
  89. }
  90. });
  91. MWF.xApplication.Setting.BaseExplorer = new Class({
  92. Implements: [Events],
  93. initialize: function(app, content){
  94. this.app = app;
  95. this.lp = this.app.lp;
  96. this.container = content;
  97. this.actions = this.app.actions;
  98. this.css = this.app.css;
  99. this.naviItems = [];
  100. this.collectData = null;
  101. this.personData = null;
  102. this.tokenData = null;
  103. this.loadDataBack = null;
  104. this.load();
  105. },
  106. getData: function(){
  107. var checkData = function(){
  108. if (this.collectData && this.personData && this.tokenData){
  109. if (this.loadDataBack){
  110. var fun = this.loadDataBack;
  111. this.loadDataBack = null;
  112. fun();
  113. }
  114. }
  115. }.bind(this);
  116. this.actions.getCollect(function(json){
  117. this.collectData = json.data;
  118. checkData();
  119. }.bind(this));
  120. this.actions.getPerson(function(json){
  121. this.personData = json.data;
  122. checkData();
  123. }.bind(this));
  124. this.actions.getToken(function(json){
  125. this.tokenData = json.data;
  126. checkData();
  127. }.bind(this));
  128. },
  129. load: function(){
  130. if (MWF.AC.isAdministrator()) this.getData();
  131. this.naviAreaNode = new Element("div", {"styles": this.css.explorerNaviAreaNode}).inject(this.container);
  132. this.naviNode = new Element("div", {"styles": this.css.explorerNaviNode}).inject(this.naviAreaNode);
  133. this.contentAreaNode = new Element("div", {"styles": this.css.explorerContentAreaNode}).inject(this.container);
  134. this.loadNavi();
  135. },
  136. loadNavi: function(){
  137. var json = this.getNaviJson();
  138. json.each(function(navi){
  139. this.naviItems.push(this.createNaviItem(navi));
  140. }.bind(this));
  141. this.naviItems[0].click();
  142. },
  143. createNaviItem: function(navi){
  144. var naviItemNode = new Element("div", {"styles": this.css.naviItemNode}).inject(this.naviNode);
  145. //var naviItemIconNode = new Element("div", {"styles": this.css.naviItemIconNode}).inject(naviItemNode);
  146. naviItemNode.setStyle("background-image", "url(/x_component_Setting/$Main/default/icon/"+navi.icon+".png)");
  147. //var naviItemTextNode = new Element("div", {"styles": this.css.naviItemTextNode}).inject(naviItemNode);
  148. naviItemNode.set("text", navi.text);
  149. naviItemNode.store("navi", navi);
  150. var _self = this;
  151. naviItemNode.addEvent("click", function(){
  152. _self.setNavi(this);
  153. });
  154. return naviItemNode;
  155. },
  156. setNavi: function(item){
  157. var navi = item.retrieve("navi");
  158. this.naviItems.each(function(node){
  159. var itemNavi = node.retrieve("navi");
  160. var content = node.retrieve("content", null);
  161. if (content) content.destroy();
  162. node.eliminate("content");
  163. node.setStyles(this.css.naviItemNode);
  164. node.setStyle("background-image", "url(/x_component_Setting/$Main/default/icon/"+itemNavi.icon+".png)");
  165. }.bind(this));
  166. item.setStyles(this.css.naviItemNode_current);
  167. item.setStyle("background-image", "url(/x_component_Setting/$Main/default/icon/"+navi.icon+"_current.png)");
  168. if (this[navi.action]) this[navi.action](item);
  169. },
  170. getNaviJson: function(){
  171. return [
  172. {
  173. "text": this.app.lp.tab_name,
  174. "icon": "name",
  175. "action": "loadSystemNameSetting"
  176. },
  177. {
  178. "text": this.app.lp.tab_user,
  179. "icon": "user",
  180. "action": "loadSystemPersonSetting"
  181. },
  182. {
  183. "text": this.app.lp.tab_login,
  184. "icon": "login",
  185. "action": "loadSystemLoginSetting"
  186. },
  187. {
  188. "text": this.app.lp.tab_sso,
  189. "icon": "sso",
  190. "action": "loadSystemSSOSetting"
  191. }
  192. ];
  193. },
  194. loadSystemNameSetting: function(item){
  195. if (MWF.AC.isAdministrator()) {
  196. if (this.collectData && this.personData && this.tokenData){
  197. this.baseNameSetting = new MWF.xApplication.Setting.BaseNameDocument(this, this.contentAreaNode);
  198. item.store("content", this.baseNameSetting);
  199. }else{
  200. this.loadDataBack = function(){this.loadSystemNameSetting(item)}.bind(this);
  201. }
  202. }
  203. },
  204. loadSystemPersonSetting: function(item){
  205. if (MWF.AC.isAdministrator()) if (this.collectData && this.personData && this.tokenData){
  206. this.basePersonSetting = new MWF.xApplication.Setting.BasePersonDocument(this, this.contentAreaNode);
  207. item.store("content", this.basePersonSetting);
  208. }else{
  209. this.loadDataBack = function(){this.loadSystemPersonSetting(item)}.bind(this);
  210. }
  211. },
  212. loadSystemLoginSetting: function(item){
  213. if (MWF.AC.isAdministrator()) if (this.collectData && this.personData && this.tokenData){
  214. this.baseLoginSetting = new MWF.xApplication.Setting.BaseLoginDocument(this, this.contentAreaNode);
  215. item.store("content", this.baseLoginSetting);
  216. }else{
  217. this.loadDataBack = function(){this.loadSystemLoginSetting(item)}.bind(this);
  218. }
  219. },
  220. loadSystemSSOSetting: function(item){
  221. if (MWF.AC.isAdministrator()) if (this.collectData && this.personData && this.tokenData){
  222. this.baseLoginSetting = new MWF.xApplication.Setting.BaseSSODocument(this, this.contentAreaNode);
  223. item.store("content", this.baseLoginSetting);
  224. }else{
  225. this.loadDataBack = function(){this.loadSystemSSOSetting(item)}.bind(this);
  226. }
  227. }
  228. });
  229. MWF.xApplication.Setting.MobileExplorer = new Class({
  230. Extends: MWF.xApplication.Setting.BaseExplorer,
  231. initialize: function(app, content){
  232. this.app = app;
  233. this.lp = this.app.lp;
  234. this.container = content;
  235. this.actions = this.app.actions;
  236. this.css = this.app.css;
  237. this.naviItems = [];
  238. this.collectData = null;
  239. this.personData = null;
  240. this.tokenData = null;
  241. this.loadDataBack = null;
  242. this.load();
  243. },
  244. getNaviJson: function(){
  245. return [
  246. {
  247. "text": this.app.lp.tab_mobile_connect,
  248. "icon": "connect",
  249. "action": "loadMobileConnectSetting"
  250. },
  251. {
  252. "text": this.app.lp.tab_mobile_module,
  253. "icon": "module",
  254. "action": "loadMobileModuleSetting"
  255. },
  256. {
  257. "text": this.app.lp.tab_mobile_style,
  258. "icon": "style",
  259. "action": "loadMobileStyleSetting"
  260. }
  261. ];
  262. },
  263. getData: function(){
  264. var checkData = function(){
  265. if (this.proxyData && this.nativeData && this.imagesData){
  266. if (this.loadDataBack){
  267. var fun = this.loadDataBack;
  268. this.loadDataBack = null;
  269. fun();
  270. }
  271. }
  272. }.bind(this);
  273. this.actions.getProxy(function(json){
  274. this.proxyData = json.data;
  275. checkData();
  276. }.bind(this));
  277. this.actions.mobile_currentStyle(function(json){
  278. this.nativeData = {"indexType": json.data.indexType, "indexPortal": json.data.indexPortal, "nativeAppList": Array.clone(json.data.nativeAppList)};
  279. this.imagesData = {"images": Array.clone(json.data.images)};
  280. //this.indexData = {"indexType": json.data.indexType, "indexId": json.data.indexId};
  281. this.portalData = {"portalList": Array.clone(json.data.portalList)};
  282. delete json.data;
  283. json = null;
  284. checkData();
  285. }.bind(this));
  286. },
  287. loadMobileConnectSetting: function(item){
  288. if (MWF.AC.isAdministrator()) if (this.proxyData && this.nativeData && this.imagesData){
  289. this.mobileConnectSetting = new MWF.xApplication.Setting.MobileConnectDocument(this, this.contentAreaNode);
  290. item.store("content", this.mobileConnectSetting);
  291. }else{
  292. this.loadDataBack = function(){this.loadMobileConnectSetting(item)}.bind(this);
  293. }
  294. },
  295. loadMobileModuleSetting: function(item){
  296. if (MWF.AC.isAdministrator()) if (this.proxyData && this.nativeData && this.imagesData){
  297. this.mobileModuleSetting = new MWF.xApplication.Setting.MobileModuleDocument(this, this.contentAreaNode);
  298. item.store("content", this.mobileModuleSetting);
  299. }else{
  300. this.loadDataBack = function(){this.loadMobileModuleSetting(item)}.bind(this);
  301. }
  302. },
  303. loadMobileStyleSetting: function(item){
  304. if (MWF.AC.isAdministrator()) if (this.proxyData && this.nativeData && this.imagesData){
  305. this.mobileStyleSetting = new MWF.xApplication.Setting.MobileStyleDocument(this, this.contentAreaNode);
  306. item.store("content", this.mobileStyleSetting);
  307. }else{
  308. this.loadDataBack = function(){this.loadMobileStyleSetting(item)}.bind(this);
  309. }
  310. }
  311. });
  312. MWF.xApplication.Setting.UIExplorer = new Class({
  313. Extends: MWF.xApplication.Setting.BaseExplorer,
  314. initialize: function(app, content){
  315. this.app = app;
  316. this.lp = this.app.lp;
  317. this.container = content;
  318. this.actions = this.app.actions;
  319. this.css = this.app.css;
  320. this.naviItems = [];
  321. this.load();
  322. },
  323. getNaviJson: function(){
  324. return [
  325. {
  326. "text": this.app.lp.tab_ui_module,
  327. "icon": "module",
  328. "action": "loadUIModuleSetting"
  329. },
  330. {
  331. "text": this.app.lp.tab_ui_index,
  332. "icon": "index",
  333. "action": "loadUIIndexSetting"
  334. },
  335. {
  336. "text": this.app.lp.tab_ui_login,
  337. "icon": "login",
  338. "action": "loadUILoginSetting"
  339. }
  340. ];
  341. },
  342. getData: function(){
  343. },
  344. loadUILoginSetting: function(item){
  345. if (MWF.AC.isAdministrator()){
  346. this.uiLoginSetting = new MWF.xApplication.Setting.UILoginDocument(this, this.contentAreaNode);
  347. item.store("content", this.uiLoginSetting);
  348. }
  349. },
  350. loadUIIndexSetting: function(item){
  351. if (MWF.AC.isAdministrator()) {
  352. this.uiIndexSetting = new MWF.xApplication.Setting.UIIndexDocument(this, this.contentAreaNode);
  353. item.store("content", this.uiIndexSetting);
  354. }
  355. },
  356. loadUIModuleSetting: function(item){
  357. if (MWF.AC.isAdministrator()) {
  358. this.uiModuleSetting = new MWF.xApplication.Setting.UIModuleDocument(this, this.contentAreaNode);
  359. item.store("content", this.uiModuleSetting);
  360. }
  361. }
  362. });