CustomPalettesFlyout.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * Licensed Materials - Property of IBM
  3. *
  4. * IBM Cognos Products: BI Glass
  5. *
  6. * Copyright IBM Corp. 2018
  7. *
  8. * US Government Users Restricted Rights - Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
  9. */
  10. define(['lib/@waca/core-client/js/core-client/ui/core/View', 'authoring-common'],
  11. function(View, AC) {
  12. var CustomPalettesFlyout = View.extend({
  13. open: function(){
  14. this.palettesView.render();
  15. },
  16. paletteCreated: function(paletteId){
  17. if(paletteId){
  18. this.fn_applyCreatedPalette(paletteId);
  19. // the returned paletteId is used by ChangePaletteView to update selection
  20. return paletteId;
  21. }
  22. },
  23. paletteSelected: function(propName, paletteDef){
  24. if(paletteDef && paletteDef.id){
  25. this.fn_applyPalette(paletteDef);
  26. }
  27. },
  28. closeFlyout: function(){
  29. this.fn_hide();
  30. },
  31. init: function(options){
  32. this.fn_applyPalette = options.fn_applyPalette;
  33. this.fn_applyCreatedPalette = options.fn_applyCreatedPalette;
  34. this.fn_hide = options.fn_hide;
  35. // why is this here??
  36. options.slideout.$el[0].style.borderLeft = '1px solid #BEBEBE';
  37. var paletteViewOptions = {
  38. name: 'colorPalette',
  39. el: options.slideout.$el[0],
  40. glassContext: options.glassContext,
  41. getPalettes: options.fn_getPalettes,
  42. slideout: options.slideout,
  43. selectedId: options.selectedPalette,
  44. createPaletteType: options.paletteType,
  45. onCreatePalette: this.paletteCreated.bind(this),
  46. onChange: this.paletteSelected.bind(this)
  47. };
  48. this.palettesView = new AC.ChangePaletteView(paletteViewOptions);
  49. if(this.palettesView)
  50. {
  51. this.open();
  52. }
  53. }
  54. });
  55. return CustomPalettesFlyout;
  56. });