filesizeplugin.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com>
  3. *
  4. * @license GNU AGPL version 3 or any later version
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU Affero General Public License as
  8. * published by the Free Software Foundation, either version 3 of the
  9. * License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU Affero General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Affero General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. *
  19. */
  20. (function() {
  21. OCA.WorkflowEngine = OCA.WorkflowEngine || {};
  22. OCA.WorkflowEngine.Plugins = OCA.WorkflowEngine.Plugins || {};
  23. OCA.WorkflowEngine.Plugins.FileSizePlugin = {
  24. getCheck: function() {
  25. return {
  26. 'class': 'OCA\\WorkflowEngine\\Check\\FileSize',
  27. 'name': t('workflowengine', 'File size (upload)'),
  28. 'operators': [
  29. {'operator': 'less', 'name': t('workflowengine', 'less')},
  30. {'operator': '!greater', 'name': t('workflowengine', 'less or equals')},
  31. {'operator': '!less', 'name': t('workflowengine', 'greater or equals')},
  32. {'operator': 'greater', 'name': t('workflowengine', 'greater')}
  33. ]
  34. };
  35. },
  36. render: function(element, check) {
  37. if (check['class'] !== 'OCA\\WorkflowEngine\\Check\\FileSize') {
  38. return;
  39. }
  40. var placeholder = '12 MB'; // Do not translate!!!
  41. $(element).css('width', '250px')
  42. .attr('placeholder', placeholder)
  43. .attr('title', t('workflowengine', 'Example: {placeholder}', {placeholder: placeholder}))
  44. .addClass('has-tooltip')
  45. .tooltip({
  46. placement: 'bottom'
  47. });
  48. }
  49. };
  50. })();
  51. OC.Plugins.register('OCA.WorkflowEngine.CheckPlugins', OCA.WorkflowEngine.Plugins.FileSizePlugin);