Edit functions in Utils
This commit is contained in:
parent
93ba07adeb
commit
8a0ade63f5
|
@ -379,10 +379,12 @@ var metrics = new(function() {
|
||||||
return me.defaultMetric;
|
return me.defaultMetric;
|
||||||
},
|
},
|
||||||
|
|
||||||
fnRecalcToMM: function(value) {
|
fnRecalcToMM: function(value, unit) {
|
||||||
// value in pt/cm/inch. need to convert to mm
|
// value in pt/cm/inch. need to convert to mm
|
||||||
|
if(unit==undefined)
|
||||||
|
unrt=me.currentMetric
|
||||||
if (value!==null && value!==undefined) {
|
if (value!==null && value!==undefined) {
|
||||||
switch (me.currentMetric) {
|
switch (unit) {
|
||||||
case me.c_MetricUnits.cm:
|
case me.c_MetricUnits.cm:
|
||||||
return value * 10;
|
return value * 10;
|
||||||
case me.c_MetricUnits.pt:
|
case me.c_MetricUnits.pt:
|
||||||
|
@ -394,9 +396,11 @@ var metrics = new(function() {
|
||||||
return value;
|
return value;
|
||||||
},
|
},
|
||||||
|
|
||||||
fnRecalcFromMM: function(value) {
|
fnRecalcFromMM: function(value, unit) {
|
||||||
// value in mm. need to convert to pt/cm/inch
|
// value in mm. need to convert to pt/cm/inch
|
||||||
switch (me.currentMetric) {
|
if(unit==undefined)
|
||||||
|
unrt=me.currentMetric
|
||||||
|
switch (unit) {
|
||||||
case me.c_MetricUnits.cm:
|
case me.c_MetricUnits.cm:
|
||||||
return parseFloat((value/10.).toFixed(4));
|
return parseFloat((value/10.).toFixed(4));
|
||||||
case me.c_MetricUnits.pt:
|
case me.c_MetricUnits.pt:
|
||||||
|
|
|
@ -89,9 +89,9 @@ define([
|
||||||
this.isChart = false;
|
this.isChart = false;
|
||||||
|
|
||||||
this._arrLineRule = [
|
this._arrLineRule = [
|
||||||
{displayValue: this.textAtLeast,defaultValue: 4.24, value: c_paragraphLinerule.LINERULE_LEAST, minValue: 0.03, step: 0.01, defaultUnit: 'pt'},
|
{displayValue: this.textAtLeast,defaultValue: 4.24, value: c_paragraphLinerule.LINERULE_LEAST, minValue: 0.03, step: 1, defaultUnit: 'pt'},
|
||||||
{displayValue: this.textAuto, defaultValue: 1.08, value: c_paragraphLinerule.LINERULE_AUTO, minValue: 0.5, step: 0.01, defaultUnit: ''},
|
{displayValue: this.textAuto, defaultValue: 1, value: c_paragraphLinerule.LINERULE_AUTO, minValue: 0.5, step: 0.01, defaultUnit: ''},
|
||||||
{displayValue: this.textExact, defaultValue: 4.24, value: c_paragraphLinerule.LINERULE_EXACT, minValue: 0.03, step: 0.01, defaultUnit: 'pt'}
|
{displayValue: this.textExact, defaultValue: 4.24, value: c_paragraphLinerule.LINERULE_EXACT, minValue: 0.03, step: 1, defaultUnit: 'pt'}
|
||||||
];
|
];
|
||||||
|
|
||||||
this._arrSpecial = [
|
this._arrSpecial = [
|
||||||
|
@ -136,11 +136,11 @@ define([
|
||||||
|
|
||||||
this.numSpacingBefore = new Common.UI.MetricSpinner({
|
this.numSpacingBefore = new Common.UI.MetricSpinner({
|
||||||
el: $markup.findById('#paragraph-spin-spacing-before'),
|
el: $markup.findById('#paragraph-spin-spacing-before'),
|
||||||
step: .1,
|
step: 1,
|
||||||
width: 85,
|
width: 85,
|
||||||
value: '',
|
value: '',
|
||||||
defaultUnit : "cm",
|
defaultUnit : "pt",
|
||||||
maxValue: 55.88,
|
maxValue: 1584,
|
||||||
minValue: 0,
|
minValue: 0,
|
||||||
allowAuto : true,
|
allowAuto : true,
|
||||||
autoText : this.txtAutoText,
|
autoText : this.txtAutoText,
|
||||||
|
@ -151,11 +151,11 @@ define([
|
||||||
|
|
||||||
this.numSpacingAfter = new Common.UI.MetricSpinner({
|
this.numSpacingAfter = new Common.UI.MetricSpinner({
|
||||||
el: $markup.findById('#paragraph-spin-spacing-after'),
|
el: $markup.findById('#paragraph-spin-spacing-after'),
|
||||||
step: .1,
|
step: 1,
|
||||||
width: 85,
|
width: 85,
|
||||||
value: '',
|
value: '',
|
||||||
defaultUnit : "cm",
|
defaultUnit : "pt",
|
||||||
maxValue: 55.88,
|
maxValue: 1584,
|
||||||
minValue: 0,
|
minValue: 0,
|
||||||
allowAuto : true,
|
allowAuto : true,
|
||||||
autoText : this.txtAutoText,
|
autoText : this.txtAutoText,
|
||||||
|
@ -275,14 +275,14 @@ define([
|
||||||
return;
|
return;
|
||||||
var type = c_paragraphLinerule.LINERULE_AUTO;
|
var type = c_paragraphLinerule.LINERULE_AUTO;
|
||||||
if (this.api)
|
if (this.api)
|
||||||
this.api.put_PrLineSpacing(this.cmbLineRule.getValue(), (this.cmbLineRule.getValue()==c_paragraphLinerule.LINERULE_AUTO) ? field.getNumberValue() : field.getNumberValue()* 25.4 / 72.0);
|
// this.api.put_PrLineSpacing(this.cmbLineRule.getValue(), (this.cmbLineRule.getValue()==c_paragraphLinerule.LINERULE_AUTO) ? field.getNumberValue() : field.getNumberValue()* 25.4 / 72.0);
|
||||||
// this.api.put_PrLineSpacing(this.cmbLineRule.getValue(), (this.cmbLineRule.getValue()==c_paragraphLinerule.LINERULE_AUTO) ? field.getNumberValue() : Common.Utils.Metric.fnRecalcToMM(field.getNumberValue()));
|
this.api.put_PrLineSpacing(this.cmbLineRule.getValue(), (this.cmbLineRule.getValue()==c_paragraphLinerule.LINERULE_AUTO) ? field.getNumberValue() : Common.Utils.Metric.fnRecalcToMM(field.getNumberValue(),Common.Utils.Metric.c_MetricUnits.pt));
|
||||||
},
|
},
|
||||||
|
|
||||||
onNumSpacingBeforeChange: function(field, newValue, oldValue, eOpts){
|
onNumSpacingBeforeChange: function(field, newValue, oldValue, eOpts){
|
||||||
if (this.api) {
|
if (this.api) {
|
||||||
var num = field.getNumberValue();
|
var num = field.getNumberValue();
|
||||||
this._state.LineSpacingBefore = (num<0) ? -1 : Common.Utils.Metric.fnRecalcToMM(num);
|
this._state.LineSpacingBefore = (num<0) ? -1 : Common.Utils.Metric.fnRecalcToMM(num,Common.Utils.Metric.c_MetricUnits.pt);
|
||||||
this.api.put_LineSpacingBeforeAfter(0, this._state.LineSpacingBefore);
|
this.api.put_LineSpacingBeforeAfter(0, this._state.LineSpacingBefore);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -290,7 +290,7 @@ define([
|
||||||
onNumSpacingAfterChange: function(field, newValue, oldValue, eOpts){
|
onNumSpacingAfterChange: function(field, newValue, oldValue, eOpts){
|
||||||
if (this.api){
|
if (this.api){
|
||||||
var num = field.getNumberValue();
|
var num = field.getNumberValue();
|
||||||
this._state.LineSpacingAfter = (num<0) ? -1 : Common.Utils.Metric.fnRecalcToMM(num);
|
this._state.LineSpacingAfter = (num<0) ? -1 : Common.Utils.Metric.fnRecalcToMM(num,Common.Utils.Metric.c_MetricUnits.pt);
|
||||||
this.api.put_LineSpacingBeforeAfter(1, this._state.LineSpacingAfter);
|
this.api.put_LineSpacingBeforeAfter(1, this._state.LineSpacingAfter);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -329,8 +329,8 @@ define([
|
||||||
if ( linerule == c_paragraphLinerule.LINERULE_AUTO ) {
|
if ( linerule == c_paragraphLinerule.LINERULE_AUTO ) {
|
||||||
val = line;
|
val = line;
|
||||||
} else if (linerule !== null && line !== null ) {
|
} else if (linerule !== null && line !== null ) {
|
||||||
//val = Common.Utils.Metric.fnRecalcFromMM(line);
|
val = Common.Utils.Metric.fnRecalcFromMM(line, Common.Utils.Metric.c_MetricUnits.pt);
|
||||||
val=parseFloat((line * 72.0 / 25.4).toFixed(3));
|
//val=parseFloat((line * 72.0 / 25.4).toFixed(3));
|
||||||
}
|
}
|
||||||
this.numLineHeight.setValue((val !== null) ? val : '', true);
|
this.numLineHeight.setValue((val !== null) ? val : '', true);
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ define([
|
||||||
if ( Spacing.LineRule == c_paragraphLinerule.LINERULE_AUTO ) {
|
if ( Spacing.LineRule == c_paragraphLinerule.LINERULE_AUTO ) {
|
||||||
val = Spacing.Line;
|
val = Spacing.Line;
|
||||||
} else if (Spacing.LineRule !== null && Spacing.Line !== null ) {
|
} else if (Spacing.LineRule !== null && Spacing.Line !== null ) {
|
||||||
val = Common.Utils.Metric.fnRecalcFromMM(Spacing.Line);
|
val = Common.Utils.Metric.fnRecalcFromMM(Spacing.Line, Common.Utils.Metric.c_MetricUnits.pt);
|
||||||
}
|
}
|
||||||
this.numLineHeight.setValue((val !== null) ? val : '', true);
|
this.numLineHeight.setValue((val !== null) ? val : '', true);
|
||||||
|
|
||||||
|
@ -463,14 +463,14 @@ define([
|
||||||
if ( Math.abs(this._state.LineSpacingBefore-Spacing.Before)>0.001 ||
|
if ( Math.abs(this._state.LineSpacingBefore-Spacing.Before)>0.001 ||
|
||||||
(this._state.LineSpacingBefore===null || Spacing.Before===null)&&(this._state.LineSpacingBefore!==Spacing.Before)) {
|
(this._state.LineSpacingBefore===null || Spacing.Before===null)&&(this._state.LineSpacingBefore!==Spacing.Before)) {
|
||||||
|
|
||||||
this.numSpacingBefore.setValue((Spacing.Before !== null) ? ((Spacing.Before<0) ? Spacing.Before : Common.Utils.Metric.fnRecalcFromMM(Spacing.Before) ) : '', true);
|
this.numSpacingBefore.setValue((Spacing.Before !== null) ? ((Spacing.Before<0) ? Spacing.Before : Common.Utils.Metric.fnRecalcFromMM(Spacing.Before, Common.Utils.Metric.c_MetricUnits.pt) ) : '', true);
|
||||||
this._state.LineSpacingBefore=Spacing.Before;
|
this._state.LineSpacingBefore=Spacing.Before;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Math.abs(this._state.LineSpacingAfter-Spacing.After)>0.001 ||
|
if ( Math.abs(this._state.LineSpacingAfter-Spacing.After)>0.001 ||
|
||||||
(this._state.LineSpacingAfter===null || Spacing.After===null)&&(this._state.LineSpacingAfter!==Spacing.After)) {
|
(this._state.LineSpacingAfter===null || Spacing.After===null)&&(this._state.LineSpacingAfter!==Spacing.After)) {
|
||||||
|
|
||||||
this.numSpacingAfter.setValue((Spacing.After !== null) ? ((Spacing.After<0) ? Spacing.After : Common.Utils.Metric.fnRecalcFromMM(Spacing.After) ) : '', true);
|
this.numSpacingAfter.setValue((Spacing.After !== null) ? ((Spacing.After<0) ? Spacing.After : Common.Utils.Metric.fnRecalcFromMM(Spacing.After, Common.Utils.Metric.c_MetricUnits.pt) ) : '', true);
|
||||||
this._state.LineSpacingAfter=Spacing.After;
|
this._state.LineSpacingAfter=Spacing.After;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -554,17 +554,16 @@ define([
|
||||||
for (var i=0; i<this.spinners.length; i++) {
|
for (var i=0; i<this.spinners.length; i++) {
|
||||||
var spinner = this.spinners[i];
|
var spinner = this.spinners[i];
|
||||||
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
|
spinner.setDefaultUnit(Common.Utils.Metric.getCurrentMetricName());
|
||||||
if (spinner.el.id == 'paragraphadv-spin-position' || spinner.el.id == 'paragraph-spin-spacing-before' || spinner.el.id == 'paragraph-spin-spacing-after')
|
if(spinner.el.id == 'paragraph-spin-spacing-before' || spinner.el.id == 'paragraph-spin-spacing-after')
|
||||||
|
spinner.setDefaultUnit( Common.Utils.Metric.getMetricName(Common.Utils.Metric.c_MetricUnits.pt));
|
||||||
|
if (spinner.el.id == 'paragraphadv-spin-position' )
|
||||||
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.01);
|
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.01);
|
||||||
|
else if( spinner.el.id == 'paragraph-spin-spacing-before' || spinner.el.id == 'paragraph-spin-spacing-after')
|
||||||
|
spinner.setStep(1);
|
||||||
else
|
else
|
||||||
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.1);
|
spinner.setStep(Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt ? 1 : 0.1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//this._arrLineRule[2].defaultUnit = this._arrLineRule[0].defaultUnit = Common.Utils.Metric.getCurrentMetricName();
|
|
||||||
//this._arrLineRule[2].minValue = this._arrLineRule[0].minValue = parseFloat(parseFloat((0.3 * 72.0 / 25.4).toFixed(3)).toFixed(2));
|
|
||||||
//this._arrLineRule[2].minValue = this._arrLineRule[0].minValue = parseFloat(Common.Utils.Metric.fnRecalcFromMM(0.3).toFixed(2));
|
|
||||||
//this._arrLineRule[2].step = this._arrLineRule[0].step = (Common.Utils.Metric.getCurrentMetric()==Common.Utils.Metric.c_MetricUnits.pt) ? 1 : 0.01;
|
|
||||||
//this._arrLineRule[2].step = this._arrLineRule[0].step = 1;
|
|
||||||
|
|
||||||
if (this._state.LineRuleIdx !== null) {
|
if (this._state.LineRuleIdx !== null) {
|
||||||
this.numLineHeight.setDefaultUnit(this._arrLineRule[this._state.LineRuleIdx].defaultUnit);
|
this.numLineHeight.setDefaultUnit(this._arrLineRule[this._state.LineRuleIdx].defaultUnit);
|
||||||
|
@ -574,16 +573,15 @@ define([
|
||||||
val = this._state.LineHeight;
|
val = this._state.LineHeight;
|
||||||
} else if (this._state.LineHeight !== null ) {
|
} else if (this._state.LineHeight !== null ) {
|
||||||
|
|
||||||
val = parseFloat((this._state.LineHeight* 72.0 / 25.4).toFixed(3));
|
val = Common.Utils.Metric.fnRecalcFromMM(this._state.LineHeight,Common.Utils.Metric.c_MetricUnits.pt);
|
||||||
//val = Common.Utils.Metric.fnRecalcFromMM(this._state.LineHeight);
|
|
||||||
}
|
}
|
||||||
this.numLineHeight && this.numLineHeight.setValue((val !== null) ? val : '', true);
|
this.numLineHeight && this.numLineHeight.setValue((val !== null) ? val : '', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
var val = this._state.LineSpacingBefore;
|
var val = this._state.LineSpacingBefore;
|
||||||
this.numSpacingBefore && this.numSpacingBefore.setValue((val !== null) ? ((val<0) ? val : Common.Utils.Metric.fnRecalcFromMM(val) ) : '', true);
|
this.numSpacingBefore && this.numSpacingBefore.setValue((val !== null) ? ((val<0) ? val : Common.Utils.Metric.fnRecalcFromMM(val, Common.Utils.Metric.c_MetricUnits.pt) ) : '', true);
|
||||||
val = this._state.LineSpacingAfter;
|
val = this._state.LineSpacingAfter;
|
||||||
this.numSpacingAfter && this.numSpacingAfter.setValue((val !== null) ? ((val<0) ? val : Common.Utils.Metric.fnRecalcFromMM(val) ) : '', true);
|
this.numSpacingAfter && this.numSpacingAfter.setValue((val !== null) ? ((val<0) ? val : Common.Utils.Metric.fnRecalcFromMM(val, Common.Utils.Metric.c_MetricUnits.pt) ) : '', true);
|
||||||
},
|
},
|
||||||
|
|
||||||
createDelayedElements: function() {
|
createDelayedElements: function() {
|
||||||
|
|
Loading…
Reference in a new issue