Application.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "Person", null, false);
  3. MWF.xApplication.Selector.Application = new Class({
  4. Extends: MWF.xApplication.Selector.Person,
  5. options: {
  6. "style": "default",
  7. "count": 0,
  8. "title": MWF.xApplication.Selector.LP.selectAppliction,
  9. "values": [],
  10. "expand": false,
  11. "forceSearchInItem" : true
  12. },
  13. loadSelectItems: function(addToNext){
  14. this.processAction.listApplications(function(json){
  15. json.data.each(function(data){
  16. var category = this._newItem(data, this, this.itemAreaNode);
  17. this.items.push( category );
  18. }.bind(this));
  19. }.bind(this));
  20. },
  21. _scrollEvent: function(y){
  22. return true;
  23. },
  24. _getChildrenItemIds: function(){
  25. return null;
  26. },
  27. _listItemByKey: function(callback, failure, key){
  28. return false;
  29. },
  30. _getItem: function(callback, failure, id, async){
  31. this.processAction.getApplications(function(json){
  32. if (callback) callback.apply(this, [json]);
  33. }.bind(this), failure, ((typeOf(id)==="string") ? id : id.id), async);
  34. },
  35. _newItemSelected: function(data, selector, item){
  36. return new MWF.xApplication.Selector.Application.ItemSelected(data, selector, item)
  37. },
  38. _listItemByPinyin: function(callback, failure, key){
  39. return false;
  40. },
  41. _newItem: function(data, selector, container, level){
  42. return new MWF.xApplication.Selector.Application.Item(data, selector, container, level);
  43. }
  44. });
  45. MWF.xApplication.Selector.Application.Item = new Class({
  46. Extends: MWF.xApplication.Selector.Person.Item,
  47. _getShowName: function(){
  48. return this.data.name;
  49. },
  50. _setIcon: function(){
  51. var style = "default";
  52. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/applicationicon.png)");
  53. },
  54. loadSubItem: function(){
  55. return false;
  56. },
  57. checkSelectedSingle: function(){
  58. var selectedItem = this.selector.options.values.filter(function(item, index){
  59. if (typeOf(item)==="object"){
  60. if( this.data.id && item.id ){
  61. return this.data.id === item.id;
  62. }else{
  63. return this.data.name === item.name;
  64. }
  65. // return (this.data.id === item.id) || (this.data.name === item.name) ;
  66. }
  67. if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
  68. return false;
  69. }.bind(this));
  70. if (selectedItem.length){
  71. this.selectedSingle();
  72. }
  73. },
  74. checkSelected: function(){
  75. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  76. //return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  77. if( item.data.id && this.data.id){
  78. return item.data.id === this.data.id;
  79. }else{
  80. return item.data.name === this.data.name;
  81. }
  82. }.bind(this));
  83. if (selectedItem.length){
  84. //selectedItem[0].item = this;
  85. selectedItem[0].addItem(this);
  86. this.selectedItem = selectedItem[0];
  87. this.setSelected();
  88. }
  89. }
  90. });
  91. MWF.xApplication.Selector.Application.ItemSelected = new Class({
  92. Extends: MWF.xApplication.Selector.Person.ItemSelected,
  93. _getShowName: function(){
  94. return this.data.name;
  95. },
  96. _setIcon: function(){
  97. var style = "default";
  98. this.iconNode.setStyle("background-image", "url("+"../x_component_Selector/$Selector/"+style+"/icon/applicationicon.png)");
  99. },
  100. check: function(){
  101. if (this.selector.items.length){
  102. var items = this.selector.items.filter(function(item, index){
  103. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  104. }.bind(this));
  105. this.items = items;
  106. if (items.length){
  107. items.each(function(item){
  108. item.selectedItem = this;
  109. item.setSelected();
  110. }.bind(this));
  111. }
  112. }
  113. }
  114. });