Main.js 78 KB

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