init repo
This commit is contained in:
133
OfficeWeb/apps/common/main/lib/plugin/ComboBoxScrollPane.js
Normal file
133
OfficeWeb/apps/common/main/lib/plugin/ComboBoxScrollPane.js
Normal file
@@ -0,0 +1,133 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
Ext.define("Common.plugin.ComboBoxScrollPane", {
|
||||
extend: "Common.plugin.ScrollPane",
|
||||
alias: "plugin.comboboxscrollpane",
|
||||
areaSelector: ".list-ct",
|
||||
init: function (comboBox) {
|
||||
comboBox.on("expand", this.onExpand, this);
|
||||
},
|
||||
onExpand: function (comboBox) {
|
||||
var me = this;
|
||||
if (!me.picker) {
|
||||
me.picker = comboBox.getPicker();
|
||||
me.picker.on({
|
||||
viewready: me.onViewReady,
|
||||
resize: function () {
|
||||
me.updateScrollPane();
|
||||
},
|
||||
beforecontainerclick: function () {
|
||||
return false;
|
||||
},
|
||||
beforeitemmouseenter: function (picker, record, item, index, event, opts) {
|
||||
if (comboBox.scrolllocked) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
scope: me
|
||||
});
|
||||
me.cmp.on("afterlayout", me.onViewReady, me, {
|
||||
single: true
|
||||
});
|
||||
comboBox.on("keydown", me.onKeyDown, me);
|
||||
var store = comboBox.getStore();
|
||||
store.on("datachanged", me.onDataChanged, me, {
|
||||
buffer: 10
|
||||
});
|
||||
}
|
||||
},
|
||||
onKeyDown: function (cmp, e, eOpts) {
|
||||
var me = this;
|
||||
var highlightAt = function (index) {
|
||||
var boundList = me.picker,
|
||||
item = boundList.all.item(index);
|
||||
if (item) {
|
||||
var container = Ext.getDom(boundList.getTargetEl()) || Ext.getBody().dom;
|
||||
var el = item.dom,
|
||||
offsets = item.getOffsetsTo(container),
|
||||
top = offsets[1] + container.scrollTop,
|
||||
bottom = top + el.offsetHeight,
|
||||
ctClientHeight = container.clientHeight,
|
||||
ctScrollTop = parseInt(container.scrollTop, 10),
|
||||
ctBottom = ctScrollTop + ctClientHeight;
|
||||
if (el.offsetHeight > ctClientHeight || top < ctScrollTop) {
|
||||
if (me.jspApi) {
|
||||
me.jspApi.scrollByY(top, false);
|
||||
}
|
||||
} else {
|
||||
if (bottom > ctBottom) {
|
||||
if (me.jspApi) {
|
||||
me.jspApi.scrollByY(bottom - ctClientHeight, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
switch (e.getKey()) {
|
||||
case e.UP:
|
||||
var boundList = me.picker,
|
||||
allItems = boundList.all,
|
||||
oldItem = boundList.highlightedItem,
|
||||
oldItemIdx = oldItem ? boundList.indexOf(oldItem) : -1,
|
||||
newItemIdx = oldItemIdx > 0 ? oldItemIdx - 1 : allItems.getCount() - 1;
|
||||
highlightAt(newItemIdx);
|
||||
break;
|
||||
case e.DOWN:
|
||||
var boundList = me.picker,
|
||||
allItems = boundList.all,
|
||||
oldItem = boundList.highlightedItem,
|
||||
oldItemIdx = oldItem ? boundList.indexOf(oldItem) : -1,
|
||||
newItemIdx = oldItemIdx < allItems.getCount() - 1 ? oldItemIdx + 1 : 0;
|
||||
highlightAt(newItemIdx);
|
||||
break;
|
||||
case e.PAGE_UP:
|
||||
case e.PAGE_DOWN:
|
||||
break;
|
||||
case e.HOME:
|
||||
highlightAt(0);
|
||||
break;
|
||||
case e.END:
|
||||
highlightAt(me.picker.all.getCount() - 1);
|
||||
break;
|
||||
}
|
||||
},
|
||||
onViewReady: function () {
|
||||
var me = this;
|
||||
me.initScrollPane(me.picker.getEl().dom);
|
||||
},
|
||||
onDataChanged: function () {
|
||||
var me = this;
|
||||
if (me.picker.getWidth() && me.picker.getHeight()) {
|
||||
me.initScrollPane(me.picker.getEl().dom);
|
||||
}
|
||||
}
|
||||
});
|
||||
104
OfficeWeb/apps/common/main/lib/plugin/DataViewScrollPane.js
Normal file
104
OfficeWeb/apps/common/main/lib/plugin/DataViewScrollPane.js
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
Ext.define("Common.plugin.DataViewScrollPane", {
|
||||
extend: "Common.plugin.ScrollPane",
|
||||
alias: "plugin.dataviewscrollpane",
|
||||
areaSelector: ".x-component",
|
||||
init: function (cmp) {
|
||||
var me = this,
|
||||
store;
|
||||
me.callParent(arguments);
|
||||
store = me.cmp.getStore();
|
||||
if (store) {
|
||||
store.on("datachanged", function () {
|
||||
me.cmp && me.cmp.rendered && me.cmp.getWidth() > 0 && me.cmp.getHeight() > 0 && me.updateScrollPane();
|
||||
},
|
||||
me, {
|
||||
buffer: 10
|
||||
});
|
||||
}
|
||||
me.cmp.on("viewready", me.onViewReady, me, {
|
||||
single: true
|
||||
});
|
||||
},
|
||||
onKeyDown: function (e, eOpts) {
|
||||
var me = this;
|
||||
var store = me.cmp.getStore();
|
||||
var highlightAt = function (index) {
|
||||
var item = me.cmp.getNode(store.getAt(index)),
|
||||
itemEl = Ext.create("Ext.Element", item);
|
||||
if (item) {
|
||||
var container = Ext.getDom(me.cmp.getTargetEl()) || Ext.getBody().dom;
|
||||
var offsets = itemEl.getOffsetsTo(container),
|
||||
top = offsets[1] + container.scrollTop,
|
||||
bottom = top + item.offsetHeight,
|
||||
ctClientHeight = container.clientHeight,
|
||||
ctScrollTop = parseInt(container.scrollTop, 10),
|
||||
ctBottom = ctScrollTop + ctClientHeight;
|
||||
if (item.offsetHeight > ctClientHeight || top < ctScrollTop) {
|
||||
if (me.jspApi) {
|
||||
me.jspApi.scrollByY(top, false);
|
||||
}
|
||||
} else {
|
||||
if (bottom > ctBottom) {
|
||||
if (me.jspApi) {
|
||||
me.jspApi.scrollByY(bottom - ctClientHeight, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
switch (e.getKey()) {
|
||||
case e.UP:
|
||||
case e.DOWN:
|
||||
var currItem = me.cmp.getSelectionModel().getLastSelected(),
|
||||
currItemIdx = currItem ? store.indexOf(currItem) : -1;
|
||||
highlightAt(currItemIdx);
|
||||
break;
|
||||
case e.PAGE_UP:
|
||||
case e.PAGE_DOWN:
|
||||
break;
|
||||
case e.HOME:
|
||||
me.cmp.select(0);
|
||||
highlightAt(0);
|
||||
break;
|
||||
case e.END:
|
||||
me.cmp.select(store.count() - 1);
|
||||
highlightAt(store.count() - 1);
|
||||
break;
|
||||
}
|
||||
},
|
||||
onViewReady: function () {
|
||||
var me = this;
|
||||
me.cmp.getEl().on("keydown", me.onKeyDown, me);
|
||||
}
|
||||
});
|
||||
105
OfficeWeb/apps/common/main/lib/plugin/GridScrollPane.js
Normal file
105
OfficeWeb/apps/common/main/lib/plugin/GridScrollPane.js
Normal file
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
Ext.define("Common.plugin.GridScrollPane", {
|
||||
extend: "Common.plugin.ScrollPane",
|
||||
alias: "plugin.gridscrollpane",
|
||||
areaSelector: ".x-grid-view",
|
||||
settings: {
|
||||
enableKeyboardNavigation: true,
|
||||
keyboardSpeed: 0.001
|
||||
},
|
||||
init: function (cmp) {
|
||||
var me = this,
|
||||
store;
|
||||
me.callParent(arguments);
|
||||
store = me.cmp.getStore();
|
||||
if (store) {
|
||||
store.on("datachanged", me.updateScrollPane, me, {
|
||||
buffer: 10
|
||||
});
|
||||
}
|
||||
me.cmp.on("viewready", me.onViewReady, me, {
|
||||
single: true
|
||||
});
|
||||
},
|
||||
onKeyDown: function (e, eOpts) {
|
||||
var me = this;
|
||||
var store = me.cmp.getStore();
|
||||
var highlightAt = function (index) {
|
||||
var item = me.cmp.getView().getNode(store.getAt(index)),
|
||||
itemEl = Ext.create("Ext.Element", item);
|
||||
if (item) {
|
||||
var container = Ext.getDom(me.cmp.getTargetEl()) || Ext.getBody().dom;
|
||||
var offsets = itemEl.getOffsetsTo(container),
|
||||
top = offsets[1] + container.scrollTop,
|
||||
bottom = top + item.offsetHeight,
|
||||
ctClientHeight = container.clientHeight,
|
||||
ctScrollTop = parseInt(container.scrollTop, 10),
|
||||
ctBottom = ctScrollTop + ctClientHeight;
|
||||
if (item.offsetHeight > ctClientHeight || top < ctScrollTop) {
|
||||
if (me.jspApi) {
|
||||
me.jspApi.scrollByY(top, false);
|
||||
}
|
||||
} else {
|
||||
if (bottom > ctBottom) {
|
||||
if (me.jspApi) {
|
||||
me.jspApi.scrollByY(bottom - ctClientHeight, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
switch (e.getKey()) {
|
||||
case e.UP:
|
||||
case e.DOWN:
|
||||
var currItem = me.cmp.getSelectionModel().getLastSelected(),
|
||||
currItemIdx = currItem ? store.indexOf(currItem) : -1;
|
||||
highlightAt(currItemIdx);
|
||||
break;
|
||||
case e.PAGE_UP:
|
||||
case e.PAGE_DOWN:
|
||||
break;
|
||||
case e.HOME:
|
||||
highlightAt(0);
|
||||
break;
|
||||
case e.END:
|
||||
highlightAt(store.count() - 1);
|
||||
break;
|
||||
}
|
||||
},
|
||||
onViewReady: function () {
|
||||
var me = this;
|
||||
me.cmp.getView().getEl().on("keydown", me.onKeyDown, me, {
|
||||
stopEvent: true
|
||||
});
|
||||
}
|
||||
});
|
||||
113
OfficeWeb/apps/common/main/lib/plugin/MenuExpand.js
Normal file
113
OfficeWeb/apps/common/main/lib/plugin/MenuExpand.js
Normal file
@@ -0,0 +1,113 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
Ext.define("Common.plugin.MenuExpand", {
|
||||
extend: "Ext.AbstractPlugin",
|
||||
alias: "plugin.menuexpand",
|
||||
init: function (cmp) {
|
||||
var me = this,
|
||||
originLeave = cmp.onMouseLeave;
|
||||
cmp.onMouseLeave = function (e) {
|
||||
originLeave.apply(cmp, arguments);
|
||||
if (cmp.parentItem) {
|
||||
cmp.parentItem.menuEntered = false;
|
||||
}
|
||||
};
|
||||
cmp.onMouseOver = me.onMouseOver;
|
||||
cmp.checkItemMenuEntered = me.checkItemMenuEntered;
|
||||
me.callParent(arguments);
|
||||
},
|
||||
checkItemMenuEntered: function () {
|
||||
var me = this;
|
||||
if (me.activeItem && me.activeItem.menuEntered && me.MouseOverInterval) {
|
||||
clearInterval(me.MouseOverInterval);
|
||||
me.MouseOverInterval = undefined;
|
||||
me.activeItem.menuEntered = false;
|
||||
if (me.checkeditem) {
|
||||
me.checkeditem.el.removeCls(me.checkeditem.activeCls);
|
||||
}
|
||||
me.activeItem.el.addCls(me.activeItem.activeCls);
|
||||
}
|
||||
},
|
||||
onMouseOver: function (e) {
|
||||
var me = this,
|
||||
fromEl = e.getRelatedTarget(),
|
||||
mouseEnter = !me.el.contains(fromEl),
|
||||
item = me.getItemFromEvent(e);
|
||||
if (mouseEnter && me.parentMenu) {
|
||||
me.parentMenu.setActiveItem(me.parentItem);
|
||||
me.parentMenu.mouseMonitor.mouseenter();
|
||||
}
|
||||
if (me.disabled) {
|
||||
return;
|
||||
}
|
||||
if (me.checkeditem && item != me.checkeditem) {
|
||||
me.checkeditem.el.removeCls(me.checkeditem.activeCls);
|
||||
}
|
||||
if (me.checkeditem = item) {
|
||||
me.checkeditem.el.addCls(me.checkeditem.activeCls);
|
||||
}
|
||||
if (me.activeItem && me.activeItem.menu) {
|
||||
if (item && (item != me.activeItem && item != me.focusedItem) && me.MouseOverInterval === undefined) {
|
||||
var counter = 0;
|
||||
me.activeItem.menuEntered = false;
|
||||
me.MouseOverInterval = setInterval(function () {
|
||||
me.checkItemMenuEntered();
|
||||
if (counter++>8) {
|
||||
clearInterval(me.MouseOverInterval);
|
||||
me.MouseOverInterval = undefined;
|
||||
if (me.checkeditem) {
|
||||
me.setActiveItem(me.checkeditem);
|
||||
if (me.checkeditem.activated && me.checkeditem.expandMenu) {
|
||||
me.checkeditem.expandMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
20);
|
||||
}
|
||||
} else {
|
||||
if (item) {
|
||||
me.setActiveItem(item);
|
||||
if (item.activated && item.expandMenu) {
|
||||
item.expandMenu();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (mouseEnter) {
|
||||
if (me.parentItem) {
|
||||
me.parentItem.menuEntered = true;
|
||||
}
|
||||
me.fireEvent("mouseenter", me, e);
|
||||
}
|
||||
me.fireEvent("mouseover", me, item, e);
|
||||
}
|
||||
});
|
||||
158
OfficeWeb/apps/common/main/lib/plugin/ScrollPane.js
Normal file
158
OfficeWeb/apps/common/main/lib/plugin/ScrollPane.js
Normal file
@@ -0,0 +1,158 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
Ext.define("Common.plugin.ScrollPane", {
|
||||
extend: "Ext.AbstractPlugin",
|
||||
alias: "plugin.scrollpane",
|
||||
areaSelector: ".x-panel-body",
|
||||
settings: {},
|
||||
init: function (cmp) {
|
||||
var me = this,
|
||||
origin;
|
||||
me.settings = $.extend({
|
||||
enableKeyboardNavigation: true,
|
||||
verticalDragMinHeight: 16,
|
||||
horizontalDragMinWidth: 16
|
||||
},
|
||||
me.settings);
|
||||
origin = cmp.afterComponentLayout;
|
||||
cmp.afterComponentLayout = function (width, height) {
|
||||
origin.apply(cmp, arguments);
|
||||
if (width > 0 && height > 0) {
|
||||
me.initScrollPane();
|
||||
}
|
||||
};
|
||||
me.callParent(arguments);
|
||||
},
|
||||
initScrollPane: function (domEl) {
|
||||
var me = this,
|
||||
children, jspCt, elem;
|
||||
if (me.initializing) {
|
||||
return;
|
||||
}
|
||||
me.initializing = true;
|
||||
if (!me.area || !me.area.length) {
|
||||
elem = domEl || me.cmp.getEl().dom;
|
||||
me.area = $(elem).find("*").andSelf().filter(me.areaSelector).first();
|
||||
}
|
||||
children = me.area.children();
|
||||
jspCt = children.filter("div.jspContainer");
|
||||
if (children.length > 1 && jspCt.length > 0) {
|
||||
jspCt.replaceWith($(".jspPane", jspCt).children());
|
||||
jspCt = $();
|
||||
}
|
||||
if (me.jspApi && jspCt.length === 0) {
|
||||
me.area.removeData("jsp");
|
||||
}
|
||||
me.area.jScrollPane(me.settings);
|
||||
me.jspApi = me.area.data("jsp");
|
||||
me.doLayout();
|
||||
delete me.initializing;
|
||||
elem = domEl || me.cmp.getEl().dom;
|
||||
this._initSelectingScroll(elem);
|
||||
if (jspCt.length) {
|
||||
var thumb = jspCt.find(">.jspVerticalBar").find(">.jspTrack").find(">.jspDrag");
|
||||
thumb.on("mousedown.asc", function (event) {
|
||||
if (thumb[0].setCapture) {
|
||||
thumb[0].setCapture();
|
||||
}
|
||||
me.cmp.scrolllocked = true;
|
||||
$("html").bind("mouseup.asc", function (e) {
|
||||
if (thumb[0].releaseCapture) {
|
||||
thumb[0].releaseCapture();
|
||||
}
|
||||
me.cmp.scrolllocked = false;
|
||||
$("html").unbind("mouseup.asc");
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
},
|
||||
_initSelectingScroll: function (elem) {
|
||||
var me = this;
|
||||
$(elem).off("mousedown.jsp");
|
||||
$(elem).on("mousedown.jsp", function (event) {
|
||||
$(document).on("mousemove.jsp", _onTextSelectionScrollMouseMove);
|
||||
$(document).on("mouseup.jsp", function (event) {
|
||||
$(document).off("mousemove.jsp").off("mouseup.jsp");
|
||||
_clearTextSelectionInterval();
|
||||
});
|
||||
});
|
||||
var getPos = function (event, c) {
|
||||
var p = c == "X" ? "Left" : "Top";
|
||||
return event["page" + c] || (event["client" + c] + (document.documentElement["scroll" + p] || document.body["scroll" + p])) || 0;
|
||||
};
|
||||
var textSelectionInterval;
|
||||
var _onTextSelectionScrollMouseMove = function (event) {
|
||||
var offset = $(elem).offset().top;
|
||||
var maxOffset = offset + $(elem).innerHeight();
|
||||
var mouseOffset = getPos(event, "Y");
|
||||
var textDragDistanceAway = mouseOffset < offset ? mouseOffset - offset : (mouseOffset > maxOffset ? mouseOffset - maxOffset : 0);
|
||||
if (textDragDistanceAway == 0) {
|
||||
_clearTextSelectionInterval();
|
||||
} else {
|
||||
if (!textSelectionInterval) {
|
||||
textSelectionInterval = setInterval(function () {
|
||||
me.jspApi.scrollByY(textDragDistanceAway);
|
||||
},
|
||||
10);
|
||||
}
|
||||
}
|
||||
};
|
||||
var _clearTextSelectionInterval = function () {
|
||||
if (textSelectionInterval) {
|
||||
clearInterval(textSelectionInterval);
|
||||
textSelectionInterval = undefined;
|
||||
}
|
||||
};
|
||||
},
|
||||
updateScrollPane: function (domEl) {
|
||||
this.initScrollPane(domEl);
|
||||
if (this.area) {
|
||||
this.area.attr("tabindex", "-1");
|
||||
}
|
||||
},
|
||||
scrollToElement: function (elem, stickToTop, animate) {
|
||||
var me = this;
|
||||
if (me.jspApi) {
|
||||
me.jspApi.scrollToElement(elem, stickToTop, animate);
|
||||
}
|
||||
},
|
||||
doLayout: function () {
|
||||
var me = this,
|
||||
items = me.cmp.items;
|
||||
if (items && typeof items.each === "function") {
|
||||
items.each(function (item) {
|
||||
item.doComponentLayout();
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
121
OfficeWeb/apps/common/main/lib/plugin/TextAreaAutoHeight.js
Normal file
121
OfficeWeb/apps/common/main/lib/plugin/TextAreaAutoHeight.js
Normal file
@@ -0,0 +1,121 @@
|
||||
/*
|
||||
* (c) Copyright Ascensio System SIA 2010-2014
|
||||
*
|
||||
* This program is a free software product. You can redistribute it and/or
|
||||
* modify it under the terms of the GNU Affero General Public License (AGPL)
|
||||
* version 3 as published by the Free Software Foundation. In accordance with
|
||||
* Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect
|
||||
* that Ascensio System SIA expressly excludes the warranty of non-infringement
|
||||
* of any third-party rights.
|
||||
*
|
||||
* This program is distributed WITHOUT ANY WARRANTY; without even the implied
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For
|
||||
* details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
*
|
||||
* You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia,
|
||||
* EU, LV-1021.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of the Program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU AGPL version 3.
|
||||
*
|
||||
* Pursuant to Section 7(b) of the License you must retain the original Product
|
||||
* logo when distributing the program. Pursuant to Section 7(e) we decline to
|
||||
* grant you any rights under trademark law for use of our trademarks.
|
||||
*
|
||||
* All the Product's GUI elements, including illustrations and icon sets, as
|
||||
* well as technical writing content are licensed under the terms of the
|
||||
* Creative Commons Attribution-ShareAlike 4.0 International. See the License
|
||||
* terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
|
||||
*
|
||||
*/
|
||||
Ext.define("Common.plugin.TextAreaAutoHeight", {
|
||||
extend: "Ext.AbstractPlugin",
|
||||
alias: "plugin.textareaautoheight",
|
||||
settings: {
|
||||
minHeight: 32,
|
||||
maxHeight: 120,
|
||||
growStep: 17
|
||||
},
|
||||
init: function (cmp) {
|
||||
this.callParent(arguments);
|
||||
cmp.addEvents("elastic");
|
||||
cmp.on("afterrender", this.onAfterRender, this);
|
||||
cmp.on("change", this.onChange, this);
|
||||
},
|
||||
onAfterRender: function (cmp) {
|
||||
var textareaEl = cmp.getEl().down("textarea");
|
||||
if (textareaEl) {
|
||||
this.initHelper(textareaEl.id);
|
||||
this.elasticTextArea(textareaEl.id);
|
||||
}
|
||||
},
|
||||
onChange: function (cmp) {
|
||||
if (!this.textareaElId) {
|
||||
this.textareaElId = cmp.getEl().down("textarea").id;
|
||||
}
|
||||
this.elasticTextArea(this.textareaElId);
|
||||
},
|
||||
initHelper: function (elementId) {
|
||||
var getStyles = function (el, args) {
|
||||
var ret = {},
|
||||
total = args.length;
|
||||
for (var n = 0; n < total; n++) {
|
||||
ret[args[n]] = el.getStyle(args[n]);
|
||||
}
|
||||
return ret;
|
||||
};
|
||||
var applyStyles = function (el, styles) {
|
||||
if (styles) {
|
||||
var i = 0,
|
||||
len;
|
||||
el = Ext.fly(el);
|
||||
if (Ext.isFunction(styles)) {
|
||||
styles = styles.call();
|
||||
}
|
||||
if (typeof styles == "string") {
|
||||
styles = styles.split(/:|;/g);
|
||||
for (len = styles.length; i < len;) {
|
||||
el.setStyle(styles[i++], styles[i++]);
|
||||
}
|
||||
} else {
|
||||
if (Ext.isObject(styles)) {
|
||||
el.setStyle(styles);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
this.domEl = Ext.get(elementId);
|
||||
this.textareaElId = elementId;
|
||||
var styles = getStyles(this.domEl, ["font-size", "font-family", "font-weight", "font-style", "line-height", "letter-spacing", "padding-left", "padding-top", "padding-right", "padding-bottom"]);
|
||||
this.domEl.setStyle("overflow", "hidden");
|
||||
if (!this.helperEl) {
|
||||
this.helperEl = Ext.DomHelper.append(this.domEl.parent(), {
|
||||
id: elementId + "-textarea-elastic-helper",
|
||||
tag: "div",
|
||||
style: "position: absolute; top: 0; left: 0; visibility: hidden; white-space: pre-wrap; word-wrap: break-word;"
|
||||
},
|
||||
true);
|
||||
applyStyles(this.helperEl, styles);
|
||||
}
|
||||
},
|
||||
elasticTextArea: function (elementId) {
|
||||
var me = this,
|
||||
value = this.domEl.dom.value || " ";
|
||||
this.helperEl.setWidth(this.domEl.getWidth());
|
||||
this.helperEl.update(value.replace(/<br \/> /, "<br />").replace(/<|>/g, " ").replace(/&/g, "&").replace(/\n/g, "<br />"));
|
||||
var textHeight = this.helperEl.getHeight();
|
||||
if ((textHeight > me.settings.maxHeight) && (me.settings.maxHeight > 0)) {
|
||||
textHeight = me.settings.maxHeight;
|
||||
this.domEl.setStyle("overflow", "auto");
|
||||
}
|
||||
if ((textHeight < me.settings.minHeight) && (me.settings.minHeight > 0)) {
|
||||
textHeight = me.settings.minHeight;
|
||||
}
|
||||
var newHeight = textHeight + me.settings.growStep;
|
||||
if (me.cmp.getHeight() != newHeight) {
|
||||
me.cmp.setHeight(newHeight);
|
||||
me.cmp.fireEvent("elastic", me.cmp, this.domEl.getWidth(), newHeight);
|
||||
}
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user