Add JS files
This commit is contained in:
402
modules/EcmProductB2Bs/AjaxSearch/AjaxSearch.js
Executable file
402
modules/EcmProductB2Bs/AjaxSearch/AjaxSearch.js
Executable file
@@ -0,0 +1,402 @@
|
||||
|
||||
function addEvent(object,eventName,do_function) {
|
||||
if(typeof(object) == "string") object = document.getElementById(object);
|
||||
if(!object) { alert('No object in function addEvent!'); return; }
|
||||
if(object.addEventListener) {
|
||||
object.addEventListener(eventName, do_function, false);
|
||||
} else {
|
||||
object.attachEvent('on'+eventName, do_function);
|
||||
}
|
||||
}
|
||||
|
||||
function setSelectionRange(obj) {
|
||||
if(obj && typeof(obj) == "object" && (obj.type == "text" || obj.type == "textarea")) {
|
||||
if(obj.createTextRange) {
|
||||
var range = obj.createTextRange();
|
||||
range.moveStart("character", 0);
|
||||
range.moveEnd("character", obj.value.lengh-1);
|
||||
range.select();
|
||||
} else {
|
||||
if(obj.setSelectionRange) {
|
||||
obj.setSelectionRange(0,obj.value.length);
|
||||
}
|
||||
}
|
||||
obj.focus();
|
||||
}
|
||||
if(obj && typeof(obj) == "object" && obj.options) { obj.focus(); }
|
||||
}
|
||||
|
||||
var AjaxSearchItems;
|
||||
function AjaxSearch(div,displayNone) {
|
||||
|
||||
//fields
|
||||
|
||||
this.parentDIV = div; //pole w ktorym zawiera sie pole wyszukiwania
|
||||
this.div; //pole glowne wyszukiwania
|
||||
this.inputSearch; //input wyszukiwania
|
||||
this.timeout; //wskaznik zwracany przez setTimeout przy wcisnieciu klawisza
|
||||
this.searchDelay = 800; //opoznienie wyszukiwania
|
||||
this.divList; //pole w ktorym wyswietlana bedzie lista znalezionnych elementow
|
||||
this.ajaxSearchItem; //unikalny identyfikator;
|
||||
this.module = 'EcmQuotes';
|
||||
this.inputCode;
|
||||
|
||||
this.positionSelected;
|
||||
|
||||
//functions
|
||||
this.setInputCode = function(input) {
|
||||
this.inputCode = input;
|
||||
this.inputCode.previousCode = this.inputCode.value;
|
||||
}
|
||||
|
||||
this.inputSearchOnKeyDown = function(e,other) {
|
||||
var keynum;
|
||||
if(typeof(e) == "number")
|
||||
keynum = e;
|
||||
else {
|
||||
if(window.event) //IE
|
||||
keynum = e.keyCode;
|
||||
else
|
||||
keynum = e.which;
|
||||
}
|
||||
|
||||
if(keynum == 38) { this.selectPreviousPosition(); return false; }
|
||||
if(keynum == 40) { this.selectNextPosition(); return false; }
|
||||
if(keynum == 13 || keynum == 9) { this.inputSearchEnterPressed(other); return false; }
|
||||
if(keynum == 27) { this.div.style.display = 'none'; }
|
||||
|
||||
if(this.timeout) { clearTimeout(this.timeout); this.timeout = null; }
|
||||
this.timeout = setTimeout("document.getElementById('"+this.div.id+"').AjaxSearch.search();", 500);
|
||||
}
|
||||
|
||||
this.inputSearchEnterPressed = function(other) {
|
||||
if(this.positionSelected) {
|
||||
var row;
|
||||
if(N.selectedRow) {
|
||||
N.selectedRow.setData(this.positionSelected.positionData);
|
||||
row = N.selectedRow;
|
||||
}
|
||||
else {
|
||||
row = N.addRow().setData(this.positionSelected.positionData);
|
||||
}
|
||||
row.calculateTotal();
|
||||
if((other && other == "clear") || OPT['quick_product_item_adding']==0) {
|
||||
this.clearList();
|
||||
this.div.style.display = 'none';
|
||||
if(OPT['quick_product_item_adding'] == 0) if(N.selectedCell && N.selectedCell.index == 1) N.selectedCell.selectNext();
|
||||
} else {
|
||||
row.noHideASP = true;
|
||||
if(N.selectedRow) row = row.myTable.addRow(row.index+1);
|
||||
row.select();
|
||||
row.cells.item(0).select();
|
||||
setSelectionRange(this.inputSearch);
|
||||
}
|
||||
}
|
||||
else if(N.selectedRow) {
|
||||
if(this.inputSearch.value != this.inputCode.previousCode || this.inputCode.previousCode == '') {
|
||||
var data = new Object();
|
||||
N.selectedRow.setData(data);
|
||||
N.selectedRow.cells.item(1).select();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
//N.addRow();
|
||||
}
|
||||
|
||||
this.selectNextPosition = function() {
|
||||
if(this.positionSelected) {
|
||||
if(this.positionSelected.nextSibling) {
|
||||
this.positionSelect(this.positionSelected.nextSibling);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.positionSelect(this.divList.lastChild);
|
||||
}
|
||||
|
||||
this.selectPreviousPosition = function() {
|
||||
if(this.positionSelected) {
|
||||
if(this.positionSelected.previousSibling) {
|
||||
this.positionSelect(this.positionSelected.previousSibling);
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.positionSelect(this.divList.firstChild);
|
||||
}
|
||||
|
||||
this.search = function() {
|
||||
|
||||
if(this.inputSearch.value == '') { this.clearList(); return; }
|
||||
var _ajax_search_process_search_ = this;
|
||||
this.Display = function(result) { _ajax_search_process_search_.processSearch(result.responseText); }
|
||||
this.Fail = function(result) { alert(result.responseText); }
|
||||
YAHOO.util.Connect.asyncRequest('POST','index.php',{success:this.Display,failure:this.Fail},'module='+this.module+'&action=AjaxSearchQuery&to_pdf=1&as_inputSearch='+this.inputSearch.value); //+'&ecmlanguage='+document.forms.EditView.ecmlanguage.value);
|
||||
|
||||
}
|
||||
|
||||
this.processSearch = function(result) {
|
||||
this.clearList();
|
||||
var list = eval(result);
|
||||
if(typeof(list) != "object") return;
|
||||
this.fillList(list);
|
||||
}
|
||||
|
||||
this.clearList = function() {
|
||||
this.divList.innerHTML = '';
|
||||
this.divList.style.height = '';
|
||||
this.positionDeselect();
|
||||
}
|
||||
|
||||
this.fillList = function(list) {
|
||||
for(x in list) {
|
||||
this.addPosition(list[x]);
|
||||
}
|
||||
this.positionSelect();
|
||||
this.setScrolls();
|
||||
}
|
||||
|
||||
this.setScrolls = function() {
|
||||
var clientH = -1;
|
||||
if(window.innerHeight && window.innerHeight > 0) clientH = window.innerHeight;
|
||||
else if(document.documentElement && document.documentElement.clientHeight > 0) clientH = document.documentElement.clientHeight;
|
||||
else if(document.body && document.body.clientHeight > 0) clientH = document.body.clientHeight;
|
||||
var XY = YAHOO.util.Dom.getXY(this.div);
|
||||
var divTop = (XY[1]+this.div.offsetHeight);
|
||||
if((divTop - (clientH+document.body.scrollTop)) > 0) {
|
||||
var newPos = divTop-clientH;
|
||||
document.body.scrollTop = newPos;
|
||||
}
|
||||
}
|
||||
|
||||
this.positionSelect = function(div,noScroll) {
|
||||
if(!div) {
|
||||
if(!this.positionSelected) {
|
||||
if(this.divList.firstChild) this.positionSelect(this.divList.firstChild);
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.positionDeselect();
|
||||
div.className = 'AjaxSearchPositionDivSelected';
|
||||
this.positionSelected = div;
|
||||
if(!noScroll) this.divList.scrollTop = div.offsetTop;
|
||||
}
|
||||
|
||||
this.positionDeselect = function() {
|
||||
if(this.positionSelected) {
|
||||
this.positionSelected.className = '';
|
||||
this.positionSelected = null;
|
||||
}
|
||||
}
|
||||
|
||||
this.addPosition = function(list) {
|
||||
if(typeof(list.code) == "undefined") return;
|
||||
var position = document.createElement('div');
|
||||
position.positionData = list;
|
||||
position.onclick = function() { this.parentNode.AjaxSearch.inputSearchEnterPressed(this); }
|
||||
position.onmouseover = function() { this.parentNode.AjaxSearch.positionSelect(this,true); };
|
||||
position.innerHTML = '<table width="100%" class="AjaxSearchPositionTable"><tr><td class="AjaxSearchPositionTableCode">'+this.markElement(list['code'])+'</td><td align="right" class="AjaxSearchPositionTablePrice">'+list['purchase_price']+' '+list['currency_symbol']+'<span style="color:black"> - </span><b>'+list['selling_price']+' '+list['currency_symbol']+'</b></td></tr><tr><td colspan="2" class="AjaxSearchPositionTableName">'+this.markElement(list['name'])+'</td></tr></table>';
|
||||
this.divList.appendChild(position);
|
||||
if((position.offsetTop+position.offsetHeight) > 300) this.divList.style.height = '300px'; else this.divList.style.height = '';
|
||||
}
|
||||
|
||||
this.markElement = function(str) {
|
||||
var s = "("+this.inputSearch.value+")";
|
||||
var regExp = new RegExp(s,'gi');
|
||||
return str.replace(regExp,"<b>$1</b>");
|
||||
}
|
||||
|
||||
this.AjaxSearchFrozen = false;
|
||||
this.AjaxSearchGetSettings = function () {
|
||||
var AjaxSearchToReq = this;
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
'POST',
|
||||
'index.php',
|
||||
{
|
||||
success: function(response) {
|
||||
if(response.responseText) {
|
||||
var str = response.responseText;
|
||||
var obj = eval(str);
|
||||
if(obj && obj[0]) {
|
||||
obj = obj[0];
|
||||
//if(obj.frozen) {
|
||||
AjaxSearchToReq.div.style.left = obj.pos_left;
|
||||
AjaxSearchToReq.div.style.top = obj.pos_top;
|
||||
AjaxSearchToReq.AjaxSearchFrozen = !(obj.frozen == "true" ? true : false);
|
||||
AjaxSearchToReq.AjaxSearchFreezePosition(true);
|
||||
//}
|
||||
}
|
||||
}
|
||||
},
|
||||
failure: function(response) {}
|
||||
},
|
||||
'module=Home&action=EcmAjaxSearchSettings&function=GetSettings&to_pdf=1&from_module='+this.module
|
||||
);
|
||||
}
|
||||
this.AjaxSearchSaveSettings = function () {
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
'POST',
|
||||
'index.php',
|
||||
{
|
||||
success: function(response) {},
|
||||
failure: function(response) {}
|
||||
},
|
||||
'module=Home&action=EcmAjaxSearchSettings&function=SaveSettings&to_pdf=1&from_module='+this.module+'&pos_top='+this.div.style.top+'&pos_left='+this.div.style.left+'&frozen='+this.AjaxSearchFrozen
|
||||
);
|
||||
}
|
||||
this.AjaxSearchFreezePosition = function (dontSave) {
|
||||
var img = document.getElementById('AjaxSearchPin');
|
||||
if(this.AjaxSearchFrozen) {
|
||||
img.src='modules/'+this.module+'/AjaxSearch/AjaxSearchPinOff.gif';
|
||||
this.AjaxSearchFrozen = false;
|
||||
} else {
|
||||
img.src='modules/'+this.module+'/AjaxSearch/AjaxSearchPinOn.gif';
|
||||
this.AjaxSearchFrozen = true;
|
||||
}
|
||||
if(!dontSave) this.AjaxSearchSaveSettings();
|
||||
}
|
||||
|
||||
this.createForm = function() {
|
||||
/*
|
||||
var div = document.createElement('div');
|
||||
div.className = 'AjaxSearch';
|
||||
div.AjaxSearch = this;
|
||||
*/
|
||||
var tmp = document.createElement('div');
|
||||
var div = "<div></div>";
|
||||
tmp.innerHTML = div;
|
||||
div = tmp.firstChild;
|
||||
|
||||
div.className = 'AjaxSearch';
|
||||
div.AjaxSearch = this;
|
||||
div.onMouseMoveEvent = function(ev) {
|
||||
if(!this.isOnMouseDown) return;
|
||||
ev = ev || window.event;
|
||||
var x = 0; var y = 0;
|
||||
if(ev.pageX || ev.pageY) {
|
||||
x = ev.pageX;
|
||||
y = ev.pageY;
|
||||
} else {
|
||||
x = ev.clientX + document.body.scrollLeft - document.body.clientLeft,
|
||||
y = ev.clientY + document.body.scrollTop - document.body.clientTop
|
||||
}
|
||||
this.style.left = x-this.MouseX;
|
||||
this.style.top = y-this.MouseY;
|
||||
}
|
||||
div.onMouseDownEvent = function(ev) {
|
||||
if(this.noDrag) { this.noDrag = false; return; }
|
||||
ev = ev || window.event;
|
||||
var x = 0; var y = 0;
|
||||
if(ev.pageX || ev.pageY) {
|
||||
x = ev.pageX;
|
||||
y = ev.pageY;
|
||||
} else {
|
||||
x = ev.clientX + document.body.scrollLeft - document.body.clientLeft,
|
||||
y = ev.clientY + document.body.scrollTop - document.body.clientTop
|
||||
}
|
||||
this.MouseX = x-this.offsetLeft;
|
||||
this.MouseY = y-this.offsetTop;
|
||||
this.isOnMouseDown = true;
|
||||
this.style.cursor = 'move';
|
||||
}
|
||||
div.onmouseup = function() {
|
||||
this.isOnMouseDown = false;
|
||||
this.style.cursor = '';
|
||||
//this.AjaxSearch.AjaxSearchSaveSettings();
|
||||
}
|
||||
//div.onmouseout = function() { this.onmouseup(); }
|
||||
ddiv = document.createElement('div');
|
||||
ddiv.id = 'AjaxSearch_ddiv';
|
||||
ddiv.className = 'AjaxSearch_ddiv';
|
||||
ddiv.appendChild(document.createTextNode('Search Product:'));
|
||||
ddiv.appendChild(document.createElement('br'));
|
||||
div.appendChild(ddiv);
|
||||
/*
|
||||
var inputSearch = document.createElement('input');
|
||||
inputSearch.type = 'text';
|
||||
inputSearch.id = 'as_inputSearch';
|
||||
inputSearch.className = 'AjaxSearchInputSearch';
|
||||
inputSearch.AjaxSearch = this;
|
||||
inputSearch.onkeydown = this.inputSearchOnKeyDown;
|
||||
this.inputSearch = inputSearch;
|
||||
div.appendChild(inputSearch);
|
||||
*/
|
||||
var img = '<img src="modules/'+this.module+'/AjaxSearch/AjaxSearchPinOff.gif" id="AjaxSearchPin" class="AjaxSearchPin" onclick="this.parentNode.AjaxSearch.AjaxSearchFreezePosition();" />';
|
||||
img += '<img src="modules/'+this.module+'/AjaxSearch/AjaxSearchCloseIcon.gif" class="AjaxSearchCloseIcon" onclick="this.parentNode.AjaxSearch.inputSearchOnKeyDown(27);" />';
|
||||
div.innerHTML += img;
|
||||
|
||||
|
||||
var inputSearch = '<input type="text" id="as_inputSearch" class="AjaxSearchInputSearch" onKeyDown="return this.AjaxSearch.inputSearchOnKeyDown(event);">';
|
||||
div.innerHTML = div.innerHTML + inputSearch;
|
||||
this.inputSearch = div.lastChild;
|
||||
this.inputSearch.AjaxSearch = this;
|
||||
this.inputSearch.onmousedown = function() { this.parentNode.noDrag = true; }
|
||||
|
||||
div.appendChild(document.createElement('br'));
|
||||
div.appendChild(document.createElement('br'));
|
||||
|
||||
/*
|
||||
div.appendChild(document.createTextNode('List:'));
|
||||
|
||||
var separator = document.createElement('hr');
|
||||
separator.className = 'AjaxSearchSeparator';
|
||||
div.appendChild(separator);
|
||||
*/
|
||||
|
||||
var divList = document.createElement('div');
|
||||
|
||||
divList.id = 'as_divList';
|
||||
divList.className = 'AjaxSearchDivList';
|
||||
divList.AjaxSearch = this;
|
||||
this.divList = divList;
|
||||
divList.onmousedown = function() { this.parentNode.noDrag = true; }
|
||||
div.appendChild(divList);
|
||||
|
||||
var tmpDiv = document.createElement('div');
|
||||
tmpDiv.style.height = '10px';
|
||||
div.appendChild(tmpDiv);
|
||||
|
||||
this.parentDIV.appendChild(div);
|
||||
this.div = div;
|
||||
|
||||
}
|
||||
|
||||
this.KeyDown = function(e) {
|
||||
|
||||
var keynum;
|
||||
if(window.event) //IE
|
||||
keynum = e.keyCode;
|
||||
else
|
||||
keynum = e.which;
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//constructor
|
||||
|
||||
if(AjaxSearchItems) {
|
||||
if(typeof(AjaxSearchItems) == "number")
|
||||
AjaxSearchItem++;
|
||||
else
|
||||
AjaxSearchItem = 0;
|
||||
this.ajaxSearchItem = AjaxSearchItem;
|
||||
}
|
||||
|
||||
this.createForm();
|
||||
|
||||
this.div.AjaxSearch = this;
|
||||
this.div.id = 'AjaxSearch_'+this.AjaxSearchItem;
|
||||
var AjaxSearch_draganddrop = new YAHOO.util.DD(this.div.id);
|
||||
AjaxSearch_draganddrop.AjaxSearch = this;
|
||||
AjaxSearch_draganddrop.endDrag = function(e) {
|
||||
this.AjaxSearch.AjaxSearchSaveSettings();
|
||||
};
|
||||
AjaxSearch_draganddrop.setHandleElId("AjaxSearch_ddiv");
|
||||
this.div.style.left = (screen.availWidth - this.div.offsetWidth) / 2;
|
||||
this.div.style.top = (screen.availHeight - this.div.offsetHeight) / 2;
|
||||
if(displayNone == true) this.div.style.display = 'none';
|
||||
this.AjaxSearchGetSettings();
|
||||
|
||||
|
||||
};
|
||||
202
modules/EcmProductB2Bs/Categories.js
Executable file
202
modules/EcmProductB2Bs/Categories.js
Executable file
@@ -0,0 +1,202 @@
|
||||
//categories
|
||||
function saveItems3(){
|
||||
document.getElementById('position_list3').value = ItemsList3(true);
|
||||
}
|
||||
function doRequest(where,post,doFunction,error) {
|
||||
this.Display = function(result) { doFunction(result.responseText); }
|
||||
this.Fail = function(result){ if(error) alert(error);}
|
||||
YAHOO.util.Connect.asyncRequest('POST',where,{success:this.Display,failure:this.Fail},post);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function addEvent(object,eventName,do_function) {
|
||||
if(typeof(object) == "string") object = document.getElementById(object);
|
||||
if(!object) { alert('No object in function addEvent!'); return; }
|
||||
if(object.addEventListener) {
|
||||
object.addEventListener(eventName, do_function, false);
|
||||
} else {
|
||||
object.attachEvent('on'+eventName, do_function);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var tbody_;
|
||||
var ItemListSave3;
|
||||
var ItemListClear3;
|
||||
var ItemListFil3;
|
||||
var FillText;
|
||||
|
||||
addEvent(
|
||||
window,
|
||||
'load',
|
||||
function() {
|
||||
var paramsTable3 = new paramsMT('itemsTable3');
|
||||
paramsTable3.onCreateRow = function(row) {
|
||||
row.newPos = false;
|
||||
row.noAddNew = true;
|
||||
row.ondblclick = function() {}
|
||||
row.onSelect = function() {
|
||||
}
|
||||
row.onDeselect = function() {
|
||||
}
|
||||
}
|
||||
|
||||
refreshPositionIndex = function() {
|
||||
for(var i=0; i<paramsTable3.rowCount(); i++) {
|
||||
var data = paramsTable3.row(i).getData();
|
||||
data.position = i+1;
|
||||
paramsTable3.row(i).setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
paramsTable3.onCreateCell = function(cell) {
|
||||
|
||||
var i = cell.index;
|
||||
if(i == 0) {
|
||||
|
||||
cell.setData = function(data) {
|
||||
console.log(data);
|
||||
if(data.ecmproductcategory_name) {
|
||||
cell.firstChild.value = data.ecmproductcategory_name;
|
||||
|
||||
cell.getElementsByTagName('input')[1].value = data.ecmproductcategory_id;
|
||||
if (data.id)
|
||||
cell.getElementsByTagName('input')[2].value = data.id;
|
||||
}
|
||||
};
|
||||
cell.getData = function(data) {
|
||||
data.ecmproductcategory_name = cell.firstChild.value;
|
||||
data.ecmproductcategory_id = cell.getElementsByTagName('input')[1].value;
|
||||
data.id = cell.getElementsByTagName('input')[2].value;
|
||||
}
|
||||
|
||||
cell.onSelect = function() {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
cn[0].name = 'name_p';
|
||||
cn[0].id = 'name_p';
|
||||
|
||||
cn[1].name = 'id_p';
|
||||
cn[1].id = 'id_p';
|
||||
}
|
||||
cell.onDeselect = function() {
|
||||
ERROR = false;
|
||||
var data = new Object();
|
||||
this.getData(data);
|
||||
if(!ERROR) {
|
||||
data.product_group = data.product_group;
|
||||
this.setData(data);
|
||||
}
|
||||
|
||||
var cn = this.getElementsByTagName('input');
|
||||
cn[0].name = '';
|
||||
cn[0].id = '';
|
||||
|
||||
cn[1].name = '';
|
||||
cn[1].id = '';
|
||||
}
|
||||
//cell.select = function() { this.selectNext(); }
|
||||
//cell.selectNext = function() { var row = this.parentNode.selectNext(); row.select(); row.cells.item(i).select(); };
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type','text');
|
||||
edit.setAttribute('tabIndex',1);
|
||||
edit.className = 'inputs';
|
||||
cell.appendChild(edit);
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type','hidden');
|
||||
edit.setAttribute('readonly','readonly');
|
||||
edit.setAttribute('tabIndex',1);
|
||||
edit.className = 'inputs';
|
||||
cell.appendChild(edit);
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type','hidden');
|
||||
edit.setAttribute('readonly','readonly');
|
||||
edit.setAttribute('tabIndex',1);
|
||||
edit.className = 'inputs';
|
||||
cell.appendChild(edit);
|
||||
var img = document.createElement('img');
|
||||
img.setAttribute('alt',MOD['LBL_IMG_SEARCH']);
|
||||
img.setAttribute('src','modules/EcmQuotes/images/search.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
img.onclick = function() {
|
||||
var ecmpopup = open_popup( "EcmProductB2BCategories", 600, 400, "", true, false, {"call_back_function":"set_return","form_name":"EditView","field_to_name_array":{"id":"id_p","name":"name_p"}}, "single", true );
|
||||
setTimeout(function(){ecmpopup.focus();},200);
|
||||
}
|
||||
cell.appendChild(img);
|
||||
}
|
||||
if(i == 1) {
|
||||
var img;
|
||||
|
||||
cell.style.padding="auto auto auto auto";
|
||||
//insert
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt',MOD['LBL_INSERT_NEW_ROW']);
|
||||
img.setAttribute('src','modules/EcmQuotes/images/insertrow.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
img.onclick = function() {
|
||||
this.parentNode.myTable.addRow(this.parentNode.parentNode.index+1);
|
||||
refreshPositionIndex();
|
||||
};
|
||||
|
||||
//delete
|
||||
cell.appendChild(img);
|
||||
cell.appendChild(document.createTextNode(" "));
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt',MOD['LBL_DELETE_ROW']);
|
||||
img.setAttribute('src','modules/EcmQuotes/images/deleterow.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
img.onclick = function() { this.parentNode.parentNode.deleteRow(); refreshPositionIndex();};
|
||||
cell.appendChild(img);
|
||||
cell.appendChild(document.createTextNode(" "));
|
||||
|
||||
cell.appendChild(document.createElement('br'));
|
||||
//move up
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt',MOD['LBL_MOVE_ROW_UP']);
|
||||
img.setAttribute('src','modules/EcmQuotes/images/moverowup.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
img.onclick = function() { this.parentNode.parentNode.moveUp(); refreshPositionIndex();};
|
||||
cell.appendChild(img);
|
||||
cell.appendChild(document.createTextNode(" "));
|
||||
//move down
|
||||
img = document.createElement('img');
|
||||
img.setAttribute('alt',MOD['LBL_MOVE_ROW_DOWN']);
|
||||
img.setAttribute('src','modules/EcmQuotes/images/moverowdown.gif');
|
||||
img.style.cursor = 'pointer';
|
||||
img.onclick = function() { this.parentNode.parentNode.moveDown();refreshPositionIndex(); }
|
||||
cell.appendChild(img);
|
||||
}
|
||||
}
|
||||
ItemsList3 = function(json) {
|
||||
var data = '';
|
||||
for(var i=0; i<paramsTable3.rowCount(); i++) {
|
||||
data = data + '||||' + JSON.stringifyNoSecurity(paramsTable3.row(i).getData());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
if(paramsTable3.rowCount() == 0) {paramsTable3.addRow();};
|
||||
paramsTable3.onSetCellData = function(row,cell,data) {
|
||||
if(cell.innerHTML == '') cell.innerHTML = ' ';
|
||||
}
|
||||
|
||||
ItemListFill3 = function() {
|
||||
var pl;
|
||||
pl = document.getElementById('position_list3').value;
|
||||
console.log(pl);
|
||||
if(pl && pl != '') {
|
||||
try {
|
||||
pl = eval(pl);
|
||||
for(x in pl) { var pl_row = pl[x]; if (pl_row.template=='') continue; paramsTable3.addRow().setData(pl_row); }
|
||||
} catch(err) { pl = null; };
|
||||
}
|
||||
}
|
||||
|
||||
ItemListClear3 = function(noNew,save) {
|
||||
if(typeof(save)=="string") ItemListSave3(null,save);
|
||||
while(paramsTable3.rowCount()>0) paramsTable3.row(0).deleteRow(noNew);
|
||||
}
|
||||
|
||||
ItemListClear3();
|
||||
ItemListFill3();
|
||||
}
|
||||
);
|
||||
98
modules/EcmProductB2Bs/Menu/ecmproducts.js
Executable file
98
modules/EcmProductB2Bs/Menu/ecmproducts.js
Executable file
@@ -0,0 +1,98 @@
|
||||
//<2F>Xara Ltd
|
||||
if(typeof(loc)=="undefined"||loc==""){var loc="";if(document.body&&document.body.innerHTML){var tt=document.body.innerHTML;var ml=tt.match(/["']([^'"]*)ecmproducts.js["']/i);if(ml && ml.length > 1) loc=ml[1];}}
|
||||
|
||||
var bd=1
|
||||
document.write("<style type=\"text/css\">");
|
||||
document.write("\n<!--\n");
|
||||
document.write(".ecmproducts_menu {z-index:999;border-color:#adc6d6;border-style:solid;border-width:"+bd+"px "+bd+"px "+bd+"px "+bd+"px;background-color:#f7f7f7;position:absolute;left:0px;top:0px;visibility:hidden;}");
|
||||
document.write(".ecmproducts_plain, a.ecmproducts_plain:link, a.ecmproducts_plain:visited{text-align:left;background-color:#f7f7f7;color:#000000;text-decoration:none;border-color:#adc6d6;border-style:solid;border-width:"+bd+"px "+bd+"px "+bd+"px "+bd+"px;padding:2px 2px 2px 2px;cursor:hand;display:block;font-size:8pt;font-weight:bold;font-family:Arial, Helvetica, sans-serif;}");
|
||||
document.write("a.ecmproducts_plain:hover, a.ecmproducts_plain:active{background-color:#adc6d6;color:#ffffff;text-decoration:bolder;border-color:#adc6d6;border-style:solid;border-width:"+bd+"px "+bd+"px "+bd+"px "+bd+"px;padding:2px 2px 2px 2px;cursor:hand;display:block;font-size:8pt;font-weight:bold;font-family:Arial, Helvetica, sans-serif;}");
|
||||
document.write("a.ecmproducts_l:link, a.ecmproducts_l:visited{text-align:left;background:#f7f7f7 url("+loc+"ecmproducts_l.png) no-repeat right;color:#000000;text-decoration:none;border-color:#adc6d6;border-style:solid;border-width:"+bd+"px "+bd+"px "+bd+"px "+bd+"px;padding:2px 2px 2px 2px;cursor:hand;display:block;font-size:8pt;font-weight:bold;font-family:Arial, Helvetica, sans-serif;}");
|
||||
document.write("a.ecmproducts_l:hover, a.ecmproducts_l:active{background:#adc6d6 url("+loc+"ecmproducts_l2.png) no-repeat right;color: #ffffff;text-decoration:none;border-color:#adc6d6;border-style:solid;border-width:"+bd+"px "+bd+"px "+bd+"px "+bd+"px;padding:2px 2px 2px 2px;cursor:hand;display:block;font-size:8pt;font-weight:bold;font-family:Arial, Helvetica, sans-serif;}");
|
||||
document.write("\n-->\n");
|
||||
document.write("</style>");
|
||||
|
||||
var fc=0x000000;
|
||||
var bc=0xadc6d6;
|
||||
if(typeof(frames)=="undefined"){var frames=0;}
|
||||
|
||||
startMainMenu("",0,0,2,0,0)
|
||||
mainMenuItem("ecmproducts_b1",".png",23,117,loc+"../../../index.php?module=EcmProductB2Bs&action=index","","Products",2,2,"ecmproducts_plain");
|
||||
mainMenuItem("ecmproducts_b2",".png",23,117,loc+"../../../index.php?module=EcmVendors&action=index","","Vendors",2,2,"ecmproducts_plain");
|
||||
mainMenuItem("ecmproducts_b3",".png",23,117,loc+"../../../index.php?module=EcmPriceBooks&action=index","","Price Books",2,2,"ecmproducts_plain");
|
||||
mainMenuItem("ecmproducts_b4",".png",23,117,loc+"../../../index.php?module=EcmProductB2BCategorys&action=index","","Product Category",2,2,"ecmproducts_plain");
|
||||
mainMenuItem("ecmproducts_b5",".png",23,117,loc+"../../../index.php?module=EcmProductB2BExchangeRates&action=index","","Exchange Rate",2,2,"ecmproducts_plain");
|
||||
mainMenuItem("ecmproducts_b6",".png",23,117,"javascript:;","","Additional Information",2,2,"ecmproducts_plain");
|
||||
endMainMenu("",0,0);
|
||||
|
||||
startSubmenu("ecmproducts_b6_7","ecmproducts_menu",44);
|
||||
submenuItem("Create",loc+"../../../index.php?module=EcmGlAccounts&action=EditView","","ecmproducts_plain");
|
||||
submenuItem("List",loc+"../../../index.php?module=EcmGlAccounts&action=index","","ecmproducts_plain");
|
||||
endSubmenu("ecmproducts_b6_7");
|
||||
|
||||
startSubmenu("ecmproducts_b6_6","ecmproducts_menu",44);
|
||||
submenuItem("Create",loc+"../../../index.php?module=EcmProductB2BUsageUnits&action=EditView","","ecmproducts_plain");
|
||||
submenuItem("List",loc+"../../../index.php?module=EcmProductB2BUsageUnits&action=index","","ecmproducts_plain");
|
||||
endSubmenu("ecmproducts_b6_6");
|
||||
|
||||
startSubmenu("ecmproducts_b6_5","ecmproducts_menu",44);
|
||||
submenuItem("Create",loc+"../../../index.php?module=EcmProductB2BPackingTypes&action=EditView","","ecmproducts_plain");
|
||||
submenuItem("List",loc+"../../../index.php?module=EcmProductB2BPackingTypes&action=index","","ecmproducts_plain");
|
||||
endSubmenu("ecmproducts_b6_5");
|
||||
|
||||
startSubmenu("ecmproducts_b6_4","ecmproducts_menu",44);
|
||||
submenuItem("Create",loc+"../../../index.php?module=EcmProductB2BBasiss&action=EditView","","ecmproducts_plain");
|
||||
submenuItem("List",loc+"../../../index.php?module=EcmProductB2BBasis&action=index","","ecmproducts_plain");
|
||||
endSubmenu("ecmproducts_b6_4");
|
||||
|
||||
startSubmenu("ecmproducts_b6_3","ecmproducts_menu",44);
|
||||
submenuItem("Create",loc+"../../../index.php?module=EcmProductB2BLines&action=EditView","","ecmproducts_plain");
|
||||
submenuItem("List",loc+"../../../index.php?module=EcmProductB2BLines&action=index","","ecmproducts_plain");
|
||||
endSubmenu("ecmproducts_b6_3");
|
||||
|
||||
startSubmenu("ecmproducts_b6_2","ecmproducts_menu",44);
|
||||
submenuItem("Create",loc+"../../../index.php?module=EcmProductB2BTaxs&action=EditView","","ecmproducts_plain");
|
||||
submenuItem("List",loc+"../../../index.php?module=EcmProductB2BTaxs&action=index","","ecmproducts_plain");
|
||||
endSubmenu("ecmproducts_b6_2");
|
||||
|
||||
startSubmenu("ecmproducts_b6_1","ecmproducts_menu",44);
|
||||
submenuItem("Create",loc+"../../../index.php?module=EcmProductB2BManufacturers&action=EditView","","ecmproducts_plain");
|
||||
submenuItem("List",loc+"../../../index.php?module=EcmProductB2BManufacturers&action=index","","ecmproducts_plain");
|
||||
endSubmenu("ecmproducts_b6_1");
|
||||
|
||||
startSubmenu("ecmproducts_b6","ecmproducts_menu",117);
|
||||
mainMenuItem("ecmproducts_b6_1","Manufacturers",0,0,loc+"../../../index.php?module=EcmProductB2BManufacturers&action=index","","",1,1,"ecmproducts_l");
|
||||
mainMenuItem("ecmproducts_b6_2","Tax Rate",0,0,loc+"../../../index.php?module=EcmProductB2BTaxs&action=index","","",1,1,"ecmproducts_l");
|
||||
mainMenuItem("ecmproducts_b6_3","Product Lines",0,0,loc+"../../../index.php?module=EcmProductB2BLines&action=index","","",1,1,"ecmproducts_l");
|
||||
mainMenuItem("ecmproducts_b6_4","FOB Basis",0,0,loc+"../../../index.php?module=EcmProductB2BBasis&action=index","","",1,1,"ecmproducts_l");
|
||||
mainMenuItem("ecmproducts_b6_5","Packing Type",0,0,loc+"../../../index.php?module=EcmProductB2BPackingTypes&action=index","","",1,1,"ecmproducts_l");
|
||||
mainMenuItem("ecmproducts_b6_6","Usage Unit",0,0,loc+"../../../index.php?module=EcmProductB2BUsageUnits&action=index","","",1,1,"ecmproducts_l");
|
||||
mainMenuItem("ecmproducts_b6_7","GL Accounts",0,0,loc+"../../../index.php?module=EcmGlAccounts&action=index","","",1,1,"ecmproducts_l");
|
||||
endSubmenu("ecmproducts_b6");
|
||||
|
||||
startSubmenu("ecmproducts_b5","ecmproducts_menu",117);
|
||||
submenuItem("Create",loc+"../../../index.php?module=EcmProductB2BExchangeRates&action=EditView","","ecmproducts_plain");
|
||||
submenuItem("List",loc+"../../../index.php?module=EcmProductB2BExchangeRates&action=index","","ecmproducts_plain");
|
||||
endSubmenu("ecmproducts_b5");
|
||||
|
||||
startSubmenu("ecmproducts_b4","ecmproducts_menu",117);
|
||||
submenuItem("Create",loc+"../../../index.php?module=EcmProductB2BCategorys&action=EditView","","ecmproducts_plain");
|
||||
submenuItem("List",loc+"../../../index.php?module=EcmProductB2BCategorys&action=index","","ecmproducts_plain");
|
||||
endSubmenu("ecmproducts_b4");
|
||||
|
||||
startSubmenu("ecmproducts_b3","ecmproducts_menu",117);
|
||||
submenuItem("Create",loc+"../../../index.php?module=EcmProductB2Bs&action=EditView","","ecmproducts_plain");
|
||||
submenuItem("List",loc+"../../../index.php?module=EcmProductB2Bs&action=index","","ecmproducts_plain");
|
||||
endSubmenu("ecmproducts_b3");
|
||||
|
||||
startSubmenu("ecmproducts_b2","ecmproducts_menu",117);
|
||||
submenuItem("Create",loc+"../../../index.php?module=EcmVendors&action=EditView","","ecmproducts_plain");
|
||||
submenuItem("List",loc+"../../../index.php?module=EcmVendors&action=index","","ecmproducts_plain");
|
||||
endSubmenu("ecmproducts_b2");
|
||||
|
||||
startSubmenu("ecmproducts_b1","ecmproducts_menu",117);
|
||||
submenuItem("Create",loc+"../../../index.php?module=EcmProductB2Bs&action=EditView","","ecmproducts_plain");
|
||||
submenuItem("List",loc+"../../../index.php?module=EcmProductB2Bs&action=index","","ecmproducts_plain");
|
||||
endSubmenu("ecmproducts_b1");
|
||||
|
||||
loc="";
|
||||
1
modules/EcmProductB2Bs/Menu/xaramenu.js
Executable file
1
modules/EcmProductB2Bs/Menu/xaramenu.js
Executable file
File diff suppressed because one or more lines are too long
172
modules/EcmProductB2Bs/Prices.js
Executable file
172
modules/EcmProductB2Bs/Prices.js
Executable file
@@ -0,0 +1,172 @@
|
||||
//categories
|
||||
function saveItems4(){
|
||||
document.getElementById('position_list4').value = ItemsList4(true);
|
||||
|
||||
}
|
||||
function doRequest(where,post,doFunction,error) {
|
||||
this.Display = function(result) { doFunction(result.responseText); }
|
||||
this.Fail = function(result){ if(error) alert(error);}
|
||||
YAHOO.util.Connect.asyncRequest('POST',where,{success:this.Display,failure:this.Fail},post);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function addEvent(object,eventName,do_function) {
|
||||
if(typeof(object) == "string") object = document.getElementById(object);
|
||||
if(!object) { alert('No object in function addEvent!'); return; }
|
||||
if(object.addEventListener) {
|
||||
object.addEventListener(eventName, do_function, false);
|
||||
} else {
|
||||
object.attachEvent('on'+eventName, do_function);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var tbody_;
|
||||
var ItemListSave4;
|
||||
var ItemListClear4;
|
||||
var ItemListFil4;
|
||||
var FillText;
|
||||
|
||||
addEvent(
|
||||
window,
|
||||
'load',
|
||||
function() {
|
||||
var paramsTable4 = new paramsMT('itemsTable4');
|
||||
paramsTable4.onCreateRow = function(row) {
|
||||
row.newPos = false;
|
||||
row.noAddNew = true;
|
||||
row.ondblclick = function() {}
|
||||
row.onSelect = function() {
|
||||
}
|
||||
row.onDeselect = function() {
|
||||
}
|
||||
}
|
||||
|
||||
refreshPositionIndex = function() {
|
||||
for(var i=0; i<paramsTable4.rowCount(); i++) {
|
||||
var data = paramsTable4.row(i).getData();
|
||||
data.position = i+1;
|
||||
paramsTable4.row(i).setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
paramsTable4.onCreateCell = function(cell) {
|
||||
|
||||
var i = cell.index;
|
||||
if(i == 0) {
|
||||
|
||||
cell.setData = function(data) {
|
||||
if(data.pricebook_name) {
|
||||
cell.firstChild.value = data.pricebook_name;
|
||||
|
||||
cell.getElementsByTagName('input')[1].value = data.pricebook_id;
|
||||
}
|
||||
};
|
||||
cell.getData = function(data) {
|
||||
data.ecmpricebook_name = cell.firstChild.value;
|
||||
data.ecmpricebook_id = cell.getElementsByTagName('input')[1].value;
|
||||
}
|
||||
|
||||
|
||||
//cell.select = function() { this.selectNext(); }
|
||||
//cell.selectNext = function() { var row = this.parentNode.selectNext(); row.select(); row.cells.item(i).select(); };
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type','text');
|
||||
edit.setAttribute('readonly','readonly');
|
||||
edit.setAttribute('tabIndex',1);
|
||||
edit.className = 'inputs';
|
||||
cell.appendChild(edit);
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type','hidden');
|
||||
edit.setAttribute('readonly','readonly');
|
||||
edit.setAttribute('tabIndex',1);
|
||||
edit.className = 'inputs';
|
||||
cell.appendChild(edit);
|
||||
}
|
||||
|
||||
if(i == 1) {
|
||||
cell.getData = function(data) {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
data.price = UserFormatNumberToNumber(cn[0].value);
|
||||
}
|
||||
cell.setData = function(data) {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
cn[0].value = ((data.price)?NumberToUserFormatNumber(data.price):NumberToUserFormatNumber(0));
|
||||
}
|
||||
cell.onDeselect = function() {
|
||||
ERROR = false;
|
||||
var data = new Object();
|
||||
this.getData(data);
|
||||
if(!ERROR) {
|
||||
data.price = data.price;
|
||||
this.setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type','text');
|
||||
edit.setAttribute('tabIndex',1);
|
||||
edit.className = 'inputs';
|
||||
cell.appendChild(edit);
|
||||
}
|
||||
if(i == 2) {
|
||||
cell.getData = function(data) {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
data.currency = cn[0].value;
|
||||
}
|
||||
cell.setData = function(data) {
|
||||
var cn = this.getElementsByTagName('input');
|
||||
cn[0].value = data.currency;
|
||||
}
|
||||
cell.onDeselect = function() {
|
||||
ERROR = false;
|
||||
var data = new Object();
|
||||
this.getData(data);
|
||||
if(!ERROR) {
|
||||
data.currency = data.currency;
|
||||
this.setData(data);
|
||||
}
|
||||
}
|
||||
|
||||
var edit = document.createElement('input');
|
||||
edit.setAttribute('type','text');
|
||||
edit.setAttribute('tabIndex',1);
|
||||
edit.className = 'inputs';
|
||||
cell.appendChild(edit);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
ItemsList4 = function(json) {
|
||||
var data = '';
|
||||
for(var i=0; i<paramsTable4.rowCount(); i++) {
|
||||
data = data + '||||' + JSON.stringifyNoSecurity(paramsTable4.row(i).getData());
|
||||
}
|
||||
return data;
|
||||
}
|
||||
//if(paramsTable4.rowCount() == 0) {paramsTable4.addRow();};
|
||||
paramsTable4.onSetCellData = function(row,cell,data) {
|
||||
if(cell.innerHTML == '') cell.innerHTML = ' ';
|
||||
}
|
||||
|
||||
ItemListFill4 = function() {
|
||||
var pl;
|
||||
pl = document.getElementById('position_list4').value;
|
||||
if(pl && pl != '') {
|
||||
try {
|
||||
pl = eval(pl);
|
||||
for(x in pl) { var pl_row = pl[x];if (pl_row.pricebook_name=='') continue; paramsTable4.addRow().setData(pl_row); }
|
||||
} catch(err) { pl = null; };
|
||||
}
|
||||
}
|
||||
|
||||
ItemListClear4 = function(noNew,save) {
|
||||
if(typeof(save)=="string") ItemListSave4(null,save);
|
||||
while(paramsTable4.rowCount()>0) paramsTable4.row(0).deleteRow(noNew);
|
||||
}
|
||||
|
||||
ItemListClear4();
|
||||
ItemListFill4();
|
||||
}
|
||||
);
|
||||
235
modules/EcmProductB2Bs/helper.js
Executable file
235
modules/EcmProductB2Bs/helper.js
Executable file
@@ -0,0 +1,235 @@
|
||||
function insert_selected(U){
|
||||
//alert(parent.opener.document.PositionList);
|
||||
var arr=new Array();
|
||||
var ajs=new Array();
|
||||
var lv=document.getElementById('list_view');
|
||||
var is=lv.getElementsByTagName('input');
|
||||
var l=0;
|
||||
var id;
|
||||
for(var i=0;i<is.length;i++) {
|
||||
if(is[i].type=='checkbox' && is[i].name=='mass[]' && is[i].checked==true) {
|
||||
arr[l]=is[i].value;
|
||||
|
||||
id=associated_javascript_data[is[i].value];
|
||||
ajs[l]=associated_javascript_data[is[i].value];
|
||||
ajs[l].code=id['CODE'];
|
||||
ajs[l].name=id['NAME'];
|
||||
ajs[l].price=id['SELLING_PRICE'];
|
||||
ajs[l].unit_id=id['UNIT_ID'];
|
||||
|
||||
ajs[l].vat_value=23;
|
||||
ajs[l].ecmvat_value=23;
|
||||
ajs[l].vat_name='23%';
|
||||
ajs[l].ecmvat_name='23%';
|
||||
ajs[l].vat_id='28079566-b825-e38f-9993-4ccc7b781de5';
|
||||
ajs[l].ecmvat_id='28079566-b825-e38f-9993-4ccc7b781de5';
|
||||
|
||||
ajs[l].total=id['SELLING_PRICE'];
|
||||
ajs[l].id=is[i].value;
|
||||
l++;
|
||||
}
|
||||
}
|
||||
var pl = ajs;
|
||||
if(pl && pl != '') {
|
||||
pl = eval(pl);
|
||||
for(x in pl) {
|
||||
var pl_row = pl[x];
|
||||
// if(pl_row.vat_id)
|
||||
U.addRow().setData(pl_row);
|
||||
}
|
||||
}
|
||||
|
||||
if(U.rowCount() == 0) U.addRow();
|
||||
|
||||
window.close();
|
||||
}
|
||||
function showdescription(id,title,desc,minus,object)
|
||||
{
|
||||
if(!minus)minus=0;
|
||||
var sum=17-minus;
|
||||
document.getElementById("desc").style.display="inline";
|
||||
document.getElementById("desc-title").innerHTML=title;
|
||||
document.getElementById("desc-desc").innerHTML=desc;
|
||||
posy=findPosY(object)+sum;
|
||||
posx=findPosX(object);
|
||||
moveDiv(document.getElementById("desc"),posy,posx);
|
||||
}
|
||||
function hidedescription()
|
||||
{
|
||||
document.getElementById("desc").style.display="none";
|
||||
}
|
||||
function mintajaxget(url,tag)
|
||||
{
|
||||
var req=mint.Request();
|
||||
req.Set('timeout',10000000);
|
||||
req.Set('retryNum',0);
|
||||
req.OnLoading=function(){$(tag).innerHTML='<img src="themes/default/images/loading.gif" border="0">';}
|
||||
req.OnSuccess = function(){if($(tag).type=='text'){if(this.responseText!="")$(tag).value=this.responseText;}else{if(this.responseText!="")$(tag).innerHTML=this.responseText;}}
|
||||
req.Send(url,tag);
|
||||
|
||||
}
|
||||
function mintajaxpost(url,tag,form)
|
||||
{
|
||||
var req=mint.Request();
|
||||
req.OnSuccess=function(){$(tag).innerHTML=this.responseText;}
|
||||
req.OnLoading=function(){$(tag).innerHTML='<img src="themes/default/images/loading.gif" border="0">';}
|
||||
req.SendForm(form);
|
||||
}
|
||||
function moveDiv(obj, mvTop, mvLeft) {
|
||||
obj.style.position = "absolute";
|
||||
obj.style.top = mvTop;
|
||||
obj.style.left = mvLeft;
|
||||
}
|
||||
function getPos(inputElement) {
|
||||
var coords = new Object();
|
||||
coords.x = 0;
|
||||
coords.y = 0;
|
||||
try {
|
||||
targetElement = inputElement;
|
||||
if(targetElement.x && targetElement.y) {
|
||||
coords.x = targetElement.x;
|
||||
coords.y = targetElement.y;
|
||||
} else {
|
||||
if(targetElement.offsetParent) {
|
||||
coords.x += targetElement.offsetLeft;
|
||||
coords.y += targetElement.offsetTop;
|
||||
while(targetElement = targetElement.offsetParent) {
|
||||
coords.x += targetElement.offsetLeft;
|
||||
coords.y += targetElement.offsetTop;
|
||||
}
|
||||
} else {
|
||||
//alert("Could not find any reference for coordinate positioning.");
|
||||
}
|
||||
}
|
||||
return coords;
|
||||
} catch(error) {
|
||||
//alert(error.msg);
|
||||
return coords;
|
||||
}
|
||||
}
|
||||
|
||||
function findPosX(obj)
|
||||
{
|
||||
var curleft = 0;
|
||||
if(obj.offsetParent)
|
||||
while(1)
|
||||
{
|
||||
curleft += obj.offsetLeft;
|
||||
if(!obj.offsetParent)
|
||||
break;
|
||||
obj = obj.offsetParent;
|
||||
}
|
||||
else if(obj.x)
|
||||
curleft += obj.x;
|
||||
return curleft;
|
||||
//return getPos(obj).x;
|
||||
}
|
||||
|
||||
function findPosY(obj)
|
||||
{
|
||||
var curtop = 0;
|
||||
if(obj.offsetParent)
|
||||
while(1)
|
||||
{
|
||||
curtop += obj.offsetTop;
|
||||
if(!obj.offsetParent)
|
||||
break;
|
||||
obj = obj.offsetParent;
|
||||
}
|
||||
else if(obj.y)
|
||||
curtop += obj.y;
|
||||
return curtop;
|
||||
//return getPos(obj).y;
|
||||
}
|
||||
function showdiv(id,div,minusy,minusx)
|
||||
{
|
||||
document.getElementById(div).style.display="inline";
|
||||
posy=findPosY(document.getElementById(id))-minusy;
|
||||
posx=findPosX(document.getElementById(id))-minusx;
|
||||
moveDiv(document.getElementById(div),posy,posx);
|
||||
}
|
||||
|
||||
function hidediv(div)
|
||||
{
|
||||
document.getElementById(div).style.display="none";
|
||||
}
|
||||
function showprice(id,price,purchase_price,margin,remarks_pl,remarks_en,remarks_de,order_by,sorder,recipient_code)
|
||||
{
|
||||
document.getElementById('price').value=price;
|
||||
document.getElementById('purchase_price').value=purchase_price;
|
||||
document.getElementById('margin').value=margin;
|
||||
document.getElementById('recipient_code').value=recipient_code;
|
||||
document.getElementById('remarks_pl').value=remarks_pl;
|
||||
document.getElementById('remarks_en').value=remarks_en;
|
||||
document.getElementById('remarks_de').value=remarks_de;
|
||||
document.getElementById('product_id').value=id;
|
||||
document.getElementById('order_by').value=order_by;
|
||||
document.getElementById('sorder').value=sorder;
|
||||
document.getElementById('price-block').style.display="block";
|
||||
}
|
||||
function getPrice(id,type)
|
||||
{
|
||||
var purchase_price=document.getElementById('purchase_price_'+id).value;
|
||||
var margin_rate=document.getElementById('margin_rate_'+id).value;
|
||||
var list_price;
|
||||
|
||||
list_price=parseFloat(purchase_price)/(1-parseFloat(margin_rate)/100);
|
||||
|
||||
if(!isNaN(list_price))document.getElementById('list_price_'+id).value=roundNumber(list_price,2);
|
||||
|
||||
}
|
||||
function getPricePricebook()
|
||||
{
|
||||
var purchase_price=document.getElementById('purchase_price').value;
|
||||
var margin_rate=document.getElementById('margin').value;
|
||||
var list_price;
|
||||
margin_rate=margin_rate.replace(".","");
|
||||
margin_rate=margin_rate.replace(",",".");
|
||||
purchase_price=purchase_price.replace(".","");
|
||||
purchase_price=purchase_price.replace(",",".");
|
||||
list_price=parseFloat(purchase_price)/(1-parseFloat(margin_rate)/100);
|
||||
|
||||
if(!isNaN(list_price))document.getElementById('price').value=CurrencyFormatted(list_price);
|
||||
|
||||
}
|
||||
function CurrencyFormatted(amount)
|
||||
{
|
||||
var i = parseFloat(amount);
|
||||
if(isNaN(i)) { i = 0.00; }
|
||||
var minus = '';
|
||||
if(i < 0) { minus = '-'; }
|
||||
i = Math.abs(i);
|
||||
i = parseInt((i + .005) * 100);
|
||||
i = i / 100;
|
||||
s = new String(i);
|
||||
if(s.indexOf('.') < 0) { s += ',00'; }
|
||||
if(s.indexOf('.') == (s.length - 2)) { s += '0'; }
|
||||
s = minus + s;
|
||||
s=s.replace(".",",");
|
||||
return s;
|
||||
}
|
||||
function roundN(rnum,rlength)
|
||||
{
|
||||
var newnumber = Math.round(rnum*Math.pow(10,rlength))/Math.pow(10,rlength);
|
||||
return newnumber;
|
||||
}
|
||||
function roundNumber(num, dec)
|
||||
{
|
||||
if(!isNaN(num))return CurrencyFormatted(roundN(parseFloat(num),dec));
|
||||
else return "";
|
||||
}
|
||||
function ShowHideBlock(id)
|
||||
{
|
||||
if(document.getElementById(id).style.display=="block")
|
||||
{
|
||||
document.getElementById(id).style.display="none"
|
||||
}
|
||||
else
|
||||
{
|
||||
document.getElementById(id).style.display="block"
|
||||
}
|
||||
}
|
||||
|
||||
function generateEAN() {
|
||||
alert('Coming soon! :)');
|
||||
}
|
||||
1398
modules/EcmProductB2Bs/javascript/EcmProductB2B.js
Executable file
1398
modules/EcmProductB2Bs/javascript/EcmProductB2B.js
Executable file
File diff suppressed because it is too large
Load Diff
1478
modules/EcmProductB2Bs/javascript/EcmProductB2BDetailView.js
Executable file
1478
modules/EcmProductB2Bs/javascript/EcmProductB2BDetailView.js
Executable file
File diff suppressed because it is too large
Load Diff
2330
modules/EcmProductB2Bs/javascript/MyTable.js
Executable file
2330
modules/EcmProductB2Bs/javascript/MyTable.js
Executable file
File diff suppressed because it is too large
Load Diff
164
modules/EcmProductB2Bs/javascript/formloader.js
Executable file
164
modules/EcmProductB2Bs/javascript/formloader.js
Executable file
@@ -0,0 +1,164 @@
|
||||
|
||||
|
||||
function doRequest(where,post,doFunction,error) {
|
||||
|
||||
this.Display = function(result) { doFunction(result.responseText); }
|
||||
|
||||
this.Fail = function(result){ if(error) alert(error);}
|
||||
|
||||
YAHOO.util.Connect.asyncRequest('POST',where,{success:this.Display,failure:this.Fail},post);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function changeValidateRequired(formname,name,required) {
|
||||
|
||||
for(var i=0; i<validate[formname].length; i++)
|
||||
|
||||
if(validate[formname][i][0] == name) { validate[formname][i][2] = required; break; }
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function my_popup(module, field_array, call_back_function, form_name) {
|
||||
|
||||
if(!call_back_function) call_back_function = "set_return";
|
||||
|
||||
if(!form_name) form_name = "EditView";
|
||||
|
||||
return open_popup(module, 900, 700, "", true, false, {"call_back_function":call_back_function,"form_name":form_name,"field_to_name_array":field_array});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function addEvent(object,eventName,do_function) {
|
||||
|
||||
if(typeof(object) == "string") object = document.getElementById(object);
|
||||
|
||||
if(!object) { alert('No object in function addEvent!'); return; }
|
||||
|
||||
if(object.addEventListener) {
|
||||
|
||||
object.addEventListener(eventName, do_function, false);
|
||||
|
||||
} else {
|
||||
|
||||
object.attachEvent('on'+eventName, do_function);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function FormLoader() {
|
||||
|
||||
|
||||
|
||||
this.module;
|
||||
|
||||
this.createModule;
|
||||
|
||||
this.fieldName;
|
||||
|
||||
this.buttonName = 'FormLoaderButton';
|
||||
|
||||
|
||||
|
||||
this.load = function(module,createModule,fieldName) {
|
||||
|
||||
this.module = module;
|
||||
|
||||
this.createModule = createModule;
|
||||
|
||||
this.fieldName = fieldName;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.createButton = function() {
|
||||
|
||||
var b = document.createElement('input');
|
||||
|
||||
b.type = 'button';
|
||||
|
||||
b.className = 'button';
|
||||
|
||||
b.name = this.buttonName;
|
||||
|
||||
b.value = 'Create';
|
||||
|
||||
b.FL = this;
|
||||
|
||||
b.onclick = function() {
|
||||
|
||||
if(this.FL.createModule == '') return;
|
||||
|
||||
if(this.FL.onButtonClick) var data = this.FL.onButtonClick();
|
||||
|
||||
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create10"+this.FL.module,"resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
|
||||
|
||||
}
|
||||
|
||||
return b;
|
||||
|
||||
}
|
||||
|
||||
this.setEditDblClick = function(edit) { edit.FL=this; edit.ondblclick=this.editDblClick; }
|
||||
|
||||
this.editDblClick = function() {
|
||||
|
||||
if(this.FL.createModule == '') return;
|
||||
|
||||
if(this.FL.onEditDblClick) var data = this.FL.onEditDblClick();
|
||||
|
||||
window.open("index.php?module="+this.FL.module+"&action=formloader&to_pdf=1&loaderAction=ViewForm&loaderFieldName="+this.FL.fieldName+"&createModule="+this.FL.createModule+(data?data:''),"Create10"+this.FL.module,"resizable=yes,scrollbars=no,status=no,height=540,width=700").focus();
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.responseData = function(data) {
|
||||
|
||||
if(this.onResponseData) this.onResponseData(data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.onResponseData;
|
||||
|
||||
|
||||
|
||||
this.addPostData = function() {
|
||||
|
||||
if(this.onAddPostData)
|
||||
|
||||
return this.onAddPostData();
|
||||
|
||||
else
|
||||
|
||||
return '';
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
this.onAddPostData;
|
||||
|
||||
this.onButtonClick;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
2
modules/EcmProductB2Bs/mintajax.js
Executable file
2
modules/EcmProductB2Bs/mintajax.js
Executable file
File diff suppressed because one or more lines are too long
374
modules/EcmProductB2Bs/paramsMT.js
Executable file
374
modules/EcmProductB2Bs/paramsMT.js
Executable file
@@ -0,0 +1,374 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
function keyPressedNumber(e) {
|
||||
var keynum;
|
||||
if(window.event) //IE
|
||||
keynum = e.keyCode;
|
||||
else
|
||||
keynum = e.which;
|
||||
return keynum;
|
||||
}
|
||||
|
||||
function isEnterOrTabPressed(e) {
|
||||
var keynum = keyPressedNumber(e);
|
||||
if(keynum == 9 || keynum == 13) return true; else return false;
|
||||
}
|
||||
|
||||
function setSelectionRange(obj) {
|
||||
if(obj && typeof(obj) == "object" && (obj.type == "text" || obj.type == "textarea")) {
|
||||
if(obj.createTextRange) {
|
||||
var range = obj.createTextRange();
|
||||
range.moveStart("character", 0);
|
||||
range.moveEnd("character", obj.value.lengh-1);
|
||||
range.select();
|
||||
} else {
|
||||
if(obj.setSelectionRange) {
|
||||
obj.setSelectionRange(0,obj.value.length);
|
||||
}
|
||||
}
|
||||
obj.focus();
|
||||
}
|
||||
if(obj && typeof(obj) == "object" && obj.options) { obj.focus(); }
|
||||
|
||||
}
|
||||
|
||||
function paramsMT(name) {
|
||||
|
||||
this.myTableName = name;
|
||||
this.table = document.getElementById(this.myTableName);
|
||||
|
||||
this.thead = this.table.tHead;
|
||||
this.tbody = this.table.tBodies.item(0);
|
||||
|
||||
this.cellSelectedClass = 'selectedCell';
|
||||
this.rowSelectedClass = 'selectedRow';
|
||||
|
||||
this.selectedRow;
|
||||
this.selectedCell;
|
||||
|
||||
this.rowCount = function() {
|
||||
return this.tbody.rows.length;
|
||||
}
|
||||
|
||||
this.colCount = function() {
|
||||
return this.thead.rows.item(0).cells.length;
|
||||
};
|
||||
|
||||
this.colWidth = function(i) {
|
||||
return this.thead.rows.item(0).cells.item(i).width;
|
||||
};
|
||||
|
||||
this.moveUpRow = function() {
|
||||
if(this.selectedRow) this.selectedRow.moveUp();
|
||||
};
|
||||
|
||||
this.moveDownRow = function() {
|
||||
if(this.selectedRow) this.selectedRow.moveDown();
|
||||
};
|
||||
|
||||
this.insertRow = function(row, newRow) {
|
||||
if(!row)
|
||||
if(this.rowCount())
|
||||
if(typeof(row) == "number")
|
||||
row = this.tbody.rows.item(row);
|
||||
else
|
||||
row = this.tbody.rows.item(this.tbody.rows.length-1);
|
||||
|
||||
var row_tmp;
|
||||
if((newRow) && (row)) row_tmp = newRow; else { row_tmp = this.createRow(); this.fillWithDefaultData(row_tmp); }
|
||||
|
||||
if(this.rowCount() > 0 && row.nextSibling)
|
||||
this.tbody.insertBefore(row_tmp, row.nextSibling);
|
||||
else
|
||||
this.tbody.appendChild(row_tmp);
|
||||
|
||||
return row_tmp;
|
||||
};
|
||||
|
||||
this.refreshRowIndex = function() {
|
||||
for(var i=0; i<this.rowCount(); i++) {
|
||||
this.tbody.rows.item(i).index = i;
|
||||
if(this.onRefreshRowIndex) this.onRefreshRowIndex(this.tbody.rows.item(i));
|
||||
}
|
||||
}
|
||||
this.onRefreshRowIndex;
|
||||
|
||||
this.addRow = function(i,data) {
|
||||
var row = this.createRow();
|
||||
if(this.selectedRow) this.selectedRow.deselect();
|
||||
if(this.selectedCell) this.selectedCell.deselect();
|
||||
row.myTable = this;
|
||||
if(i || i===0)
|
||||
this.tbody.insertBefore(row,this.tbody.rows.item(i));
|
||||
else
|
||||
this.tbody.appendChild(row);
|
||||
this.refreshRowIndex();
|
||||
this.setRowData(row, data);
|
||||
for(var i=0; i<this.colCount(); i++) row.cells.item(i).afterCreate();
|
||||
return row;
|
||||
}
|
||||
|
||||
this.createRow = function(row) {
|
||||
var row = document.createElement('tr');
|
||||
row.myTable = this;
|
||||
row.isnew = false;
|
||||
row.onclick = function() { this.select(); }
|
||||
row.select = function() {
|
||||
if(!this.myTable.selectedRow || this.myTable.selectedRow !== this) {
|
||||
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
|
||||
this.myTable.selectedRow = this;
|
||||
this.className = this.myTable.rowSelectedClass;
|
||||
if(row.onSelect) row.onSelect();
|
||||
}
|
||||
}
|
||||
row.deselect = function() {
|
||||
if(this.myTable.selectedRow === this) {
|
||||
this.className = '';
|
||||
this.myTable.selectedRow = '';
|
||||
if(row.onDeselect) row.onDeselect();
|
||||
}
|
||||
};
|
||||
|
||||
row.selectNext = function() {
|
||||
|
||||
if(this.index < this.myTable.rowCount()-1) { this.deselect(); this.nextSibling.select(); return this.nextSibling; }
|
||||
else {
|
||||
if(this.noAddNew) return this;
|
||||
|
||||
this.deselect();
|
||||
var row = this.myTable.addRow(); return row;
|
||||
}
|
||||
}
|
||||
row.selectPrevious = function() {
|
||||
this.deselect();
|
||||
if(this.previousSibling && this.index > 0) { this.previousSibling.select(); return this.previousSibling; }else return this;
|
||||
}
|
||||
row.deleteRow = function(noNew) {
|
||||
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
|
||||
if(this.myTable.selectedRow) this.myTable.selectedRow.deselect();
|
||||
if(this.myTable.rowCount() == 1 && !noNew) {
|
||||
var MyTaBlE = this.myTable;
|
||||
setTimeout( function() { MyTaBlE.addRow(); refreshPositionIndex();} , 1000);
|
||||
}
|
||||
this.myTable.tbody.removeChild(this);
|
||||
this.myTable.refreshRowIndex();
|
||||
}
|
||||
row.moveUp = function() {
|
||||
if(!this.previousSibling) return;
|
||||
this.myTable.tbody.insertBefore(this,this.previousSibling);
|
||||
this.myTable.refreshRowIndex();
|
||||
}
|
||||
row.moveDown = function() {
|
||||
if(!this.nextSibling) this.myTable.addRow(row);
|
||||
this.myTable.tbody.insertBefore(this.nextSibling,this);
|
||||
this.myTable.refreshRowIndex();
|
||||
}
|
||||
row.setData = function(data) {
|
||||
if(!data || typeof(data) != "object") { return; };
|
||||
for(var i=0; i<this.myTable.colCount(); i++) {
|
||||
this.cells.item(i).setData(data);
|
||||
}
|
||||
}
|
||||
row.getData = function() {
|
||||
var data = new Object();
|
||||
for(var i=0; i<this.myTable.colCount(); i++) {
|
||||
if(this.cells.item(i).getData) this.cells.item(i).getData(data,true);
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
||||
for(var i=0; i<this.colCount(); i++) {
|
||||
var cell = this.createCell(i);
|
||||
row.appendChild(cell);
|
||||
}
|
||||
if(this.onCreateRow) this.onCreateRow(row);
|
||||
return row;
|
||||
|
||||
};
|
||||
|
||||
|
||||
this.onCreateRow; //function(row) {}
|
||||
|
||||
this.createCell = function(i) {
|
||||
var cell = document.createElement('td');
|
||||
cell.index = i;
|
||||
cell.myTable = this;
|
||||
cell.onclick = function() { this.select(); }
|
||||
cell.select = function() {
|
||||
|
||||
if(!this.myTable.selectedCell || this.myTable.selectedCell !== this) {
|
||||
if(this.myTable.selectedCell) this.myTable.selectedCell.deselect();
|
||||
this.myTable.selectedCell = this;
|
||||
if(this.firstChild.focus && !this.noSelect) setSelectionRange(this.firstChild);
|
||||
|
||||
if(this.onSelect) this.onSelect();
|
||||
this.className = this.myTable.cellSelectedClass;
|
||||
|
||||
}
|
||||
}
|
||||
cell.deselect = function() {
|
||||
if(this.myTable.selectedCell === this) {
|
||||
if(cell.onDeselect) cell.onDeselect();
|
||||
this.className = '';
|
||||
this.selected = false;
|
||||
this.myTable.selectedCell = '';
|
||||
}
|
||||
};
|
||||
cell.selectNext = function() {
|
||||
this.deselect();
|
||||
if(this.nextSibling) this.nextSibling.select();
|
||||
else {
|
||||
if(!this.parentNode.nextSibling) { if(this.noNewAdd) return; else this.myTable.addRow(); }
|
||||
this.parentNode.nextSibling.select();
|
||||
this.parentNode.nextSibling.firstChild.select();
|
||||
}
|
||||
}
|
||||
cell.afterCreate = function() {}
|
||||
cell.setData = function(data) {}
|
||||
cell.getData = function(data) {}
|
||||
if(this.onCreateCell) this.onCreateCell(cell);
|
||||
return cell;
|
||||
};
|
||||
this.onCreateCell; //function(cell) {}
|
||||
|
||||
|
||||
this.setRowData = function(row,data) {
|
||||
for(var i=0; i<this.colCount(); i++) {
|
||||
this.setCellData(row,row.cells.item(i),data);
|
||||
}
|
||||
}
|
||||
|
||||
this.setCellData = function(row,cell,data) {
|
||||
if(typeof(row) == "number")
|
||||
if(this.tbody.rows.item(row)) row = this.tbody.rows.item(row);
|
||||
if(typeof(cell) != "object")
|
||||
if(typeof(cell) == "number" && typeof(row) == "object") {
|
||||
if(row.cells.item(cell))
|
||||
cell = row.cells.item(cell);
|
||||
else return;
|
||||
}
|
||||
else return;
|
||||
if(this.onSetCellData) this.onSetCellData(row,cell,data);
|
||||
}
|
||||
|
||||
this.onSetCellData; //function(row,cell,data) {}
|
||||
|
||||
|
||||
|
||||
|
||||
this.selectRow = function(row) {
|
||||
if(this.selectedRow === row) return;
|
||||
|
||||
|
||||
if(this.selectedRow) this.deselectRow();
|
||||
|
||||
|
||||
this.selectedRow = row;
|
||||
|
||||
|
||||
this.selectedRow.className = this.rowSelectedClass;
|
||||
|
||||
|
||||
this.setEditNames(this.selectedRow,!this.selectedRow.isnew);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
this.selectNextRow = function() {
|
||||
|
||||
if(!this.selectedRow) return;
|
||||
|
||||
|
||||
if(!this.selectedRow.nextSibling) this.insertRow();
|
||||
|
||||
|
||||
var cell_id = this.selectedCell.lp;
|
||||
|
||||
|
||||
this.selectRow(this.selectedRow.nextSibling);
|
||||
|
||||
|
||||
this.selectCell(this.selectedRow.cells.item(cell_id));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
this.selectPreviousRow = function() {
|
||||
|
||||
|
||||
if(!this.selectedRow) return;
|
||||
|
||||
|
||||
if(!this.selectedRow.previousSibling) return;
|
||||
|
||||
|
||||
if(this.selectedRow === this.tbody.rows.item(0)) return;
|
||||
|
||||
|
||||
var cell_id = this.selectedCell.lp;
|
||||
|
||||
|
||||
this.selectRow(this.selectedRow.previousSibling);
|
||||
|
||||
|
||||
this.selectCell(this.selectedRow.cells.item(cell_id));
|
||||
|
||||
|
||||
}
|
||||
|
||||
this.refreshNumeration = function() {
|
||||
for(var i=0; i<this.tbody.rows.length; i++)
|
||||
this.tbody.rows.item(i).cells.item(0).firstChild.value = i+1;
|
||||
}
|
||||
|
||||
this.KeyPressedNumber = function(e) {
|
||||
var keynum;
|
||||
if(window.event) //IE
|
||||
keynum = e.keyCode;
|
||||
else
|
||||
keynum = e.which;
|
||||
return keynum;
|
||||
}
|
||||
|
||||
this.KeyPressed = function(e, cell, method) {
|
||||
var keynum;
|
||||
if(window.event) //IE
|
||||
keynum = e.keyCode;
|
||||
else
|
||||
keynum = e.which;
|
||||
if((keynum == 9) || (keynum == 13)) {
|
||||
cell.selectNext();
|
||||
return false;
|
||||
}
|
||||
if(keynum == 40) { var id = cell.index; var row = cell.parentNode.selectNext(); if(row) { row.select(); row.cells.item(id).select(); } }
|
||||
if(keynum == 38) { var id = cell.index; var row = cell.parentNode.selectPrevious(); if(row) { row.select(); row.cells.item(id).select(); } }
|
||||
if(e.shiftKey && (method == "decimalNumber" || method == "onlyNumber")) return false;
|
||||
if(method == "decimalNumber") return this.OnlyNumbers(keynum);
|
||||
if(method == "onlyNumber") return this.OnlyNumbers(keynum, true);
|
||||
return true;
|
||||
}
|
||||
|
||||
this.OnlyNumbers = function(e, noQuote) { var keynum = e, keychar, numcheck;
|
||||
keychar = String.fromCharCode(keynum);
|
||||
numcheck = /\d/;
|
||||
return numcheck.test(keychar) || ((!noQuote)?(keynum == 190):false)
|
||||
|| (keynum == 8) //backspace
|
||||
|| (keynum == 46) //delete
|
||||
|| (keynum == 13) //enter || (keynum == 0) //special keys with FF
|
||||
|| (keynum == 37) //left arrow
|
||||
|| (keynum == 39) //right arrow
|
||||
|| (keynum == 188); //,
|
||||
}
|
||||
|
||||
this.row = function(i) { if(this.tbody.rows.item(i)) return this.tbody.rows.item(i); }
|
||||
this.cells = function(i,j) { if(this.tbody.rows.item(i).cells.item(i)) return this.tbody.rows.item(i).cells.item(i); }
|
||||
}
|
||||
Reference in New Issue
Block a user