',
'
',
'',
'',
'
',
'
',
'
',
- '',
+ '',
'
',
'
',
'
',
'
',
'
',
- '',
- '',
- '
',
- '
',
+ '
',
+ '
',
'
',
'
',
'',
@@ -124,13 +122,6 @@ define([
});
me.btnInternal.on('click', _.bind(me.onLinkTypeClick, me, Asc.c_oAscHyperlinkType.RangeLink));
- me.cmbSheets = new Common.UI.ComboBox({
- el : $('#id-dlg-hyperlink-sheet'),
- cls : 'input-group-nr',
- editable: false,
- menuStyle: 'min-width: 100%;max-height: 150px;'
- });
-
me.inputUrl = new Common.UI.InputField({
el : $('#id-dlg-hyperlink-url'),
allowBlank : false,
@@ -143,6 +134,13 @@ define([
return (urltype>0) ? true : me.txtNotUrl;
}
});
+ me.inputUrl._input.on('input', function (e) {
+ me.isInputFirstChange_url && me.inputUrl.showError();
+ me.isInputFirstChange_url = false;
+ var val = $(e.target).val();
+ me.isAutoUpdate && me.inputDisplay.setValue(val);
+ me.btnOk.setDisabled($.trim(val)=='');
+ });
me.inputRange = new Common.UI.InputField({
el : $('#id-dlg-hyperlink-range'),
@@ -153,6 +151,8 @@ define([
validateOnBlur: false,
value: Common.Utils.InternalSettings.get("sse-settings-r1c1") ? 'R1C1' : 'A1',
validation : function(value) {
+ if (me.inputRange.isDisabled()) // named range
+ return true;
var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.FormatTable, value, false);
if (isvalid == Asc.c_oAscError.ID.No) {
return true;
@@ -161,6 +161,13 @@ define([
}
}
});
+ me.inputRange._input.on('input', function (e) {
+ me.isInputFirstChange_range && me.inputRange.showError();
+ me.isInputFirstChange_range = false;
+ var val = $(e.target).val();
+ me.isAutoUpdate && me.inputDisplay.setValue(me.internalList.getSelectedRec().get('name') + (val!=='' ? '!' + val : ''));
+ me.btnOk.setDisabled($.trim(val)=='');
+ });
me.inputDisplay = new Common.UI.InputField({
el : $('#id-dlg-hyperlink-display'),
@@ -168,6 +175,9 @@ define([
validateOnBlur: false,
style : 'width: 100%;'
});
+ me.inputDisplay._input.on('input', function (e) {
+ me.isAutoUpdate = ($(e.target).val()=='');
+ });
me.inputTip = new Common.UI.InputField({
el : $('#id-dlg-hyperlink-tip'),
@@ -175,8 +185,20 @@ define([
maxLength : Asc.c_oAscMaxTooltipLength
});
- $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
+ me.internalList = new Common.UI.TreeView({
+ el: $('#id-dlg-hyperlink-list'),
+ store: new Common.UI.TreeViewStore(),
+ enableKeyEvents: true
+ });
+ me.internalList.on('item:select', _.bind(this.onSelectItem, this));
+ me.btnOk = new Common.UI.Button({
+ el: $window.find('.primary'),
+ disabled: true
+ });
+
+ $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
+ me.internalList.on('entervalue', _.bind(me.onPrimary, me));
me.externalPanel = $window.find('#id-external-link');
me.internalPanel = $window.find('#id-internal-link');
},
@@ -193,45 +215,61 @@ define([
setSettings: function(settings) {
if (settings) {
var me = this;
+ me.settings = settings;
- this.cmbSheets.setData(settings.sheets);
var type = (settings.props) ? settings.props.asc_getType() : Asc.c_oAscHyperlinkType.WebLink;
(type == Asc.c_oAscHyperlinkType.WebLink) ? me.btnExternal.toggle(true) : me.btnInternal.toggle(true);
- me.ShowHideElem(type);
+ me.ShowHideElem(type, settings.props);
me.btnInternal.setDisabled(!settings.allowInternal && (type == Asc.c_oAscHyperlinkType.WebLink));
me.btnExternal.setDisabled(!settings.allowInternal && (type == Asc.c_oAscHyperlinkType.RangeLink));
+ var defrange = '';
if (!settings.props) {
this.inputDisplay.setValue(settings.isLock ? this.textDefault : settings.text);
this.focusedInput = this.inputUrl.cmpEl.find('input');
- this.cmbSheets.setValue(settings.currentSheet);
} else {
if (type == Asc.c_oAscHyperlinkType.RangeLink) {
- this.cmbSheets.setValue(settings.props.asc_getSheet());
- this.inputRange.setValue(settings.props.asc_getRange());
- this.focusedInput = this.inputRange.cmpEl.find('input');
+ if (settings.props.asc_getSheet()) {
+ this.inputRange.setValue(settings.props.asc_getRange());
+ this.focusedInput = this.inputRange.cmpEl.find('input');
+ defrange = settings.props.asc_getSheet() + '!' + settings.props.asc_getRange();
+ } else {// named range
+ this.inputRange.setDisabled(true);
+ defrange = settings.props.asc_getLocation();
+ }
} else {
this.inputUrl.setValue(settings.props.asc_getHyperlinkUrl().replace(new RegExp(" ",'g'), "%20"));
this.focusedInput = this.inputUrl.cmpEl.find('input');
- this.cmbSheets.setValue(settings.currentSheet);
+ this.btnOk.setDisabled($.trim(this.inputUrl.getValue())=='');
}
this.inputDisplay.setValue(settings.isLock ? this.textDefault : settings.props.asc_getText());
this.inputTip.setValue(settings.props.asc_getTooltip());
}
-
this.inputDisplay.setDisabled(settings.isLock);
+ !settings.isLock && (this.isAutoUpdate = (this.inputDisplay.getValue()=='' || type == Asc.c_oAscHyperlinkType.WebLink && me.inputUrl.getValue()==me.inputDisplay.getValue()) ||
+ type == Asc.c_oAscHyperlinkType.RangeLink && defrange==me.inputDisplay.getValue());
}
},
getSettings: function() {
var props = new Asc.asc_CHyperlink(),
- def_display = "";
- props.asc_setType(this.btnInternal.isActive() ? Asc.c_oAscHyperlinkType.RangeLink : Asc.c_oAscHyperlinkType.WebLink);
+ def_display = "",
+ type = this.btnInternal.isActive() ? Asc.c_oAscHyperlinkType.RangeLink : Asc.c_oAscHyperlinkType.WebLink;
+ props.asc_setType(type);
- if (this.btnInternal.isActive()) {
- props.asc_setSheet(this.cmbSheets.getValue());
- props.asc_setRange(this.inputRange.getValue());
- def_display = this.cmbSheets.getValue() + '!' + this.inputRange.getValue();
+ if (type==Asc.c_oAscHyperlinkType.RangeLink) {
+ var rec = this.internalList.getSelectedRec();
+ if (rec && rec.get('level')>0) {
+ if (rec.get('type')) {// named range
+ props.asc_setSheet(null);
+ props.asc_setLocation(rec.get('name'));
+ def_display = rec.get('name');
+ } else {
+ props.asc_setSheet(rec.get('name'));
+ props.asc_setRange(this.inputRange.getValue());
+ def_display = rec.get('name') + '!' + this.inputRange.getValue();
+ }
+ }
} else {
var url = this.inputUrl.getValue().replace(/^\s+|\s+$/g,'');
if (! /(((^https?)|(^ftp)):\/\/)|(^mailto:)/i.test(url) )
@@ -244,7 +282,7 @@ define([
if (this.inputDisplay.isDisabled())
props.asc_setText(null);
else {
- if (_.isEmpty(this.inputDisplay.getValue()))
+ if (_.isEmpty(this.inputDisplay.getValue()) || type==Asc.c_oAscHyperlinkType.WebLink && this.isAutoUpdate)
this.inputDisplay.setValue(def_display);
props.asc_setText(this.inputDisplay.getValue());
}
@@ -271,10 +309,12 @@ define([
checkdisp = this.inputDisplay.checkValidate();
if (checkurl !== true) {
this.inputUrl.cmpEl.find('input').focus();
+ this.isInputFirstChange_url = true;
return;
}
if (checkrange !== true) {
this.inputRange.cmpEl.find('input').focus();
+ this.isInputFirstChange_range = true;
return;
}
if (checkdisp !== true) {
@@ -289,17 +329,112 @@ define([
this.close();
},
- ShowHideElem: function(value) {
+ ShowHideElem: function(value, props) {
this.externalPanel.toggleClass('hidden', value !== Asc.c_oAscHyperlinkType.WebLink);
this.internalPanel.toggleClass('hidden', value !== Asc.c_oAscHyperlinkType.RangeLink);
+ var store = this.internalList.store;
+ if (value==Asc.c_oAscHyperlinkType.RangeLink) {
+ if (store.length<1 && this.settings) {
+ var sheets = this.settings.sheets,
+ count = sheets.length,
+ arr = [];
+ arr.push(new Common.UI.TreeViewModel({
+ name : this.textSheets,
+ level: 0,
+ index: 0,
+ hasParent: false,
+ isEmptyItem: false,
+ isNotHeader: true,
+ isExpanded: false,
+ hasSubItems: true
+ }));
+ for (var i=0; i