CMSApplication.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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") return (this.data.id === item.id) || (this.data.name === item.name) ;
  63. if (typeOf(item)==="string") return (this.data.id === item) || (this.data.name === item);
  64. return false;
  65. }.bind(this));
  66. if (selectedItem.length){
  67. this.selectedSingle();
  68. }
  69. },
  70. checkSelected: function(){
  71. var selectedItem = this.selector.selectedItems.filter(function(item, index){
  72. return (item.data.id === this.data.id) || (item.data.name === this.data.name);
  73. }.bind(this));
  74. if (selectedItem.length){
  75. //selectedItem[0].item = this;
  76. selectedItem[0].addItem(this);
  77. this.selectedItem = selectedItem[0];
  78. this.setSelected();
  79. }
  80. }
  81. });
  82. MWF.xApplication.Selector.CMSApplication.ItemSelected = new Class({
  83. Extends: MWF.xApplication.Selector.Identity.ItemSelected,
  84. getData: function(callback){
  85. if (callback) callback();
  86. },
  87. _getShowName: function(){
  88. return this.data.name;
  89. },
  90. _setIcon: function(){
  91. this.iconNode.setStyle("background-image", "url("+"/x_component_Selector/$Selector/default/icon/applicationicon.png)");
  92. }
  93. });