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: [{ properties: [{
type: 'slider', type: 'slider',
property: 'opacity', property: 'opacity',
defaults: 1,
step: 0.01, step: 0.01,
max: 1, max: 1,
min:0, 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({ module.exports = require('./PropertyView').extend({
template(model) { templateInput() {
const pfx = this.pfx; return '';
return `
<div class="${pfx}label">
${this.templateLabel(model)}
</div>
`;
}, },
init() { init() {
@ -22,13 +17,16 @@ module.exports = require('./PropertyView').extend({
}, },
onRender() { onRender() {
const ppfx = this.ppfx;
if (!this.input) { if (!this.input) {
const inputNumber = new InputNumber({ const inputNumber = new InputNumber({
model: this.model, model: this.model,
ppfx: this.ppfx ppfx: this.ppfx
}); });
const input = inputNumber.render(); 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.$input = input.inputEl;
this.$unit = input.unitEl; this.$unit = input.unitEl;
this.input = this.$input.get(0); this.input = this.$input.get(0);

46
src/style_manager/view/PropertySliderView.js

@ -1,37 +1,24 @@
const InputNumber = require('domain_abstract/ui/InputNumber'); const InputNumber = require('domain_abstract/ui/InputNumber');
module.exports = require('./PropertyView').extend({ module.exports = require('./PropertyIntegerView').extend({
events: { events: {
'change': 'inputValueChanged', 'change': 'inputValueChanged',
'input': 'inputValueChangedSoft', 'input': 'inputValueChangedSoft',
}, },
template(model) { templateInput(model) {
const pfx = this.pfx;
const ppfx = this.ppfx; const ppfx = this.ppfx;
return ` return `
<div class="${pfx}label"> <div class="${ppfx}field ${ppfx}field-range">
${this.templateLabel(model)} <input type="range"
</div> min="${model.get('min')}"
<div class="${ppfx}fields"> max="${model.get('max')}"
<div class="${ppfx}field ${ppfx}field-range"> step="${model.get('step')}"/>
<input type="range"
min="${model.get('min')}"
max="${model.get('max')}"
step="${model.get('step')}"/>
</div>
</div> </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() { getSliderEl() {
if (!this.slider) { if (!this.slider) {
this.slider = this.el.querySelector('input[type=range]'); this.slider = this.el.querySelector('input[type=range]');
@ -56,24 +43,7 @@ module.exports = require('./PropertyView').extend({
}, },
setValue(value) { setValue(value) {
this.getSliderEl().value = value;
this.inputInst.setValue(value, {silent: 1}); 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"> <div class="${pfx}label">
${this.templateLabel(model)} ${this.templateLabel(model)}
</div> </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; line-height: 18px;
} }
.#{$app-prefix}fields {
display: flex;
}
.#{$app-prefix}field { .#{$app-prefix}field {
background-color: $mainDkColor; background-color: $mainDkColor;
border: none; border: none;
@ -43,6 +47,10 @@
position: relative; position: relative;
padding: $inputPadding; padding: $inputPadding;
z-index: 1; z-index: 1;
&:focus {
outline: none;
}
} }
textarea { textarea {

Loading…
Cancel
Save