Main.js 89 KB

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