Application.js 3.7 KB

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