0
1
Fork 0
This commit is contained in:
Juan Ferrer Toribio 2017-03-22 17:57:21 +01:00
parent 86a19925d8
commit 5640951c80
15 changed files with 188 additions and 119 deletions

View File

@ -1,4 +1,5 @@
extends: eslint:recommended extends: eslint:recommended
rules: rules:
no-undef: 0 no-undef: 0
no-redeclare: 0 no-redeclare: 0
no-mixed-spaces-and-tabs: 0

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
hedera-web (2.0.3) stable; urgency=low hedera-web (2.0.4) stable; urgency=low
* Initial Release. * Initial Release.

View File

@ -273,7 +273,7 @@ Hedera.Catalog = new Class
this.$('card-popup').show (button.node); this.$('card-popup').show (button.node);
} }
,onAddLotClick: function (column, value, row, button) ,onAddLotClick: function (column, value, row)
{ {
var model = this.$('item-lots'); var model = this.$('item-lots');
var grouping = model.get (row, 'grouping'); var grouping = model.get (row, 'grouping');
@ -342,7 +342,7 @@ Hedera.Catalog = new Class
this.$('card-item').value = undefined; this.$('card-item').value = undefined;
} }
,onStatusChange: function (model) ,onStatusChange: function ()
{ {
this.$('card-popup').reset (); this.$('card-popup').reset ();
} }
@ -413,7 +413,7 @@ Vn.Filter = new Class
var node = this.createRoot ('div'); var node = this.createRoot ('div');
node.className = 'vn-filter'; node.className = 'vn-filter';
this._select = new Htk.Select (); this._select = new Htk.Combo ();
this._select.on ('mousedown', this._onMouseDown, this); this._select.on ('mousedown', this._onMouseDown, this);
this._select.on ('changed', this._onChange, this); this._select.on ('changed', this._onChange, this);
this._select.on ('ready', this._onReady, this); this._select.on ('ready', this._onReady, this);
@ -426,13 +426,13 @@ Vn.Filter = new Class
this.parent (props); this.parent (props);
} }
,_onMouseDown: function (e) ,_onMouseDown: function ()
{ {
if (this._model && this._model.status === Db.Model.Status.CLEAN) if (this._model && this._model.status === Db.Model.Status.CLEAN)
this._model.refresh (); this._model.refresh ();
} }
,_onCloseClick: function (li) ,_onCloseClick: function ()
{ {
this._removeSelectionNode (); this._removeSelectionNode ();
this._changeValue (undefined); this._changeValue (undefined);

View File

@ -210,11 +210,6 @@
/* Card */ /* Card */
.card-popup
{
overflow: auto;
}
.item-card .item-card
{ {
font-size: .9em; font-size: .9em;

View File

@ -408,7 +408,6 @@
</htk-popup> </htk-popup>
<htk-popup <htk-popup
id="card-popup" id="card-popup"
class="card-popup"
modal="true" modal="true"
on-closed="onPopupClose"> on-closed="onPopupClose">
<div property="child-node" class="item-card"> <div property="child-node" class="item-card">

View File

@ -24,13 +24,13 @@ Hedera.New = new Class
,"save table contextmenu directionality emoticons template" ,"save table contextmenu directionality emoticons template"
,"paste textcolor" ,"paste textcolor"
] ]
,toolbar1: ,toolbar:
" print preview | link image media emoticons blockquote" " print preview | link image media emoticons blockquote"
+"| insertfile undo redo | bold italic" +" | insertfile undo redo | bold italic"
+"| alignleft aligncenter alignright alignjustify" +" | alignleft aligncenter alignright alignjustify"
+"| bullist numlist outdent indent" +" | bullist numlist outdent indent"
+"| styleselect | fontselect fontsizeselect" +" | styleselect | fontselect fontsizeselect"
+"| forecolor backcolor" +" | forecolor backcolor"
,image_advtab: true ,image_advtab: true
,init_instance_callback : this._onEditorInit.bind (this) ,init_instance_callback : this._onEditorInit.bind (this)
}); });

