Main.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. MWF.xApplication.ftsearch.options.multitask = false;
  2. MWF.xApplication.ftsearch.Main = new Class({
  3. Extends: MWF.xApplication.Common.Main,
  4. Implements: [Options, Events],
  5. options: {
  6. "style1": "default",
  7. "style": "default",
  8. "name": "ftsearch",
  9. "mvcStyle": "style.css",
  10. "icon": "icon.png",
  11. "title": MWF.xApplication.ftsearch.LP.title,
  12. "query":""
  13. },
  14. onQueryLoad: function(){
  15. this.lp = MWF.xApplication.ftsearch.LP;
  16. },
  17. loadApplication: function(callback){
  18. var url;
  19. if( layout.config.searchEnable === false){
  20. url = this.path+this.options.style+"/disabled.html";
  21. this.content.loadHtml(url, {"bind": {"lp": this.lp}});
  22. }else{
  23. url = this.path+this.options.style+"/main.html";
  24. this.content.loadHtml(url, {"bind": {"lp": this.lp}, "module": this}, function(){
  25. var query = this.options.query || "";
  26. if( this.status && this.status.query ){
  27. query = this.status.query;
  28. }
  29. if( query ){
  30. this.openFTSearchView( query );
  31. }
  32. this.status = null;
  33. }.bind(this));
  34. }
  35. },
  36. getEventTarget: function(e, className) {
  37. var parentItem = e.target;
  38. if( parentItem.hasClass(className) )return parentItem;
  39. while ( parentItem && !parentItem.hasClass(className) ){
  40. parentItem = parentItem.getParent();
  41. if( parentItem.hasClass(className) )return parentItem;
  42. }
  43. },
  44. searchKeydown: function(e){
  45. if( e.keyCode === 13 ){
  46. var query = this.searchInput.get("value");
  47. if(query)this.openFTSearchView( query );
  48. }
  49. },
  50. searchClick: function(e){
  51. var query = this.searchInput.get("value");
  52. if(query)this.openFTSearchView( query );
  53. },
  54. doSearch: function(query){
  55. this.openFTSearchView(query);
  56. },
  57. openFTSearchView: function( query ){
  58. if( this.view && this.view.destroy )this.view.destroy();
  59. this.contentArea.empty();
  60. o2.requireApp("ftsearch", "FTSearchView", function () {
  61. this.view = new MWF.xApplication.ftsearch.FTSearchView(this.contentArea, this, {
  62. query: query
  63. });
  64. }.bind(this), false);
  65. },
  66. iconOver: function(e){
  67. e.target.addClass('mainColor_color');
  68. },
  69. iconOut: function(e){
  70. e.target.removeClass('mainColor_color');
  71. },
  72. inputOver: function(e){
  73. this.getEventTarget(e, "main_inputArea").addClass('mainColor_border');
  74. },
  75. inputOut: function(e){
  76. this.getEventTarget(e, "main_inputArea").removeClass('mainColor_border');
  77. },
  78. recordStatus: function () {
  79. return this.view ? this.view.recordStatus() : "";
  80. }
  81. });