text_widget.js 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /**
  2. * Licensed to the Apache Software Foundation (ASF) under one
  3. * or more contributor license agreements. See the NOTICE file
  4. * distributed with this work for additional information
  5. * regarding copyright ownership. The ASF licenses this file
  6. * to you under the Apache License, Version 2.0 (the
  7. * "License"); you may not use this file except in compliance
  8. * with the License. You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. var App = require('app');
  19. var date = require('utils/date/date');
  20. App.TextDashboardWidgetView = App.DashboardWidgetView.extend({
  21. templateName: require('templates/main/dashboard/widgets/simple_text'),
  22. classNameBindings: ['isRed', 'isOrange', 'isGreen', 'isNA'],
  23. isRed: Em.computed.lteProperties('data', 'thresh1'),
  24. isOrange: Em.computed.and('!isGreen', '!isRed'),
  25. isGreen: Em.computed.gtProperties('data', 'thresh2'),
  26. isNA: function () {
  27. return this.get('data') === null;
  28. }.property('data'),
  29. hiddenInfo: [],
  30. thresh1: null,
  31. thresh2: null,
  32. maxValue: null,
  33. updateColors: function(handlers, colors) {
  34. var colorstops = colors[0] + ", "; // start with the first color
  35. for (var i = 0; i < handlers.length; i++) {
  36. colorstops += colors[i] + " " + handlers[i] + "%,";
  37. colorstops += colors[i+1] + " " + handlers[i] + "%,";
  38. }
  39. colorstops += colors[colors.length - 1];
  40. var cssForChromeAndSafari = '-webkit-linear-gradient(left,' + colorstops + ')'; // chrome & safari
  41. var slider = $('#slider-range');
  42. slider.css('background-image', cssForChromeAndSafari);
  43. var cssForIE = '-ms-linear-gradient(left,' + colorstops + ')'; // IE 10+
  44. slider.css('background-image', cssForIE);
  45. //$('#slider-range').css('filter', 'progid:DXImageTransform.Microsoft.gradient( startColorStr= ' + colors[0] + ', endColorStr= ' + colors[2] +', GradientType=1 )' ); // IE 10-
  46. var cssForFireFox = '-moz-linear-gradient(left,' + colorstops + ')'; // Firefox
  47. slider.css('background-image', cssForFireFox);
  48. slider.find('.ui-widget-header').css({'background-color': '#FF8E00', 'background-image': 'none'}); // change the original ranger color
  49. }
  50. });