View File

@ -280,13 +280,14 @@
} }
.vn-gui .form-holder .vn-gui .form-holder
{ {
position: relative;
height: inherit; height: inherit;
} }
.vn-gui .form-holder > * .vn-gui .form-holder > *
{ {
position: relative; position: relative;
height: inherit; height: inherit;
border: 1px solid transparent;
box-sizing: border-box;
opacity: 0; opacity: 0;
transform: translateZ(0) translateX(-2em); transform: translateZ(0) translateX(-2em);

View File

@ -436,7 +436,7 @@ module.exports = new Class
div.appendChild (form); div.appendChild (form);
this.$('form-holder').appendChild (div); this.$('form-holder').appendChild (div);
setTimeout (this._onSetFormTimeout.bind (this)); setTimeout (this._onSetFormTimeout.bind (this), 10);
} }
} }

View File

@ -418,6 +418,7 @@ img.editable
display: block; display: block;
padding: 1em; padding: 1em;
border-bottom: 1px solid #DDD; border-bottom: 1px solid #DDD;
transition: background-color 200ms ease-out;
} }
a.list-row:hover a.list-row:hover
{ {

View File

@ -1,6 +1,12 @@
var ColumnText = require ('../column/text'); var ColumnText = require ('../column/text');
var nativeEvents = {
'click' : 1
,'mousedown' : 1
,'focusout' : 1
};
module.exports = new Class module.exports = new Class
({ ({
Extends: Htk.Field Extends: Htk.Field
@ -122,17 +128,11 @@ module.exports = new Class
,on: function (id, callback, instance) ,on: function (id, callback, instance)
{ {
switch (id) if (nativeEvents[id] !== undefined)
{ this.node.addEventListener (id,
case 'click': callback.bind (instance, this));
case 'mousedown': else
case 'focusout': this.parent (id, callback, instance);
this.node.addEventListener (id,
callback.bind (instance, this));
break;
default:
this.parent (id, callback, instance);
}
} }
,_setRow: function (row) ,_setRow: function (row)
@ -167,11 +167,9 @@ module.exports = new Class
var popup = this._popup = new Htk.Popup ({childNode: menu}); var popup = this._popup = new Htk.Popup ({childNode: menu});
popup.on ('closed', this._onPopupClose.bind (this)); popup.on ('closed', this._onPopupClose.bind (this));
popup.show (this.node); popup.show (this.node, true, e);
this.signalEmit ('menu-show'); this.signalEmit ('menu-show');
e.stopPropagation ();
} }
,_onGridClicked: function (grid, e) ,_onGridClicked: function (grid, e)
@ -256,7 +254,7 @@ module.exports = new Class
this._setRow (row); this._setRow (row);
} }
,putValue: function (value) ,putValue: function ()
{ {
this._selectOption (); this._selectOption ();
} }

View File

@ -31,7 +31,7 @@ var Fields = {
,TextArea : require ('./field/text-area') ,TextArea : require ('./field/text-area')
,Spin : require ('./field/spin') ,Spin : require ('./field/spin')
,Check : require ('./field/check') ,Check : require ('./field/check')
,Select : require ('./field/select') ,Combo : require ('./field/combo')
,Calendar : require ('./field/calendar') ,Calendar : require ('./field/calendar')
,DateChooser : require ('./field/date-chooser') ,DateChooser : require ('./field/date-chooser')
,Image : require ('./field/image') ,Image : require ('./field/image')

View File

@ -60,6 +60,7 @@ module.exports = new Class
} }
,_parent: null ,_parent: null
,_fitParent: false
,_modal: false ,_modal: false
,_isOpen: false ,_isOpen: false
,_child: null ,_child: null
@ -67,6 +68,7 @@ module.exports = new Class
,initialize: function (props) ,initialize: function (props)
{ {
this._bgMouseDownHandler = this._bgMouseDown.bind (this); this._bgMouseDownHandler = this._bgMouseDown.bind (this);
this._bgKeyPressHandler = this._bgKeyPress.bind (this);
this.parent (props); this.parent (props);
} }
@ -82,26 +84,41 @@ module.exports = new Class
this.node.appendChild (childNode); this.node.appendChild (childNode);
} }
,show: function (parent) /**
* Shows the popup relative to another element.
*
* @param {Node} parent The relative element
* @param {Boolean} fitParent Wether to set the width same to the parent
* @param {HTMLEvent} ignoreEvent An optional event object to ignore
*/
,show: function (parent, fitParent, ignoreEvent)
{ {
this._parent = parent; this._parent = parent;
this.open (); this._fitParent = fitParent;
} this.open (ignoreEvent);
,isModal: function ()
{
return this._modal || Vn.isMobile ();
} }
,open: function () /**
* Opens the popup.
*
* @param {Node} parent The relative element
* @param {Boolean} fitParent Wether to set the width same to the parent
*/
,open: function (ignoreEvent)
{ {
if (ignoreEvent)
this._ignoreEvent = ignoreEvent;
if (this._isOpen) if (this._isOpen)
{ {
this.reset (); this.resetAsync ();
return; return;
} }
var node = this.node;
this.node.addEventListener ('mousedown', this._onMouseDown.bind (this)); node.addEventListener ('mousedown', this._onPopupMouseDown.bind (this));
this.doc.addEventListener ('keypress', this._bgKeyPressHandler);
if (this.isModal ()) if (this.isModal ())
{ {
@ -110,106 +127,138 @@ module.exports = new Class
bg.addEventListener ('mousedown', this._bgMouseDownHandler); bg.addEventListener ('mousedown', this._bgMouseDownHandler);
Htk.Toast.pushTop (bg); Htk.Toast.pushTop (bg);
Vn.Node.addClass (this.node, 'modal'); Vn.Node.addClass (node, 'modal');
bg.appendChild (this.node); bg.appendChild (node);
this.doc.body.appendChild (bg); this.doc.body.appendChild (bg);
setTimeout (this._onOpacityTimeout.bind (this), 0);
} }
else else
{ {
this.doc.addEventListener ('mousedown', this._bgMouseDownHandler); this.doc.addEventListener ('mousedown', this._bgMouseDownHandler);
this.doc.body.appendChild (this.node); this.doc.body.appendChild (node);
Vn.Node.addClass (node, 'fixed');
this.resetAsync ();
} }
setTimeout (this._onOpacityTimeout.bind (this), 10);
this._isOpen = true; this._isOpen = true;
this.reset (); }
setTimeout (this._onResetTimeout.bind (this), 0);
/**
* Returns if the popup window shoud be modal based on the modal property
* and if the device is mobile.
*
* @return {Boolean} %true if it's modal, %false otherwise
*/
,isModal: function ()
{
return this._modal || Vn.isMobile () || !this._parent;
} }
,_onOpacityTimeout: function () ,_onOpacityTimeout: function ()
{ {
if (!this._isOpen)
return;
if (this._bg) if (this._bg)
this._bg.style.opacity = 1; this._bg.style.opacity = 1;
this._node.style.opacity = 1;
} }
,_onResetTimeout: function () ,_onResetTimeout: function ()
{ {
this.reset (); this.reset ();
} }
,resetAsync: function ()
{
setTimeout (this._onResetTimeout.bind (this));
}
/**
* Repositions the popup.
*/
,reset: function () ,reset: function ()
{ {
if (!this._isOpen) if (!this._isOpen || this.isModal ())
return; return;
var node = this._node; var node = this._node;
var style = node.style; var style = node.style;
style.visibility = 'hidden';
style.height = ''; style.height = '';
style.width = ''; style.width = '';
var margin = 20; var margin = 20;
var dblMargin = margin * 2; var dblMargin = margin * 2;
var width = node.offsetWidth;
var height = node.offsetHeight; var iniWidth;
var innerWidth = window.innerWidth; var iniHeight;
var innerHeight = window.innerHeight; var width = iniWidth = node.offsetWidth;
var height = iniHeight = node.offsetHeight;
if (width + dblMargin > innerWidth) var windowWidth = window.innerWidth;
{ var windowHeight = window.innerHeight;
width = innerWidth - dblMargin;
style.width = width +'px';
}
if (height + dblMargin > innerHeight)
{
height = innerHeight - dblMargin;
style.height = height +'px';
}
if (this.isModal ())
{
style.marginLeft = (-node.offsetWidth / 2) +'px';
style.marginTop = (-node.offsetHeight / 2) +'px';
}
else
{
var spacing = 4;
var rect = this._parent.getBoundingClientRect ();
var left = rect.left;
var top = rect.top + spacing + this._parent.offsetHeight;
if (left + width > innerWidth) if (width + dblMargin > windowWidth)
left -= (left + width) - window.innerWidth + margin; width = windowWidth - dblMargin;
if (top + height > innerHeight) if (height + dblMargin > windowHeight)
top -= height + this._parent.offsetHeight + spacing * 2; height = windowHeight - dblMargin;
if (left < 0) var rect = this._parent.getBoundingClientRect ();
left = margin; var left = rect.left;
if (top < 0) var top = rect.top + this._parent.offsetHeight;
top = margin;
style.top = (top) +'px'; if (this._fitParent)
style.left = (left) +'px'; width = this._parent.offsetWidth;
}
if (left + width + margin > windowWidth)
left -= (left + width) - window.windowWidth + margin;
if (top + height + margin > windowHeight)
top -= height + this._parent.offsetHeight;
if (left < margin)
left = margin;
if (top < margin)
top = margin;
style.top = (top) +'px';
style.left = (left) +'px';
if (width != iniWidth)
style.width = (width) +'px';
if (height != iniHeight)
style.height = (height) +'px';
style.visibility = 'initial';
} }
/**
* Hides the popup.
*/
,hide: function () ,hide: function ()
{ {
if (!this._isOpen) if (!this._isOpen)
return; return;
var node = this._node;
if (this._bg) if (this._bg)
{ {
Htk.Toast.popTop (); Htk.Toast.popTop ();
Vn.Node.remove (this._bg); Vn.Node.remove (this._bg);
Vn.Node.removeClass (this._node, 'modal'); Vn.Node.removeClass (node, 'modal');
this._bg = null; this._bg = null;
} }
else else
{
this.doc.removeEventListener ('mousedown', this._bgMouseDownHandler); this.doc.removeEventListener ('mousedown', this._bgMouseDownHandler);
Vn.Node.removeClass (node, 'fixed');
}
Vn.Node.remove (this._node); Vn.Node.remove (node);
this._parent = null; this._parent = null;
this._isOpen = false; this._isOpen = false;
this.signalEmit ('closed'); this.signalEmit ('closed');
@ -217,15 +266,21 @@ module.exports = new Class
,_bgMouseDown: function (e) ,_bgMouseDown: function (e)
{ {
if (e !== this._lastEvent) if (e !== this._ignoreEvent)
this.hide (); this.hide ();
this._lastEvent = null; this._ignoreEvent = null;
}
,_bgKeyPress: function (e)
{
if (e.keyCode == 27) // Escape
this.hide ();
} }
,_onMouseDown: function (e) ,_onPopupMouseDown: function (e)
{ {
this._lastEvent = e; this._ignoreEvent = e;
} }
}); });

