Main.js 79 KB

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