Setting.js 85 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767
  1. MWF.xApplication.Forum = MWF.xApplication.Forum || {};
  2. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  3. MWF.require("MWF.widget.Identity", null,false);
  4. MWF.xApplication.Forum.Setting = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default",
  9. "index" : 0
  10. },
  11. initialize: function (node, app, actions, options) {
  12. this.setOptions(options);
  13. this.app = app;
  14. this.lp = app.lp;
  15. this.path = "/x_component_Forum/$Setting/";
  16. this.loadCss();
  17. this.actions = actions;
  18. this.node = $(node);
  19. },
  20. loadCss: function () {
  21. this.cssPath = "/x_component_Forum/$Setting/" + this.options.style + "/css.wcss";
  22. this._loadCss();
  23. },
  24. load: function () {
  25. //this.middleContent = this.app.middleContent;
  26. this.createNaviContent();
  27. this.createContentDiv();
  28. this.resizeWindowFun = this.resizeWindow.bind(this)
  29. this.resizeWindow();
  30. this.app.addEvent("resize", this.resizeWindowFun);
  31. },
  32. destroy: function(){
  33. if( this.contentDiv )this.contentDiv.empty();
  34. if( this.explorer ){
  35. this.explorer.destroy();
  36. delete this.explorer;
  37. }
  38. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  39. this.node.empty();
  40. delete this;
  41. },
  42. resizeWindow: function(){
  43. var size = this.app.node.getSize();
  44. var topSize = this.app.topNode ? this.app.topNode.getSize() : {"x": 0, "y": 0};
  45. // var topSize = {"x": 0, "y": 0};
  46. //var pt = this.app.contentContainerNode.getStyle("padding-top").toFloat();
  47. //var pb = this.app.contentContainerNode.getStyle("padding-bottom").toFloat();
  48. var height = size.y - topSize.y; //- pt - pb;
  49. this.naviDiv.setStyles({"height":height+"px"});
  50. this.naviContentDiv.setStyles({"height":(height-120)+"px"});
  51. this.contentDiv.setStyles({"height":height+"px"});
  52. },
  53. createNaviContent: function(){
  54. this.naviDiv = new Element("div.naviDiv",{
  55. "styles":this.css.naviDiv
  56. }).inject(this.node);
  57. this.naviTitleDiv = new Element("div.naviTitleDiv",{
  58. "styles":this.css.naviTitleDiv,
  59. "text": this.lp.setting
  60. }).inject(this.naviDiv);
  61. this.naviContentDiv = new Element("div.naviContentDiv",{"styles":this.css.naviContentDiv}).inject(this.naviDiv);
  62. this.naviBottomDiv = new Element("div.naviBottomDiv",{"styles":this.css.naviBottomDiv}).inject(this.naviDiv);
  63. var jsonUrl = this.path+"navi.json";
  64. MWF.getJSON(jsonUrl, function(json){
  65. json.each(function(data, i){
  66. var naviContentLi = new Element("li.naviContentLi",{"styles":this.css.naviContentLi}).inject(this.naviContentDiv);
  67. naviContentLi.addEvents({
  68. "mouseover" : function(ev){
  69. if(this.bindObj.currentNaviItem != this.node) this.node.setStyles( this.styles );
  70. }.bind({"styles": this.css.naviContentLi_over, "node":naviContentLi, "bindObj": this }),
  71. "mouseout" : function(ev){
  72. if(this.bindObj.currentNaviItem != this.node)this.node.setStyles( this.styles )
  73. }.bind({"styles": this.css.naviContentLi, "node":naviContentLi, "bindObj": this }) ,
  74. "click" : function(ev){
  75. if( this.bindObj.currentNaviItem )this.bindObj.currentNaviItem.setStyles( this.bindObj.css.naviContentLi );
  76. this.node.setStyles( this.styles );
  77. this.bindObj.currentNaviItem = this.node;
  78. this.node.store( "index" , i );
  79. if( this.action && this.bindObj[this.action] )this.bindObj[this.action]();
  80. }.bind({"styles": this.css.naviContentLi_current, "node":naviContentLi, "bindObj": this, "action" : data.action }) ,
  81. });
  82. var naviContentImg = new Element("img.naviContentImg",{
  83. "styles":this.css.naviContentImg,
  84. "src":this.path+this.options.style+"/icon/"+data.icon
  85. }).inject(naviContentLi);
  86. var naviContentSpan = new Element("span.naviContentSpan",{
  87. "styles":this.css.naviContentSpan,
  88. "text":data.title
  89. }).inject(naviContentLi);
  90. if( i == this.options.index )naviContentLi.click();
  91. }.bind(this));
  92. }.bind(this));
  93. },
  94. createContentDiv: function(){
  95. this.contentDiv = new Element("div.contentDiv",{"styles":this.css.contentDiv}).inject(this.node);
  96. },
  97. openCategorySetting: function(){
  98. if( this.contentDiv )this.contentDiv.empty();
  99. if( this.explorer ){
  100. this.explorer.destroy();
  101. delete this.explorer;
  102. }
  103. this.explorer = new MWF.xApplication.Forum.Setting.CategorySettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  104. this.explorer.load();
  105. },
  106. openSectionSetting: function(){
  107. if( this.contentDiv )this.contentDiv.empty();
  108. if( this.explorer ){
  109. this.explorer.destroy();
  110. delete this.explorer;
  111. }
  112. this.explorer = new MWF.xApplication.Forum.Setting.SectionSettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  113. this.explorer.load();
  114. },
  115. openSystemSetting : function(){
  116. if( this.contentDiv )this.contentDiv.empty();
  117. if( this.explorer ){
  118. this.explorer.destroy();
  119. delete this.explorer;
  120. }
  121. this.explorer = new MWF.xApplication.Forum.Setting.SystemSettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  122. this.explorer.load();
  123. },
  124. openRoleSetting: function(){
  125. if( this.contentDiv )this.contentDiv.empty();
  126. if( this.explorer ){
  127. this.explorer.destroy();
  128. delete this.explorer;
  129. }
  130. this.explorer = new MWF.xApplication.Forum.Setting.RoleSettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  131. this.explorer.load();
  132. },
  133. openPermissionSetting: function(){
  134. if( this.contentDiv )this.contentDiv.empty();
  135. if( this.explorer ){
  136. this.explorer.destroy();
  137. delete this.explorer;
  138. }
  139. this.explorer = new MWF.xApplication.Forum.Setting.PermissionSettingExplorer(this.contentDiv, this.app, this,{style:this.options.style});
  140. this.explorer.load();
  141. },
  142. selectPerson: function( item, type , count ){
  143. if( type == "person" ){
  144. var title = this.lp.selectPerson
  145. }else if( type == "department" ){
  146. title = this.lp.selectDepartment
  147. }else if( type == "company" ){
  148. title = this.lp.selectCompany
  149. }
  150. MWF.xDesktop.requireApp("Organization", "Selector.package",null, false);
  151. var value = item.get("text").split( "," );
  152. var options = {
  153. "type": type,
  154. "title": title ,
  155. "count" : count,
  156. "names": value || [],
  157. "onComplete": function(items){
  158. var arr = [];
  159. items.each(function(item){
  160. arr.push(item.data.name);
  161. }.bind(this));
  162. item.set("text",arr.join(","));
  163. }.bind(this)
  164. };
  165. var selector = new MWF.OrgSelector(this.app.content, options);
  166. }
  167. });
  168. MWF.xApplication.Forum.Setting.CategorySettingExplorer = new Class({
  169. Extends: MWF.widget.Common,
  170. Implements: [Options, Events],
  171. options: {
  172. "style": "default"
  173. },
  174. initialize: function (container, app, parent, options) {
  175. this.container = container;
  176. this.parent = parent;
  177. this.app = app;
  178. this.css = this.parent.css;
  179. this.lp = this.app.lp;
  180. },
  181. load: function () {
  182. this.container.empty();
  183. if( this.app.access.isAdmin() ){
  184. this.loadToolbar();
  185. }
  186. this.loadView();
  187. },
  188. destroy : function(){
  189. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun);
  190. this.view.destroy();
  191. },
  192. loadToolbar: function(){
  193. this.toolbar = new Element("div",{
  194. styles : this.css.toolbar
  195. }).inject(this.container)
  196. this.createActionNode = new Element("div",{
  197. styles : this.css.toolbarActionNode,
  198. text: this.lp.createCategory
  199. }).inject(this.toolbar);
  200. this.createActionNode.addEvent("click",function(){
  201. var form = new MWF.xApplication.Forum.Setting.CategorySettingForm(this, {}, {
  202. onPostOk : function(){
  203. this.view.reload();
  204. }.bind(this)})
  205. form.create();
  206. }.bind(this))
  207. this.fileterNode = new Element("div",{
  208. styles : this.css.fileterNode
  209. }).inject(this.toolbar);
  210. },
  211. loadView : function(){
  212. this.viewContainer = Element("div",{
  213. "styles" : this.css.viewContainer
  214. }).inject(this.container);
  215. this.resizeWindow();
  216. this.resizeWindowFun = this.resizeWindow.bind(this)
  217. this.app.addEvent("resize", this.resizeWindowFun );
  218. this.view = new MWF.xApplication.Forum.Setting.CategorySettingView( this.viewContainer, this.app, this, {
  219. templateUrl : this.parent.path+"listItemCategory.json",
  220. scrollEnable : true
  221. } )
  222. this.view.load();
  223. },
  224. resizeWindow: function(){
  225. var size = this.container.getSize();
  226. if( this.toolbar ){
  227. this.viewContainer.setStyles({"height":(size.y-121)+"px"});
  228. }else{
  229. this.viewContainer.setStyles({"height":(size.y-56)+"px"});
  230. }
  231. }
  232. })
  233. MWF.xApplication.Forum.Setting.CategorySettingView = new Class({
  234. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  235. _createDocument: function(data){
  236. return new MWF.xApplication.Forum.Setting.CategorySettingDocument(this.viewNode, data, this.explorer, this);
  237. },
  238. _getCurrentPageData: function(callback, count){
  239. if (!count)count = 20;
  240. //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  241. //var filter = this.filterData || {};
  242. this.actions.listCategoryAllByAdmin( function (json) {
  243. if (callback)callback(json);
  244. }.bind(this))
  245. },
  246. _removeDocument: function(documentData, all){
  247. this.actions.deleteCategory(documentData.id, function(json){
  248. this.reload();
  249. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  250. }.bind(this));
  251. },
  252. _create: function(){
  253. },
  254. _openDocument: function( documentData ){
  255. var form = new MWF.xApplication.Forum.Setting.CategorySettingForm(this, documentData, {
  256. onPostOk : function(){
  257. this.reload();
  258. }.bind(this)
  259. })
  260. //if( this.app.access.hasForumAdminAuthority( documentData ) ){
  261. if( this.app.access.isAdmin() ){
  262. form.edit();
  263. }else{
  264. form.open();
  265. }
  266. },
  267. _queryCreateViewNode: function(){
  268. },
  269. _postCreateViewNode: function( viewNode ){
  270. },
  271. _queryCreateViewHead:function(){
  272. },
  273. _postCreateViewHead: function( headNode ){
  274. }
  275. })
  276. MWF.xApplication.Forum.Setting.CategorySettingDocument = new Class({
  277. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  278. _queryCreateDocumentNode:function( itemData ){
  279. },
  280. _postCreateDocumentNode: function( itemNode, itemData ){
  281. }
  282. })
  283. MWF.xApplication.Forum.Setting.CategorySettingForm = new Class({
  284. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  285. Implements: [Options, Events],
  286. options: {
  287. "style": "default",
  288. "width": "1011",
  289. "height": "90%",
  290. "hasTop": true,
  291. "hasIcon": false,
  292. "hasTopIcon" : true,
  293. "hasTopContent" : true,
  294. "hasBottom": true,
  295. "title": MWF.xApplication.Forum.LP.categoryFormTitle,
  296. "draggable": true,
  297. "closeAction": true
  298. },
  299. createContent: function () {
  300. this.formContentNode = new Element("div.formContentNode", {
  301. "styles": this.css.formContentNode
  302. }).inject(this.formNode);
  303. this.formTableContainer = new Element("div.formTableContainer", {
  304. "styles": this.css.formTableContainer
  305. }).inject(this.formContentNode);
  306. this.formTableArea = new Element("div.formTableArea", {
  307. "styles": this.css.formTableArea
  308. }).inject(this.formTableContainer);
  309. this._createTableContent();
  310. },
  311. _createTableContent: function () {
  312. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  313. "<tr>" +
  314. " <td styles='formTableTitle' lable='forumName' width='10%'></td>" +
  315. " <td styles='formTableValue' item='forumName' width='40%'></td>" +
  316. " <td styles='formTableTitle' width='10%'></td>" +
  317. " <td styles='formTableValue' width='40%'></td>" +
  318. "</tr><tr>" +
  319. " <td styles='formTableTitle' lable='forumStatus'></td>" +
  320. " <td styles='formTableValue' item='forumStatus'></td>" +
  321. " <td styles='formTableTitle' lable='creatorName'></td>" +
  322. " <td styles='formTableValue' item='creatorName'></td>" +
  323. "</tr><tr>" +
  324. " <td styles='formTableTitle' lable='forumManagerName'></td>" +
  325. " <td styles='formTableValue' item='forumManagerName'></td>" +
  326. " <td styles='formTableTitle' lable='orderNumber'></td>" +
  327. " <td styles='formTableValue' item='orderNumber'></td>" +
  328. "</tr><tr>" +
  329. " <td styles='formTableTitle' lable='forumVisiable'></td>" +
  330. " <td styles='formTableValue' item='forumVisiable'></td>" +
  331. " <td styles='formTableValue' colspan='2'>" +
  332. " <span item='forumVisiableCompanyButton'></span>"+
  333. " <span item='forumVisiableDepartmentButton'></span>"+
  334. " <span item='forumVisiablePersonButton'></span>"+
  335. " </td>" +
  336. "</tr><tr>" +
  337. " <td></td>" +
  338. " <td colspan='3'>"+
  339. " <div item='forumVisiableCompany'></div>"+
  340. " <div item='forumVisiableDepartment'></div>"+
  341. " <div item='forumVisiablePerson'></div>"+
  342. " </td>" +
  343. "</tr><tr>" +
  344. " <td styles='formTableTitle' lable='forumColorArea'></td>" +
  345. " <td styles='formTableValue'>"+
  346. " <div item='forumColorArea' style='float:left;'></div>"+
  347. " <div item='forumColorButton' style='float:left;'></div>"+
  348. " </td>" +
  349. " <td styles='formTableTitle' lable='subjectType'></td>" +
  350. " <td styles='formTableValue' item='subjectType'></td>" +
  351. //"</tr><tr>" +
  352. //" <td styles='formTableTitle' lable='indexRecommendable'></td>" +
  353. // " <td styles='formTableValue' item='indexRecommendable'></td>" +
  354. //" <td styles='formTableTitle' lable=''></td>" +
  355. //" <td styles='formTableValue' item=''></td>" +
  356. "</tr><tr>" +
  357. " <td styles='formTableTitle' lable='indexListStyleLable'></td>" +
  358. " <td styles='formTableValue' colspan='3'><div item='indexListStyleShow'></div><div item='indexListStyleButton'></div></td>" +
  359. "</tr><tr>" +
  360. " <td styles='formTableTitle' lable='forumNotice'></td>" +
  361. " <td styles='formTableValue' item='forumNotice' colspan='3'></td>" +
  362. "</tr>"
  363. "</table>"
  364. this.formTableArea.set("html", html);
  365. //value : function(){ return this.lp.defaultForumColor }.bind(this), defaultValue : this.lp.defaultForumColor
  366. var formVisiableButtonStyle = (( !this.isEdited && !this.isNew ) || !this.data.forumVisiable ||(this.data.forumVisiable == this.lp.allPerson )) ? { display:"none"} : { display:""};
  367. var formVisiableStyle = ( !this.data.forumVisiable ||(this.data.forumVisiable == this.lp.allPerson )) ? { display:"none"} : { display:""};
  368. var selectColorButtonStyle = (!this.isEdited && !this.isNew) ? { display : "none" } : {};
  369. this.indexListStyleShow = this.formTableArea.getElements("[item='indexListStyleShow']")[0];
  370. if( this.data.indexListStyle ){
  371. this.getDefaultTypeTemplateList( function(){
  372. new Element("img", {
  373. src : this.defalutTypeTemplateList[this.data.indexListStyle].preview,
  374. styles : this.css.indexListStylePreview
  375. }).inject(this.indexListStyleShow);
  376. }.bind(this));
  377. }
  378. MWF.xDesktop.requireApp("Template", "MForm", function () {
  379. this.form = new MForm(this.formTableArea, this.data, {
  380. style: "forum",
  381. isEdited: this.isEdited || this.isNew,
  382. itemTemplate: {
  383. forumName: {text: this.lp.forumName, notEmpty: true},
  384. forumManagerName: {text: this.lp.forumManagerName, tType : "person", "defaultValue" : this.app.userName, "count" : 0 },
  385. forumVisiable: {text: this.lp.forumVisiable, type : "select", selectValue : this.lp.forumVisiableValue.split(","), event : {
  386. change : function( it, ev ){
  387. var styles = it.getValue() == this.lp.allPerson ? { display : "none" } : { display : "" };
  388. it.form.getItem("forumVisiablePersonButton").setStyles( styles );
  389. it.form.getItem("forumVisiableDepartmentButton").setStyles( styles );
  390. it.form.getItem("forumVisiableCompanyButton").setStyles( styles );
  391. it.form.getItem("forumVisiablePerson").setStyles( styles );
  392. it.form.getItem("forumVisiableDepartment").setStyles( styles );
  393. it.form.getItem("forumVisiableCompany").setStyles( styles );
  394. }.bind(this)
  395. }},
  396. forumVisiablePersonButton : { value : this.lp.selectPerson , type : "button", style : formVisiableButtonStyle, event : {
  397. click : function( it, ev ){
  398. this.explorer.explorer.parent.selectPerson( it.form.getItem("forumVisiablePerson").getElements()[0], "person" , 0 ) }.bind(this)
  399. }},
  400. forumVisiableDepartmentButton : { value : this.lp.selectDepartment , type : "button", style : formVisiableButtonStyle, event : {
  401. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("forumVisiableDepartment").getElements()[0], "department" , 0 )}.bind(this)
  402. }},
  403. forumVisiableCompanyButton : { value : this.lp.selectCompany , type : "button", style : formVisiableButtonStyle, event : {
  404. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("forumVisiableCompany").getElements()[0], "company" , 0 )}.bind(this)
  405. }},
  406. forumVisiableCompany : { type : "innerText", value : function(){ return this.getRoleMemberByCode("FORUM_GUEST_")["company"].join(",") }.bind(this), style : formVisiableStyle },
  407. forumVisiableDepartment : { type : "innerText", value : function(){ return this.getRoleMemberByCode("FORUM_GUEST_")["department"].join(",") }.bind(this), style : formVisiableStyle },
  408. forumVisiablePerson : { type : "innerText", value : function(){ return this.getRoleMemberByCode("FORUM_GUEST_")["person"].join(",") }.bind(this), style : formVisiableStyle },
  409. indexListStyleLable: {text: this.lp.indexListStyle }, //selectValue : this.lp.indexListStyleValue.split(",")
  410. indexListStyleButton: { type : "button", value: this.lp.indexListStyleButton, event : {
  411. click : function( it, ev ){ this.selectIndexType() }.bind(this)
  412. } },
  413. forumIndexStyle: {text: this.lp.forumIndexStyle, type : "select", selectValue : this.lp.forumIndexStyleValue.split(",") },
  414. indexRecommendable: {text: this.lp.indexRecommendable, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") },
  415. subjectNeedAudit: {text: this.lp.subjectNeedAudit, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(","), defaultValue : "false" },
  416. replyNeedAudit: {text: this.lp.replyNeedAudit, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(","), defaultValue : "false" },
  417. //sectionCreateAble: {text: this.lp.sectionCreateAble, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") },
  418. creatorName: {text: this.lp.creatorName, type : "innerText", "defaultValue" : this.app.userName },
  419. forumStatus: {text: this.lp.forumStatus, type : "select", selectValue : this.lp.forumStatusValue.split(",") },
  420. orderNumber: {text: this.lp.orderNumber, tType : "number" },
  421. forumColorArea: {text: this.lp.forumColor, type: "innerText" },
  422. forumColorButton : { value : this.lp.selectColor , type : "button", style : selectColorButtonStyle, event : {
  423. click : function( it, ev ){ this.selectColor() }.bind(this)
  424. }},
  425. subjectType: {text: this.lp.subjectType, type: "text", defaultValue : this.lp.subjectTypeDefaultValue },
  426. forumNotice: {text: this.lp.forumNotice, type: "rtf", RTFConfig : { skin : "bootstrapck" }}
  427. }
  428. }, this.app);
  429. this.form.load();
  430. var forumColorArea = this.formTableArea.getElements("[item='forumColorArea']")[0];
  431. this.forumColorNode = new Element( "div", {
  432. styles : { "font-size":"12px", height : "24px", "line-height" : "24px", width : "70px", "margin-right" : "20px" , "color" : "#fff", "text-align" : "center", "background-color" : this.data.forumColor || this.lp.defaultForumColor },
  433. text : "效果"
  434. }).inject( forumColorArea )
  435. }.bind(this), true);
  436. },
  437. selectColor: function(){
  438. var form = new MWF.xApplication.Forum.Setting.ForumColorForm(this, {}, {
  439. onPostOk : function( color ){
  440. this.forumColorNode.setStyle( "background-color" , color );
  441. this.data.forumColor = color;
  442. }.bind(this)
  443. })
  444. form.edit();
  445. },
  446. _ok: function (data, callback) {
  447. this.app.restActions.saveCategory( data, function(json){
  448. this.saveRole( json.data.id, function(){
  449. if( callback )callback(json);
  450. this.fireEvent("postOk")
  451. }.bind(this))
  452. }.bind(this));
  453. },
  454. saveRole : function( id, callback ){
  455. var data = this.form.getResult(true, ",", true, false, true);
  456. if( this.isNew )data.id = id;
  457. this.saveRoleMember( true, "forumManagerName" ,"FORUM_SUPER_MANAGER_", data, true )
  458. var flag = data.forumVisiable != this.lp.allPerson;
  459. this.saveRoleMember( flag, "forumVisiable" ,"FORUM_GUEST_", data )
  460. if( callback )callback();
  461. },
  462. saveRoleMember : function( flag, dataKey, code, data , isSingle, callback ){
  463. var orgArray = [];
  464. if( flag ){
  465. if( isSingle ){
  466. if( data[ dataKey ] ){
  467. data[ dataKey ].split(",").each( function( p ){
  468. if( p!= "") orgArray.push( { objectName : p, objectType : "人员" } );
  469. })
  470. }
  471. }else{
  472. if( data[ dataKey + "Person" ] ){
  473. data[ dataKey + "Person" ].split(",").each( function( p ){
  474. if( p!= "") orgArray.push( { objectName : p, objectType : "人员" } );
  475. })
  476. }
  477. if( data[ dataKey + "Department" ] ) {
  478. data[dataKey + "Department"].split(",").each(function (p) {
  479. if (p != "") orgArray.push({objectName: p, objectType: "部门"});
  480. })
  481. }
  482. if( data[ dataKey + "Company" ] ) {
  483. data[ dataKey + "Company" ].split(",").each( function( p ){
  484. if( p!= "") orgArray.push( { objectName : p, objectType : "公司" } );
  485. })
  486. }
  487. }
  488. }
  489. var d = {
  490. bindObjectArray : orgArray,
  491. bindRoleCode : code + this.data.id
  492. };
  493. this.app.restActions.bindRole( d, function( rData ){
  494. if( callback )callback(json);
  495. }.bind(this))
  496. },
  497. getRoleMemberByCode : function( code ){
  498. if( !this.RoleMember )this.RoleMember = {};
  499. if( this.RoleMember[ code ] ){
  500. return this.RoleMember[ code ];
  501. }
  502. var r = this.RoleMember[ code ] = {
  503. company : [],
  504. department : [],
  505. person : []
  506. };
  507. if( this.data && this.data.id ){
  508. this.actions.listRoleMemberByCode( { "bindRoleCode" : code+ this.data.id }, function(json){
  509. json.data = json.data || [];
  510. json.data.each( function( d ){
  511. if(d.objectType == "公司"){
  512. r.company.push( d.objectName );
  513. }else if(d.objectType == "部门"){
  514. r.department.push( d.objectName );
  515. }else{
  516. r.person.push( d.objectName );
  517. }
  518. }.bind(this) )
  519. }, function(){}, false );
  520. }
  521. return r;
  522. },
  523. selectIndexType : function(){
  524. this.getDefaultTypeTemplateList( function(){
  525. this.selectTypeTemplate();
  526. }.bind(this))
  527. },
  528. getDefaultTypeTemplateList : function(callback){
  529. if (this.defalutTypeTemplateList){
  530. if (callback) callback();
  531. }else{
  532. var url = "/x_component_Forum/$ColumnTemplate/template/setting.json";
  533. MWF.getJSON(url, function(json){
  534. this.defalutTypeTemplateList = json;
  535. if (callback) callback();
  536. }.bind(this));
  537. }
  538. },
  539. selectTypeTemplate: function(e){
  540. this.typeTemplateList = null;
  541. var _self = this;
  542. var createTemplateMaskNode = new Element("div", {"styles": this.css.createTemplateMaskNode}).inject(this.app.content);
  543. var createTemplateAreaNode = new Element("div", {"styles": this.css.createTypeTemplateAreaNode}).inject(this.app.content);
  544. createTemplateAreaNode.fade("in");
  545. var createTemplateTitleNode = new Element("div", {"styles": this.css.createTemplateFormTitleNode, "text": this.app.lp.selectIndexType }).inject(createTemplateAreaNode);
  546. var createTemplateCategoryNode = new Element("div", {"styles": this.css.createTemplateFormCategoryNode}).inject(createTemplateAreaNode);
  547. var createTemplateCategoryTitleNode = new Element("div", {"styles": this.css.createTemplateFormCategoryTitleNode, "text": this.app.lp.typeColumn}).inject(createTemplateCategoryNode);
  548. var createTemplateContentNode = new Element("div", {"styles": this.css.createTemplateFormContentNode}).inject(createTemplateAreaNode);
  549. var createTemplateCategoryAllNode = new Element("div", {"styles": this.css.createTemplateFormCategoryItemNode, "text": this.app.lp.all}).inject(createTemplateCategoryNode);
  550. createTemplateCategoryAllNode.addEvent("click", function(){
  551. loadAllTemplates();
  552. });
  553. var columnCountList = [];
  554. this.getDefaultTypeTemplateList( function(){
  555. for( var key in this.defalutTypeTemplateList ) {
  556. var template = this.defalutTypeTemplateList[key];
  557. if( !columnCountList.contains( template.column ) )columnCountList.push( template.column )
  558. }
  559. }.bind(this));
  560. columnCountList.each(function( columnCount ){
  561. var createTemplateCategoryItemNode = new Element("div", {"styles": this.css.createTemplateFormCategoryItemNode, "text": columnCount+"列", "value": columnCount}).inject(createTemplateCategoryNode);
  562. createTemplateCategoryItemNode.addEvent("click", function(){
  563. createTemplateContentNode.empty();
  564. createTemplateCategoryNode.getElements("div").each(function(node, i){
  565. if (i>0) node.setStyles(_self.css.createTemplateFormCategoryItemNode);
  566. });
  567. this.setStyles(_self.css.createTemplateFormCategoryItemNode_current);
  568. loadDefaultTemplate(this.get("value"));
  569. });
  570. }.bind(this));
  571. var resize = function(){
  572. var size = this.app.content.getSize();
  573. var y = (size.y*0.1)/2;
  574. var x = (size.x*0.1)/2;
  575. if (y<0) y=0;
  576. if (x<0) x=0;
  577. createTemplateAreaNode.setStyles({
  578. "top": ""+y+"px",
  579. "left": ""+x+"px"
  580. });
  581. y = size.y*0.9-createTemplateCategoryNode.getSize().y-70;
  582. createTemplateContentNode.setStyle("height", ""+y+"px");
  583. }.bind(this);
  584. resize();
  585. this.app.addEvent("resize", resize);
  586. var loadDefaultTemplate = function( columnCount ){
  587. this.getDefaultTypeTemplateList(function(){
  588. for( var key in this.defalutTypeTemplateList ){
  589. var template = this.defalutTypeTemplateList[key];
  590. if( columnCount && template.column != parseInt( columnCount ) ){
  591. continue;
  592. }
  593. template.key = key;
  594. var templateNode = new Element("div", {"styles": this.css.typeTemplateNode}).inject(createTemplateContentNode);
  595. var templateIconNode = new Element("div", {"styles": this.css.typeTemplateIconNode}).inject(templateNode);
  596. //var templateTitleNode = new Element("div", {"styles": this.css.typeTemplateTitleNode, "text": template.title}).inject(templateNode);
  597. templateNode.store("template", template.key);
  598. var templateIconImgNode = new Element("img", {"styles": this.css.typeTemplateIconImgNode}).inject(templateIconNode);
  599. templateIconImgNode.set("src", template.preview);
  600. templateNode.addEvents({
  601. "mouseover": function(){this.setStyles(_self.css.typeTemplateNode_over)},
  602. "mouseout": function(){this.setStyles(_self.css.typeTemplateNode)},
  603. "mousedown": function(){this.setStyles(_self.css.typeTemplateNode_down)},
  604. "mouseup": function(){this.setStyles(_self.css.typeTemplateNode_over)},
  605. "click": function(e){
  606. selectType(e, this.retrieve("template"));
  607. _self.app.removeEvent("resize", resize);
  608. createTemplateAreaNode.destroy();
  609. createTemplateMaskNode.destroy();
  610. }
  611. });
  612. }
  613. }.bind(this));
  614. }.bind(this);
  615. var selectType = function( e, type ){
  616. this.data.indexListStyle = type;
  617. this.indexListStyleShow.empty();
  618. new Element("img", {
  619. src : this.defalutTypeTemplateList[type].preview,
  620. styles : this.css.indexListStylePreview
  621. }).inject(this.indexListStyleShow);
  622. }.bind(this);
  623. var loadAllTemplates = function(){
  624. createTemplateContentNode.empty();
  625. createTemplateCategoryNode.getElements("div").each(function(node, i){
  626. if (i>0) node.setStyles(_self.css.createTemplateFormCategoryItemNode);
  627. });
  628. createTemplateCategoryAllNode.setStyles(_self.css.createTemplateFormCategoryItemNode_current);
  629. loadDefaultTemplate();
  630. };
  631. loadAllTemplates();
  632. createTemplateMaskNode.addEvent("click", function(){
  633. this.app.removeEvent("resize", resize);
  634. createTemplateAreaNode.destroy();
  635. createTemplateMaskNode.destroy();
  636. }.bind(this));
  637. }
  638. });
  639. MWF.xApplication.Forum.Setting.ForumColorForm = new Class({
  640. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  641. Implements: [Options, Events],
  642. options: {
  643. "style": "default",
  644. "width": "820",
  645. "height": "280",
  646. "hasTop": true,
  647. "hasIcon": false,
  648. "hasTopIcon" : true,
  649. "hasTopContent" : true,
  650. "hasBottom": false,
  651. "title": MWF.xApplication.Forum.LP.forumColorFormTitle,
  652. "draggable": true,
  653. "closeAction": true
  654. },
  655. _createTableContent: function () {
  656. var div = new Element("div",{
  657. "styles" : this.css.sectionFormContent
  658. }).inject(this.formTableArea);
  659. div.setStyle( "margin-top" , "10px" );
  660. this.lp.optionsForumColors.each(function(arr, i){
  661. arr.each( function(c , j ){
  662. var iconAreaNode = new Element("div",{
  663. "styles" : this.css.iconAreaNode
  664. }).inject(div);
  665. var iconNode = new Element("div",{
  666. "styles" : {height : "20px", width : "40px", "margin" : "5px 5px 5px 5px" , "background-color" : c, "cursor" : "pointer"}
  667. }).inject(iconAreaNode);
  668. iconAreaNode.store( "color", c );
  669. iconAreaNode.addEvents({
  670. "click" : function(){
  671. this.obj.fireEvent("postOk", this.node.retrieve("color") );
  672. this.obj.close();
  673. }.bind({ obj : this, node : iconAreaNode })
  674. })
  675. }.bind(this))
  676. }.bind(this));
  677. }
  678. });
  679. MWF.xApplication.Forum.Setting.SectionSettingExplorer = new Class({
  680. Extends: MWF.widget.Common,
  681. Implements: [Options, Events],
  682. options: {
  683. "style": "default"
  684. },
  685. initialize: function (container, app, parent, options) {
  686. this.container = container;
  687. this.parent = parent;
  688. this.app = app;
  689. this.css = this.parent.css;
  690. this.lp = this.app.lp;
  691. },
  692. load: function () {
  693. this.container.empty();
  694. this.loadToolbar();
  695. },
  696. destroy : function(){
  697. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun)
  698. this.view.destroy();
  699. },
  700. loadToolbar: function(){
  701. this.toolbar = new Element("div",{
  702. styles : this.css.toolbar
  703. }).inject(this.container)
  704. this.createActionNode = new Element("div",{
  705. styles : this.css.toolbarActionNode,
  706. text: this.lp.createSection
  707. }).inject(this.toolbar);
  708. this.createActionNode.addEvent("click",function(){
  709. var form = new MWF.xApplication.Forum.Setting.SectionSettingForm(this, {}, {
  710. onPostOk : function(){
  711. this.view.reload();
  712. }.bind(this)})
  713. form.create();
  714. }.bind(this))
  715. this.loadCategoryBar();
  716. //this.fileterNode = new Element("div",{
  717. // styles : this.css.fileterNode
  718. //}).inject(this.toolbar);
  719. },
  720. loadCategoryBar : function(){
  721. var _self = this;
  722. //this.categoryBar = new Element("div.categoryBar",{"styles":this.css.categoryBar}).inject(this.contentDiv);
  723. this.allCategoryNode = new Element("li.allCategoryNode", {
  724. "styles": this.css.categoryNode,
  725. "text" : "全部"
  726. }).inject(this.toolbar)
  727. this.allCategoryNode.addEvents({
  728. "mouseover" : function(){ if( this.currentCategoryNode != this.allCategoryNode)this.allCategoryNode.setStyles(this.css.categoryNode_over) }.bind(this),
  729. "mouseout" : function(){ if( this.currentCategoryNode != this.allCategoryNode)this.allCategoryNode.setStyles(this.css.categoryNode) }.bind(this),
  730. "click":function(){
  731. if( this.currentCategoryNode )this.currentCategoryNode.setStyles(this.css.categoryNode);
  732. this.currentCategoryNode = this.allCategoryNode;
  733. this.allCategoryNode.setStyles(this.css.categoryNode_current);
  734. this.loadView( )
  735. }.bind(this)
  736. })
  737. var isManager = false;
  738. this.forumAdminObj = {};
  739. this.app.restActions.listCategoryAllByAdmin( function( json ){
  740. json.data.each( function( d ){
  741. var flag = this.app.access.hasForumAdminAuthority( d );
  742. this.forumAdminObj[d.id] = flag;
  743. if( !isManager ){
  744. isManager = flag;
  745. }
  746. var categoryNode = new Element("li.categoryNode", {
  747. "styles": this.css.categoryNode,
  748. "text" : d.forumName
  749. }).inject(this.toolbar);
  750. categoryNode.store( "categoryId" , d.id );
  751. categoryNode.addEvents({
  752. "mouseover" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.categoryNode_over) }.bind({node : categoryNode }),
  753. "mouseout" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.categoryNode) }.bind({node : categoryNode }),
  754. "click":function(){
  755. if( _self.currentCategoryNode )_self.currentCategoryNode.setStyles(_self.css.categoryNode);
  756. _self.currentCategoryNode = this.node;
  757. this.node.setStyles(_self.css.categoryNode_current);
  758. _self.loadView( )
  759. }.bind({ name : d.id, node : categoryNode })
  760. })
  761. }.bind(this))
  762. }.bind(this), null, false
  763. )
  764. if( !isManager )this.createActionNode.destroy();
  765. this.allCategoryNode.click();
  766. },
  767. loadView : function(){
  768. var categoryId;
  769. if( this.currentCategoryNode ){
  770. categoryId = this.currentCategoryNode.retrieve("categoryId");
  771. }
  772. categoryId = categoryId || "all";
  773. if(this.viewContainer)this.viewContainer.destroy();
  774. this.viewContainer = Element("div",{
  775. "styles" : this.css.viewContainer
  776. }).inject(this.container);
  777. this.resizeWindow();
  778. this.resizeWindowFun = this.resizeWindow.bind(this)
  779. this.app.addEvent("resize", this.resizeWindowFun );
  780. this.view = new MWF.xApplication.Forum.Setting.SectionSettingView( this.viewContainer, this.app, this, {
  781. templateUrl : this.parent.path+"listItemSection.json",
  782. scrollEnable : true,
  783. categoryId : categoryId
  784. } )
  785. this.view.load();
  786. },
  787. resizeWindow: function(){
  788. var size = this.container.getSize();
  789. this.viewContainer.setStyles({"height":(size.y-65)+"px"});
  790. }
  791. })
  792. MWF.xApplication.Forum.Setting.SectionSettingView = new Class({
  793. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  794. _createDocument: function(data){
  795. return new MWF.xApplication.Forum.Setting.SectionSettingDocument(this.viewNode, data, this.explorer, this);
  796. },
  797. _getCurrentPageData: function(callback, count){
  798. if (!count)count = 20;
  799. //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  800. //var filter = this.filterData || {};
  801. if( this.options.categoryId == "all" ){
  802. this.actions.listSectionAll( function (json) {
  803. if( !json.data )json.data = [];
  804. if (callback)callback(json);
  805. }.bind(this))
  806. }else{
  807. this.actions.listSectionByAdmin( this.options.categoryId, function (json) {
  808. if( !json.data )json.data = [];
  809. if (callback)callback(json);
  810. }.bind(this))
  811. }
  812. },
  813. _removeDocument: function(documentData, all){
  814. this.actions.deleteSection(documentData.id, function(json){
  815. this.reload();
  816. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  817. }.bind(this));
  818. },
  819. _create: function(){
  820. },
  821. _openDocument: function( documentData ){
  822. var form = new MWF.xApplication.Forum.Setting.SectionSettingForm(this, documentData, {
  823. title : this.lp.sectionFormTitle + " - " + documentData.sectionName,
  824. onPostOk : function(){
  825. this.reload();
  826. }.bind(this)
  827. })
  828. //this.app.access.hasSectionAdminAuthority( documentData , function( flag ){ 只有分区管理员可以对分区以下的板块进行增删改,版主不能
  829. this.app.access.hasForumAdminAuthority( documentData.forumId , function( flag ){
  830. flag ? form.edit() : form.open();
  831. } )
  832. },
  833. _queryCreateViewNode: function(){
  834. },
  835. _postCreateViewNode: function( viewNode ){
  836. },
  837. _queryCreateViewHead:function(){
  838. },
  839. _postCreateViewHead: function( headNode ){
  840. }
  841. })
  842. MWF.xApplication.Forum.Setting.SectionSettingDocument = new Class({
  843. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  844. mouseoverSection : function(sectionNode, ev){
  845. var removeNode = sectionNode.getElements("[styles='sectionRemoveNode']")[0];
  846. if( removeNode )removeNode.setStyle("opacity",1)
  847. },
  848. mouseoutSection : function(sectionNode, ev){
  849. var removeNode = sectionNode.getElements("[styles='sectionRemoveNode']")[0];
  850. if( removeNode )removeNode.setStyle("opacity",0)
  851. },
  852. _queryCreateDocumentNode:function( itemData ){
  853. },
  854. _postCreateDocumentNode: function( itemNode, itemData ){
  855. }
  856. })
  857. MWF.xApplication.Forum.Setting.SectionSettingForm = new Class({
  858. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  859. Implements: [Options, Events],
  860. options: {
  861. "style": "default",
  862. "width": "1100",
  863. "height": "90%",
  864. "hasTop": true,
  865. "hasIcon": false,
  866. "hasTopIcon" : true,
  867. "hasTopContent" : true,
  868. "hasBottom": true,
  869. "title": MWF.xApplication.Forum.LP.sectionFormTitle,
  870. "draggable": true,
  871. "closeAction": true
  872. },
  873. createToolbar: function(){
  874. var _self = this;
  875. this.toolbar = new Element("div",{
  876. styles : this.css.formToolbar
  877. }).inject(this.formNode)
  878. var categoryNode = new Element("li.categoryNode", {
  879. "styles": this.css.formCategoryNode,
  880. "text" : this.lp.baseSetting
  881. }).inject(this.toolbar);
  882. categoryNode.addEvents({
  883. "mouseover" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.formCategoryNode_over) }.bind({node : categoryNode }),
  884. "mouseout" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.formCategoryNode) }.bind({node : categoryNode }),
  885. "click":function(){
  886. if( _self.currentCategoryNode )_self.currentCategoryNode.setStyles(_self.css.formCategoryNode);
  887. _self.currentCategoryNode = this.node;
  888. this.node.setStyles(_self.css.formCategoryNode_current);
  889. _self.baseContainer.setStyle("display","");
  890. _self.permissionContainer.setStyle("display","none");
  891. }.bind({ node : categoryNode })
  892. })
  893. categoryNode.setStyles( this.css.formCategoryNode_current );
  894. _self.currentCategoryNode = categoryNode;
  895. var categoryNode = new Element("li.categoryNode", {
  896. "styles": this.css.formCategoryNode,
  897. "text" : this.lp.permissionSetting
  898. }).inject(this.toolbar);
  899. categoryNode.addEvents({
  900. "mouseover" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.formCategoryNode_over) }.bind({node : categoryNode }),
  901. "mouseout" : function(){ if( _self.currentCategoryNode != this.node)this.node.setStyles(_self.css.formCategoryNode) }.bind({node : categoryNode }),
  902. "click":function(){
  903. if( _self.currentCategoryNode )_self.currentCategoryNode.setStyles(_self.css.formCategoryNode);
  904. _self.currentCategoryNode = this.node;
  905. this.node.setStyles(_self.css.formCategoryNode_current);
  906. _self.baseContainer.setStyle("display","none");
  907. _self.permissionContainer.setStyle("display","");
  908. }.bind({ node : categoryNode })
  909. })
  910. },
  911. createContent: function () {
  912. this.createToolbar();
  913. this.formContentNode = new Element("div.formContentNode", {
  914. "styles": this.css.formContentNode
  915. }).inject(this.formNode);
  916. this.formTableContainer = new Element("div.formTableContainer", {
  917. "styles": this.css.formTableContainer
  918. }).inject(this.formContentNode);
  919. this.formTableArea = new Element("div.formTableArea", {
  920. "styles": this.css.formTableArea
  921. }).inject(this.formTableContainer);
  922. this._createTableContent();
  923. },
  924. _createTableContent: function () {
  925. _self = this;
  926. this.baseContainer = new Element("div").inject(this.formTableArea)
  927. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  928. "<tr>" +
  929. " <td styles='formTableTitle' lable='sectionName' width='10%'></td>" +
  930. " <td styles='formTableValue' item='sectionName' width='40%'></td>" +
  931. " <td styles='formTableTitle' lable='forumId' width='10%'></td>" +
  932. " <td styles='formTableValue' item='forumId' width='40%'></td>" +
  933. "</tr><tr>" +
  934. //" <td styles='formTableTitle' lable='sectionType'></td>" +
  935. //" <td styles='formTableValue' item='sectionType'></td>" +
  936. //"</tr><tr>" +
  937. " <td styles='formTableTitle' lable='sectionStatus'></td>" +
  938. " <td styles='formTableValue' item='sectionStatus'></td>" +
  939. " <td styles='formTableTitle' lable='orderNumber'></td>" +
  940. " <td styles='formTableValue' item='orderNumber'></td>" +
  941. "</tr><tr>" +
  942. " <td styles='formTableTitle' lable='typeCatagory'></td>" +
  943. " <td styles='formTableValue' item='typeCatagory'></td>" +
  944. " <td styles='formTableTitle' lable='subjectType'></td>" +
  945. " <td styles='formTableValue' item='subjectType'></td>" +
  946. "</tr><tr>" +
  947. " <td styles='formTableTitle' lable='creatorName'></td>" +
  948. " <td styles='formTableValue' item='creatorName'></td>" +
  949. " <td styles='formTableTitle' lable='createTime'></td>" +
  950. " <td styles='formTableValue' item='createTime'></td>" +
  951. "</tr><tr>" +
  952. " <td styles='formTableTitle' lable='sectionIcon'></td>" +
  953. " <td styles='formTableValue' item='sectionIconArea' colspan='3' valign='bottom'></td>" +
  954. "</tr><tr>" +
  955. " <td styles='formTableTitle' lable='sectionDescription'></td>" +
  956. " <td styles='formTableValue' item='sectionDescription' colspan='3'></td>" +
  957. "</tr><tr>" +
  958. " <td styles='formTableTitle' lable='sectionNotice'></td>" +
  959. " <td styles='formTableValue' item='sectionNotice' colspan='3'></td>" +
  960. "</tr>"
  961. "</table>"
  962. this.baseContainer.set("html", html);
  963. this.permissionContainer = new Element("div", { styles : {"display":"none"} }).inject( this.formTableArea );
  964. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  965. "<tr>" +
  966. " <td styles='formTableTitle' lable='moderatorNames'></td>" +
  967. " <td styles='formTableValue' item='moderatorNames' colspan='3'></td>"+
  968. "</tr><tr>" +
  969. " <td styles='formTableTitle' lable='sectionVisiable' width='10%'></td>" +
  970. " <td styles='formTableValue' item='sectionVisiable' width='40%'></td>" +
  971. " <td styles='formTableValue' width='50%' colspan='2'>"+
  972. " <span item='sectionVisiableCompanyButton'></span>"+
  973. " <span item='sectionVisiableDepartmentButton'></span>"+
  974. " <span item='sectionVisiablePersonButton'></span>"+
  975. " </td>" +
  976. "</tr><tr>" +
  977. " <td></td>"+
  978. " <td styles='formTableValue' colspan='3'>"+
  979. " <div styles='formItemSpan' item='sectionVisiableCompany'></div>"+
  980. " <div styles='formItemSpan' item='sectionVisiableDepartment'></div>"+
  981. " <div styles='formItemSpan' item='sectionVisiablePerson'></div>"+
  982. " </td>" +
  983. "</tr><tr>" +
  984. " <td styles='formTableTitle' lable='subjectPublishAble' width='10%'></td>" +
  985. " <td styles='formTableValue' item='subjectPublishAble' width='40%'></td>" +
  986. " <td styles='formTableValue' width='50%' colspan='2'>"+
  987. " <span item='subjectPublishCompanyButton'></span>"+
  988. " <span item='subjectPublishDepartmentButton'></span>"+
  989. " <span item='subjectPublishPersonButton'></span>"+
  990. " </td>" +
  991. "</tr><tr>" +
  992. " <td></td>"+
  993. " <td styles='formTableValue' colspan='3'>"+
  994. " <div styles='formItemSpan' item='subjectPublishCompany'></div>"+
  995. " <div styles='formItemSpan' item='subjectPublishDepartment'></div>"+
  996. " <div styles='formItemSpan' item='subjectPublishPerson'></div>"+
  997. " </td>" +
  998. "</tr><tr>" +
  999. " <td styles='formTableTitle' lable='replyPublishAble'></td>" +
  1000. " <td styles='formTableValue' item='replyPublishAble'></td>" +
  1001. " <td styles='formTableValue' width='50%' colspan='2'>"+
  1002. " <span styles='formItemDiv' item='replyPublishCompanyButton'></span>"+
  1003. " <span styles='formItemDiv' item='replyPublishDepartmentButton'></span>"+
  1004. " <span styles='formItemDiv' item='replyPublishPersonButton'></span>"+
  1005. " </td>" +
  1006. "</tr><tr>" +
  1007. " <td></td>"+
  1008. " <td styles='formTableValue' coldiv='3'>"+
  1009. " <div item='replyPublishCompany'></div>"+
  1010. " <div item='replyPublishDepartment'></div>"+
  1011. " <div item='replyPublishPerson'></div>"+
  1012. " </td>" +
  1013. "</tr><tr item='indexRecommendTr' style='"+ ( this.data.sectionVisiable == this.lp.byPermission ? "display:none;" : "display:;" ) +"'>" +
  1014. " <td styles='formTableTitle' lable='indexRecommendable'></td>" +
  1015. " <td styles='formTableValue' item='indexRecommendable'></td>" +
  1016. " <td styles='formTableTitle' lable='indexRecommenPerson' style='"+ ( this.data.indexRecommendable == false ? "display:none;" : "display:;" ) +"'></td>" +
  1017. " <td styles='formTableValue' item='indexRecommenPerson' style='"+ ( this.data.indexRecommendable == false ? "display:none;" : "display:;" ) +"'></td>" +
  1018. "</tr><tr>" +
  1019. " <td styles='formTableTitle' lable='subjectNeedAudit' width='10%'></td>" +
  1020. " <td styles='formTableValue' item='subjectNeedAudit' width='40%'></td>" +
  1021. " <td styles='formTableTitle' lable='subjectAuditPerson' width='10%' style='"+ ( this.data.subjectNeedAudit == true ? "display:;" : "display:none;" ) +"'></td>" +
  1022. " <td styles='formTableValue' item='subjectAuditPerson' width='40%' style='"+ ( this.data.subjectNeedAudit == true ? "display:;" : "display:none;" ) +"'></td>" +
  1023. "</tr><tr>" +
  1024. " <td styles='formTableTitle' lable='replyNeedAudit'></td>" +
  1025. " <td styles='formTableValue' item='replyNeedAudit'></td>" +
  1026. " <td styles='formTableTitle' lable='replyAuditPerson' style='"+ ( this.data.replyNeedAudit == true ? "display:;" : "display:none;" ) +"'></td>" +
  1027. " <td styles='formTableValue' item='replyAuditPerson' style='"+ ( this.data.replyNeedAudit == true ? "display:;" : "display:none;" ) +"'></td>" +
  1028. "</tr>"
  1029. "</table>"
  1030. this.permissionContainer.set("html", html);
  1031. var forumNames = [""];
  1032. var forumIds = [""];
  1033. this.app.restActions.listCategoryAllByAdmin( function( json ){
  1034. json.data.each( function( d ){
  1035. if( this.isNew ){
  1036. if( this.app.access.hasForumAdminAuthority( d ) ){
  1037. forumNames.push(d.forumName );
  1038. forumIds.push(d.id);
  1039. }
  1040. }else{
  1041. forumNames.push(d.forumName );
  1042. forumIds.push(d.id);
  1043. }
  1044. }.bind(this))
  1045. }.bind(this), null ,false)
  1046. if( !this.data.typeCatagory ){
  1047. this.data.typeCatagory = this.lp.typeCategorySelectValue.split("|");
  1048. }else{
  1049. this.data.typeCatagory = typeof this.data.typeCatagory == "string" ? this.data.typeCatagory.split("|") : this.data.typeCatagory;
  1050. }
  1051. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1052. this.form = new MForm(this.formTableArea, this.data, {
  1053. style: "forum",
  1054. isEdited: this.isEdited || this.isNew,
  1055. itemTemplate: {
  1056. sectionName: {text: this.lp.sectionName, notEmpty: true},
  1057. forumId: {text: this.lp.owneForum, type : "select", "selectText" : forumNames, "selectValue" : forumIds , notEmpty: true, isEdited : function(){ return this.isNew }.bind(this)},
  1058. sectionVisiable: {text: this.lp.sectionVisiable, type : "select", selectValue : this.lp.sectionVisiableValue.split(","), event : {
  1059. change : function( it, ev ){
  1060. this.setItemStyle( it, "sectionVisiable" );
  1061. if( it.getValue() == this.lp.allPerson ){
  1062. this.formTableArea.getElements("[item='indexRecommendTr']")[0].setStyle("display","")
  1063. }else{
  1064. this.formTableArea.getElements("[item='indexRecommendTr']")[0].setStyle("display","none")
  1065. }
  1066. }.bind(this)
  1067. }},
  1068. sectionVisiableCompanyButton : { value : this.lp.selectCompany , type : "button", style : this.getButtonStyle("sectionVisiable"), event : {
  1069. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("sectionVisiableCompany").getElements()[0], "company" , 0 )}.bind(this)
  1070. }},
  1071. sectionVisiableDepartmentButton : { value : this.lp.selectDepartment , type : "button", style : this.getButtonStyle("sectionVisiable"), event : {
  1072. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("sectionVisiableDepartment").getElements()[0], "department" , 0 )}.bind(this)
  1073. }},
  1074. sectionVisiablePersonButton : { value : this.lp.selectPerson , type : "button", style : this.getButtonStyle("sectionVisiable"), event : {
  1075. click : function( it, ev ){
  1076. this.explorer.explorer.parent.selectPerson( it.form.getItem("sectionVisiablePerson").getElements()[0], "person" , 0 ) }.bind(this)
  1077. }},
  1078. sectionVisiableCompany : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_GUEST_")["company"].join(",") }.bind(this), style : this.getContainerStyle("sectionVisiable") },
  1079. sectionVisiableDepartment : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_GUEST_")["department"].join(",") }.bind(this), style : this.getContainerStyle("sectionVisiable") },
  1080. sectionVisiablePerson : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_GUEST_")["person"].join(",") }.bind(this), style : this.getContainerStyle("sectionVisiable") },
  1081. subjectPublishAble: {text: this.lp.subjectPublishAble, type : "select", selectValue : this.lp.subjectPublishAbleValue.split(","), event : {
  1082. change : function( it, ev ){ this.setItemStyle( it, "subjectPublish" ); }.bind(this)
  1083. }},
  1084. subjectPublishCompanyButton : { value : this.lp.selectCompany , type : "button", style : this.getButtonStyle("subjectPublishAble"), event : {
  1085. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("subjectPublishCompany").getElements()[0], "company" , 0 )}.bind(this)
  1086. }},
  1087. subjectPublishDepartmentButton : { value : this.lp.selectDepartment , type : "button", style : this.getButtonStyle("subjectPublishAble"), event : {
  1088. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("subjectPublishDepartment").getElements()[0], "department" , 0 )}.bind(this)
  1089. }},
  1090. subjectPublishPersonButton : { value : this.lp.selectPerson , type : "button", style : this.getButtonStyle("subjectPublishAble"), event : {
  1091. click : function( it, ev ){
  1092. this.explorer.explorer.parent.selectPerson( it.form.getItem("subjectPublishPerson").getElements()[0], "person" , 0 ) }.bind(this)
  1093. }},
  1094. subjectPublishCompany : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_SUBJECT_PUBLISHER_")["company"].join(",") }.bind(this), style : this.getContainerStyle("subjectPublishAble") },
  1095. subjectPublishDepartment : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_SUBJECT_PUBLISHER_")["department"].join(",") }.bind(this), style : this.getContainerStyle("subjectPublishAble") },
  1096. subjectPublishPerson : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_SUBJECT_PUBLISHER_")["person"].join(",") }.bind(this), style : this.getContainerStyle("subjectPublishAble") },
  1097. replyPublishAble: {text: this.lp.replyPublishAble, type : "select", selectValue : this.lp.replyPublishAbleValue.split(","), event : {
  1098. change : function( it, ev ){ this.setItemStyle( it, "replyPublish" ); }.bind(this)
  1099. }},
  1100. replyPublishCompanyButton : { value : this.lp.selectCompany , type : "button", style : this.getButtonStyle("replyPublishAble"), event : {
  1101. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("replyPublishCompany").getElements()[0], "company" , 0 )}.bind(this)
  1102. }},
  1103. replyPublishDepartmentButton : { value : this.lp.selectDepartment , type : "button", style : this.getButtonStyle("replyPublishAble"), event : {
  1104. click : function(it, ev){ this.explorer.explorer.parent.selectPerson( it.form.getItem("replyPublishDepartment").getElements()[0], "department" , 0 )}.bind(this)
  1105. }},
  1106. replyPublishPersonButton : { value : this.lp.selectPerson , type : "button", style : this.getButtonStyle("replyPublishAble"), event : {
  1107. click : function( it, ev ){
  1108. this.explorer.explorer.parent.selectPerson( it.form.getItem("replyPublishPerson").getElements()[0], "person" , 0 ) }.bind(this)
  1109. }},
  1110. replyPublishCompany : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_REPLY_PUBLISHER_")["company"].join(",") }.bind(this), style : this.getContainerStyle("replyPublishAble") },
  1111. replyPublishDepartment : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_REPLY_PUBLISHER_")["department"].join(",") }.bind(this), style : this.getContainerStyle("replyPublishAble") },
  1112. replyPublishPerson : { type : "innerText", value : function(){ return this.getRoleMemberByCode("SECTION_REPLY_PUBLISHER_")["person"].join(",") }.bind(this), style : this.getContainerStyle("replyPublishAble") },
  1113. indexRecommendable: {text: this.lp.indexRecommendable, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") , defaultValue : "true" ,event : {
  1114. change : function( it, ev ){
  1115. var styles = it.getValue() == "true" ? {"display":""} : {"display":"none"};
  1116. this.permissionContainer.getElements("[item='indexRecommenPerson']")[0].setStyles( styles );
  1117. this.permissionContainer.getElements("[lable='indexRecommenPerson']")[0].setStyles( styles );
  1118. }.bind(this)
  1119. }},
  1120. indexRecommenPerson : { text: this.lp.indexRecommenPerson , tType : "person", count : 0, value : function(){
  1121. var v = this.getRoleMemberByCode("SECTION_RECOMMENDER_")["person"].join(",");
  1122. return v == "" ? this.app.userName : v;
  1123. }.bind(this)},
  1124. subjectNeedAudit: {text: this.lp.subjectNeedAudit, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(","), defaultValue : "false" ,event : {
  1125. change : function( it, ev ){
  1126. var styles = it.getValue() == "true" ? {"display":""} : {"display":"none"};
  1127. this.permissionContainer.getElements("[item='subjectAuditPerson']")[0].setStyles( styles );
  1128. this.permissionContainer.getElements("[lable='subjectAuditPerson']")[0].setStyles( styles );
  1129. }.bind(this)
  1130. }},
  1131. subjectAuditPerson : { text: this.lp.auditPerson , tType : "person", count : 0, value : function(){ return this.getRoleMemberByCode("SECTION_SUBJECT_AUDITOR_")["person"].join(",") }.bind(this) },
  1132. replyNeedAudit: {text: this.lp.replyNeedAudit, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") , defaultValue : "false" ,event : {
  1133. change : function( it, ev ){
  1134. var styles = it.getValue() == "true" ? {"display":""} : {"display":"none"};
  1135. this.permissionContainer.getElements("[item='replyAuditPerson']")[0].setStyles( styles );
  1136. this.permissionContainer.getElements("[lable='replyAuditPerson']")[0].setStyles( styles );
  1137. }.bind(this)
  1138. }},
  1139. replyAuditPerson : { text: this.lp.auditPerson , tType : "person", count : 0, value : function(){ return this.getRoleMemberByCode("SECTION_REPLY_AUDITOR_")["person"].join(",") }.bind(this) },
  1140. moderatorNames : {text:this.lp.moderatorNames, tType:"person", count : 0, defaultValue : this.app.userName },
  1141. sectionType : {text: this.lp.sectionType, type : "select", selectValue : this.lp.sectionTypeValue.split(",") },
  1142. //sectionCreateAble: {text: this.lp.sectionCreateAble, type : "select", selectValue : ["true","false"], selectText : this.lp.yesOrNo.split(",") },
  1143. creatorName: {text: this.lp.creatorName, type : "innerText", "defaultValue" : this.app.userName },
  1144. createTime: {text: this.lp.createTime, type : "innerText" },
  1145. sectionStatus: {text: this.lp.sectionStatus, type : "select", selectValue : this.lp.sectionStatusValue.split(",") },
  1146. orderNumber: {text: this.lp.orderNumber, tType : "number" },
  1147. subjectType: {text: this.lp.subjectType, defaultValue : this.lp.subjectTypeDefaultValue },
  1148. typeCatagory: {text: this.lp.typeCatagory, selectValue : this.lp.typeCategorySelectValue.split("|"), type : "checkbox", notEmpty : true},
  1149. sectionDescription : {text: this.lp.sectionDescription, type: "textarea", style:{"height":"45px"} },
  1150. sectionNotice: {text: this.lp.sectionNotice, type: "rtf", RTFConfig : { skin : "bootstrapck" } },
  1151. sectionIcon : { text : this.lp.sectionIcon }
  1152. }
  1153. }, this.app);
  1154. this.form.load();
  1155. this.createIconNode();
  1156. }.bind(this), true);
  1157. },
  1158. saveRole : function( id, callback ){
  1159. var data = this.form.getResult(true, ",", true, false, true);
  1160. if( this.isNew )data.id = id;
  1161. this.saveRoleMember( true, "moderatorNames" ,"SECTION_MANAGER_", data, true );
  1162. var flag = data.sectionVisiable != this.lp.allPerson;
  1163. this.saveRoleMember( flag, "sectionVisiable" ,"SECTION_GUEST_", data )
  1164. flag = data.subjectPublishAble != this.lp.allPerson;
  1165. this.saveRoleMember( flag, "subjectPublish" ,"SECTION_SUBJECT_PUBLISHER_", data )
  1166. flag = data.replyPublishAble != this.lp.allPerson;
  1167. this.saveRoleMember( flag, "replyPublish" ,"SECTION_REPLY_PUBLISHER_", data )
  1168. flag = data.indexRecommendable == "true";
  1169. this.saveRoleMember( flag, "indexRecommenPerson" ,"SECTION_RECOMMENDER_", data, true );
  1170. flag = data.subjectNeedAudit == "true";
  1171. this.saveRoleMember( flag, "subjectAuditPerson" ,"SECTION_SUBJECT_AUDITOR_", data, true );
  1172. flag = data.replyNeedAudit == "true";
  1173. this.saveRoleMember( flag, "replyAuditPerson" ,"SECTION_REPLY_AUDITOR_", data, true );
  1174. if( callback )callback();
  1175. },
  1176. saveRoleMember : function( flag, dataKey, code, data , isSingle, callback ){
  1177. var orgArray = [];
  1178. if( flag ){
  1179. if( isSingle ){
  1180. if( data[ dataKey ] ){
  1181. data[ dataKey ].split(",").each( function( p ){
  1182. if( p!= "") orgArray.push( { objectName : p, objectType : "人员" } );
  1183. })
  1184. }
  1185. }else{
  1186. if( data[ dataKey + "Person" ] ){
  1187. data[ dataKey + "Person" ].split(",").each( function( p ){
  1188. if( p!= "") orgArray.push( { objectName : p, objectType : "人员" } );
  1189. })
  1190. }
  1191. if( data[ dataKey + "Department" ] ) {
  1192. data[dataKey + "Department"].split(",").each(function (p) {
  1193. if (p != "") orgArray.push({objectName: p, objectType: "部门"});
  1194. })
  1195. }
  1196. if( data[ dataKey + "Company" ] ) {
  1197. data[ dataKey + "Company" ].split(",").each( function( p ){
  1198. if( p!= "") orgArray.push( { objectName : p, objectType : "公司" } );
  1199. })
  1200. }
  1201. }
  1202. }
  1203. var d = {
  1204. bindObjectArray : orgArray,
  1205. bindRoleCode : code + this.data.id
  1206. };
  1207. this.app.restActions.bindRole( d, function( rData ){
  1208. if( callback )callback(json);
  1209. }.bind(this))
  1210. },
  1211. getRoleMemberByCode : function( code ){
  1212. if( !this.RoleMember )this.RoleMember = {};
  1213. if( this.RoleMember[ code ] ){
  1214. return this.RoleMember[ code ];
  1215. }
  1216. var r = {
  1217. company : [],
  1218. department : [],
  1219. person : []
  1220. };
  1221. if( !this.data.id ){
  1222. return r;
  1223. }
  1224. this.RoleMember[ code ] = r;
  1225. if( this.data && this.data.id ){
  1226. this.actions.listRoleMemberByCode( { "bindRoleCode" : code+ this.data.id }, function(json){
  1227. json.data = json.data || [];
  1228. json.data.each( function( d ){
  1229. if(d.objectType == "公司"){
  1230. r.company.push( d.objectName );
  1231. }else if(d.objectType == "部门"){
  1232. r.department.push( d.objectName );
  1233. }else{
  1234. r.person.push( d.objectName );
  1235. }
  1236. }.bind(this) )
  1237. }, function(){}, false );
  1238. }
  1239. //}
  1240. return r;
  1241. },
  1242. getButtonStyle : function( key ){
  1243. if( this.isEdited || this.isNew ){
  1244. return this.getContainerStyle( key )
  1245. }else{
  1246. return { display:"none"};
  1247. }
  1248. },
  1249. getContainerStyle : function( key ){
  1250. return (!this.data[key] ||(this.data[key] == this.lp.allPerson )) ? { display:"none"} : { display:""};
  1251. },
  1252. setItemStyle : function( it, preStr ){
  1253. var styles = it.getValue() == this.lp.allPerson ? { display : "none" } : { display : "" };
  1254. it.form.getItem(preStr + "PersonButton").setStyles( styles );
  1255. it.form.getItem(preStr + "DepartmentButton").setStyles( styles );
  1256. it.form.getItem(preStr + "CompanyButton").setStyles( styles );
  1257. it.form.getItem(preStr + "Person").setStyles( styles );
  1258. it.form.getItem(preStr + "Department").setStyles( styles );
  1259. it.form.getItem(preStr + "Company").setStyles( styles );
  1260. },
  1261. createIconNode: function(){
  1262. var iconPth = "/x_component_Forum/$Setting/"+ this.options.style +"/sectionIcon/";
  1263. var defaultIconSrc = iconPth + "forum_icon.png";
  1264. var sectionIconArea = this.formTableArea.getElements("[item='sectionIconArea']")[0];
  1265. this.iconNode = new Element("img",{
  1266. "styles" : this.css.iconNode
  1267. }).inject(sectionIconArea);
  1268. if (this.data.icon){
  1269. this.iconNode.set("src", "data:image/png;base64,"+this.data.icon+"");
  1270. }else{
  1271. this.iconNode.set("src", defaultIconSrc)
  1272. }
  1273. if( this.isEdited || this.isNew ){
  1274. //var selectIconActionNode = new Element("div", {
  1275. // "styles": this.css.changeIconActionNode,
  1276. // "text": this.lp.selectIcon
  1277. //}).inject(sectionIconArea);
  1278. //selectIconActionNode.addEvent("click", function () {
  1279. // this.selectIcon();
  1280. //}.bind(this));
  1281. var changeIconActionNode = new Element("div", {
  1282. "styles": this.css.changeIconActionNode,
  1283. "text": this.lp.uploadIcon
  1284. }).inject(sectionIconArea);
  1285. changeIconActionNode.addEvent("click", function () {
  1286. this.changeIcon();
  1287. }.bind(this));
  1288. }
  1289. },
  1290. selectIcon: function(){
  1291. var form = new MWF.xApplication.Forum.Setting.SectionIconForm(this, {}, {
  1292. onPostOk : function( icon ){
  1293. if( this.formData )this.formData = null;
  1294. this.iconNode.set("src",icon.path );
  1295. }.bind(this)
  1296. })
  1297. form.edit();
  1298. },
  1299. changeIcon: function () {
  1300. if (!this.uploadFileAreaNode) {
  1301. this.uploadFileAreaNode = new Element("div");
  1302. var html = "<input name=\"file\" type=\"file\"/>";
  1303. this.uploadFileAreaNode.set("html", html);
  1304. this.fileUploadNode = this.uploadFileAreaNode.getFirst();
  1305. this.fileUploadNode.addEvent("change", function () {
  1306. var files = fileNode.files;
  1307. if (files.length) {
  1308. for (var i = 0; i < files.length; i++) {
  1309. var file = files.item(i);
  1310. if (!file.type.match('image.*'))continue;
  1311. this.file = file;
  1312. this.formData = new FormData();
  1313. this.formData.append('file', this.file);
  1314. if (!window.FileReader) continue;
  1315. var reader = new FileReader();
  1316. reader.onload = (function (theFile) {
  1317. return function (e) {
  1318. this.iconNode.set("src",e.target.result)
  1319. }.bind(this);
  1320. }.bind(this))(file);
  1321. reader.readAsDataURL(file);
  1322. }
  1323. }
  1324. }.bind(this));
  1325. }
  1326. var fileNode = this.uploadFileAreaNode.getFirst();
  1327. fileNode.click();
  1328. },
  1329. saveIcon: function (id, callback) {
  1330. this.app.restActions.uploadSectionIcon(id, function () {
  1331. if (callback)callback();
  1332. }.bind(this), null, this.formData, this.file);
  1333. },
  1334. _ok: function (data, callback) {
  1335. data.sectionLevel = "主版块";
  1336. data.typeCatagory = data.typeCatagory.split(",").join("|");
  1337. this.app.restActions.saveSection( data, function(json){
  1338. if( this.formData ){
  1339. this.saveIcon( json.data.id, function(){
  1340. this.saveRole( json.data.id, function( data ){
  1341. if( callback )callback(json);
  1342. }.bind(this) )
  1343. }.bind(this) );
  1344. }else{
  1345. this.saveRole( json.data.id, function( data ){
  1346. if( callback )callback(json);
  1347. }.bind(this) )
  1348. }
  1349. this.fireEvent("postOk")
  1350. }.bind(this));
  1351. },
  1352. setFormNodeSize: function (width, height, top, left) {
  1353. if (!width)width = this.options.width ? this.options.width : "50%"
  1354. if (!height)height = this.options.height ? this.options.height : "50%"
  1355. if (!top) top = this.options.top ? this.options.top : 0;
  1356. if (!left) left = this.options.left ? this.options.left : 0;
  1357. var allSize = this.app.content.getSize();
  1358. var limitWidth = allSize.x; //window.screen.width
  1359. var limitHeight = allSize.y; //window.screen.height
  1360. "string" == typeof width && (1 < width.length && "%" == width.substr(width.length - 1, 1)) && (width = parseInt(limitWidth * parseInt(width, 10) / 100, 10));
  1361. "string" == typeof height && (1 < height.length && "%" == height.substr(height.length - 1, 1)) && (height = parseInt(limitHeight * parseInt(height, 10) / 100, 10));
  1362. 300 > width && (width = 300);
  1363. 220 > height && (height = 220);
  1364. top = top || parseInt((limitHeight - height) / 2, 10); //+appTitleSize.y);
  1365. left = left || parseInt((limitWidth - width) / 2, 10);
  1366. this.formAreaNode.setStyles({
  1367. "width": "" + width + "px",
  1368. "height": "" + height + "px",
  1369. "top": "" + top + "px",
  1370. "left": "" + left + "px"
  1371. });
  1372. this.formNode.setStyles({
  1373. "width": "" + width + "px",
  1374. "height": "" + height + "px"
  1375. });
  1376. var iconSize = this.formIconNode ? this.formIconNode.getSize() : {x: 0, y: 0};
  1377. var topSize = this.formTopNode ? this.formTopNode.getSize() : {x: 0, y: 0};
  1378. var bottomSize = this.formBottomNode ? this.formBottomNode.getSize() : {x: 0, y: 0};
  1379. var toolbarSize = this.toolbar ? this.toolbar.getSize() : {x: 0, y: 0};
  1380. var contentHeight = height - iconSize.y - topSize.y - bottomSize.y - toolbarSize.y;
  1381. //var formMargin = formHeight -iconSize.y;
  1382. this.formContentNode.setStyles({
  1383. "height": "" + contentHeight + "px"
  1384. });
  1385. this.formTableContainer.setStyles({
  1386. "height": "" + contentHeight + "px"
  1387. });
  1388. }
  1389. });
  1390. MWF.xApplication.Forum.Setting.SectionIconForm = new Class({
  1391. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  1392. Implements: [Options, Events],
  1393. options: {
  1394. "style": "default",
  1395. "width": "650",
  1396. "height": "400",
  1397. "hasTop": true,
  1398. "hasIcon": false,
  1399. "hasTopIcon" : true,
  1400. "hasTopContent" : true,
  1401. "hasBottom": false,
  1402. "title": MWF.xApplication.Forum.LP.sectionIconFormTitle,
  1403. "draggable": true,
  1404. "closeAction": true
  1405. },
  1406. _createTableContent: function () {
  1407. var iconPath = "/x_component_Forum/$Setting/" + this.options.style +"/sectionIcon/";
  1408. var jsonPath = "/x_component_Forum/$Setting/sectionIcon.json";
  1409. var div = new Element("div",{
  1410. "styles" : this.css.sectionFormContent
  1411. }).inject(this.formTableArea);
  1412. MWF.getJSON(jsonPath, function(json){
  1413. json.icons.each(function(iconName, i){
  1414. var iconAreaNode = new Element("div",{
  1415. "styles" : this.css.iconAreaNode
  1416. }).inject(div);
  1417. var iconNode = new Element("img",{
  1418. "styles" : this.css.iconSelectNode,
  1419. "src" : iconPath + iconName
  1420. }).inject(iconAreaNode);
  1421. iconAreaNode.store( "iconName", iconName );
  1422. iconAreaNode.store( "iconPath", iconPath + iconName );
  1423. iconAreaNode.addEvents({
  1424. "mouseover" : function(){
  1425. this.node.setStyles( this.obj.css.iconAreaNodeOver )
  1426. }.bind({ obj : this, node : iconAreaNode }),
  1427. "mouseout" : function(){
  1428. this.node.setStyles( this.obj.css.iconAreaNode )
  1429. }.bind({ obj : this, node : iconAreaNode }),
  1430. "click" : function(){
  1431. var icon = {
  1432. "path": this.node.retrieve("iconPath"),
  1433. "name": this.node.retrieve("iconName")
  1434. }
  1435. this.obj.fireEvent("postOk", icon );
  1436. this.obj.close();
  1437. }.bind({ obj : this, node : iconAreaNode })
  1438. })
  1439. }.bind(this));
  1440. }.bind(this));
  1441. }
  1442. });
  1443. MWF.xApplication.Forum.Setting.SystemSettingExplorer = new Class({
  1444. Extends: MWF.widget.Common,
  1445. Implements: [Options, Events],
  1446. options: {
  1447. "style": "default"
  1448. },
  1449. initialize: function (container, app, parent, options) {
  1450. this.container = container;
  1451. this.parent = parent;
  1452. this.app = app;
  1453. this.css = this.parent.css;
  1454. this.lp = this.app.lp;
  1455. },
  1456. load: function () {
  1457. this.container.empty();
  1458. this.loadView();
  1459. },
  1460. destroy : function(){
  1461. if(this.resizeWindowFun)this.app.removeEvent("resize",this.resizeWindowFun)
  1462. this.view.destroy();
  1463. },
  1464. loadView : function(){
  1465. this.viewContainer = Element("div",{
  1466. "styles" : this.css.viewContainer
  1467. }).inject(this.container);
  1468. this.resizeWindow();
  1469. this.resizeWindowFun = this.resizeWindow.bind(this)
  1470. this.app.addEvent("resize", this.resizeWindowFun );
  1471. this.view = new MWF.xApplication.Forum.Setting.SystemSettingView( this.viewContainer, this.app, this, {
  1472. templateUrl : this.parent.path+"listItemSystem.json",
  1473. scrollEnable : true
  1474. } )
  1475. this.view.load();
  1476. },
  1477. resizeWindow: function(){
  1478. var size = this.container.getSize();
  1479. this.viewContainer.setStyles({"height":(size.y)+"px"});
  1480. }
  1481. })
  1482. MWF.xApplication.Forum.Setting.SystemSettingView = new Class({
  1483. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  1484. _createDocument: function(data){
  1485. return new MWF.xApplication.Forum.Setting.SystemSettingDocument(this.viewNode, data, this.explorer, this);
  1486. },
  1487. _getCurrentPageData: function(callback, count){
  1488. if (!count)count = 20;
  1489. //var id = (this.items.length) ? this.items[this.items.length - 1].data.id : "(0)";
  1490. //var filter = this.filterData || {};
  1491. this.actions.listSystemSettingAll(function (json) {
  1492. if (callback)callback(json);
  1493. }.bind(this))
  1494. },
  1495. _removeDocument: function(documentData, all){
  1496. },
  1497. _openDocument: function( documentData ){
  1498. var form = new MWF.xApplication.Forum.Setting.SystemSettingForm(this, documentData, {
  1499. onPostOk : function(){
  1500. this.reload();
  1501. }.bind(this)
  1502. })
  1503. if( MWF.AC.isAdministrator() ){
  1504. form.edit();
  1505. }else{
  1506. form.open();
  1507. }
  1508. }
  1509. })
  1510. MWF.xApplication.Forum.Setting.SystemSettingDocument = new Class({
  1511. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  1512. _queryCreateDocumentNode:function( itemData ){
  1513. },
  1514. _postCreateDocumentNode: function( itemNode, itemData ){
  1515. }
  1516. })
  1517. MWF.xApplication.Forum.Setting.SystemSettingForm = new Class({
  1518. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  1519. Implements: [Options, Events],
  1520. options: {
  1521. "style": "default",
  1522. "width": "600",
  1523. "height": "320",
  1524. "hasTop": true,
  1525. "hasIcon": false,
  1526. "hasTopIcon" : true,
  1527. "hasTopContent" : true,
  1528. "hasBottom": true,
  1529. "title": MWF.xApplication.Forum.LP.systemSettingFormTitle,
  1530. "draggable": true,
  1531. "closeAction": true
  1532. },
  1533. _createTableContent: function () {
  1534. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1535. "<tr><td styles='formTableTitle' lable='configName' width='20%'></td>" +
  1536. " <td styles='formTableValue' item='configName' width='80%'></td></tr>" +
  1537. "<tr><td styles='formTableTitle' lable='configValue'></td>" +
  1538. " <td styles='formTableValue' item='configValue'></td></tr>" +
  1539. "<tr><td styles='formTableTitle' lable='orderNumber'></td>" +
  1540. " <td styles='formTableValue' item='orderNumber'></td></tr>" +
  1541. "<tr><td styles='formTableTitle' lable='description'></td>" +
  1542. " <td styles='formTableValue' item='description'></td></tr>" +
  1543. "</table>"
  1544. this.formTableArea.set("html", html);
  1545. var configValueSetting = {text: this.lp.configValue };
  1546. configValueSetting.tType = "text";
  1547. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1548. this.form = new MForm(this.formTableArea, this.data, {
  1549. style: "execution",
  1550. isEdited: this.isEdited || this.isNew,
  1551. itemTemplate: {
  1552. configName: {text: this.lp.configName, type : "innerText" },
  1553. configValue : configValueSetting,
  1554. orderNumber: {text: this.lp.orderNumber, type : "innerText" },
  1555. description: {text: this.lp.description, type : "innerText" }
  1556. }
  1557. }, this.app);
  1558. this.form.load();
  1559. }.bind(this), true);
  1560. },
  1561. _ok: function (data, callback) {
  1562. this.app.restActions.saveSystemSetting( data, function(json){
  1563. if( callback )callback(json);
  1564. this.fireEvent("postOk")
  1565. }.bind(this));
  1566. }
  1567. });
  1568. MWF.xApplication.Forum.Setting.SelectOrgForm = new Class({
  1569. Extends: MWF.xApplication.Template.Explorer.PopupForm,
  1570. Implements: [Options, Events],
  1571. options: {
  1572. "style": "default",
  1573. "width": "900",
  1574. "height": "230",
  1575. "hasTop": true,
  1576. "hasIcon": false,
  1577. "hasTopIcon" : true,
  1578. "hasTopContent" : true,
  1579. "hasBottom": true,
  1580. "title": MWF.xApplication.Forum.LP.SelectOrgForm,
  1581. "draggable": true,
  1582. "closeAction": true
  1583. },
  1584. _createTableContent: function () {
  1585. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1586. "<tr><td styles='formTableTitle' lable='person' width='15%'></td>" +
  1587. " <td styles='formTableValue' item='person' colspan='3' width='85%'></td></tr>" +
  1588. "<tr><td styles='formTableTitle' lable='department'></td>" +
  1589. " <td styles='formTableValue' item='department' colspan='3'></td></tr>" +
  1590. "<tr><td styles='formTableTitle' lable='company'></td>" +
  1591. " <td styles='formTableValue' item='company' colspan='3'></td></tr>" +
  1592. "</table>"
  1593. this.formTableArea.set("html", html);
  1594. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1595. this.form = new MForm(this.formTableArea, this.data, {
  1596. style: "forum",
  1597. isEdited: this.isEdited || this.isNew,
  1598. itemTemplate: {
  1599. person: {text: this.lp.selectPerson, tType: "person", count: 0},
  1600. department: {text: this.lp.selectDepartment, tType: "department", count: 0},
  1601. company: {text: this.lp.selectCompany, tType: "company", count: 0}
  1602. }
  1603. }, this.app);
  1604. this.form.load();
  1605. }.bind(this), false);
  1606. },
  1607. _ok: function (data, callback) {
  1608. var orgArray = [];
  1609. data.person.split(",").each( function( p ){
  1610. orgArray.push( p+"#人员" )
  1611. })
  1612. data.department.split(",").each( function( p ){
  1613. orgArray.push( p+"#组织" )
  1614. })
  1615. data.company.split(",").each( function( p ){
  1616. orgArray.push( p+"#组织" )
  1617. })
  1618. this.app.restActions.saveRole( data, function(json){
  1619. this.app.restActions.getRole( data.id, function( j ){
  1620. var roleData = {
  1621. bindObjectArray : orgArray,
  1622. bindRoleCode : j.roleCode
  1623. };
  1624. this.app.restActions.bindRole( roleData, function( rData ){
  1625. if( callback )callback(json);
  1626. this.fireEvent("postOk")
  1627. }.bind(this))
  1628. })
  1629. }.bind(this));
  1630. }
  1631. });