View File

@ -54,6 +54,7 @@
.htk-grid td .htk-grid td
{ {
text-align: left; text-align: left;
box-sizing: border-box;
} }
.htk-grid td:first-child, .htk-grid td:first-child,
.htk-grid th:first-child .htk-grid th:first-child
@ -136,15 +137,16 @@ td.cell-image .htk-image
.htk-select .htk-select
{ {
width: 100%; max-width: 100%;
height: 2em; height: 2em;
text-align: left; text-align: left;
} }
.htk-select-menu .htk-select-menu
{ {
height: 100%; max-width: 100%;
max-height: 80em; }
overflow: auto; .modal > .htk-select-menu
{
min-width: 14em; min-width: 14em;
} }
.htk-select-menu tbody > tr .htk-select-menu tbody > tr
@ -163,7 +165,7 @@ td.cell-image .htk-image
} }
.htk-select-menu td .htk-select-menu td
{ {
max-width: 11em; max-width: 0;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
white-space: nowrap; white-space: nowrap;
@ -437,26 +439,36 @@ td.cell-image .htk-image
bottom: 0; bottom: 0;
z-index: 190; z-index: 190;
background-color: rgba(1, 1, 1, 0.7); background-color: rgba(1, 1, 1, 0.7);
padding: 1.5em;
display: flex;
justify-content: center;
align-items: center;
opacity: 0; opacity: 0;
transition: opacity 200ms ease-in-out; transition: opacity 200ms ease-in-out;
} }
.htk-popup .htk-popup
{ {
z-index: 200;
display: block;
position: fixed;
overflow: hidden;
background-color: white; background-color: white;
border-radius: 0.15em; border-radius: 0.15em;
box-shadow: 0 0 0.4em rgba(1, 1, 1, 0.6); box-shadow: 0 0 0.4em rgba(1, 1, 1, 0.6);
box-sizing: content-box; box-sizing: content-box;
overflow: auto;
opacity: 0;
transition: opacity 200ms ease-in-out;
}
.htk-popup.fixed
{
z-index: 200;
position: fixed;
display: block;
} }
.htk-popup.modal .htk-popup.modal
{ {
position: absolute; max-height: 100%;
max-width: 100%;
font-size: 1.2em; font-size: 1.2em;
top: 50%;
left: 50%;
} }
.htk-popup > * .htk-popup > *
{ {

View File

@ -86,7 +86,7 @@ module.exports =
this._timeouts = null; this._timeouts = null;
document.removeEventListener ('mousedown', this.hideHandler); document.removeEventListener ('mousedown', this._onDocMouseDownHandler);
Vn.Node.remove (this._container); Vn.Node.remove (this._container);
this._container = null; this._container = null;
this.nodes = []; this.nodes = [];
@ -100,8 +100,8 @@ module.exports =
container.className = 'htk-toast'; container.className = 'htk-toast';
document.body.appendChild (container); document.body.appendChild (container);
this.hideHandler = this.hide.bind (this); this._onDocMouseDownHandler = this._onDocMouseDown.bind (this);
document.addEventListener ('mousedown', this.hideHandler); document.addEventListener ('mousedown', this._onDocMouseDownHandler);
this._timeouts = []; this._timeouts = [];
this._container = container; this._container = container;
@ -119,7 +119,7 @@ module.exports =
var toast = document.createElement ('div'); var toast = document.createElement ('div');
toast.className = className; toast.className = className;
toast.addEventListener ('mousedown', this._onMessageMouseDown); toast.addEventListener ('mousedown', this._onMessageMouseDown.bind (this));
var textNode = document.createTextNode (message); var textNode = document.createTextNode (message);
toast.appendChild (textNode); toast.appendChild (textNode);
@ -153,8 +153,15 @@ module.exports =
this.hide (); this.hide ();
} }
,_onMessageMouseDown: function (event) ,_onMessageMouseDown: function (e)
{ {
event.stopPropagation (); this._lastEvent = e;
}
,_onDocMouseDown: function (e) {
if (this._lastEvent !== e)
this.hide();
this._lastEvent = null;
} }
}; };

View File

@ -1,6 +1,6 @@
{ {
"name": "hedera-web", "name": "hedera-web",
"version": "2.0.3", "version": "2.0.4",
"description": "Verdnatura web page", "description": "Verdnatura web page",
"devDependencies": { "devDependencies": {
"assets-webpack-plugin": "^3.5.1", "assets-webpack-plugin": "^3.5.1",