scale.js 1.2 KB

12345678910111213141516171819202122232425262728293031
  1. export default (function () {
  2. function t() {
  3. // json模板 options 对应键值 key
  4. this.name = "scale";
  5. }
  6. // 涉及修改元素样式, 添加一个 css 方法
  7. // t: 元素对象, e 参数值
  8. return t.prototype.css = function (t, e) {
  9. if (t && t.length) {
  10. if (e) return t.css('transform', 'scale(' + e + ')');
  11. }
  12. return null;
  13. },
  14. // 创建 DOM
  15. t.prototype.createTarget = function (t, i, e) { // t: 元素对象,i: 元素options, e: 元素printElementType
  16. return this.target = $('<div class="hiprint-option-item">\n <div class="hiprint-option-item-label">\n 缩放\n </div>\n <div class="hiprint-option-item-field">\n <input type="number" value="1" step="0.1" min="0.1" max="3" class="auto-submit"/>\n </div>\n </div>'), this.target;
  17. },
  18. // 获取值
  19. t.prototype.getValue = function () {
  20. var t = this.target.find("input").val();
  21. if (t) return parseFloat(t.toString());
  22. },
  23. // 设置值
  24. t.prototype.setValue = function (t) { // t: options 对应键的值
  25. this.target.find("input").val(t);
  26. },
  27. // 销毁 DOM
  28. t.prototype.destroy = function () {
  29. this.target.remove();
  30. }, t;
  31. }())