CMSApplication.js 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. MWF.xApplication.Selector = MWF.xApplication.Selector || {};
  2. MWF.xDesktop.requireApp("Selector", "Identity", null, false);
  3. MWF.xApplication.Selector.CMSApplication = new Class({
  4. Extends: MWF.xApplication.Selector.Identity,
  5. options: {
  6. "style": "default",
  7. "count": 0,
  8. "title": MWF.xApplication.Selector.LP.selectCMSApplication,
  9. "values": [],
  10. "names": [],
  11. "expand": false
  12. },
  13. loadSelectItems: function(addToNext){
  14. this.cmsAction.listCMSApplication(function(json){
  15. json.data.each(function(data){
  16. data.name = data.appName;
  17. var category = this._newItem(data, this, this.itemAreaNode);
  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.cmsAction.getCMSApplication(function(json){
  32. if(json.data)json.data.name = json.data.appName;
  33. if (callback) callback.apply(this, [json]);
  34. }.bind(this), failure, id, async);
  35. },
  36. _newItemSelected: function(data, selector, item){
  37. return new MWF.xApplication.Selector.CMSApplication.ItemSelected(data, selector, item)
  38. },
  39. _listItemByPinyin: function(callback, failure, key){
  40. return false;
  41. },
  42. _newItem: function(data, selector, container, level){
  43. return new MWF.xApplication.Selector.CMSApplication.Item(data, selector, container, level);
  44. }
  45. });
  46. MWF.xApplication.Selector.CMSApplication.Item = new Class({
  47. Extends: MWF.xApplication.Selector.Identity.Item,
  48. _getShowName: function(){
  49. return this.data.appName;
  50. },
  51. _setIcon: function(){
  52. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/applicationicon.png)");
  53. },
  54. loadSubItem: function(){
  55. return false;
  56. },
  57. getData: function(callback){
  58. if (callback) callback();
  59. },
  60. checkSelectedSingle: function(){
  61. var selectedItem = this.selector.options.values.filter(function(item, index){
  62. if (typeOf(item)==="object"){
  63. // return (this.data.id === item.id) || (this.data.name === item.name) ;
  64. if( this.data.id && item.id ){
  65. return this.data.id === item.id;
  66. }else{
  67. return this.data.name === item.name;
  68. }
  69. }
  70. if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
  71. return false;
  72. }.bind(this));
  73. if (selectedItem.length){
  74. this.selectedSingle();
  75. }
  76. },
  77. checkSelected: function(){
  78. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  79. //return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  80. if( item.data.id && this.data.id){
  81. return item.data.id === this.data.id;
  82. }else{
  83. return item.data.name === this.data.name;
  84. }
  85. }.bind(this));
  86. if (selectedItem.length){
  87. //selectedItem[0].item = this;
  88. selectedItem[0].addItem(this);
  89. this.selectedItem = selectedItem[0];
  90. this.setSelected();
  91. }
  92. }
  93. });
  94. MWF.xApplication.Selector.CMSApplication.ItemSelected = new Class({
  95. Extends: MWF.xApplication.Selector.Identity.ItemSelected,
  96. getData: function(callback){
  97. if (callback) callback();
  98. },
  99. _getShowName: function(){
  100. return this.data.name;
  101. },
  102. _setIcon: function(){
  103. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/applicationicon.png)");
  104. }
  105. });