Browse Source

Update slider property

pull/330/head
Artur Arseniev 9 years ago
parent
commit
7bda70df25
  1. 2
      dist/css/grapes.min.css
  2. 1
      index.html
  3. 14
      src/style_manager/view/PropertyIntegerView.js
  4. 46
      src/style_manager/view/PropertySliderView.js
  5. 4
      src/style_manager/view/PropertyView.js
  6. 8
      src/styles/scss/_gjs_inputs.scss

2
dist/css/grapes.min.css

File diff suppressed because one or more lines are too long

1
index.html

@ -1041,6 +1041,7 @@
properties: [{
type: 'slider',
property: 'opacity',
defaults: 1,
step: 0.01,
max: 1,
min:0,

14
src/style_manager/view/PropertyIntegerView.js

@ -2,13 +2,8 @@ const InputNumber = require('domain_abstract/ui/InputNumber');
module.exports = require('./PropertyView').extend({
template(model) {
const pfx = this.pfx;
return `
<div class="${pfx}label">
${this.templateLabel(model)}
</div>
`;
templateInput() {
return '';
},
init() {
@ -22,13 +17,16 @@ module.exports = require('./PropertyView').extend({
},
onRender() {
const ppfx = this.ppfx;
if (!this.input) {
const inputNumber = new InputNumber({
model: this.model,
ppfx: this.ppfx
});
const input = inputNumber.render();
this.$el.append(input.$el);
const fields = this.el.querySelector(`.${ppfx}fields`);
fields.appendChild(input.el);
this.$input = input.inputEl;
this.$unit = input.unitEl;
this.input = this.$input.get(0);

46
src/style_manager/view/PropertySliderView.js

@ -1,37 +1,24 @@
const InputNumber = require('domain_abstract/ui/InputNumber');
module.exports = require('./PropertyView').extend({
module.exports = require('./PropertyIntegerView').extend({
events: {
'change': 'inputValueChanged',
'input': 'inputValueChangedSoft',
},
template(model) {
const pfx = this.pfx;
templateInput(model) {
const ppfx = this.ppfx;
return `
<div class="${pfx}label">
${this.templateLabel(model)}
</div>
<div class="${ppfx}fields">
<div class="${ppfx}field ${ppfx}field-range">
<input type="range"
min="${model.get('min')}"
max="${model.get('max')}"
step="${model.get('step')}"/>
</div>
<div class="${ppfx}field ${ppfx}field-range">
<input type="range"
min="${model.get('min')}"
max="${model.get('max')}"
step="${model.get('step')}"/>
</div>
`;
},
init() {
console.log('Init slider');
const model = this.model;
this.listenTo(model, 'change:unit', this.modelValueChanged);
this.listenTo(model, 'el:change', this.elementUpdated);
},
getSliderEl() {
if (!this.slider) {
this.slider = this.el.querySelector('input[type=range]');
@ -56,24 +43,7 @@ module.exports = require('./PropertyView').extend({
},
setValue(value) {
this.getSliderEl().value = value;
this.inputInst.setValue(value, {silent: 1});
},
onRender() {
const ppfx = this.ppfx;
if (!this.input) {
const inputNumber = new InputNumber({
model: this.model,
ppfx: this.ppfx
});
const input = inputNumber.render();
this.$el.find(`.${ppfx}fields`).append(input.$el);
this.$input = input.inputEl;
this.$unit = input.unitEl;
this.input = this.$input.get(0);
this.inputInst = input;
}
},
});

4
src/style_manager/view/PropertyView.js

@ -8,7 +8,9 @@ module.exports = Backbone.View.extend({
<div class="${pfx}label">
${this.templateLabel(model)}
</div>
${this.templateInput(model)}
<div class="${this.ppfx}fields">
${this.templateInput(model)}
</div>
`;
},

8
src/styles/scss/_gjs_inputs.scss

@ -20,6 +20,10 @@
line-height: 18px;
}
.#{$app-prefix}fields {
display: flex;
}
.#{$app-prefix}field {
background-color: $mainDkColor;
border: none;
@ -43,6 +47,10 @@
position: relative;
padding: $inputPadding;
z-index: 1;
&:focus {
outline: none;
}
}
textarea {

Loading…
Cancel
Save