Main.js 77 KB

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