Alpha
This commit is contained in:
parent
fd75840c82
commit
b93a39f0a9
|
@ -1,8 +1,8 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="address">
|
||||
<vn-hash-param key="address"/>
|
||||
</vn-param>
|
||||
<vn-hash-param key="address">
|
||||
<vn-param id="address"/>
|
||||
</vn-hash-param>
|
||||
<db-form id="iter" on-status-changed="onStatusChange">
|
||||
<db-param id="country" one-way="true" column="country_id"/>
|
||||
<db-model id="model" updatable="true" mode="ON_DEMAND" on-operations-done="onOperationsDone">
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="user">
|
||||
<vn-hash-param key="user"/>
|
||||
</vn-param>
|
||||
<vn-hash-param key="user">
|
||||
<vn-param id="user"/>
|
||||
</vn-hash-param>
|
||||
<db-form id="user-form">
|
||||
<db-model>
|
||||
SELECT Id_Cliente, Cliente, Telefono, movil
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="agency">
|
||||
<vn-hash-param key="agency"/>
|
||||
</vn-param>
|
||||
<vn-hash-param key="agency">
|
||||
<vn-param id="agency"/>
|
||||
</vn-hash-param>
|
||||
</vn-group>
|
||||
<div id="title">
|
||||
<h1><t>ByProvince</t></h1>
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
|
||||
Vn.resource ('forms/ecomerce/catalog/filter-button.xml');
|
||||
Vn.define (function () {
|
||||
|
||||
Vn.Catalog = new Class
|
||||
({
|
||||
Extends: Vn.Module
|
||||
|
@ -345,21 +342,12 @@ Vn.Catalog = new Class
|
|||
if (this.popup)
|
||||
this.popup.reset ();
|
||||
}
|
||||
|
||||
,onSelectClick: function (select, e)
|
||||
{
|
||||
console.debug ('Select clicked!');
|
||||
console.debug (select, e);
|
||||
|
||||
if (select.model.status === Db.Model.Status.CLEAN)
|
||||
select.model.refresh ();
|
||||
}
|
||||
});
|
||||
|
||||
Vn.FilterButton = new Class
|
||||
Vn.Filter = new Class
|
||||
({
|
||||
Extends: Htk.Widget
|
||||
,Tag: 'vn-filter-button'
|
||||
,Tag: 'vn-filter'
|
||||
,Child: 'model'
|
||||
,Properties:
|
||||
{
|
||||
|
@ -368,7 +356,7 @@ Vn.FilterButton = new Class
|
|||
type: Db.Model
|
||||
,set: function (x)
|
||||
{
|
||||
this._grid.model = x;
|
||||
this._select.model = x;
|
||||
this._model = x;
|
||||
}
|
||||
,get: function ()
|
||||
|
@ -376,17 +364,17 @@ Vn.FilterButton = new Class
|
|||
return this._model;
|
||||
}
|
||||
},
|
||||
text:
|
||||
placeholder:
|
||||
{
|
||||
type: String
|
||||
,set: function (x)
|
||||
{
|
||||
Vn.Node.setText (this._button, x);;
|
||||
this._text = x;
|
||||
this._select.placeholder = x;
|
||||
this._placeholder = x;
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
return this._text;
|
||||
return this._placeholder;
|
||||
}
|
||||
},
|
||||
column:
|
||||
|
@ -394,41 +382,72 @@ Vn.FilterButton = new Class
|
|||
type: String
|
||||
,set: function (x)
|
||||
{
|
||||
this._col.column = x;
|
||||
this._column = x;
|
||||
}
|
||||
,get: function ()
|
||||
{
|
||||
return this._col.column;
|
||||
return this._column;
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
,_columnIndex: 1
|
||||
|
||||
,initialize: function (props)
|
||||
{
|
||||
this.parent (props);
|
||||
this.builderInit ('forms/ecomerce/catalog/filter-button.xml');
|
||||
|
||||
this._button = this.createElement ('button');
|
||||
this._button.className = 'vn-filter-button thin';
|
||||
this._button.addEventListener ('click', this._onButtonClick.bind (this));
|
||||
this.createElement ('div');
|
||||
this.node.className = 'vn-filter';
|
||||
|
||||
this._grid = new Htk.Grid ();
|
||||
this._grid.showHeader = false;
|
||||
this._select = new Htk.Select ();
|
||||
this._select.on ('mousedown', this._onClick.bind (this));
|
||||
this._select.on ('changed', this._onChange.bind (this));
|
||||
this.node.appendChild (this._select.getNode ());
|
||||
|
||||
this._col = new Htk.ColumnText ();
|
||||
this._grid.appendColumn (this._col);
|
||||
this._ul = document.createElement ('ul');
|
||||
this.node.appendChild (this._ul);
|
||||
}
|
||||
|
||||
,_onButtonClick: function ()
|
||||
,_onClick: function ()
|
||||
{
|
||||
if (!this._model)
|
||||
if (this._model && this._model.status === Db.Model.Status.CLEAN)
|
||||
this._model.refresh ();
|
||||
}
|
||||
|
||||
,_onCloseClick: function (li)
|
||||
{
|
||||
Vn.Node.remove (li);
|
||||
}
|
||||
|
||||
,_onChange: function ()
|
||||
{
|
||||
if (this._select.value === null
|
||||
|| this._select.value === undefined)
|
||||
return;
|
||||
|
||||
this._model.refresh ();
|
||||
var li = document.createElement ('li');
|
||||
this._ul.appendChild (li);
|
||||
|
||||
var popup = new Htk.Popup ();
|
||||
popup.setChild (this._grid);
|
||||
popup.show (this._button);
|
||||
var button = document.createElement ('button');
|
||||
button.addEventListener ('click',
|
||||
this._onCloseClick.bind (this, li));
|
||||
li.appendChild (button);
|
||||
|
||||
var img = document.createElement ('img');
|
||||
img.src = 'image/close.svg';
|
||||
button.appendChild (img);
|
||||
|
||||
var label = this._select.getByIndex (this._columnIndex);
|
||||
var text = document.createTextNode (label);
|
||||
li.appendChild (text);
|
||||
|
||||
setTimeout (this._onTimeout.bind (this));
|
||||
}
|
||||
|
||||
,_onTimeout: function ()
|
||||
{
|
||||
this._select.value = null;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -459,4 +478,3 @@ Vn.ColumnItem = new Class
|
|||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
<vn>
|
||||
<button
|
||||
id="button"
|
||||
class="vn-filter-button thin"
|
||||
on-click="_onButtonClick"/>
|
||||
<htk-repeater id="popup" form-id="form">
|
||||
<div>
|
||||
<htk-text form="form" id="cell"/>
|
||||
</div>
|
||||
</htk-repeater>
|
||||
</vn>
|
|
@ -59,34 +59,53 @@
|
|||
|
||||
/* Right panel */
|
||||
|
||||
.right-panel > .body
|
||||
{
|
||||
text-align: center;
|
||||
padding: 1em;
|
||||
overflow: auto;
|
||||
}
|
||||
.right-panel
|
||||
{
|
||||
position: absolute;
|
||||
top: 3.9em;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 17em;
|
||||
background-color: white;
|
||||
box-shadow: 0 0.2em 0.2em #AAA;
|
||||
}
|
||||
.right-panel select
|
||||
{
|
||||
margin: .8em auto;
|
||||
width: 12em;
|
||||
/* color: #333;
|
||||
background-color: #EEE;
|
||||
border: 0;*/
|
||||
}
|
||||
option.placeholder
|
||||
{
|
||||
color: #999;
|
||||
}
|
||||
|
||||
.right-panel
|
||||
.vn-filter ul
|
||||
{
|
||||
position: absolute;
|
||||
z-index: 20;
|
||||
top: 3.9em;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
width: 15em;
|
||||
background-color: white;
|
||||
box-shadow: 0 0.2em 0.2em #AAA;
|
||||
|
||||
text-align: center;
|
||||
padding: 1em;
|
||||
overflow: auto;
|
||||
margin: 0;
|
||||
list-style-type: none;
|
||||
text-align: left;
|
||||
color: #666;
|
||||
padding-left: 2em;
|
||||
}
|
||||
.right-panel select,
|
||||
.right-panel button
|
||||
.vn-filter li
|
||||
{
|
||||
margin: 1em auto;
|
||||
width: 12em;
|
||||
/* color: #333;
|
||||
background-color: #EEE;
|
||||
border: 0;*/
|
||||
line-height: 2em;
|
||||
}
|
||||
.vn-filter li > button
|
||||
{
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
padding: .2em;
|
||||
margin-right: .2em;
|
||||
}
|
||||
|
||||
button.basket
|
||||
|
@ -314,6 +333,7 @@ td.third-category
|
|||
{
|
||||
top: 0;
|
||||
right: -17em;
|
||||
z-index: 20;
|
||||
}
|
||||
.right-panel.show
|
||||
{
|
||||
|
|
|
@ -1,21 +1,48 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="realm" on-changed="onTypeChange">
|
||||
<vn-hash-param key="realm"/>
|
||||
</vn-param>
|
||||
<vn-param id="type" on-changed="onTypeChange">
|
||||
<vn-hash-param key="type"/>
|
||||
</vn-param>
|
||||
<!--
|
||||
<sql-filter-item type="EQUAL" id="op-realm">
|
||||
<sql-field name="reino_id" target="t"/>
|
||||
<sql-set param="realm"/>
|
||||
</sql-filter-item>
|
||||
<sql-filter-item type="EQUAL" id="op-type">
|
||||
<sql-field name="tipo_id"/>
|
||||
<sql-set param="type"/>
|
||||
</sql-filter-item>
|
||||
<sql-filter-item type="EQUAL" id="op-color">
|
||||
<sql-field name="Color"/>
|
||||
<sql-set param="color"/>
|
||||
</sql-filter-item>
|
||||
<sql-filter-item type="EQUAL" id="op-origin">
|
||||
<sql-field name="id_origen"/>
|
||||
<sql-set param="origin"/>
|
||||
</sql-filter-item>
|
||||
<sql-filter-item type="EQUAL" id="op-category">
|
||||
<sql-field name="Categoria"/>
|
||||
<sql-set param="category"/>
|
||||
</sql-filter-item>
|
||||
-->
|
||||
</vn-group>
|
||||
<vn-group>
|
||||
<vn-hash-param key="realm">
|
||||
<vn-param id="realm" on-changed="onTypeChange"/>
|
||||
</vn-hash-param>
|
||||
<vn-hash-param key="type">
|
||||
<vn-param id="type" on-changed="onTypeChange"/>
|
||||
</vn-hash-param>
|
||||
<vn-param id="search"/>
|
||||
<sql-filter type="AND" id="filter">
|
||||
<sql-filter-item type="EQUAL" id="sql-type">
|
||||
<sql-field name="tipo_id"/>
|
||||
<sql-value param="type"/>
|
||||
</sql-filter-item>
|
||||
<sql-filter-item type="LIKE">
|
||||
<sql-filter-item type="LIKE" id="op-name">
|
||||
<sql-field name="Article"/>
|
||||
<sql-search-tags param="search"/>
|
||||
</sql-filter-item>
|
||||
<!--
|
||||
<pointer object="op-realm"/>
|
||||
<pointer object="op-type"/>
|
||||
<pointer object="op-color"/>
|
||||
<pointer object="op-origin"/>
|
||||
<pointer object="op-category"/>
|
||||
-->
|
||||
</sql-filter>
|
||||
<db-query id="basket-lines">
|
||||
SELECT item_id, warehouse_id, SUM(amount) amount
|
||||
|
@ -29,7 +56,7 @@
|
|||
SELECT Id_Article item_id FROM vn2008.Articles
|
||||
WHERE #filter;
|
||||
CALL bionic_calc ();
|
||||
SELECT a.Id_Article, t.available, t.price, p.producer,
|
||||
SELECT a.Id_Article item_id, t.available, t.price, p.producer,
|
||||
a.Foto, a.Article, a.Categoria, a.Medida, a.Tallos, a.Color, o.Abreviatura
|
||||
FROM tmp.bionic_item t
|
||||
JOIN vn2008.Articles a ON a.Id_Article = t.item_id
|
||||
|
@ -100,9 +127,16 @@
|
|||
show-full="true"
|
||||
full-dir="900x900"
|
||||
editable="true"/>
|
||||
<vn-column-item title="_Name" column="Article" renderer="nameRenderer"/>
|
||||
<htk-column-text title="_Cat" renderer="featuresRender"/>
|
||||
<htk-column-spin title="_Aval" column="available"/>
|
||||
<vn-column-item
|
||||
title="_Name"
|
||||
column="Article"
|
||||
renderer="nameRenderer"/>
|
||||
<htk-column-text
|
||||
title="_Cat"
|
||||
renderer="featuresRender"/>
|
||||
<htk-column-spin
|
||||
title="_Aval"
|
||||
column="available"/>
|
||||
<htk-column-text
|
||||
title="_Price"
|
||||
column="price"
|
||||
|
@ -162,16 +196,8 @@
|
|||
</div>
|
||||
</template>
|
||||
</htk-repeater>
|
||||
<div id="realm-popup">
|
||||
<htk-grid show-header="false">
|
||||
<db-model property="model" id="filter-model">
|
||||
SELECT id, reino, color FROM vn2008.reinos
|
||||
WHERE display != FALSE ORDER BY reino
|
||||
</db-model>
|
||||
<htk-column-text column="reino"/>
|
||||
</htk-grid>
|
||||
</div>
|
||||
<div id="right-panel" class="right-panel" on-click="onRightPanelClick">
|
||||
<div class="body">
|
||||
<select>
|
||||
<option value="" disabled="true" selected="true">
|
||||
<t>Order by</t>
|
||||
|
@ -201,36 +227,64 @@
|
|||
<t>Origin</t>
|
||||
</option>
|
||||
</select>
|
||||
<htk-combo placeholder="_Realm" on-click="onSelectClick">
|
||||
<db-model property="model" result-index="1" auto-load="false">
|
||||
SELECT SLEEP(2);
|
||||
SELECT id, reino, color FROM vn2008.reinos
|
||||
WHERE display != FALSE ORDER BY reino
|
||||
<vn-filter placeholder="_Realm">
|
||||
<db-model auto-load="false" result-index="1">
|
||||
CALL item_available ();
|
||||
SELECT DISTINCT r.id, r.reino
|
||||
FROM vn2008.reinos r
|
||||
JOIN vn2008.Tipos t ON t.reino_id = r.id
|
||||
JOIN vn2008.Articles a ON a.tipo_id = t.tipo_id
|
||||
JOIN tmp.item_available i ON i.item_id = a.Id_Article
|
||||
WHERE /*#filter
|
||||
AND*/ r.display
|
||||
ORDER BY r.reino
|
||||
</db-model>
|
||||
</htk-combo>
|
||||
<vn-filter-button text="_Subtype" column="Tipo">
|
||||
<db-model>
|
||||
CALL type_list (1)
|
||||
</vn-filter>
|
||||
<vn-filter placeholder="_Subtype">
|
||||
<db-model auto-load="false" result-index="1">
|
||||
CALL item_available ();
|
||||
SELECT DISTINCT t.tipo_id, LEFT(t.Tipo, 18) type
|
||||
FROM vn2008.Tipos t
|
||||
JOIN vn2008.Articles a ON a.tipo_id = t.tipo_id
|
||||
JOIN tmp.item_available i ON i.item_id = a.Id_Article
|
||||
/*WHERE #filter*/
|
||||
ORDER BY t.Tipo
|
||||
</db-model>
|
||||
</vn-filter-button>
|
||||
<vn-filter-button text="_Color" column="Color">
|
||||
<db-model>
|
||||
SELECT Id_Color, Color
|
||||
FROM vn2008.Colores ORDER BY Color
|
||||
</vn-filter>
|
||||
<vn-filter placeholder="_Color">
|
||||
<db-model auto-load="false" result-index="1">
|
||||
CALL item_available ();
|
||||
SELECT DISTINCT c.Id_Tinta, c.name
|
||||
FROM vn2008.Tintas c
|
||||
JOIN vn2008.Articles a ON a.Color = c.Id_Tinta
|
||||
JOIN tmp.item_available i ON i.item_id = a.Id_Article
|
||||
/*WHERE #filter*/
|
||||
ORDER BY c.name
|
||||
</db-model>
|
||||
</vn-filter-button>
|
||||
<vn-filter-button text="_Origin" column="Origen">
|
||||
<db-model>
|
||||
SELECT id, Abreviatura, Origen
|
||||
FROM vn2008.Origen ORDER BY Origen
|
||||
</vn-filter>
|
||||
<vn-filter placeholder="_Origin">
|
||||
<db-model auto-load="false" result-index="1">
|
||||
CALL item_available ();
|
||||
SELECT DISTINCT o.id, o.Origen, o.Abreviatura
|
||||
FROM vn2008.Origen o
|
||||
JOIN vn2008.Articles a ON a.id_origen = o.id
|
||||
JOIN tmp.item_available i ON i.item_id = a.Id_Article
|
||||
/*WHERE #filter*/
|
||||
ORDER BY o.Origen
|
||||
</db-model>
|
||||
</vn-filter-button>
|
||||
<vn-filter-button text="_Category" column="category">
|
||||
<db-model>
|
||||
SELECT 'A1' category UNION SELECT 'A2' UNION SELECT 'B1'
|
||||
</vn-filter>
|
||||
<vn-filter placeholder="_Category">
|
||||
<db-model auto-load="false" result-index="1">
|
||||
CALL item_available ();
|
||||
SELECT DISTINCT a.Categoria, a.Categoria category
|
||||
FROM vn2008.Articles a
|
||||
JOIN tmp.item_available i ON i.item_id = a.Id_Article
|
||||
/*WHERE #filter*/
|
||||
ORDER BY a.Categoria
|
||||
</db-model>
|
||||
</vn-filter-button>
|
||||
<div style="display: none">
|
||||
</vn-filter>
|
||||
</div>
|
||||
<!--
|
||||
<htk-repeater
|
||||
model="realms-model"
|
||||
form-id="realm-form"
|
||||
|
@ -264,7 +318,7 @@
|
|||
</a>
|
||||
</template>
|
||||
</htk-repeater>
|
||||
</div>
|
||||
-->
|
||||
</div>
|
||||
<div id="lots-popup" class="lots-popup">
|
||||
<htk-grid class="lots-grid" model="item-lots" show-header="false">
|
||||
|
|
|
@ -65,21 +65,17 @@ Vn.Checkout = new Class
|
|||
return;
|
||||
|
||||
if (this.$('order-form').numRows > 0)
|
||||
{
|
||||
Htk.Toast.showMessage (_('OrderUpdated'));
|
||||
window.history.back();
|
||||
}
|
||||
else
|
||||
{
|
||||
Htk.Toast.showMessage (_('OrderStarted'));
|
||||
|
||||
this.hash.set ({'form': 'ecomerce/catalog'});
|
||||
}
|
||||
}
|
||||
|
||||
,onCancelClick: function ()
|
||||
{
|
||||
if (this.$('order-form').numRows > 0)
|
||||
this.hash.set ({'form': 'ecomerce/basket'});
|
||||
window.history.back();
|
||||
else
|
||||
this.hash.set ({'form': 'ecomerce/orders'});
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="ticket-id">
|
||||
<vn-hash-param key="ticket"/>
|
||||
</vn-param>
|
||||
<vn-hash-param key="ticket">
|
||||
<vn-param id="ticket-id"/>
|
||||
</vn-hash-param>
|
||||
<db-form id="ticket">
|
||||
<db-model id="ticket-data">
|
||||
SELECT t.id, date, a.Agencia, note, p.name province,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<vn>
|
||||
<vn-group>
|
||||
<vn-param id="new-id">
|
||||
<vn-hash-param key="new"/>
|
||||
</vn-param>
|
||||
<vn-hash-param key="new">
|
||||
<vn-param id="new-id"/>
|
||||
</vn-hash-param>
|
||||
<db-form id="iter" on-status-changed="onStatusChange">
|
||||
<db-param column="text" on-changed="onBodyChange"/>
|
||||
<db-model id="model" updatable="true" on-operations-done="onOperationsDone">
|
||||
|
|
|
@ -123,6 +123,8 @@ if (file_exists ($basePath))
|
|||
|
||||
require ($basePath .'/html.php');
|
||||
}
|
||||
else
|
||||
header ('Location: ./');
|
||||
|
||||
myExitHandler ();
|
||||
|
||||
|
|
|
@ -98,7 +98,8 @@ Htk.Select = new Class
|
|||
{
|
||||
this.parent (props);
|
||||
this.createElement ('select');
|
||||
this.node.addEventListener ('change', this.changed.bind (this));
|
||||
this.node.addEventListener ('change', this._onChange.bind (this));
|
||||
this._addPlaceholder (this._placeholder);
|
||||
}
|
||||
|
||||
,on: function (id, callback, instance)
|
||||
|
@ -106,6 +107,8 @@ Htk.Select = new Class
|
|||
switch (id)
|
||||
{
|
||||
case 'click':
|
||||
case 'mousedown':
|
||||
case 'focusout':
|
||||
this.node.addEventListener (id,
|
||||
callback.bind (instance, this));
|
||||
break;
|
||||
|
@ -116,11 +119,16 @@ Htk.Select = new Class
|
|||
|
||||
,setRow: function (row)
|
||||
{
|
||||
if (row != -1)
|
||||
this.node.selectedIndex = row + 1;
|
||||
else
|
||||
this.node.selectedIndex = 0;
|
||||
|
||||
this._row = row;
|
||||
this.iterChanged ();
|
||||
}
|
||||
|
||||
,changed: function (event)
|
||||
,_onChange: function (event)
|
||||
{
|
||||
var value;
|
||||
var row = this.node.selectedIndex - 1;
|
||||
|
@ -130,8 +138,8 @@ Htk.Select = new Class
|
|||
else
|
||||
value = null;
|
||||
|
||||
this.valueChanged (value);
|
||||
this.setRow (row);
|
||||
this.valueChanged (value);
|
||||
}
|
||||
|
||||
,addOption: function (value, text)
|
||||
|
@ -145,23 +153,21 @@ Htk.Select = new Class
|
|||
this.node.appendChild (option);
|
||||
}
|
||||
|
||||
,addPlaceholder: function (text)
|
||||
,_addPlaceholder: function (text)
|
||||
{
|
||||
var option = document.createElement ('option');
|
||||
option.className = 'htk-option';
|
||||
option.disabled = true;
|
||||
option.selected = true;
|
||||
option.value = null;
|
||||
|
||||
if (text)
|
||||
option.appendChild (document.createTextNode (text));
|
||||
|
||||
Vn.Node.setText (option, text ? text : '');
|
||||
this.node.appendChild (option);
|
||||
this._placeholderNode = option;
|
||||
}
|
||||
|
||||
,onModelChange: function ()
|
||||
{
|
||||
var placeholder = '';
|
||||
var placeholder = null;
|
||||
var model = this._model;
|
||||
this.signalEmit ('status-changed');
|
||||
|
||||
|
@ -169,26 +175,49 @@ Htk.Select = new Class
|
|||
|
||||
switch (model.status)
|
||||
{
|
||||
case Db.Model.Status.READY:
|
||||
case Db.Model.Status.ERROR:
|
||||
placeholder = _('Error');
|
||||
break;
|
||||
case Db.Model.Status.LOADING:
|
||||
placeholder = _('Loading...');
|
||||
break;
|
||||
default:
|
||||
placeholder = this._placeholder;
|
||||
}
|
||||
|
||||
if (placeholder)
|
||||
this._addPlaceholder (placeholder);
|
||||
|
||||
if (model.ready)
|
||||
{
|
||||
var data = model.data;
|
||||
this.addPlaceholder (this._placeholder);
|
||||
|
||||
for (var i = 0; i < data.length; i++)
|
||||
this.addOption (data[i][this.showColumnIndex], data[i][1]);
|
||||
|
||||
this.selectOption ();
|
||||
break;
|
||||
this._onTimeout ();
|
||||
}
|
||||
case Db.Model.Status.ERROR:
|
||||
placeholder = 'Error';
|
||||
break;
|
||||
case Db.Model.Status.LOADING:
|
||||
placeholder = 'Loading...';
|
||||
default:
|
||||
this.addPlaceholder (_(placeholder));
|
||||
else
|
||||
this.setRow (-1);
|
||||
}
|
||||
|
||||
,_onTimeout: function ()
|
||||
{
|
||||
if (this._blockMouseDown || !navigator.userAgent.match (/WebKit/))
|
||||
return;
|
||||
|
||||
this._blockMouseDown = true;
|
||||
|
||||
this.node.blur();
|
||||
|
||||
var e = document.createEvent('MouseEvents');
|
||||
e.initMouseEvent ('mousedown',
|
||||
true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
|
||||
this.node.dispatchEvent(e);
|
||||
|
||||
this._blockMouseDown = false;
|
||||
this.node.focus ();
|
||||
}
|
||||
|
||||
,setEditable: function (editable)
|
||||
|
@ -200,13 +229,8 @@ Htk.Select = new Class
|
|||
{
|
||||
var row;
|
||||
|
||||
if (this._model && this._model.status == Db.Model.Status.READY)
|
||||
{
|
||||
if (this._model && this._model.ready)
|
||||
row = this._model.searchByIndex (this.valueColumnIndex, this._value);
|
||||
|
||||
if (row != -1)
|
||||
this.node.selectedIndex = row + 1;
|
||||
}
|
||||
else
|
||||
row = -1;
|
||||
|
||||
|
|
|
@ -103,6 +103,13 @@
|
|||
margin: auto;
|
||||
}
|
||||
|
||||
/* Combo */
|
||||
|
||||
.htk-option
|
||||
{
|
||||
/* color: #999;*/
|
||||
}
|
||||
|
||||
/* Button */
|
||||
|
||||
.htk-button > span
|
||||
|
|
|
@ -12,6 +12,7 @@ Sql.Operation = new Class ().extend
|
|||
,LIKE : 1
|
||||
,AND : 2
|
||||
,OR : 3
|
||||
,REGEXP : 4
|
||||
}
|
||||
,Operators:
|
||||
[
|
||||
|
@ -19,6 +20,7 @@ Sql.Operation = new Class ().extend
|
|||
,'LIKE'
|
||||
,'AND'
|
||||
,'OR'
|
||||
,'REGEXP'
|
||||
]
|
||||
});
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ Sql.SearchTags = new Class
|
|||
{
|
||||
if (typeof this._value == 'string')
|
||||
{
|
||||
var value = this._value.replace (/^| +|$/g, '%');
|
||||
var value = this._value.replace (/^|\s+|$/g, '%');
|
||||
return "'" + value.replace (this.regexp, this.replaceFunc) + "'";
|
||||
}
|
||||
else
|
||||
|
|
|
@ -7,6 +7,8 @@ Vn.Builder = new Class
|
|||
,objectMap: {}
|
||||
,tags: {}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++ Deprecated
|
||||
|
||||
,loadXml: function (xmlDoc)
|
||||
{
|
||||
if (!xmlDoc)
|
||||
|
@ -146,47 +148,6 @@ Vn.Builder = new Class
|
|||
return customNode;
|
||||
}
|
||||
|
||||
,translateValue: function (value)
|
||||
{
|
||||
var chr = value.charAt (0);
|
||||
|
||||
if (chr == '_')
|
||||
return _(value.substr (1));
|
||||
else if (chr == '\\' && value.charAt (1) == '_')
|
||||
return value.substr (1);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
,getMethod: function (value)
|
||||
{
|
||||
if (this.signalData)
|
||||
var methodName = 'this.signalData.'+ value;
|
||||
else
|
||||
var methodName = value;
|
||||
|
||||
var method;
|
||||
|
||||
try {
|
||||
method = eval (methodName);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
method = null;
|
||||
}
|
||||
|
||||
if (method == null)
|
||||
console.warn ('Vn.Builder: Function \'%s\' not found',
|
||||
value);
|
||||
|
||||
return method;
|
||||
}
|
||||
|
||||
,replaceFunc: function (token)
|
||||
{
|
||||
return token.charAt(1).toUpperCase ();
|
||||
}
|
||||
|
||||
,resolveProperties: function ()
|
||||
{
|
||||
for (var i = 0; i < this.contexts.length; i++)
|
||||
|
@ -280,6 +241,365 @@ Vn.Builder = new Class
|
|||
attribute, c.node.tagName);
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++ Alpha
|
||||
|
||||
,load: function (thisData)
|
||||
{
|
||||
var contexts = this.contexts;
|
||||
var objects = new Array (contexts.length);
|
||||
|
||||
for (var i = 0; i < contexts.length; i++)
|
||||
{
|
||||
var context = contexts[i];
|
||||
objects[i] = context.func (context.template);
|
||||
}
|
||||
|
||||
var links = this.links;
|
||||
|
||||
for (var i = 0; i < links.length; i++)
|
||||
{
|
||||
var link = links[i];
|
||||
objects[link.contextId][link.propName] = objects[link.valueContext];
|
||||
}
|
||||
}
|
||||
|
||||
,compile: function (node, dstDocument)
|
||||
{
|
||||
this.contexts = [];
|
||||
this.contextMap = {};
|
||||
this.pointers = [];
|
||||
this.links = [];
|
||||
this.document = dstDocument ? dstDocument : document;
|
||||
|
||||
this.compileRec (node, null);
|
||||
|
||||
for (var i = 0; i < this.pointers.length; i++)
|
||||
{
|
||||
var pointerId = this.pointers[i].template;
|
||||
var refContext = this.contextMap[pointerId];
|
||||
}
|
||||
}
|
||||
|
||||
,compileRec: function (node, parentContext)
|
||||
{
|
||||
var tagName = null;
|
||||
|
||||
if (node.tagName)
|
||||
tagName = node.tagName.toLowerCase ();
|
||||
|
||||
var context = {
|
||||
node: node
|
||||
,parent: parentContext
|
||||
,template: template
|
||||
,id: this.contexts.length
|
||||
,func: null
|
||||
};
|
||||
this.contexts.push (context);
|
||||
|
||||
var template =
|
||||
createTextTemplate (context, node, tagName)
|
||||
|| createPointerTemplate (context, node, tagName)
|
||||
|| createObjectTemplate (context, node, tagName)
|
||||
|| createHtmlTemplate (context, node, tagName);
|
||||
|
||||
var id = node.getAttribute ('id');
|
||||
|
||||
if (id)
|
||||
this.contextMap[id] = context;
|
||||
|
||||
if (parentContext)
|
||||
{
|
||||
var parentProperty = node.getAttribute ('property');
|
||||
|
||||
if (!parentProperty && parentContext.template.klass)
|
||||
parentProperty = parentContext.template.klass.Child;
|
||||
|
||||
if (parentProperty)
|
||||
{
|
||||
this.links.push ({
|
||||
contextId: context.id,
|
||||
propName: propName,
|
||||
valueContext: valueContext.id
|
||||
});
|
||||
}
|
||||
|
||||
this.registerLink (parentContext, parentProperty, context);
|
||||
|
||||
if (klass.Parent)
|
||||
this.registerLink (context, klass.Parent, parentContext);
|
||||
}
|
||||
|
||||
var childs = node.childNodes;
|
||||
|
||||
if (childs)
|
||||
for (var i = 0; i < childs.length; i++)
|
||||
this.compileRec (childs[i], context);
|
||||
|
||||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a text node template.
|
||||
**/
|
||||
,createTextTemplate: function (context, node, tagName)
|
||||
{
|
||||
if (tagName === 't')
|
||||
var text = _(node.firstChild.textContent);
|
||||
else if (!tagName)
|
||||
var text = node.textContent;
|
||||
else
|
||||
return null;
|
||||
|
||||
return
|
||||
|
||||
context.func = createTextInstance;
|
||||
return text;
|
||||
}
|
||||
|
||||
,createTextInstance: function (template)
|
||||
{
|
||||
return this.document.createTextNode (template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a object pointer template.
|
||||
**/
|
||||
,createPointerTemplate: function (context, node, tagName)
|
||||
{
|
||||
if (tagName !== 'pointer')
|
||||
return null;
|
||||
|
||||
this.pointers.push (context);
|
||||
return node.getAttribute ('object');
|
||||
}
|
||||
|
||||
,createPointerInstance: function (template)
|
||||
{
|
||||
return this.objectMap[template];
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a object template.
|
||||
**/
|
||||
,createObjectTemplate: function (context, node, tagName)
|
||||
{
|
||||
var id = null;
|
||||
var handler;
|
||||
var props = {};
|
||||
var events = null;
|
||||
var klass = Vn.customTags[tagName];
|
||||
|
||||
if (!klass)
|
||||
return null;
|
||||
|
||||
var a = node.attributes;
|
||||
|
||||
for (var i = 0; i < a.length; i++)
|
||||
{
|
||||
var attribute = a[i].nodeName;
|
||||
var value = a[i].nodeValue;
|
||||
|
||||
if (attribute === 'id')
|
||||
{
|
||||
id = value;
|
||||
}
|
||||
else if ((handler = this.getEventHandler (attribute, value)))
|
||||
{
|
||||
if (!events)
|
||||
events = {};
|
||||
|
||||
events[attribute.substr (3)] = handler;
|
||||
}
|
||||
else if (attribute !== 'property')
|
||||
{
|
||||
this.createPropTemplate (context, klass, props,
|
||||
node, attribute, value);
|
||||
}
|
||||
}
|
||||
|
||||
context.func = createObjectInstance;
|
||||
return {
|
||||
klass: klass,
|
||||
events: events,
|
||||
id: id
|
||||
};
|
||||
}
|
||||
|
||||
,createPropTemplate: function (context, klass, props, node, attribute, value)
|
||||
{
|
||||
var newValue = null;
|
||||
var propName = attribute.replace (/-./g, this.replaceFunc);
|
||||
var propInfo = klass.Properties[propName];
|
||||
|
||||
if (!propInfo)
|
||||
{
|
||||
console.warn ('Vn.Builder: Attribute \'%s\' not valid for tag \'%s\'',
|
||||
attribute, node.tagName);
|
||||
return;
|
||||
}
|
||||
if (!value)
|
||||
{
|
||||
console.warn ('Vn.Builder: Attribute \'%s\' empty on tag \'%s\'',
|
||||
attribute, node.tagName);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (propInfo.type)
|
||||
{
|
||||
case Boolean:
|
||||
newValue = (/^(true|1)$/i).test (value);
|
||||
break;
|
||||
case Number:
|
||||
newValue = 0 + new Number (value);
|
||||
break;
|
||||
case String:
|
||||
newValue = this.translateValue (value);
|
||||
break;
|
||||
case Function:
|
||||
newValue = this.getMethod (value);
|
||||
break;
|
||||
case Vn.Enum:
|
||||
newValue = propInfo.enumType[value];
|
||||
break;
|
||||
}
|
||||
|
||||
if (newValue !== null && newValue !== undefined)
|
||||
{
|
||||
props[propName] = newValue;
|
||||
}
|
||||
else if (propInfo.type instanceof Function)
|
||||
{
|
||||
this.registerLink (context, attribute, value);
|
||||
}
|
||||
else
|
||||
console.warn ('Vn.Builder: Attribute \'%s\' invalid for tag \'%s\'',
|
||||
attribute, node.tagName);
|
||||
}
|
||||
|
||||
,createObjectInstance: function (template)
|
||||
{
|
||||
var object = new template.klass (template.props);
|
||||
|
||||
var events = template.events;
|
||||
|
||||
for (var event in events)
|
||||
object.on (event,
|
||||
events[event].bind (this.signalData));
|
||||
|
||||
if (template.id)
|
||||
this.objectMap[id] = object;
|
||||
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a HTML node template.
|
||||
**/
|
||||
,createHtmlTemplate: function (context, node, tagName)
|
||||
{
|
||||
var id = null;
|
||||
var handler;
|
||||
var events = null;
|
||||
var htmlNode = this.document.createElement (tagName);
|
||||
|
||||
var a = node.attributes;
|
||||
|
||||
for (var i = 0; i < a.length; i++)
|
||||
{
|
||||
var attribute = a[i].nodeName;
|
||||
var value = a[i].nodeValue;
|
||||
|
||||
if (attribute === 'id')
|
||||
{
|
||||
id = value;
|
||||
}
|
||||
else if ((handler = this.getEventHandler (attribute, value)))
|
||||
{
|
||||
if (!events)
|
||||
events = {};
|
||||
|
||||
events[attribute.substr (3)] = handler;
|
||||
}
|
||||
else
|
||||
htmlNode.setAttribute (nodeName,
|
||||
this.translateValue (nodeValue));
|
||||
}
|
||||
|
||||
context.func = createHtmlInstance;
|
||||
return {
|
||||
node: htmlNode,
|
||||
events: events,
|
||||
id: id
|
||||
};
|
||||
}
|
||||
|
||||
,createHtmlInstance: function (template)
|
||||
{
|
||||
var node = new template.node.cloneNode (false);
|
||||
|
||||
var events = template.events;
|
||||
|
||||
for (var event in events)
|
||||
node.addEventListener (event,
|
||||
events[event].bind (this.signalData));
|
||||
|
||||
if (template.id)
|
||||
this.objectMap[id] = node;
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
//+++++++++++++++++++++++++++++++++++++++++++ Utilities
|
||||
|
||||
,translateValue: function (value)
|
||||
{
|
||||
var chr = value.charAt (0);
|
||||
|
||||
if (chr == '_')
|
||||
return _(value.substr (1));
|
||||
else if (chr == '\\' && value.charAt (1) == '_')
|
||||
return value.substr (1);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
,getMethod: function (value)
|
||||
{
|
||||
if (this.signalData)
|
||||
var methodName = 'this.signalData.'+ value;
|
||||
else
|
||||
var methodName = value;
|
||||
|
||||
var method;
|
||||
|
||||
try {
|
||||
method = eval (methodName);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
method = null;
|
||||
}
|
||||
|
||||
if (method == null)
|
||||
console.warn ('Vn.Builder: Function \'%s\' not found',
|
||||
value);
|
||||
|
||||
return method;
|
||||
}
|
||||
|
||||
,getEventHandler: function (attribute, value)
|
||||
{
|
||||
if (!(/^on-\w+/.test (attribute)))
|
||||
return null;
|
||||
|
||||
return this.getMethod (value);
|
||||
}
|
||||
|
||||
,replaceFunc: function (token)
|
||||
{
|
||||
return token.charAt(1).toUpperCase ();
|
||||
}
|
||||
|
||||
,setParent: function (parentBuilder)
|
||||
{
|
||||
this.parentBuilder = parentBuilder;
|
||||
|
|
|
@ -3,7 +3,7 @@ Vn.HashParam = new Class
|
|||
({
|
||||
Extends: Vn.Object
|
||||
,Tag: 'vn-hash-param'
|
||||
,Parent: 'param'
|
||||
,Child: 'param'
|
||||
,Properties:
|
||||
{
|
||||
param:
|
||||
|
|
|
@ -185,3 +185,6 @@ Vn.Object = new Class
|
|||
}
|
||||
}
|
||||
});
|
||||
|
||||
Vn.Enum = function () {};
|
||||
|
||||
|
|
Loading…
Reference in New Issue