Skip to content

Commit 02dff47

Browse files
[PDF] Add button field options
1 parent 3834323 commit 02dff47

File tree

4 files changed

+89
-17
lines changed

4 files changed

+89
-17
lines changed

apps/pdfeditor/main/app/template/FormSettings.template

+3-3
Original file line numberDiff line numberDiff line change
@@ -162,14 +162,14 @@
162162
<label class="input-label" style=""><%= scope.textIcon %></label>
163163
<div id="form-btn-replace" style="width: 90px;"></div>
164164
</td>
165-
<td rowspan="2">
165+
<td rowspan="2" class="padding-small">
166166
<div class="texture-img float-right" style="width: 90px; height: 80px;">
167167
<div id="form-icon-img" style="width: 50px;height: 50px;"></div>
168168
</div>
169169
</td>
170170
</tr>
171171
<tr>
172-
<td style="vertical-align: bottom">
172+
<td class="padding-small" style="vertical-align: bottom">
173173
<div id="form-btn-clear" style="width: 90px;"></div>
174174
</td>
175175
</tr>
@@ -203,7 +203,7 @@
203203
</td>
204204
</tr>
205205
<tr>
206-
<td class="padding-large">
206+
<td class="padding-small">
207207
<div id="form-cnt-position" style="width: 100%;">
208208
<div class="row">
209209
<div id="form-img-position-preview">

apps/pdfeditor/main/app/view/FormSettings.js

+75
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,43 @@ define([
527527
setTimeout(function(){me.txtLabel._input && me.txtLabel._input.select();}, 1);
528528
});
529529

530+
this.btnSelectImage = new Common.UI.Button({
531+
parentEl: $markup.findById('#form-btn-replace'),
532+
cls: 'btn-text-menu-default',
533+
caption: this.textSelect,
534+
style: "width:100%;",
535+
menu: new Common.UI.Menu({
536+
style: 'min-width: 90px;',
537+
maxHeight: 200,
538+
items: [
539+
{caption: this.textFromFile, value: 0},
540+
{caption: this.textFromUrl, value: 1},
541+
{caption: this.textFromStorage, value: 2}
542+
]
543+
}),
544+
dataHint: '1',
545+
dataHintDirection: 'bottom',
546+
dataHintOffset: 'big'
547+
});
548+
this.lockedControls.push(this.btnSelectImage);
549+
this.btnSelectImage.menu.on('item:click', _.bind(this.onImageSelect, this));
550+
if (this.mode.canRequestInsertImage || this.mode.fileChoiceUrl && this.mode.fileChoiceUrl.indexOf("{documentType}")>-1) {
551+
Common.NotificationCenter.on('storage:image-insert', _.bind(this.insertImageFromStorage, this));
552+
} else
553+
this.btnSelectImage.menu.items[2].setVisible(false);
554+
555+
this.btnClear = new Common.UI.Button({
556+
parentEl: $markup.findById('#form-btn-clear'),
557+
cls : 'btn-text-default',
558+
style: "width:100%;",
559+
caption : this.textClear,
560+
dataHint : '1',
561+
dataHintDirection: 'left',
562+
dataHintOffset: 'small'
563+
});
564+
this.btnClear.on('click', _.bind(this.onImageClear, this));
565+
this.lockedControls.push(this.btnClear);
566+
530567
this.chFit = new Common.UI.CheckBox({
531568
el: $markup.findById('#form-chb-fit'),
532569
labelText: this.textFitBounds,
@@ -900,6 +937,42 @@ define([
900937
}
901938
},
902939

940+
onImageClear: function() {
941+
if (this.api && !this._noApply) {
942+
this._originalSpecProps && this._originalSpecProps.put_ImageUrl(null, this._state.State);
943+
}
944+
},
945+
946+
insertImageFromStorage: function(data) {
947+
if (data && data._urls && data.c=='control') {
948+
this._originalSpecProps && this._originalSpecProps.put_ImageUrl(data._urls[0], this._state.State);
949+
}
950+
},
951+
952+
onImageSelect: function(menu, item) {
953+
if (item.value==1) {
954+
var me = this;
955+
(new Common.Views.ImageFromUrlDialog({
956+
handler: function(result, value) {
957+
if (result == 'ok') {
958+
if (me._originalSpecProps) {
959+
var checkUrl = value.replace(/ /g, '');
960+
if (!_.isEmpty(checkUrl)) {
961+
me._originalSpecProps.put_ImageUrl(checkUrl, me._state.State);
962+
}
963+
}
964+
}
965+
me.fireEvent('editcomplete', me);
966+
}
967+
})).show();
968+
} else if (item.value==2) {
969+
Common.NotificationCenter.trigger('storage:image-load', 'control');
970+
} else {
971+
this._originalSpecProps && this._originalSpecProps.showFileDialog(this._state.State);
972+
this.fireEvent('editcomplete', this);
973+
}
974+
},
975+
903976
onChFit: function(field, newValue, oldValue, eOpts){
904977
if (this.api && !this._noApply) {
905978
this.api.SetButtonFieldFitBounds(field.getValue()==='checked');
@@ -1205,6 +1278,8 @@ define([
12051278
}
12061279

12071280
if (layout!==AscPDF.Api.Types.position.textOnly) {
1281+
specProps.put_DivId('form-icon-img');
1282+
12081283
val = specProps.asc_getScaleWhen();
12091284
if (this._state.Scale!==val) {
12101285
this.cmbScale.setValue(val, '');

apps/pdfeditor/main/locale/en.json

+4
Original file line numberDiff line numberDiff line change
@@ -1453,6 +1453,10 @@
14531453
"PDFE.Views.FormSettings.textNormal": "Up",
14541454
"PDFE.Views.FormSettings.textDown": "Down",
14551455
"PDFE.Views.FormSettings.textHover": "Rollover",
1456+
"PDFE.Views.FormSettings.textClear": "Clear",
1457+
"PDFE.Views.FormSettings.textFromFile": "From file",
1458+
"PDFE.Views.FormSettings.textFromStorage": "From storage",
1459+
"PDFE.Views.FormSettings.textFromUrl": "From URL",
14561460
"PDFE.Views.FormsTab.capBtnCheckBox": "Checkbox",
14571461
"PDFE.Views.FormsTab.capBtnComboBox": "Combo Box",
14581462
"PDFE.Views.FormsTab.capBtnDownloadForm": "Download As PDF",

apps/pdfeditor/main/resources/less/rightmenu.less

+7-14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
}
1212
}
1313

14+
.texture-img {
15+
padding: 14px 20px;
16+
border: 1px solid #AFAFAF;
17+
border-radius: 2px;
18+
background: #ffffff;
19+
}
20+
1421
&#id-shape-settings {
1522
#shape-spin-transparency, #shape-line-spin-transparency {
1623
display: inline-block;
@@ -34,13 +41,6 @@
3441
margin-bottom: 3px;
3542
}
3643

37-
.texture-img {
38-
padding: 14px 20px;
39-
border: 1px solid #AFAFAF;
40-
border-radius: 2px;
41-
background: #ffffff;
42-
}
43-
4444
#shape-foreground-color-btn, #shape-background-color-btn {
4545
display: inline-block;
4646
}
@@ -102,13 +102,6 @@
102102
margin-bottom: 3px;
103103
}
104104

105-
.texture-img {
106-
padding: 14px 20px;
107-
border: 1px solid #AFAFAF;
108-
border-radius: 2px;
109-
background: #ffffff;
110-
}
111-
112105
#textart-foreground-color-btn, #textart-background-color-btn {
113106
display: inline-block;
114107
}

0 commit comments

Comments
 (0)