Main.js 78 KB

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