Main.js 78 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308
  1. MWF.xApplication.Forum = MWF.xApplication.Forum || {};
  2. MWF.xApplication.ForumDocument = MWF.xApplication.ForumDocument || {};
  3. MWF.require("MWF.widget.O2Identity", null,false);
  4. //MWF.xDesktop.requireApp("Forum", "Actions.RestActions", null, false);
  5. MWF.xDesktop.requireApp("Forum", "Common", null, false);
  6. MWF.xDesktop.requireApp("Forum", "Attachment", null, false);
  7. MWF.xDesktop.requireApp("Forum", "lp."+MWF.language, null, false);
  8. MWF.xDesktop.requireApp("Forum", "Access", null, false);
  9. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  10. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  11. MWF.xDesktop.requireApp("Forum", "TopNode", null, false);
  12. MWF.xApplication.ForumDocument.options = {
  13. multitask: true,
  14. executable: true
  15. };
  16. MWF.xApplication.ForumDocument.Main = new Class({
  17. Extends: MWF.xApplication.Common.Main,
  18. Implements: [Options, Events],
  19. options: {
  20. "style": "default",
  21. "name": "ForumDocument",
  22. "icon": "icon.png",
  23. "width": "1324",
  24. "height": "720",
  25. "isResize": true,
  26. "isMax": true,
  27. "isNew" : false,
  28. "isEdited" : true,
  29. "index" : 1,
  30. "replyIndex" : null,
  31. "viewPageNum" : 1,
  32. "title": MWF.xApplication.ForumDocument.LP.title
  33. },
  34. onQueryLoad: function(){
  35. this.lp = MWF.xApplication.Forum.LP;
  36. },
  37. onQueryClose: function(){
  38. if( this.userCache ){
  39. for( var key in this.userCache ){
  40. delete this.userCache[key];
  41. }
  42. }
  43. this.userCache;
  44. },
  45. loadApplication: function(callback){
  46. this.userData = layout.desktop.session.user;
  47. this.userName = this.userData.distinguishedName;
  48. this.restActions = this.actions = MWF.Actions.get("x_bbs_assemble_control"); //new MWF.xApplication.Forum.Actions.RestActions();
  49. this.path = "/x_component_ForumDocument/$Main/"+this.options.style+"/";
  50. if( this.status ){
  51. this.setOptions( this.status )
  52. }
  53. if( this.options.isNew && !this.options.id ){
  54. if( this.options.advanceId ){
  55. this.advanceId = this.options.advanceId;
  56. this.createNode();
  57. this.loadApplicationContent();
  58. }else{
  59. this.actions.getUUID( function( id ){
  60. this.advanceId = id;
  61. this.createNode();
  62. this.loadApplicationContent();
  63. }.bind(this))
  64. }
  65. }else{
  66. this.createNode();
  67. this.loadApplicationContent();
  68. }
  69. },
  70. loadController: function(callback){
  71. this.access = new MWF.xApplication.Forum.Access( this.restActions, this.lp );
  72. if(callback)callback();
  73. },
  74. createNode: function(){
  75. this.content.setStyle("overflow", "hidden");
  76. this.node = new Element("div", {
  77. "styles": this.css.node
  78. }).inject(this.content);
  79. },
  80. loadApplicationContent: function(){
  81. this.loadController(function(){
  82. this.access.login( function(){
  83. this.loadApplicationLayout();
  84. }.bind(this) )
  85. }.bind(this))
  86. },
  87. clearContent : function(){
  88. this.node.empty();
  89. this.pagingBarTop = null;
  90. this.pagingContainerTop = null;
  91. delete this.pagingBarTop;
  92. delete this.pagingContainerTop;
  93. },
  94. reload : function(oldid, appid){
  95. this.node.empty();
  96. this.pagingBarTop = null;
  97. this.pagingContainerTop = null;
  98. delete this.pagingBarTop;
  99. delete this.pagingContainerTop;
  100. this.loadApplicationLayout();
  101. //if( this.appCurrentList.indexOf( this > 0 ){
  102. // this.appCurrentList.erase(this);
  103. // this.appCurrentList.push(this)
  104. //}
  105. if( oldid && appid && (oldid != appid) ){
  106. delete this.desktop.apps[oldid];
  107. this.appId = appid;
  108. this.desktop.apps[appid] = this;
  109. }
  110. },
  111. loadApplicationLayout : function(){
  112. this.contentContainerNode = new Element("div.contentContainerNode", {
  113. "styles": this.css.contentContainerNode
  114. }).inject(this.node);
  115. if( this.options.id ){
  116. this.restActions.listSubjectPermission( this.options.id, function( permission ){
  117. this.permission = permission.data;
  118. if( this.options.isEdited ){
  119. this.restActions.getSubject( this.options.id , function( data ){
  120. this.data = data.data;
  121. this._loadApplicationLayout( this.data.sectionId , this.data.title );
  122. }.bind(this))
  123. }else{
  124. this.restActions.getSubjectView( this.options.id , function( data ){
  125. this.data = data.data.currentSubject;
  126. this.nextSubject = data.data.nextSubject;
  127. this.lastSubject = data.data.lastSubject;
  128. this._loadApplicationLayout( this.data.sectionId , this.data.title );
  129. }.bind(this))
  130. }
  131. }.bind(this) )
  132. }else{
  133. this._loadApplicationLayout( this.options.sectionId, this.lp.createSubject );
  134. }
  135. },
  136. _loadApplicationLayout : function( sectionId, title ){
  137. this.options.sectionId = sectionId;
  138. this.restActions.listSectionPermission( sectionId, function( permission ){
  139. this.sectionPermission = permission.data;
  140. this.restActions.getSection( sectionId, function( json ) {
  141. this.sectionData = json.data;
  142. //this.access.hasSectionAdminAuthority( this.sectionData , function( flag ){
  143. // this.isAdmin = flag;
  144. this.restActions.getCategory(this.sectionData.forumId, function (forumData) {
  145. this.forumData = forumData.data;
  146. this.createTopNode( title );
  147. var tail = this.inBrowser ? (MWFForum.getSystemConfigValue( MWFForum.BBS_TITLE_TAIL ) || "") : "";
  148. this.setTitle( title + tail );
  149. this.createMiddleNode();
  150. }.bind(this));
  151. //}.bind(this) );
  152. }.bind(this))
  153. }.bind(this) )
  154. },
  155. createTopNode: function( title ){
  156. var node = new MWF.xApplication.Forum.TopNode(this.contentContainerNode, this, this, {
  157. type: this.options.style
  158. });
  159. this.topNode = node;
  160. node.load();
  161. //var forumSetting = MWF.xApplication.Forum.ForumSetting[this.sectionData.forumId];
  162. //var forumColor = forumSetting ? forumSetting.forumColor : "";
  163. var topNode = this.topNode = new Element("div.topNode", {
  164. "styles": this.css.topNode
  165. }).inject(this.contentContainerNode);
  166. var topTitleMiddleNode = new Element("div.topTitleMiddleNode", {
  167. "styles": this.css.topTitleMiddleNode
  168. }).inject(topNode);
  169. var topItemTitleNode = new Element("div.topItemTitleNode", {
  170. "styles": this.css.topItemTitleNode,
  171. "text": MWFForum.getBBSName() || MWF.xApplication.Forum.LP.title
  172. }).inject(topTitleMiddleNode);
  173. topItemTitleNode.addEvent("click", function(){
  174. var appId = "Forum";
  175. if (this.desktop.apps[appId]){
  176. this.desktop.apps[appId].setCurrent();
  177. }else {
  178. this.desktop.openApplication(null, "Forum", { "appId": appId });
  179. }
  180. if( !this.inBrowser ){
  181. this.close();
  182. }
  183. }.bind(this));
  184. var topItemSepNode = new Element("div.topItemSepNode", {
  185. "styles": this.css.topItemSepNode,
  186. "text" : ">"
  187. }).inject(topTitleMiddleNode);
  188. var topItemTitleNode = new Element("div.topItemTitleNode", {
  189. "styles": this.css.topItemTitleNode,
  190. "text": this.sectionData.forumName
  191. }).inject(topTitleMiddleNode);
  192. topItemTitleNode.addEvent("click", function(){
  193. var appId = "ForumCategory"+this.forumId;
  194. if (this.obj.desktop.apps[appId]){
  195. this.obj.desktop.apps[appId].setCurrent();
  196. }else {
  197. this.obj.desktop.openApplication(null, "ForumCategory", { "categoryId" : this.forumId ,"appId": appId });
  198. }
  199. if( !this.obj.inBrowser ){
  200. this.obj.close();
  201. }
  202. //this.obj.close();
  203. }.bind({ obj: this, forumId : this.sectionData.forumId }));
  204. var topItemSepNode = new Element("div.topItemSepNode", {
  205. "styles": this.css.topItemSepNode,
  206. "text" : ">"
  207. }).inject(topTitleMiddleNode);
  208. var topItemTitleNode = new Element("div.topItemTitleNode", {
  209. "styles": this.css.topItemTitleNode,
  210. "text": this.sectionData.sectionName
  211. }).inject(topTitleMiddleNode);
  212. topItemTitleNode.addEvent("click", function(){
  213. var appId = "ForumSection"+this.sectionData.id;
  214. if (this.desktop.apps[appId]){
  215. this.desktop.apps[appId].setCurrent();
  216. }else {
  217. this.desktop.openApplication(null, "ForumSection", {
  218. "sectionId" : this.sectionData.id,
  219. "appId": appId
  220. });
  221. }
  222. if( !this.inBrowser ){
  223. this.close();
  224. }
  225. //this.close();
  226. }.bind(this));
  227. var topItemSepNode = new Element("div.topItemSepNode", {
  228. "styles": this.css.topItemSepNode,
  229. "text" : ">"
  230. }).inject(topTitleMiddleNode);
  231. var topItemTitleNode = new Element("div.topItemTitleNode", {
  232. "styles": this.css.topItemTitleLastNode,
  233. "text": this.options.isNew ? (this.lp.createSubject) : ("["+ this.data.type +"]" + this.data.title )
  234. }).inject(topTitleMiddleNode);
  235. //this.topRightTextNode = new Element("div", {
  236. // "styles": this.css.topRightTextNode,
  237. // "text": this.lp.setting
  238. //}).inject(this.topRightTextNode)
  239. },
  240. createMiddleNode: function(){
  241. this.middleNode = new Element("div.middleNode", {
  242. "styles": this.css.middleNode
  243. }).inject(this.contentContainerNode);
  244. this.addEvent("resize", function () {
  245. this.setContentSize();
  246. }.bind(this));
  247. this.setContentSize();
  248. this.middleNode.addEvent("selectstart", function(e){
  249. e.stopPropagation();
  250. });
  251. //MWF.require("MWF.widget.ScrollBar", function () {
  252. // this.scrollBar = new MWF.widget.ScrollBar(this.contentContainerNode, {
  253. // "indent": false,
  254. // "style": "xApp_TaskList",
  255. // "where": "before",
  256. // "distance": 30,
  257. // "friction": 4,
  258. // "axis": {"x": false, "y": true},
  259. // "onScroll": function (y) {
  260. // }
  261. // });
  262. //}.bind(this));
  263. if( this.options.isNew || this.options.isEdited ){
  264. this._createMiddleNode_eidt();
  265. }else{
  266. this._createMiddleNode_read();
  267. }
  268. },
  269. _createMiddleNode_eidt : function(){
  270. this.data = this.data || {};
  271. var _self = this;
  272. this.contentDiv = new Element("div.contentDiv",{"styles":this.css.contentDiv}).inject(this.middleNode);
  273. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  274. "<tr>" +
  275. " <td styles='formTableTitle' lable='title' width='10%' style='min-width:100px;'></td>" +
  276. " <td styles='formTableValue' item='typeCategory' width='10%'></td>" +
  277. " <td styles='formTableValue' item='type' width='10%'></td>" +
  278. " <td styles='formTableValue' item='title' width='70%'></td>" +
  279. "</tr><tr>" +
  280. " <td></td>" +
  281. " <td item='tipNode' colspan='3'></td>" +
  282. "</tr><tr>" +
  283. " <td styles='formTableTitle' lable='summary'></td>" +
  284. " <td styles='formTableValue' item='summary' colspan='3'></td>" +
  285. "</tr><tr item='portalImageTr' style='display:none'>" +
  286. " <td styles='formTableTitle' lable='picId'></td>" +
  287. " <td styles='formTableValue' colspan='3'><div item='picId' styles='portalImageAre' ></div></td>" +
  288. "</tr><tr>" +
  289. " <td styles='formTableTitle' lable='content'></td>" +
  290. " <td styles='formTableValue' item='content' colspan='3'></td>" +
  291. "</tr><tr>" +
  292. " <td styles='formTableTitle'>"+ this.lp.attachment +"</td>" +
  293. " <td item='attachment' colspan='3'></td>" +
  294. "</tr><tr style='display:none' item='voteArea'>" +
  295. " <td styles='formTableTitle'>"+ this.lp.vote +"</td>" +
  296. " <td item='voteContainer' colspan='3'></td>" +
  297. "</tr><tr>" +
  298. " <td styles='formTableTitle' lable=''></td>" +
  299. " <td item='action' colspan='3'></td>" +
  300. "</tr>"+
  301. "</table>";
  302. this.contentDiv.set("html", html);
  303. var tipNode = this.contentDiv.getElement("[item='tipNode']");
  304. var typeSettings = this._loadTypeSetting();
  305. var typeSetting = typeSettings[ this.forumData.indexListStyle ];
  306. if( typeSetting.image ){
  307. this.contentDiv.getElements("[item='portalImageTr']")[0].setStyle("display","");
  308. }
  309. var subjectTypeSelectValue;
  310. if( this.sectionData.subjectType ){
  311. subjectTypeSelectValue = this.sectionData.subjectType.split("|");
  312. }else if( this.forumData.subjectType ){
  313. subjectTypeSelectValue = this.forumData.subjectType.split("|");
  314. }else{
  315. subjectTypeSelectValue = this.lp.subjectTypeDefaultValue.split("|");
  316. }
  317. var typeCategorySelectValue;
  318. if( this.sectionData.typeCategory ){
  319. typeCategorySelectValue = this.sectionData.typeCategory.split("|");
  320. }else if( this.forumData.typeCategory ){
  321. typeCategorySelectValue = this.forumData.typeCategory.split("|");
  322. }else{
  323. typeCategorySelectValue = this.lp.typeCategoryDefaultValue.split("|");
  324. }
  325. MWF.xDesktop.requireApp("Template", "MForm", function () {
  326. this.form = new MForm(this.contentDiv, this.data , {
  327. style: "forum",
  328. verifyType: "batch",
  329. isEdited: true,
  330. itemTemplate: {
  331. title: {text: this.lp.subject, notEmpty : true,
  332. onPostLoad : function(item) {
  333. item.tipNode = tipNode;
  334. }
  335. },
  336. typeCategory :{ type : "select", selectValue : typeCategorySelectValue , notEmpty : true, event : {
  337. change : function(item, ev){
  338. if( item.getValue() == this.lp.vote ){
  339. this.contentDiv.getElements( "[item='voteArea']").setStyle("display","");
  340. this.loadVoteArea();
  341. }else{
  342. this.contentDiv.getElements( "[item='voteArea']").setStyle("display","none");
  343. }
  344. }.bind(this)}
  345. },
  346. type: {text: this.lp.type, type : "select", selectValue : subjectTypeSelectValue , notEmpty : true },
  347. summary: {text: this.lp.summary, type : "text", event : { "keyup" : function( item, ev){
  348. if( item.getValue().length > 70 ){
  349. item.setValue( item.getValue().substr( 0, 70 ) );
  350. }
  351. } } },
  352. picId: { text: this.lp.portalImage, type : "imageClipper",
  353. disable : !typeSetting.image,
  354. style : {
  355. imageStyle : this.css.portalImageNode,
  356. actionStyle : this.css.uploadActionNode
  357. },
  358. aspectRatio : 1.5,
  359. reference : this.advanceId || this.data.id,
  360. referenceType: "forumDocument"
  361. },
  362. content: {text: this.lp.content, type : "rtf", notEmpty : true, RTFConfig : {
  363. isSetImageMaxWidth : true,
  364. reference : this.advanceId || this.data.id,
  365. referenceType: "forumDocument"//,
  366. //skin : "bootstrapck" //,
  367. //filebrowserCurrentDocumentImage: function (e, callback) {
  368. // _self.selectDocImage( callback );
  369. //}
  370. }}
  371. }
  372. }, this, this.css);
  373. this.form.load();
  374. }.bind(this), true);
  375. if( this.data.typeCategory == this.lp.vote ){
  376. this.contentDiv.getElement( "[item='voteArea']").setStyle("display","");
  377. this.loadVoteArea();
  378. }
  379. var actionTd = this.contentDiv.getElements("[item='action']")[0];
  380. this.saveAction = new Element("div",{
  381. styles : this.css.actionNode,
  382. text: this.lp.saveSubject
  383. }).inject(actionTd);
  384. this.saveAction.addEvent("click",function(ev){
  385. this.saveSubject( ev );
  386. }.bind(this));
  387. var attachmentArea = this.contentDiv.getElements("[item='attachment']")[0];
  388. this.loadAttachment(attachmentArea)
  389. },
  390. _loadTypeSetting: function(){
  391. var path = "/x_component_Forum/$ColumnTemplate/template/setting.json";
  392. var templateSetting;
  393. MWF.xApplication.Forum.ColumnTemplate = MWF.xApplication.Forum.ColumnTemplate || {};
  394. if (MWF.xApplication.Forum.ColumnTemplate.Setting){
  395. templateSetting = MWF.xApplication.Forum.ColumnTemplate.Setting;
  396. }else{
  397. var r = new Request.JSON({
  398. url: path,
  399. secure: false,
  400. async: false,
  401. method: "get",
  402. noCache: false,
  403. onSuccess: function(responseJSON, responseText){
  404. templateSetting = MWF.xApplication.Forum.ColumnTemplate.Setting = responseJSON;
  405. }.bind(this),
  406. onError: function(text, error){
  407. alert(error + text);
  408. }
  409. });
  410. r.send();
  411. }
  412. return templateSetting;
  413. },
  414. loadVoteArea : function(){
  415. this.voteContainer = this.contentDiv.getElement("[item='voteContainer']");
  416. MWF.xDesktop.requireApp("ForumDocument", "Vote", function(){
  417. this.vote = new MWF.xApplication.ForumDocument.Vote(this.voteContainer, this, {
  418. isNew : this.options.isNew,
  419. isEdited : this.options.isEdited
  420. }, this.data);
  421. this.vote.load();
  422. }.bind(this), true)
  423. },
  424. reloadAllParents : function(){
  425. var aid = "Forum";
  426. if (this.desktop.apps[aid]){
  427. this.desktop.apps[aid].reload();
  428. }
  429. aid = "ForumCategory"+this.sectionData.forumId;
  430. if (this.desktop.apps[aid]){
  431. this.desktop.apps[aid].reload();
  432. }
  433. aid = "ForumSection"+this.sectionData.id;
  434. if (this.desktop.apps[aid]){
  435. this.desktop.apps[aid].reload();
  436. }
  437. },
  438. saveSubject : function(ev){
  439. var _self = this;
  440. var data = this.form.getResult(true, ",", true, false, true);
  441. if( !data ){ //校验没通过
  442. // 校验投票
  443. var typeCategory = this.form.getItem("typeCategory");
  444. if( typeCategory.getValue() == this.lp.vote ){
  445. this.vote.getVoteInfor()
  446. }
  447. return;
  448. }
  449. if( data.typeCategory == this.lp.vote ){
  450. var voteData = this.vote.getVoteInfor();
  451. if( !voteData )return;
  452. for( var key in voteData ){
  453. data[key] = voteData[key];
  454. }
  455. this.confirm("warn", ev, this.lp.confirmPublishVoteDocumentTitle, this.lp.confirmPublishVoteDocumentContent, 350, 120, function(){
  456. _self._saveSubject( data );
  457. this.close();
  458. }, function(){
  459. this.close();
  460. });
  461. }else{
  462. this._saveSubject( data );
  463. }
  464. },
  465. _saveSubject : function( data ){
  466. if( this.advanceId )data.id = this.advanceId;
  467. data.attachmentList = this.attachment.getAttachmentIds();
  468. if (data) {
  469. data.sectionId = this.sectionData.id;
  470. //data.picId = this.picId || "";
  471. this.restActions.saveSubject(data, function (json) {
  472. this.notice(this.options.isNew ? this.lp.createSuccess : this.lp.updateSuccess, "success");
  473. this.fireEvent("postPublish");
  474. this.reloadAllParents();
  475. var oldId = "ForumDocument"+ ( this.options.isNew ? this.sectionData.id : this.data.id );
  476. var appId = "ForumDocument"+json.data.id;
  477. this.advanceId = "";
  478. this.setOptions({
  479. "id" : json.data.id,
  480. "appId": appId,
  481. "isEdited" : false,
  482. "isNew" : false //,
  483. //"index" : nextIndex
  484. });
  485. this.reload(oldId , appId );
  486. }.bind(this))
  487. }
  488. },
  489. _createMiddleNode_read: function(){
  490. this.isReplyPublisher = this.permission.replyPublishAble; //this.access.isReplyPublisher( this.sectionData );
  491. this.createSidebar();
  492. this.createPagingBar();
  493. this.createToolbar_read();
  494. var contentConainer = new Element("div.subjectConainer",{
  495. "styles" : this.css.contentConainer
  496. }).inject( this.middleNode );
  497. this.subjectConainer = new Element("div.subjectConainer",{
  498. "styles" : this.css.subjectConainer
  499. }).inject( contentConainer );
  500. if( this.data.typeCategory == this.lp.question ){
  501. this.satisfiedReplyViewConainer = new Element("div.satisfiedReplyViewConainer",{
  502. "styles" : this.css.replyViewConainer
  503. }).inject( contentConainer );
  504. }
  505. this.replyViewConainer = new Element("div.replyViewConainer",{
  506. "styles" : this.css.replyViewConainer
  507. }).inject( contentConainer );
  508. this.createPagingBar();
  509. this.createSubject();
  510. if( this.data.typeCategory == this.lp.question ) {
  511. if( this.data.acceptReplyId ){
  512. this.createSatisfiedReplyView();
  513. }
  514. }
  515. this.createReplyView();
  516. if( !this.data.stopReply && this.isReplyPublisher ){
  517. if( this.access.isAnonymous() ){
  518. this.createReplyEditor_Anonymous()
  519. }else{
  520. this.createReplyEditor();
  521. }
  522. }
  523. //this.createTurnSubjectNode();
  524. },
  525. createPagingBar: function(){
  526. var pagingArea = new Element("div",{
  527. styles : this.css.pagingArea
  528. }).inject(this.middleNode);
  529. if( this.pagingBarTop ){
  530. this.pagingBarBottom = pagingArea;
  531. }else{
  532. this.pagingBarTop = pagingArea;
  533. }
  534. //if( this.access.isSubjectPublisher( this.sectionData ) ){
  535. if( this.sectionPermission.subjectPublishAble ){
  536. var createActionNode = new Element("div",{
  537. styles : this.css.pagingActionNode,
  538. text: this.lp.createSubject
  539. }).inject(pagingArea);
  540. createActionNode.addEvents(
  541. {
  542. "mouseover": function () {
  543. this.node.setStyles(this.obj.css.pagingActionNode_over);
  544. }.bind({obj: this, node: createActionNode}),
  545. "mouseout": function () {
  546. this.node.setStyles(this.obj.css.pagingActionNode);
  547. }.bind({obj: this, node: createActionNode}),
  548. "click": function () {
  549. if( this.access.isAnonymousDynamic() ){
  550. this.openLoginForm(
  551. function(){ this.createNewDocument(); }.bind(this)
  552. );
  553. }else{
  554. this.createNewDocument();
  555. }
  556. }.bind(this)
  557. }
  558. )
  559. }
  560. //var fileterNode = new Element("div",{
  561. // styles : this.css.fileterNode
  562. //}).inject(pagingArea);
  563. var pagingContainer = new Element("div").inject(pagingArea);
  564. if( this.pagingContainerTop ){
  565. this.pagingContainerBottom = pagingContainer;
  566. }else{
  567. this.pagingContainerTop = pagingContainer;
  568. }
  569. },
  570. setContentSize: function () {
  571. //var topSize = this.topNode ? this.topNode.getSize() : {"x": 0, "y": 0};
  572. var topSize = {"x": 0, "y": 0};
  573. var nodeSize = this.node.getSize();
  574. var pt = this.contentContainerNode.getStyle("padding-top").toFloat();
  575. var pb = this.contentContainerNode.getStyle("padding-bottom").toFloat();
  576. var height = nodeSize.y - topSize.y - pt - pb;
  577. this.contentContainerNode.setStyle("height", "" + height + "px");
  578. },
  579. recordStatus: function(){
  580. return {
  581. "sectionId" : this.options.sectionId,
  582. "id" : this.data ? this.data.id : "",
  583. "advanceId" : this.advanceId,
  584. "appId": ( this.data && this.data.id ) ? "ForumDocument"+this.data.id : "ForumDocument"+this.advanceId,
  585. "isEdited" : this.options.isEdited,
  586. "isNew" : this.options.isNew,
  587. "viewPageNum" : this.replyView ? this.replyView.getCurrentPageNum() : 1
  588. };
  589. },
  590. loadAttachment: function( area ){
  591. this.attachment = new MWF.xApplication.Forum.Attachment( area, this, this.restActions, this.lp, {
  592. documentId : this.advanceId || this.data.id,
  593. isNew : this.options.isNew,
  594. isEdited : this.options.isEdited,
  595. "size" : "min",
  596. onQueryUploadAttachment : function(){
  597. this.attachment.isQueryUploadSuccess = true;
  598. }.bind(this),
  599. onDelete : function( data ){
  600. //if( this.pictureData && this.pictureData.id == data.id ){
  601. // this.iconNode.set( "src", "" );
  602. // this.iconNode.setStyle("display","none");
  603. // this.pictureBase64 = "";
  604. // this.pictureData = null;
  605. //}
  606. }.bind(this)
  607. });
  608. this.attachment.load();
  609. },
  610. createToolbar_read : function(){
  611. this.toolBarReadTop = new Element("div.toolBarReadTop",{
  612. "styles" : this.css.toolBarReadTop
  613. }).inject( this.middleNode );
  614. this.toolBarRead = new Element("div.toolBarRead",{
  615. "styles" : this.css.toolBarRead
  616. }).inject( this.middleNode );
  617. this.toolbarLeft = new Element("div.toolbarLeft",{
  618. "styles" : this.css.toolbarLeft
  619. }).inject( this.toolBarRead );
  620. var toolbarLeftItem = new Element("div.toolbarViewItem",{
  621. "styles" : this.css.toolbarViewItem
  622. }).inject( this.toolbarLeft );
  623. new Element("span.toolbarLeftTextItem",{
  624. "styles" : this.css.toolbarLeftTextItem,
  625. "text" : this.lp.readed + ":"
  626. }).inject( toolbarLeftItem );
  627. new Element("span.toolbarLeftCountItem",{
  628. "styles" : this.css.toolbarLeftCountItem,
  629. "text" : this.data.viewTotal
  630. }).inject( toolbarLeftItem );
  631. new Element("div.toolbarSepItem",{
  632. "styles" : this.css.toolbarSepItem
  633. }).inject( this.toolbarLeft );
  634. var toolbarLeftItem = new Element("div.toolbarReplyItem",{
  635. "styles" : this.css.toolbarReplyItem
  636. }).inject( this.toolbarLeft );
  637. new Element("span.toolbarLeftTextItem",{
  638. "styles" : this.css.toolbarLeftTextItem,
  639. "text" : this.lp.reply + ":"
  640. }).inject( toolbarLeftItem );
  641. this.replyTotal = new Element("span.toolbarLeftCountItem",{
  642. "styles" : this.css.toolbarLeftCountItem,
  643. "text" : this.data.replyTotal
  644. }).inject( toolbarLeftItem );
  645. this.toolbarRight = new Element("div.toolbarRight",{
  646. "styles" : this.css.toolbarRight
  647. }).inject( this.toolBarRead );
  648. //this.createActionBar();
  649. if(this.data.isTopSubject){
  650. new Element( "div.top", {
  651. "styles" : this.css.toolbarZhiding,
  652. "title" : this.lp.setTop
  653. }).inject( this.toolbarRight );
  654. }else if( this.data.isCreamSubject ){
  655. new Element( "div.prime", {
  656. "styles" : this.css.toolbarPrime,
  657. "title" : (this.data.screamSetterName || "").split("@")[0]+ this.lp.at + this.data.screamSetterTime + this.lp.setPrime
  658. }).inject( this.toolbarRight );
  659. }else if( this.data.typeCategory == this.lp.vote ){
  660. new Element( "div.vote", { "styles" : this.css.toolbarVote, "title" : this.lp.vote }).inject( this.toolbarRight );
  661. }else if( this.data.typeCategory == this.lp.question ){
  662. new Element( "div.question", { "styles" : this.css.toolbarQuestion, "title" : this.lp.question }).inject( this.toolbarRight );
  663. }
  664. this.toolbarRightTitle = new Element("div.toolbarRightTitle",{
  665. "styles" : this.css.toolbarRightTitle,
  666. "text" : "["+ this.data.type +"]"+this.data.title
  667. }).inject( this.toolbarRight );
  668. this.toolbarRightTools = new Element("div.toolbarRightTools",{
  669. "styles" : this.css.toolbarRightTools
  670. }).inject( this.toolbarRight );
  671. if( this.nextSubject ){
  672. this.toolbarNext = new Element("div.toolbarNext",{
  673. "styles" : this.css.toolbarNext,
  674. "title" : this.lp.nextSubject + ":" + this.nextSubject.title
  675. }).inject( this.toolbarRightTools );
  676. this.toolbarNext.addEvents({
  677. "click" : function(){ this.gotoDocument( 1 ); }.bind(this),
  678. "mouseover" : function(){
  679. this.toolbarNext.setStyles( this.css.toolbarNext_over );
  680. }.bind(this),
  681. "mouseout" : function(){
  682. this.toolbarNext.setStyles( this.css.toolbarNext );
  683. }.bind(this)
  684. })
  685. }
  686. if( this.lastSubject ){
  687. this.toolbarPrev = new Element("div.toolbarRightTools",{
  688. "styles" : this.css.toolbarPrev,
  689. "title" : this.lp.prevSubject + ":" + this.lastSubject.title
  690. }).inject( this.toolbarRightTools );
  691. this.toolbarPrev.addEvents({
  692. "click" : function(){ this.gotoDocument( -1 ); }.bind(this),
  693. "mouseover" : function(){
  694. this.toolbarPrev.setStyles( this.css.toolbarPrev_over );
  695. }.bind(this),
  696. "mouseout" : function(){
  697. this.toolbarPrev.setStyles( this.css.toolbarPrev );
  698. }.bind(this)
  699. })
  700. }
  701. },
  702. adjustReplyCount: function( count ){
  703. this.data.replyTotal = this.data.replyTotal + count;
  704. this.replyTotal.set("text", this.data.replyTotal )
  705. },
  706. createNewDocument: function(){
  707. var _self = this;
  708. var appId = "ForumDocument"+this.sectionData.id;
  709. if (_self.desktop.apps[appId]){
  710. _self.desktop.apps[appId].setCurrent();
  711. }else {
  712. this.desktop.openApplication(null, "ForumDocument", {
  713. "sectionId": this.sectionData.id,
  714. "appId": appId,
  715. "isNew" : true,
  716. "isEdited" : true,
  717. "onPostPublish" : function(){
  718. //this.view.reload();
  719. }.bind(this)
  720. });
  721. }
  722. },
  723. edit : function(){
  724. var appId = "ForumDocument"+this.data.id;
  725. this.options.isEdited = true;
  726. this.reload(appId , appId );
  727. },
  728. delete : function( ev ){
  729. var _self = this;
  730. this.confirm("warn", ev, this.lp.deleteDocumentTitle, this.lp.deleteDocument, 350, 120, function(){
  731. _self.restActions.deleteSubject( _self.data.id, function(){
  732. _self.notice( _self.lp.deleteDocumentOK, "ok");
  733. _self.reloadAllParents();
  734. _self.close();
  735. }.bind(this) );
  736. this.close();
  737. }, function(){
  738. this.close();
  739. });
  740. },
  741. postCreateReply : function( id ){
  742. this.restActions.getReply( id, function( json ){
  743. var reply = this.replyView._createDocument( json.data );
  744. this.adjustReplyCount( 1 );
  745. var t = reply.node.getTop() - this.contentContainerNode.getCoordinates().top + this.contentContainerNode.scrollTop.toFloat();
  746. this.contentContainerNode.scrollTo( 0, t );
  747. }.bind(this))
  748. },
  749. createReply : function(){
  750. var form = new MWF.xApplication.ForumDocument.ReplyForm(this, {}, {
  751. "toMain" : true,
  752. onPostOk : function( id ){
  753. this.postCreateReply( id )
  754. }.bind(this)
  755. },{
  756. app : this, lp : this.lp, css : this.css, actions : this.restActions
  757. });
  758. form.mainData = this.data;
  759. form.create()
  760. },
  761. createActionBar : function( container ){
  762. this.actionBar = new Element("div", { "styles" : this.css.actionBar, "html" : "&nbsp;"}).inject(container);
  763. //var action = new Element("div", {
  764. // "styles" : this.css.actionItem,
  765. // "text" : this.lp.createSubject
  766. //}).inject( this.actionBar );
  767. //action.setStyle("background-image" , "url("+this.path+"icon/action_new.png)");
  768. //action.addEvents({
  769. // "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  770. // "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  771. // "click" : function(){ this.createNewDocument() }.bind(this)
  772. //})
  773. if( this.permission.manageAble ){
  774. if( this.data.isCreamSubject ){
  775. action = new Element("div", {
  776. "styles" : this.css.actionItem,
  777. "text" : this.lp.cancelPrime
  778. }).inject( this.actionBar );
  779. action.setStyle("background-image" , "url("+this.path+"icon/action_cancelprime.png)");
  780. action.addEvents({
  781. "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  782. "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  783. "click" : function(){ this.cancelPrime() }.bind(this)
  784. })
  785. }else{
  786. action = new Element("div", {
  787. "styles" : this.css.actionItem,
  788. "text" : this.lp.setPrime
  789. }).inject( this.actionBar );
  790. action.setStyle("background-image" , "url("+this.path+"icon/action_prime.png)");
  791. action.addEvents({
  792. "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  793. "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  794. "click" : function(){ this.setPrime() }.bind(this)
  795. })
  796. }
  797. action = new Element("div", {
  798. "styles" : this.css.actionItem,
  799. "text" : this.lp.moveto
  800. }).inject( this.actionBar );
  801. action.setStyle("background-image" , "url("+this.path+"icon/action_moveto.png)");
  802. action.addEvents({
  803. "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  804. "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  805. "click" : function(){ this.moveTo() }.bind(this)
  806. });
  807. if( this.data.stopReply ){
  808. action = new Element("div", {
  809. "styles" : this.css.actionItem,
  810. "text" : this.lp.unlock
  811. }).inject( this.actionBar );
  812. action.setStyle("background-image" , "url("+this.path+"icon/action_unlock.png)");
  813. action.addEvents({
  814. "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  815. "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  816. "click" : function(){ this.unlock() }.bind(this)
  817. })
  818. }else{
  819. action = new Element("div", {
  820. "styles" : this.css.actionItem,
  821. "text" : this.lp.lock
  822. }).inject( this.actionBar );
  823. action.setStyle("background-image" , "url("+this.path+"icon/action_lock.png)");
  824. action.addEvents({
  825. "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  826. "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  827. "click" : function(){ this.lock() }.bind(this)
  828. })
  829. }
  830. //if( this.data.isTopSubject ){
  831. // action = new Element("div", {
  832. // "styles" : this.css.actionItem,
  833. // "text" : this.lp.cancelTop
  834. // }).inject( this.actionBar );
  835. // action.setStyle("background-image" , "url("+this.path+"icon/action_canceltop.png)");
  836. // action.addEvents({
  837. // "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  838. // "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  839. // "click" : function(){ this.cancelTop() }.bind(this)
  840. // })
  841. //}else{
  842. action = new Element("div", {
  843. "styles" : this.css.actionItem,
  844. "text" : this.lp.setTop
  845. }).inject( this.actionBar );
  846. action.setStyle("background-image" , "url("+this.path+ ( this.data.isTopSubject ? "icon/action_canceltop.png" : "icon/action_top.png")+ ")");
  847. action.addEvents({
  848. "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  849. "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  850. "click" : function(){ this.setTop() }.bind(this)
  851. });
  852. //}
  853. }
  854. if( MWF.AC.isHotPictureManager() ){
  855. action = new Element("div", {
  856. "styles" : this.css.actionItem,
  857. "text" : this.lp.setHot
  858. }).inject( this.actionBar );
  859. action.setStyle("background-image" , "url("+this.path+ "icon/action_popular.png" + ")");
  860. action.addEvents({
  861. "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  862. "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  863. "click" : function(){ this.setHotPicture() }.bind(this)
  864. });
  865. }
  866. //if( this.access.isRecommender( this.sectionData )){
  867. if( this.permission.recommendAble ){
  868. if( this.data.recommendToBBSIndex ){
  869. action = new Element("div", {
  870. "styles" : this.css.actionItem,
  871. "text" : this.lp.cancelRecommend
  872. }).inject( this.actionBar );
  873. action.setStyle("background-image" , "url("+this.path+"icon/action_cancelrecommend.png)");
  874. action.addEvents({
  875. "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  876. "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  877. "click" : function(){ this.cancelRecommend() }.bind(this)
  878. })
  879. }else if( this.sectionData.sectionVisible == this.lp.allPerson && this.sectionData.indexRecommendable == true ){
  880. action = new Element("div", {
  881. "styles" : this.css.actionItem,
  882. "text" : this.lp.setRecommend
  883. }).inject( this.actionBar );
  884. action.setStyle("background-image" , "url("+this.path+"icon/action_recommend.png)");
  885. action.addEvents({
  886. "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  887. "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  888. "click" : function(){ this.setRecommend() }.bind(this)
  889. })
  890. }
  891. }
  892. if( this.permission.manageAble || this.permission.editAble || this.data.creatorName == this.userName ){
  893. action = new Element("div", {
  894. "styles" : this.css.actionItem,
  895. "text" : this.lp.delete
  896. }).inject( this.actionBar );
  897. action.setStyle("background-image" , "url("+this.path+"icon/action_delete.png)");
  898. action.addEvents({
  899. "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  900. "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  901. "click" : function(ev){ this["delete"](ev) }.bind(this)
  902. })
  903. }
  904. if( this.data.typeCategory != this.lp.vote ){
  905. if( this.permission.manageAble || this.permission.editAble || this.data.creatorName == this.userName ){
  906. action = new Element("div", {
  907. "styles" : this.css.actionItem,
  908. "text" : this.lp.edit
  909. }).inject( this.actionBar );
  910. action.setStyle("background-image" , "url("+this.path+"icon/action_edit.png)");
  911. action.addEvents({
  912. "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  913. "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  914. "click" : function(){ this.edit() }.bind(this)
  915. })
  916. }
  917. }
  918. if( !this.data.stopReply ){
  919. if( this.isReplyPublisher ){
  920. action = new Element("div", {
  921. "styles" : this.css.actionItem,
  922. "text" : this.lp.reply
  923. }).inject( this.actionBar );
  924. action.setStyle("background-image" , "url("+this.path+"icon/action_quote.png)");
  925. action.addEvents({
  926. "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.actionItem_over ) }.bind({ obj : this, itemNode : action }),
  927. "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.actionItem ) }.bind({ obj : this, itemNode : action }),
  928. "click" : function(){
  929. if( this.access.isAnonymousDynamic() ){
  930. this.openLoginForm( function(){ this.reload() }.bind(this) );
  931. }else{
  932. this.createReply();
  933. }
  934. }.bind(this)
  935. })
  936. }
  937. }
  938. },
  939. lock : function(){
  940. this.restActions.lock( this.data.id, function(){
  941. this.notice( this.lp.lockSuccess );
  942. this.reload();
  943. }.bind(this))
  944. },
  945. unlock : function(){
  946. this.restActions.unlock( this.data.id, function(){
  947. this.notice( this.lp.unlockSuccess );
  948. this.reload();
  949. }.bind(this))
  950. },
  951. setRecommend : function(){
  952. this.restActions.setRecommend( this.data.id, function(){
  953. this.notice( this.lp.setRecommendSuccess );
  954. this.reload();
  955. }.bind(this))
  956. },
  957. cancelRecommend : function(){
  958. this.restActions.cancelRecommend( this.data.id, function(){
  959. this.notice( this.lp.cancelRecommendSuccess );
  960. this.reload();
  961. }.bind(this))
  962. },
  963. setHotPicture : function(){
  964. MWF.xDesktop.requireApp("ForumDocument", "HotLinkForm", null, false);
  965. var form = new MWF.xApplication.ForumDocument.HotLinkForm(this, this.data, {
  966. documentId : this.data.id,
  967. onPostOk : function( id ){
  968. }.bind(this)
  969. },{
  970. app : this, lp : this.lp, css : this.css, actions : this.restActions
  971. });
  972. form.create()
  973. },
  974. setTop : function(){
  975. var form = new MWF.xApplication.ForumDocument.TopSettingForm(this, this.data, {
  976. onPostOk : function( id ){
  977. this.reload();
  978. }.bind(this)
  979. },{
  980. app : this, lp : this.lp, css : this.css, actions : this.restActions
  981. });
  982. form.create();
  983. //this.restActions.topToSection( this.data.id, function(){
  984. // this.notice( this.lp.setTopSuccess )
  985. // this.reload();
  986. //}.bind(this))
  987. },
  988. cancelTop : function(){
  989. this.restActions.cancelTopToSection( this.data.id, function(){
  990. this.notice( this.lp.cancelTopSuccess );
  991. this.reload();
  992. }.bind(this))
  993. },
  994. setPrime : function(){
  995. this.restActions.setCream( this.data.id, function(){
  996. this.notice( this.lp.setPrimeSuccess );
  997. this.reload();
  998. }.bind(this))
  999. },
  1000. cancelPrime : function(){
  1001. this.restActions.cancelCream( this.data.id, function(){
  1002. this.notice( this.lp.cancelPrimeSuccess );
  1003. this.reload();
  1004. }.bind(this))
  1005. },
  1006. createSubject : function(){
  1007. this.subjectView = new MWF.xApplication.ForumDocument.SubjectView( this.subjectConainer, this, this, {
  1008. templateUrl : this.path + "listItemSubject.json",
  1009. scrollEnable : false
  1010. } );
  1011. this.subjectView.data = this.data;
  1012. this.subjectView.load();
  1013. },
  1014. moveTo : function(){
  1015. MWF.xDesktop.requireApp("Forum", "SectionSelector", null, false);
  1016. var selector = new MWF.xApplication.Forum.SectionSelector(this.content, {
  1017. "count": 1,
  1018. "title": "选择移动到的版块",
  1019. "values": [],
  1020. "onComplete": function( array ){
  1021. if( typeOf( array ) == "array" ){
  1022. var sectionId = array[0].data.id;
  1023. this.restActions.changeSection( {"subjectIds":[ this.data.id ],"sectionId" : sectionId }, function(){
  1024. this.notice( "帖子已经移动到"+array[0].data.name );
  1025. this.reload();
  1026. }.bind(this))
  1027. }
  1028. }.bind(this)
  1029. } );
  1030. selector.load();
  1031. },
  1032. openLoginForm : function( callback ){
  1033. //MWF.xDesktop.requireApp("Forum", "Login", null, false);
  1034. //var login = new MWF.xApplication.Forum.Login(this, {
  1035. // onPostOk : function(){ if(callback)callback() }
  1036. //});
  1037. //login.openLoginForm();
  1038. MWF.require("MWF.xDesktop.Authentication", null, false);
  1039. var authentication = new MWF.xDesktop.Authentication({
  1040. style : "application",
  1041. onPostOk : function(){ if(callback)callback() }
  1042. },this);
  1043. authentication.openLoginForm({
  1044. hasMask : true
  1045. });
  1046. },
  1047. openSignUpForm : function(callback){
  1048. //MWF.xDesktop.requireApp("Forum", "Login", null, false);
  1049. //var login = new MWF.xApplication.Forum.Login(this, {
  1050. // onPostOk : function(){ if(callback)callback() }
  1051. //});
  1052. //login.openSignUpForm();
  1053. MWF.require("MWF.xDesktop.Authentication", null, false);
  1054. var authentication = new MWF.xDesktop.Authentication({
  1055. style : "application",
  1056. onPostOk : function(){ if(callback)callback() }
  1057. },this);
  1058. authentication.openSignUpForm({
  1059. hasMask : true
  1060. });
  1061. },
  1062. gotoReply : function( index ){
  1063. this.replyView.paging.gotoItem( index );
  1064. },
  1065. createSatisfiedReplyView : function( ){
  1066. this.satisfiedReplyView = new MWF.xApplication.ForumDocument.SatisfiedReplyView( this.satisfiedReplyViewConainer, this, this, {
  1067. templateUrl : this.path + "listItemSatisfied.json",
  1068. scrollEnable : false
  1069. } );
  1070. this.satisfiedReplyView.data = this.data;
  1071. this.satisfiedReplyView.load();
  1072. },
  1073. createReplyView : function( ){
  1074. this.replyView = new MWF.xApplication.ForumDocument.ReplyView( this.replyViewConainer, this, this, {
  1075. templateUrl : this.path + "listItemReply.json",
  1076. scrollEnable : false,
  1077. pagingEnable : true,
  1078. documentKeyWord : "orderNumber",
  1079. pagingPar : {
  1080. currentPage : this.options.viewPageNum || 1,
  1081. currentItem : this.options.replyIndex,
  1082. returnText : this.lp.returnToList ,
  1083. countPerPage : 10,
  1084. onPostLoad : function( pagingBar ){
  1085. if(pagingBar.nextPageNode){
  1086. pagingBar.nextPageNode.inject( this.pagingBarBottom, "before" );
  1087. }
  1088. }.bind(this),
  1089. onPageReturn : function( pagingBar ){
  1090. var appId = "ForumSection"+this.sectionData.id;
  1091. if (this.desktop.apps[appId]){
  1092. this.desktop.apps[appId].setCurrent();
  1093. }else {
  1094. this.desktop.openApplication(null, "ForumSection", {
  1095. "sectionId" : this.sectionData.id,
  1096. "appId": appId
  1097. });
  1098. }
  1099. this.close();
  1100. }.bind(this)
  1101. },
  1102. onGotoItem : function( top ){
  1103. var t = top - this.content.getTop();
  1104. this.contentContainerNode.scrollTo( 0, t );
  1105. }.bind(this)
  1106. } );
  1107. this.replyView.pagingContainerTop = this.pagingContainerTop;
  1108. this.replyView.pagingContainerBottom = this.pagingContainerBottom;
  1109. this.replyView.data = this.data;
  1110. this.replyView.filterData = { "subjectId" : this.data.id };
  1111. this.replyView.load();
  1112. },
  1113. createReplyEditor_Anonymous: function(){
  1114. this.replyArea = new Element("div.replyArea",{
  1115. "styles" : this.css.replyArea
  1116. }).inject( this.middleNode );
  1117. new Element("div.replyLeft",{
  1118. "styles" : this.css.replyLeft
  1119. }).inject( this.replyArea );
  1120. var replyPicture = new Element("div.replyPicture",{
  1121. "styles" : this.css.replyPicture
  1122. }).inject( this.replyArea );
  1123. var needloginNode = new Element("div.replyNeedLogin",{
  1124. "styles" : this.css.replyNeedLogin
  1125. }).inject(replyPicture);
  1126. new Element("div.replyNeedLogin",{
  1127. "styles" : this.css.replyNeedLoginText,
  1128. "text" : this.lp.replyNeedLoginText
  1129. }).inject(needloginNode);
  1130. var loginNode = new Element("div.replyLoginAction",{
  1131. "styles" : this.css.replyLoginAction,
  1132. "text" : this.lp.login
  1133. }).inject(needloginNode);
  1134. loginNode.addEvent("click" , function(){
  1135. this.openLoginForm(
  1136. function(){ this.reload() }.bind(this)
  1137. )
  1138. }.bind(this));
  1139. if( this.access.signUpMode != "disable" ){
  1140. new Element("div.replyNeedLogin",{
  1141. "styles" : this.css.replyNeedLoginText,
  1142. "text" : "|"
  1143. }).inject(needloginNode);
  1144. var signupNode = new Element("div.replyLoginAction",{
  1145. "styles" : this.css.replyLoginAction,
  1146. "text" : this.lp.signUp
  1147. }).inject(needloginNode);
  1148. signupNode.addEvent("click" , function(){
  1149. this.openSignUpForm()
  1150. }.bind(this))
  1151. }
  1152. },
  1153. createReplyEditor : function( ){
  1154. this.replyArea = new Element("div.replyArea",{
  1155. "styles" : this.css.replyArea
  1156. }).inject( this.middleNode );
  1157. this.replyEditor = new MWF.xApplication.ForumDocument.ReplyEditor( this.replyArea, this, {
  1158. style : this.options.style,
  1159. isNew : true,
  1160. onPostOk : function( id ){
  1161. this.postCreateReply( id )
  1162. }.bind(this)
  1163. } );
  1164. this.replyEditor.mainData = this.data;
  1165. this.replyEditor.load();
  1166. },
  1167. createTurnSubjectNode : function(){
  1168. if( !this.lastSubject && !this.nextSubject )return;
  1169. var turnSubjectNode = new Element("div.turnSubjectNode", {styles : this.css.turnSubjectNode}).inject( this.middleNode );
  1170. if( this.lastSubject ){
  1171. var lastSubjectNode = new Element( "div.lastSubjectNode", {
  1172. styles : this.css.lastSubjectNode,
  1173. text : this.lp.prevSubject + ":" + this.lastSubject.title
  1174. }).inject( turnSubjectNode );
  1175. lastSubjectNode.addEvents({
  1176. "click" : function(){
  1177. this.gotoDocument(-1)
  1178. }.bind(this),
  1179. "mouseover" : function(){ this.node.setStyles( this.obj.css.lastSubjectNode_over ) }.bind({obj :this, node : lastSubjectNode}),
  1180. "mouseout" : function(){ this.node.setStyles( this.obj.css.lastSubjectNode ) }.bind({obj :this, node : lastSubjectNode})
  1181. })
  1182. }else{
  1183. var lastSubjectNode = new Element( "div.lastSubjectNode", {
  1184. styles : this.css.lastSubjectNoneNode
  1185. }).inject( turnSubjectNode );
  1186. }
  1187. if( this.nextSubject ){
  1188. var nextSubjectNode = new Element( "div.nextSubjectNode", {
  1189. styles : this.css.nextSubjectNode,
  1190. text : this.lp.nextSubject + ":" + this.nextSubject.title
  1191. }).inject( turnSubjectNode );
  1192. nextSubjectNode.addEvents({
  1193. "click" : function(){
  1194. this.gotoDocument(1)
  1195. }.bind(this),
  1196. "mouseover" : function(){ this.node.setStyles( this.obj.css.nextSubjectNode_over ) }.bind({obj :this, node : nextSubjectNode}),
  1197. "mouseout" : function(){ this.node.setStyles( this.obj.css.nextSubjectNode ) }.bind({obj :this, node : nextSubjectNode})
  1198. })
  1199. }else{
  1200. var nextSubjectNode = new Element( "div.nextSubjectNode", {
  1201. styles : this.css.nextSubjectNoneNode
  1202. }).inject( turnSubjectNode );
  1203. }
  1204. },
  1205. gotoDocument : function( count ){
  1206. if( count == 1 ){
  1207. var documentData = this.nextSubject;
  1208. }else{
  1209. var documentData = this.lastSubject;
  1210. }
  1211. var oldId = "ForumDocument"+this.data.id;
  1212. var appId = "ForumDocument"+documentData.id;
  1213. if (this.desktop.apps[appId]){
  1214. this.desktop.apps[appId].setCurrent();
  1215. //this.close();
  1216. }else {
  1217. this.setOptions({
  1218. "sectionId" : null, //this.data.sectionId,
  1219. "id" : documentData.id,
  1220. "appId": appId,
  1221. "isEdited" : false,
  1222. "isNew" : false
  1223. });
  1224. this.reload(oldId , appId );
  1225. }
  1226. },
  1227. createSidebar: function(){
  1228. if( this.inBrowser ){
  1229. var crd = this.middleNode.getCoordinates();
  1230. this.sideBar = new Element("div.sideBar", {
  1231. styles : {
  1232. "position" : "fixed",
  1233. "left" : (crd.right+4)+"px",
  1234. "bottom" : "100px",
  1235. "width" : "50px",
  1236. "height" : "155px",
  1237. "padding-top" : "10px",
  1238. "text-align" : "center",
  1239. "background-color" : "#fff",
  1240. "box-shadow": "0 0 4px rgba(0,0,0,0.20)"
  1241. }
  1242. }).inject( this.middleNode );
  1243. window.onresize = function(){
  1244. var crd = this.middleNode.getCoordinates();
  1245. this.sideBar.setStyles( {
  1246. "left" : (crd.right+4)+"px"
  1247. })
  1248. }.bind(this)
  1249. }else{
  1250. var contentCrd = this.content.getCoordinates();
  1251. var middleNodeCrd = this.middleNode.getCoordinates();
  1252. this.sideBar = new Element("div.sideBar", {
  1253. styles : {
  1254. "position" : "fixed",
  1255. "top" : (contentCrd.top + contentCrd.height-220)+"px",
  1256. "left" : (middleNodeCrd.right+4)+"px",
  1257. "width" : "50px",
  1258. "height" : "155px",
  1259. "padding-top" : "10px",
  1260. "text-align" : "center",
  1261. "background-color" : "#fff",
  1262. "box-shadow": "0 0 4px #ccc"
  1263. }
  1264. }).inject( this.middleNode );
  1265. this.addEvent("moveDrop", function(){
  1266. var contentCrd = this.content.getCoordinates();
  1267. var middleNodeCrd = this.middleNode.getCoordinates();
  1268. this.sideBar.setStyles( {
  1269. "top" : (contentCrd.top + contentCrd.height-220)+"px",
  1270. "left" : (middleNodeCrd.right+4)+"px"
  1271. })
  1272. }.bind(this));
  1273. this.addEvent("resize", function(){
  1274. var contentCrd = this.content.getCoordinates();
  1275. var middleNodeCrd = this.middleNode.getCoordinates();
  1276. this.sideBar.setStyles( {
  1277. "top" : (contentCrd.top + contentCrd.height-220)+"px",
  1278. "left" : (middleNodeCrd.right+4)+"px"
  1279. })
  1280. }.bind(this));
  1281. }
  1282. this._createSidebar();
  1283. },
  1284. _createSidebar: function(){
  1285. var count = 1;
  1286. var sidebarTop = new Element("div",{
  1287. styles : this.css.sidebarTop,
  1288. title: this.lp.gotoTop
  1289. }).inject(this.sideBar);
  1290. sidebarTop.addEvents(
  1291. {
  1292. "mouseover": function () {
  1293. this.node.setStyles(this.obj.css.sidebarTop_over);
  1294. }.bind({obj: this, node: sidebarTop}),
  1295. "mouseout": function () {
  1296. this.node.setStyles(this.obj.css.sidebarTop);
  1297. }.bind({obj: this, node: sidebarTop}),
  1298. "click": function () {
  1299. this.contentContainerNode.scrollTo( 0, 0 );
  1300. }.bind(this)
  1301. }
  1302. );
  1303. if( this.sectionPermission.subjectPublishAble ){
  1304. count++;
  1305. var createActionNode = new Element("div",{
  1306. styles : this.css.sidebarCreate,
  1307. title: this.lp.createSubject
  1308. }).inject(this.sideBar);
  1309. createActionNode.addEvents(
  1310. {
  1311. "mouseover": function () {
  1312. this.node.setStyles(this.obj.css.sidebarCreate_over);
  1313. }.bind({obj: this, node: createActionNode}),
  1314. "mouseout": function () {
  1315. this.node.setStyles(this.obj.css.sidebarCreate);
  1316. }.bind({obj: this, node: createActionNode}),
  1317. "click": function () {
  1318. if( this.access.isAnonymousDynamic() ){
  1319. this.openLoginForm(
  1320. function(){ this.createNewDocument(); }.bind(this)
  1321. );
  1322. }else{
  1323. this.createNewDocument();
  1324. }
  1325. }.bind(this)
  1326. }
  1327. )
  1328. }
  1329. if( !this.data.stopReply ){
  1330. if( this.isReplyPublisher ){
  1331. count++;
  1332. var action = new Element("div", {
  1333. "styles" : this.css.sidebarReply,
  1334. "title" : this.lp.reply
  1335. }).inject( this.sideBar );
  1336. action.addEvents({
  1337. "mouseover" : function(){ this.itemNode.setStyles( this.obj.css.sidebarReply_over ) }.bind({ obj : this, itemNode : action }),
  1338. "mouseout" : function(){ this.itemNode.setStyles( this.obj.css.sidebarReply ) }.bind({ obj : this, itemNode : action }),
  1339. "click" : function(){
  1340. if( this.access.isAnonymousDynamic() ){
  1341. this.openLoginForm( function(){ this.reload() }.bind(this) );
  1342. }else{
  1343. this.createReply();
  1344. }
  1345. }.bind(this)
  1346. })
  1347. }
  1348. }
  1349. var container = new Element("div",{}).inject( this.sideBar );
  1350. if( this.nextSubject ){
  1351. count++;
  1352. this.sidebarNext = new Element("div.sidebarNext",{
  1353. "styles" : this.css.sidebarNext,
  1354. "title" : this.lp.nextSubject + ":" + this.nextSubject.title
  1355. }).inject( container );
  1356. this.sidebarNext.addEvents({
  1357. "click" : function(){ this.gotoDocument( 1 ); }.bind(this),
  1358. "mouseover" : function(){
  1359. this.sidebarNext.setStyles( this.css.sidebarNext_over );
  1360. }.bind(this),
  1361. "mouseout" : function(){
  1362. this.sidebarNext.setStyles( this.css.sidebarNext );
  1363. }.bind(this)
  1364. })
  1365. }
  1366. if( this.lastSubject ){
  1367. count++;
  1368. this.sidebarPrev = new Element("div.sidebarPrev",{
  1369. "styles" : this.css.sidebarPrev,
  1370. "title" : this.lp.prevSubject + ":" + this.lastSubject.title
  1371. }).inject( container );
  1372. this.sidebarPrev.addEvents({
  1373. "click" : function(){ this.gotoDocument( -1 ); }.bind(this),
  1374. "mouseover" : function(){
  1375. this.sidebarPrev.setStyles( this.css.sidebarPrev_over );
  1376. }.bind(this),
  1377. "mouseout" : function(){
  1378. this.sidebarPrev.setStyles( this.css.sidebarPrev );
  1379. }.bind(this)
  1380. })
  1381. }
  1382. this.sideBar.setStyle( "height" , (count * 30 + 5 ) +"px" );
  1383. },
  1384. openPerson : function( userName ){
  1385. var appId = "ForumPerson"+userName;
  1386. if (this.desktop.apps[userName]){
  1387. this.desktop.apps[userName].setCurrent();
  1388. }else {
  1389. this.desktop.openApplication(null, "ForumPerson", {
  1390. "personName" : userName,
  1391. "appId": appId
  1392. });
  1393. }
  1394. },
  1395. createPersonNode : function( container, personName ){
  1396. var persons = personName.split(",");
  1397. persons.each( function(userName, i){
  1398. var span = new Element("span", {
  1399. "text" : userName,
  1400. "styles" : this.css.person
  1401. }).inject(container);
  1402. span.addEvents( {
  1403. mouseover : function(){ this.node.setStyles( this.obj.css.person_over )}.bind( {node:span, obj:this} ),
  1404. mouseout : function(){ this.node.setStyles( this.obj.css.person )}.bind( {node:span, obj:this} ),
  1405. click : function(){ this.obj.openPerson( this.userName ) }.bind( {userName:userName, obj:this} )
  1406. });
  1407. if( i != persons.length - 1 ){
  1408. new Element("span", {
  1409. "text" : ","
  1410. }).inject(container);
  1411. }
  1412. }.bind(this))
  1413. },
  1414. getUserData : function( name, callback ){
  1415. if( this.userCache && this.userCache[name] ){
  1416. if( callback )callback( this.userCache[name] );
  1417. return
  1418. }
  1419. if( !this.userCache )this.userCache = {};
  1420. if( this.access.isAnonymous() ){
  1421. var url = MWF.Actions.get("x_organization_assemble_personal").getIcon(name);
  1422. if( url ){
  1423. var json = { data : { icon : url } };
  1424. this.userCache[ name ] = json;
  1425. if( callback )callback( json );
  1426. }else{
  1427. var json = { data : { icon : "/x_component_ForumDocument/$Main/"+this.options.style+"/icon/noavatar_big.gif" } };
  1428. this.userCache[ name ] = json;
  1429. if( callback )callback( json );
  1430. }
  1431. //MWF.Actions.get("x_organization_assemble_control").getPersonIcon(name, function(url){
  1432. // var json = { data : { icon : url } };
  1433. // this.userCache[ name ] = json;
  1434. // if( callback )callback( json );
  1435. //}.bind(this), function(){
  1436. // var json = { data : { icon : "/x_component_ForumDocument/$Main/"+this.options.style+"/icon/noavatar_big.gif" } };
  1437. // this.userCache[ name ] = json;
  1438. // if( callback )callback( json );
  1439. //}.bind(this))
  1440. }else{
  1441. MWF.Actions.get("x_organization_assemble_control").getPerson( function( json ){
  1442. if( !json.data )json.data = {};
  1443. var url = MWF.Actions.get("x_organization_assemble_personal").getIcon(name);
  1444. if( url ){
  1445. if( json.data ){
  1446. json.data.icon = url;
  1447. this.userCache[ name ] = json;
  1448. if( callback )callback( json );
  1449. }
  1450. }else{
  1451. if( json.data ){
  1452. json.data.icon = "/x_component_ForumDocument/$Main/"+this.options.style+"/icon/noavatar_big.gif";
  1453. this.userCache[ name ] = json;
  1454. if( callback )callback( json );
  1455. }
  1456. }
  1457. //MWF.Actions.get("x_organization_assemble_control").getPersonIcon(name, function(url){
  1458. // if( json.data ){
  1459. // json.data.icon = url;
  1460. // this.userCache[ name ] = json;
  1461. // if( callback )callback( json );
  1462. // }
  1463. //}.bind(this), function(){
  1464. // if( json.data ){
  1465. // json.data.icon = "/x_component_ForumDocument/$Main/"+this.options.style+"/icon/noavatar_big.gif";
  1466. // this.userCache[ name ] = json;
  1467. // if( callback )callback( json );
  1468. // }
  1469. //}.bind(this));
  1470. }.bind(this), function(){
  1471. var json = { data : { icon : "/x_component_ForumDocument/$Main/"+this.options.style+"/icon/noavatar_big.gif" } };
  1472. this.userCache[ name ] = json;
  1473. if( callback )callback( json );
  1474. }.bind(this), name, true )
  1475. }
  1476. }
  1477. });
  1478. MWF.xApplication.ForumDocument.SubjectView = new Class({
  1479. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  1480. _createDocument: function(data, index){
  1481. data.index = index;
  1482. var document;
  1483. this.getUserData( data.creatorName, function(json ){
  1484. data.userIcon = json.data.icon;
  1485. data.signature = json.data.signature;
  1486. this.actions.getUserInfor( {"userName":data.creatorName}, function( json ){
  1487. data.subject = json.data.subjectCount;
  1488. data.reply = json.data.replyCount;
  1489. data.todaySubject = json.data.subjectCountToday;
  1490. data.todayReply = json.data.replyCountToday;
  1491. data.prime = json.data.creamCount;
  1492. data.accessed = json.data.popularity;
  1493. document = new MWF.xApplication.ForumDocument.SubjectDocument(this.viewNode, data, this.explorer, this, null, data.index );
  1494. }.bind(this))
  1495. }.bind(this) );
  1496. return document;
  1497. },
  1498. getUserData : function( name, callback ){
  1499. this.app.getUserData( name, callback );
  1500. },
  1501. _getCurrentPageData: function(callback, count){
  1502. var json = {
  1503. type: "success",
  1504. count : 1,
  1505. size : 1,
  1506. data : [this.data]
  1507. };
  1508. if (callback)callback(json)
  1509. },
  1510. _removeDocument: function(documentData, all){
  1511. this.actions.deleteSection(documentData.id, function(json){
  1512. this.reload();
  1513. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  1514. }.bind(this));
  1515. },
  1516. _create: function(){
  1517. },
  1518. _queryCreateViewNode: function(){
  1519. },
  1520. _postCreateViewNode: function( viewNode ){
  1521. },
  1522. _queryCreateViewHead:function(){
  1523. },
  1524. _postCreateViewHead: function( headNode ){
  1525. }
  1526. });
  1527. MWF.xApplication.ForumDocument.SubjectDocument = new Class({
  1528. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  1529. mouseoverSubject : function(subjectNode, ev){
  1530. //var removeNode = sectionNode.getElements("[styles='sectionRemoveNode']")[0];
  1531. //if( removeNode )removeNode.setStyle("opacity",1)
  1532. },
  1533. mouseoutSubject : function(subjectNode, ev){
  1534. //var removeNode = sectionNode.getElements("[styles='sectionRemoveNode']")[0];
  1535. //if( removeNode )removeNode.setStyle("opacity",0)
  1536. },
  1537. _queryCreateDocumentNode:function( itemData ){
  1538. },
  1539. _postCreateDocumentNode: function( itemNode, itemData ){
  1540. var toolbar = itemNode.getElement("[item='itemSubjectTools']");
  1541. this.app.createActionBar(toolbar);
  1542. if( this.data.attachmentList && this.data.attachmentList.length > 0 ){
  1543. var attachmentArea = itemNode.getElement("[item='attachment']");
  1544. this.app.loadAttachment(attachmentArea);
  1545. }
  1546. if( this.data.typeCategory == this.lp.vote ){
  1547. var voteArea = itemNode.getElement("[item='vote']");
  1548. MWF.xDesktop.requireApp("ForumDocument", "Vote", function(){
  1549. this.vote = new MWF.xApplication.ForumDocument.Vote(voteArea, this.app, {
  1550. isNew : false,
  1551. isEdited : false
  1552. }, this.data);
  1553. this.vote.load();
  1554. }.bind(this), true)
  1555. }
  1556. },
  1557. sendMessage : function(itemNode, ev ){
  1558. var self = this;
  1559. if (layout.desktop.widgets["IMIMWidget"]) {
  1560. var IM = layout.desktop.widgets["IMIMWidget"];
  1561. IM.getOwner(function(){
  1562. this.openChat(ev, {
  1563. from : self.data.creatorName
  1564. });
  1565. }.bind(IM));
  1566. }
  1567. },
  1568. createReply : function(itemNode, ev ){
  1569. if( this.app.access.isAnonymousDynamic() ){
  1570. this.app.openLoginForm( function(){ this.app.reload() }.bind(this) );
  1571. }else{
  1572. var form = new MWF.xApplication.ForumDocument.ReplyForm(this, {}, {
  1573. "toMain" : true,
  1574. onPostOk : function( id ){
  1575. this.app.postCreateReply( id );
  1576. }.bind(this)
  1577. });
  1578. form.mainData = this.data;
  1579. form.create()
  1580. }
  1581. }
  1582. });
  1583. MWF.xApplication.ForumDocument.ReplyEditor = new Class({
  1584. Implements: [Options , Events],
  1585. options: {
  1586. "style": "default",
  1587. "isNew" : true
  1588. },
  1589. initialize: function(node, app, options){
  1590. this.setOptions(options);
  1591. this.node = node;
  1592. this.app = app;
  1593. },
  1594. load: function(){
  1595. this.app.restActions.getUUID( function( id ){
  1596. this.advanceReplyId = id;
  1597. this._load();
  1598. }.bind(this))
  1599. },
  1600. _load: function(){
  1601. var html = "<div styles='itemNode'>" +
  1602. " <div styles='itemLeftNode'>" +
  1603. " <div styles='itemUserFace'>" +
  1604. " <div styles='itemUserIcon' item='userIcon'>" +
  1605. " </div>" +
  1606. " </div>" +
  1607. " <div styles='replyUserName' item='creatorName'>" +
  1608. " </div>" +
  1609. " </div>" +
  1610. " <div styles='replyRightNode'>" +
  1611. " <div styles='itemRightMidle'>" +
  1612. " <div styles='itemBodyReply' item='content'></div>" +
  1613. " <div styles='itemBodyReply' item='action'></div>" +
  1614. " </div>" +
  1615. " </div>" +
  1616. "</div>";
  1617. this.node.set("html", html);
  1618. var actionTd = this.node.getElements("[item='action']")[0];
  1619. this.saveReplyAction = new Element("div",{
  1620. styles : this.app.css.actionNode,
  1621. text: this.app.lp.saveReply
  1622. }).inject(actionTd);
  1623. this.saveReplyAction.addEvent("click",function(){
  1624. this.saveReply();
  1625. }.bind(this));
  1626. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1627. this.form = new MForm(this.node, this.data || {}, {
  1628. style: "forum",
  1629. isEdited: true,
  1630. itemTemplate: {
  1631. userIcon: { className : "itemUserIcon2", type : "img", value : function(){
  1632. if( this.app.userData.icon ){
  1633. return "data:image/png;base64," + this.app.userData.icon
  1634. }else{
  1635. return "/x_component_ForumDocument/$Main/"+this.options.style+"/icon/noavatar_big.gif"
  1636. }
  1637. }.bind(this)},
  1638. creatorName: { type : "innerText", value : ( this.app.userName || "" ).split('@')[0] },
  1639. content: { type : "rtf", RTFConfig : {
  1640. //skin : "bootstrapck",
  1641. "resize_enabled": false,
  1642. isSetImageMaxWidth : true,
  1643. reference : this.advanceReplyId,
  1644. referenceType: "forumReply",
  1645. //uiColor : '#9AB8F3',
  1646. //toolbarCanCollapse : true,
  1647. toolbar : [
  1648. { name: 'document', items : [ 'Preview' ] },
  1649. //{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
  1650. { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','-','RemoveFormat' ] },
  1651. //{ name: 'paragraph', items : [ 'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock' ] },
  1652. { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
  1653. { name: 'colors', items : [ 'TextColor','BGColor' ] },
  1654. { name: 'links', items : [ 'Link','Unlink' ] },
  1655. { name: 'insert', items : [ 'Image' ] },
  1656. { name: 'tools', items : [ 'Maximize','-','About' ] }
  1657. ]
  1658. }}
  1659. }
  1660. }, this, this.app.css);
  1661. this.form.load();
  1662. }.bind(this), true);
  1663. },
  1664. saveReply : function(){
  1665. var data = this.form.getResult(true, ",", true, false, true);
  1666. if (data) {
  1667. data.subjectId = this.mainData.id ;
  1668. data.id = this.advanceReplyId;
  1669. this.app.restActions.saveReply(data, function (json) {
  1670. if (json.type == "error") {
  1671. this.app.notice(json.message, "error");
  1672. } else {
  1673. this.app.restActions.getUUID( function( id ){
  1674. this.advanceReplyId = id;
  1675. }.bind(this));
  1676. this.app.notice( this.app.lp.saveReplySuccess, "ok" );
  1677. this.form.getItem("content").setValue("");
  1678. this.fireEvent("postOk", json.data.id);
  1679. }
  1680. }.bind(this))
  1681. }
  1682. }
  1683. });
  1684. MWF.xApplication.ForumDocument.ReplyForm = new Class({
  1685. Extends: MPopupForm,
  1686. Implements: [Options, Events],
  1687. options: {
  1688. "style": "default",
  1689. "width": "860",
  1690. "height": "470",
  1691. "hasTop": true,
  1692. "hasIcon": false,
  1693. "hasTopIcon" : true,
  1694. "hasTopContent" : true,
  1695. "hasBottom": true,
  1696. "title": MWF.xApplication.Forum.LP.replyFormTitle,
  1697. "draggable": true,
  1698. "closeAction": true,
  1699. "toMain" : true
  1700. },
  1701. _createTableContent: function(){
  1702. if( this.isNew ){
  1703. this.app.restActions.getUUID( function(id){
  1704. this.advanceReplyId = id;
  1705. this._createTableContent_();
  1706. }.bind(this) )
  1707. }else{
  1708. this._createTableContent_()
  1709. }
  1710. },
  1711. _createTableContent_: function () {
  1712. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  1713. "<tr>" +
  1714. " <td styles='formTableValue14' item='mainSubject'></td>" +
  1715. "</tr><tr>" +
  1716. " <td styles='formTableValue' item='mainContent'></td>" +
  1717. "</tr><tr>" +
  1718. " <td styles='formTableValue' item='content'></td>" +
  1719. "</tr>"+
  1720. "</table>";
  1721. this.formTableArea.set("html", html);
  1722. if( !this.options.toMain && this.parentData ){
  1723. var mainContentEl = this.formTableArea.getElements("[item='mainContent']")[0];
  1724. var quoteTop = new Element( "div", {styles : this.css.quoteTop} ).inject( mainContentEl );
  1725. new Element( "div", {styles : this.css.quoteLeft} ).inject( quoteTop );
  1726. new Element( "div", {
  1727. styles : this.css.quoteInfor,
  1728. text : this.parentData.creatorName.split("@")[0] + this.lp.publishAt + this.parentData.createTime
  1729. }).inject( quoteTop );
  1730. var quoteBottom = new Element( "div", {styles : this.css.quoteBottom} ).inject( mainContentEl );
  1731. var text = this.parentData.contentText;
  1732. new Element( "div", {
  1733. styles : this.css.quoteText,
  1734. text : text.length > 50 ? (text.substr(0, 50) + "...") : text
  1735. }).inject( quoteBottom );
  1736. new Element( "div", {styles : this.css.quoteRight} ).inject( quoteBottom );
  1737. }
  1738. MWF.xDesktop.requireApp("Template", "MForm", function () {
  1739. this.form = new MForm(this.formTableArea, this.data, {
  1740. style: "forum",
  1741. isEdited: true,
  1742. itemTemplate: {
  1743. mainSubject: { type: "innertext", defaultValue : "RE:" + this.mainData.title },
  1744. content: { type : "rtf", RTFConfig : {
  1745. //skin : "bootstrapck",
  1746. "resize_enabled": false,
  1747. isSetImageMaxWidth : true,
  1748. reference : this.advanceReplyId || this.data.id,
  1749. referenceType: "forumReply",
  1750. toolbar : [
  1751. { name: 'document', items : [ 'Preview' ] },
  1752. //{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
  1753. { name: 'basicstyles', items : [ 'Bold','Italic','Underline','Strike','-','RemoveFormat' ] },
  1754. //{ name: 'paragraph', items : [ 'JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock' ] },
  1755. { name: 'styles', items : [ 'Styles','Format','Font','FontSize' ] },
  1756. { name: 'colors', items : [ 'TextColor','BGColor' ] },
  1757. { name: 'links', items : [ 'Link','Unlink' ] },
  1758. { name: 'insert', items : [ 'Image' ] },
  1759. { name: 'tools', items : [ 'Maximize','-','About' ] }
  1760. ]
  1761. }}
  1762. }
  1763. }, this.app, this.css);
  1764. this.form.load();
  1765. }.bind(this), true);
  1766. },
  1767. _createBottomContent: function () {
  1768. if (this.isNew || this.isEdited) {
  1769. this.okActionNode = new Element("div.formOkActionNode", {
  1770. "styles": this.css.formOkActionNode,
  1771. "text": this.app.lp.saveReply
  1772. }).inject(this.formBottomNode);
  1773. this.okActionNode.addEvent("click", function (e) {
  1774. this.ok(e);
  1775. }.bind(this));
  1776. }
  1777. this.cancelActionNode = new Element("div.formCancelActionNode", {
  1778. "styles": this.css.formCancelActionNode,
  1779. "text": this.app.lp.close
  1780. }).inject(this.formBottomNode);
  1781. this.cancelActionNode.addEvent("click", function (e) {
  1782. this.cancel(e);
  1783. }.bind(this));
  1784. },
  1785. ok: function (e) {
  1786. this.fireEvent("queryOk");
  1787. var data = this.form.getResult(true, ",", true, false, true);
  1788. if (data) {
  1789. this._ok(data, function (json) {
  1790. if (json.type == "error") {
  1791. this.app.notice(json.message, "error");
  1792. } else {
  1793. if(this.formMaskNode)this.formMaskNode.destroy();
  1794. this.formAreaNode.destroy();
  1795. this.app.notice(this.isNew ? this.app.lp.createReplySuccess : this.app.lp.updateSuccess, "success");
  1796. this.fireEvent("postOk", json.data.id);
  1797. }
  1798. }.bind(this))
  1799. }
  1800. },
  1801. _ok: function (data, callback) {
  1802. data.subjectId = this.mainData.id ;
  1803. if( this.advanceReplyId )data.id = this.advanceReplyId;
  1804. if( !this.options.toMain ){
  1805. data.parentId = this.parentData.id ;
  1806. }
  1807. this.app.restActions.saveReply( data, function(json){
  1808. if( callback )callback(json);
  1809. }.bind(this));
  1810. }
  1811. });
  1812. MWF.xApplication.ForumDocument.ReplyView = new Class({
  1813. Extends: MWF.xApplication.Template.Explorer.ComplexView,
  1814. _createDocument: function(data, index){
  1815. data.index = index;
  1816. return new MWF.xApplication.ForumDocument.ReplyDocument(this.viewNode, data, this.explorer, this, null, data.index );
  1817. },
  1818. _getCurrentPageData: function(callback, count, pageNum){
  1819. this.clearBody();
  1820. if(!count)count=10;
  1821. if(!pageNum)pageNum = 1;
  1822. if( pageNum == 1 ){
  1823. this.app.subjectConainer.setStyle("display","block");
  1824. if( this.app.satisfiedReplyViewConainer )this.app.satisfiedReplyViewConainer.setStyle("display","block");
  1825. }else{
  1826. this.app.subjectConainer.setStyle("display","none");
  1827. if( this.app.satisfiedReplyViewConainer )this.app.satisfiedReplyViewConainer.setStyle("display","none");
  1828. }
  1829. //page, count, filterData, success,failure, async
  1830. //if( !this.page ){
  1831. // this.page = 1;
  1832. //}else{
  1833. // this.page ++;
  1834. //}
  1835. //var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  1836. var filter = this.filterData || {};
  1837. this.actions.listReplyFilterPage( pageNum, count, filter, function(json){
  1838. if( !json.data )json.data = [];
  1839. if( !json.count )json.count=0;
  1840. if( callback )callback(json);
  1841. }.bind(this))
  1842. },
  1843. _removeDocument: function(documentData, all){
  1844. this.actions.deleteReply( documentData.id, function(){
  1845. this.reload();
  1846. this.app.notice( this.lp.deleteReplySuccess, "ok")
  1847. }.bind(this) )
  1848. },
  1849. _create: function(){
  1850. },
  1851. _queryCreateViewNode: function(){
  1852. },
  1853. _postCreateViewNode: function( viewNode ){
  1854. },
  1855. _queryCreateViewHead:function(){
  1856. },
  1857. _postCreateViewHead: function( headNode ){
  1858. }
  1859. });
  1860. MWF.xApplication.ForumDocument.ReplyDocument = new Class({
  1861. Extends: MWF.xApplication.Template.Explorer.ComplexDocument,
  1862. mouseoverSubject : function(subjectNode, ev){
  1863. //var removeNode = sectionNode.getElements("[styles='sectionRemoveNode']")[0];
  1864. //if( removeNode )removeNode.setStyle("opacity",1)
  1865. },
  1866. mouseoutSubject : function(subjectNode, ev){
  1867. //var removeNode = sectionNode.getElements("[styles='sectionRemoveNode']")[0];
  1868. //if( removeNode )removeNode.setStyle("opacity",0)
  1869. },
  1870. getUserData : function( name, callback ){
  1871. this.app.getUserData( name, callback );
  1872. },
  1873. _queryCreateDocumentNode:function( itemData ){
  1874. },
  1875. _postCreateDocumentNode: function( itemNode, itemData ){
  1876. var userIcon = itemNode.getElements( "[item='userIcon']" )[0];
  1877. var signatureContainer = itemNode.getElements("[item='signatureContainer']")[0];
  1878. this.getUserData( itemData.creatorName, function(json ){
  1879. userIcon.src = json.data.icon;
  1880. if( json.data.signature && json.data.signature!="" ){
  1881. var signatureNode = signatureContainer.getElements("[item='signature']")[0];
  1882. signatureNode.set("text", json.data.signature )
  1883. }else{
  1884. signatureContainer.destroy();
  1885. }
  1886. }.bind(this) );
  1887. this.actions.getUserInfor( {"userName":itemData.creatorName}, function( json ){
  1888. var d = json.data;
  1889. itemNode.getElements( "[item='subject']" )[0].set("text", d.subjectCount);
  1890. itemNode.getElements( "[item='reply']" )[0].set("text", d.replyCount);
  1891. itemNode.getElements( "[item='prime']" )[0].set("text", d.creamCount);
  1892. itemNode.getElements( "[item='todaySubject']" )[0].set("text", d.subjectCountToday);
  1893. itemNode.getElements( "[item='todayReply']" )[0].set("text", d.replyCountToday);
  1894. }.bind(this));
  1895. if( itemData.parentId && itemData.parentId != "" ){
  1896. var quoteContainer = itemNode.getElements( "[item='quoteContent']" )[0];
  1897. this.actions.getReply( itemData.parentId, function( json ){
  1898. var data = this.parentData = json.data;
  1899. var quoteContent = new Element("div", { "styles" : this.css.itemQuote }).inject(quoteContainer);
  1900. var content = quoteContent.set("html", data.content).get("text");
  1901. quoteContent.empty();
  1902. data.contentText = content;
  1903. new Element( "div", {styles : this.css.quoteLeftBig} ).inject( quoteContent );
  1904. var quoteArea = new Element( "div", {styles : this.css.quoteAreaBig } ).inject( quoteContent );
  1905. var quoteInfor = new Element( "div", {
  1906. styles : this.css.quoteInforBig,
  1907. text : data.orderNumber + this.lp.floor + ":" + data.creatorName.split('@')[0] + this.lp.publishAt + data.createTime
  1908. }).inject( quoteArea );
  1909. quoteInfor.addEvent("click", function(){
  1910. this.obj.app.gotoReply( this.index )
  1911. }.bind({obj : this, index : data.orderNumber || (data.index + 2) }));
  1912. new Element( "div", {
  1913. styles : this.css.quoteTextBig,
  1914. text : content.length > 100 ? (content.substr(0, 100) + "...") : content
  1915. }).inject( quoteArea );
  1916. new Element( "div", {styles : this.css.quoteRightBig} ).inject( quoteContent );
  1917. }.bind(this) , function( json ){
  1918. new Element( "div" , {
  1919. "styles" : this.css.replyBeinngDelete,
  1920. "text" : this.lp.quoteReplyBeingDeleted
  1921. }).inject(quoteContainer)
  1922. }.bind(this)
  1923. )
  1924. }
  1925. },
  1926. sendMessage : function(itemNode, ev ){
  1927. var self = this;
  1928. if (layout.desktop.widgets["IMIMWidget"]) {
  1929. var IM = layout.desktop.widgets["IMIMWidget"];
  1930. IM.getOwner(function(){
  1931. this.openChat(ev, {
  1932. from : self.data.creatorName
  1933. });
  1934. }.bind(IM));
  1935. }
  1936. },
  1937. createReply : function(itemNode, ev ){ // 对回复进行回复
  1938. if( this.app.access.isAnonymousDynamic() ){
  1939. this.app.openLoginForm( function(){ this.app.reload() }.bind(this) );
  1940. }else{
  1941. var form = new MWF.xApplication.ForumDocument.ReplyForm(this, {}, {
  1942. toMain: false,
  1943. onPostOk: function (id) {
  1944. this.app.postCreateReply(id)
  1945. }.bind(this)
  1946. });
  1947. this.data.contentText = this.node.getElements("[item='content']")[0].get("text");
  1948. form.mainData = this.app.data;
  1949. form.parentData = this.data;
  1950. form.create()
  1951. }
  1952. },
  1953. editReply : function(itemNode, ev ){ //编辑当前回复
  1954. var form = new MWF.xApplication.ForumDocument.ReplyForm(this, this.data, {
  1955. toMain : (this.data.parentId && this.data.parentId!="") ? false : true,
  1956. onPostOk : function( id ){
  1957. this.actions.getReply( id, function( json ){
  1958. var content = this.node.getElements("[item='content']")[0];
  1959. content.set( "html", json.data.content );
  1960. }.bind(this))
  1961. }.bind(this)
  1962. });
  1963. form.mainData = this.app.data;
  1964. form.parentData = this.parentData;
  1965. form.edit()
  1966. },
  1967. deleteReply : function( itemNode, ev ){
  1968. var _self = this;
  1969. this.app.confirm("warn", ev, this.lp.deleteReplyTitle, this.lp.deleteReplyText, 350, 120, function(){
  1970. //_self.view._removeDocument(_self.data, false);
  1971. _self.actions.deleteReply( _self.data.id, function(){
  1972. _self.destroy();
  1973. _self.app.adjustReplyCount( -1 );
  1974. _self.app.notice( _self.lp.deleteReplySuccess, "ok")
  1975. }.bind(this) );
  1976. this.close();
  1977. }, function(){
  1978. this.close();
  1979. });
  1980. },
  1981. satisfiedAction : function(){
  1982. this.actions.acceptReply({"id": this.data.id }, function(){
  1983. this.app.notice( this.lp.acceptReplySuccess, "ok");
  1984. this.app.reload();
  1985. }.bind(this))
  1986. }
  1987. });
  1988. MWF.xApplication.ForumDocument.SatisfiedReplyView = new Class({
  1989. Extends: MWF.xApplication.ForumDocument.ReplyView,
  1990. _createDocument: function (data, index) {
  1991. data.index = index;
  1992. return new MWF.xApplication.ForumDocument.SatisfiedReplyDocument(this.viewNode, data, this.explorer, this, null, data.index);
  1993. },
  1994. _getCurrentPageData: function(callback, count, pageNum){
  1995. this.clearBody();
  1996. if(!count)count=1;
  1997. if(!pageNum)pageNum = 1;
  1998. var filter = this.filterData || {};
  1999. this.actions.getAcceptedReply( this.data.acceptReplyId, function(json){
  2000. if( !json.data ){
  2001. json.data = [];
  2002. }else if( typeOf( json.data ) == "object" ){
  2003. json.data = [ json.data ];
  2004. json.count = 1;
  2005. }
  2006. if( !json.count )json.count=0;
  2007. if( callback )callback(json);
  2008. }.bind(this))
  2009. }
  2010. });
  2011. MWF.xApplication.ForumDocument.SatisfiedReplyDocument = new Class({
  2012. Extends: MWF.xApplication.ForumDocument.ReplyDocument
  2013. });
  2014. MWF.xApplication.ForumDocument.TopSettingForm = new Class({
  2015. Extends: MPopupForm,
  2016. Implements: [Options, Events],
  2017. options: {
  2018. "style": "default",
  2019. "width": "420",
  2020. "height": "250",
  2021. "hasTop": true,
  2022. "hasIcon": false,
  2023. "hasTopIcon" : true,
  2024. "hasTopContent" : true,
  2025. "hasBottom": true,
  2026. "title": MWF.xApplication.Forum.LP.topFormTitle,
  2027. "draggable": true,
  2028. "closeAction": true
  2029. },
  2030. createTopNode: function () {
  2031. if (!this.formTopNode) {
  2032. this.formTopNode = new Element("div.formTopNode", {
  2033. "styles": this.css.formTopNode
  2034. }).inject(this.formNode);
  2035. if(this.options.hasTopIcon){
  2036. this.formTopIconNode = new Element("div", {
  2037. "styles": this.css.formTopIconNodeDocument
  2038. }).inject(this.formTopNode)
  2039. }
  2040. this.formTopTextNode = new Element("div", {
  2041. "styles": this.css.formTopTextNodeTopSetting,
  2042. "text": this.options.title
  2043. }).inject(this.formTopNode);
  2044. if (this.options.closeAction) {
  2045. this.formTopCloseActionNode = new Element("div", {"styles": this.css.formTopCloseActionNode}).inject(this.formTopNode);
  2046. this.formTopCloseActionNode.addEvent("click", function () {
  2047. this.close()
  2048. }.bind(this))
  2049. }
  2050. }
  2051. },
  2052. _createTableContent: function () {
  2053. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>" +
  2054. "<tr>" +
  2055. " <td styles='formTableValue' style='font-size:14px;' lable='topType'></td>" +
  2056. //"</tr><tr>" +
  2057. //" <td styles='formTableValue' item='topToBBS'></td>" +
  2058. "</tr><tr>" +
  2059. " <td styles='formTableValue' item='topToForum'></td>" +
  2060. "</tr><tr>" +
  2061. " <td styles='formTableValue' item='topToSection'></td>" +
  2062. "</tr>"+
  2063. "</table>";
  2064. this.formTableArea.set("html", html);
  2065. this.topToBBS = this.data.topToBBS;
  2066. this.topToForum = this.data.topToForum;
  2067. this.topToSection = this.data.topToSection;
  2068. MWF.xDesktop.requireApp("Template", "MForm", function () {
  2069. this.form = new MForm(this.formTableArea, this.data, {
  2070. style: "forum",
  2071. isEdited: this.isEdited || this.isNew,
  2072. itemTemplate: {
  2073. topType : { text : this.lp.topType },
  2074. //topToBBS: { type: "checkbox", selectValue : [true], selectText : [this.lp.topToBBS] },
  2075. topToForum: { type: "checkbox", selectValue : ["true"], selectText : [this.lp.topToForum]},
  2076. topToSection: { type: "checkbox", selectValue : ["true"], selectText : [this.lp.topToSection] }
  2077. }
  2078. }, this.app, this.css);
  2079. this.form.load();
  2080. }.bind(this), true);
  2081. },
  2082. _createBottomContent: function () {
  2083. if (this.isNew || this.isEdited) {
  2084. this.okActionNode = new Element("div.formOkActionNode", {
  2085. "styles": this.css.formOkActionNode,
  2086. "text": this.app.lp.ok
  2087. }).inject(this.formBottomNode);
  2088. this.okActionNode.addEvent("click", function (e) {
  2089. this.ok(e);
  2090. }.bind(this));
  2091. }
  2092. this.cancelActionNode = new Element("div.formCancelActionNode", {
  2093. "styles": this.css.formCancelActionNode,
  2094. "text": this.app.lp.close
  2095. }).inject(this.formBottomNode);
  2096. this.cancelActionNode.addEvent("click", function (e) {
  2097. this.cancel(e);
  2098. }.bind(this));
  2099. },
  2100. ok: function (e) {
  2101. this.fireEvent("queryOk");
  2102. var data = this.form.getResult(true, ",", true, false, true);
  2103. if (data) {
  2104. var flag = true;
  2105. //if( data.topToBBS === true || data.topToBBS === "true" ){
  2106. // this.actions.topToBBS( this.app.data.id , function( json ){
  2107. // if (json.type == "error") {
  2108. // this.app.notice(json.userMessage, "error");
  2109. // flag = false;
  2110. // }
  2111. // }, function(){
  2112. // flag = false;
  2113. // }, false )
  2114. //}else if( this.topToBBS === true || this.topToBBS === "true" ){
  2115. // this.actions.cancelTopToBBS( this.app.data.id , function( json ){
  2116. // if (json.type == "error") {
  2117. // this.app.notice(json.userMessage, "error");
  2118. // flag = false;
  2119. // }
  2120. // }, function(){
  2121. // flag = false;
  2122. // }, false )
  2123. //}
  2124. if( data.topToForum === true || data.topToForum === "true" ){
  2125. this.actions.topToForum( this.app.data.id , function( json ){
  2126. if (json.type == "error") {
  2127. this.app.notice(json.message, "error");
  2128. flag = false;
  2129. }
  2130. }, function(){
  2131. flag = false;
  2132. }, false )
  2133. }else if( this.topToForum === true || this.topToForum === "true" ){
  2134. this.actions.cancelTopToForum( this.app.data.id , function( json ){
  2135. if (json.type == "error") {
  2136. this.app.notice(json.message, "error");
  2137. flag = false;
  2138. }
  2139. }, function(){
  2140. flag = false;
  2141. }, false )
  2142. }
  2143. if( data.topToSection === true || data.topToSection === "true" ){
  2144. this.actions.topToSection( this.app.data.id , function( json ){
  2145. if (json.type == "error") {
  2146. this.app.notice(json.message, "error");
  2147. flag = false;
  2148. }
  2149. }, function(){
  2150. flag = false;
  2151. }, false )
  2152. }else if( this.topToSection === true || this.topToSection === "true" ){
  2153. this.actions.cancelTopToSection( this.app.data.id , function( json ){
  2154. if (json.type == "error") {
  2155. this.app.notice(json.message, "error");
  2156. flag = false;
  2157. }
  2158. }, function(){
  2159. flag = false;
  2160. }, false )
  2161. }
  2162. if( flag ){
  2163. if(this.formMaskNode)this.formMaskNode.destroy();
  2164. this.formAreaNode.destroy();
  2165. this.app.notice( this.app.lp.setTopSuccess );
  2166. this.fireEvent("postOk");
  2167. }else{
  2168. this.app.notice( this.app.lp.setToFail , "error");
  2169. }
  2170. }
  2171. }
  2172. });