Add JS files

This commit is contained in:
2025-05-12 15:45:17 +00:00
parent 7ddd15c4fa
commit 967007b0c7
3239 changed files with 1157078 additions and 0 deletions

View File

@@ -0,0 +1,78 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
function JSTransaction(){
this.JSTransactions = new Array();
this.JSTransactionIndex = 0;
this.JSTransactionCanRedo = false;
this.JSTransactionTypes = new Array();
}
JSTransaction.prototype.record = function(transaction, data){
this.JSTransactions[this.JSTransactionIndex] = {'transaction':transaction , 'data':data};
this.JSTransactionIndex++;
this.JSTransactionCanRedo = false
}
JSTransaction.prototype.register = function(transaction, undo, redo){
this.JSTransactionTypes[transaction] = {'undo': undo, 'redo':redo};
}
JSTransaction.prototype.undo = function(){
if(this.JSTransactionIndex > 0){
if(this.JSTransactionIndex > this.JSTransactions.length ){
this.JSTransactionIndex = this.JSTransactions.length;
}
var transaction = this.JSTransactions[this.JSTransactionIndex - 1];
var undoFunction = this.JSTransactionTypes[transaction['transaction']]['undo'];
undoFunction(transaction['data']);
this.JSTransactionIndex--;
this.JSTransactionCanRedo = true;
}
}
JSTransaction.prototype.redo = function(){
if(this.JSTransactionCanRedo && this.JSTransactions.length < 0)this.JSTransactionIndex = 0;
if(this.JSTransactionCanRedo && this.JSTransactionIndex <= this.JSTransactions.length ){
this.JSTransactionIndex++;
var transaction = this.JSTransactions[this.JSTransactionIndex - 1];
var redoFunction = this.JSTransactionTypes[transaction['transaction']]['redo'];
redoFunction(transaction['data']);
}
}

View File

@@ -0,0 +1,548 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
var yahooSlots = new Array();
function addNewRowToView(id){
var curRow = document.getElementById(id);
var parent = curRow.parentNode;
var newRow = document.createElement('tr');
var newRow = parent.insertRow(parent.rows.length);
var re = /studiorow[0-9]+/g;
var cell = newRow.insertCell(0);
cell.innerHTML = curRow.cells[0].innerHTML.replace(re, 'studiorow' + slotCount);
cell.className = curRow.cells[0].className;
for(var j = 1; j < curRow.cells.length ; j++){
var cell = newRow.insertCell(j);
cell.innerHTML = '&nbsp;';
cell.className = curRow.cells[j].className;
}
var index = parent.rows.length;
for(var i = 0; i < parent.rows.length ; i++){
if(parent.rows[i].id == id){
index = i + 1;
}
}
newRow.id = 'studiorow' + slotCount;
if(typeof(curRow.parentId) == 'undefined'){
newRow.parentId = id;
}else{
newRow.parentId = curRow.parentId;
}
if(index < parent.rows.length){
parent.insertBefore(newRow, parent.rows[index]);
}else{
parent.appendChild(newRow);
}
document.getElementById('add_' + newRow.parentId).value = 1 + parseInt(document.getElementById('add_' + newRow.parentId).value);
slotCount++;
}
function deleteRowFromView(id, index){
var curRow = document.getElementById(id);
curRow.parentNode.removeChild(curRow);
if(typeof(curRow.parentId) == 'undefined'){
document.getElementById('form_' + id).value=-1;
}else{
document.getElementById('add_' + curRow.parentId).value = parseInt(document.getElementById('add_' + curRow.parentId).value) - 1;
}
}
function addNewColToView(id, index){
var curCol = document.getElementById(id);
var index = curCol.cellIndex;
var parent = curCol.parentNode;
var cell = parent.insertCell(index + 1);
if(parent.parentNode.rows[parent.rowIndex + 1])parent.parentNode.rows[parent.rowIndex + 1].insertCell(index + 1)
var re = /studiocol[0-9]+/g;
cell.innerHTML = '[NEW]';
cell.className = curCol.className;
if(typeof(curCol.parentId) == 'undefined'){
cell.parentId = id;
}else{
cell.parentId = curCol.parentId;
}
document.getElementById('add_' + cell.parentId).value = 1 + parseInt(document.getElementById('add_' + cell.parentId).value);
slotCount++;
}
function deleteColFromView(id, index){
var curCol = document.getElementById(id);
var row = curCol.parentNode;
var index = curCol.cellIndex;
if(typeof(row.cells[index + 1].parentId) == 'undefined'){
row.deleteCell(index);
row.deleteCell(index - 1);
if(row.parentNode.rows[row.rowIndex + 1]){
row.parentNode.rows[row.rowIndex + 1].deleteCell(index );
row.parentNode.rows[row.rowIndex + 1].deleteCell(index - 1);
}
}else{
row.deleteCell(index + 1);
if(row.parentNode.rows[row.rowIndex + 1])row.parentNode.rows[row.rowIndex + 1].deleteCell(index +1);
}
document.getElementById('add_' + curCol.id).value = parseInt(document.getElementById('add_' + curCol.id).value) - 1;
}
var field_count_MSI = 0;
var studioLoaded = false;
var dyn_field_count = 0;
function addNewFieldType(type){
var select = document.getElementById('studio_display_type').options;
for(var i = 0; i < select.length; i++){
if(select[i].value == type){
return;
}
}
select[i] = new Option(type, type);
}
function filterStudioFields(type){
var table = document.getElementById('studio_fields');
for(var i = 0; i < table.rows.length; i++){
children = table.rows[i].cells[0].childNodes;
for(var j = 0; j < children.length; j++){
child = children[j];
if(child.nodeName == 'DIV' && typeof(child.fieldType) != 'undefined'){
if(type == 'all'){
table.rows[i].style.display = '';
}else if(type == 'custom'){
if(child.isCustom){
table.rows[i].style.display = ''
}else{
table.rows[i].style.display = 'none';
}
}else{
if(child.fieldType == type){
table.rows[i].style.display = ''
}else{
table.rows[i].style.display = 'none';
}
}
}
}
}
}
function addNewField(id, name, label, html, fieldType,isCustom, table_id, top){
html = replaceAll(html, "&qt;", '"');
html = replaceAll(html, "&sqt;", "'");
var table = document.getElementById(table_id);
var row = false;
if(top){
row = table.insertRow(1);
}else{
row = table.insertRow(table.rows.length);
}
var cell = row.insertCell(0);
var div = document.createElement('div');
div.className = 'slot';
div.setAttribute('id', id);
div.fieldType = fieldType;
addNewFieldType(fieldType);
div.isCustom = isCustom;
div.style.width='100%';
var textEl = document.createElement('input');
textEl.setAttribute('type', 'hidden')
textEl.setAttribute('name', 'slot_field_' + field_count_MSI );
textEl.setAttribute('id', 'slot_field_' + field_count_MSI );
textEl.setAttribute('value', 'add:' + name );
field_list_MSI['form_' + name] = textEl;
document.studio.appendChild(textEl);
div.innerHTML = label;
var cell2 = row.insertCell(1);
var div2 = document.createElement('div');
setMouseOverForField(div, true);
div2.style.display = 'none';
div2.setAttribute('id', id + 'b' );
html = html.replace(/(<input)([^>]*)/g, '$1 disabled readonly $2');
html = html.replace(/(<select)([^>]*)/g, '$1 disabled readonly $2');
html = html.replace(/(onclick=')([^']*)/g, '$1'); // to strip {} from after a JS onclick call
div2.innerHTML += html;
cell.appendChild(div);
cell2.appendChild(div2);
field_count_MSI++;
if(top){
yahooSlots[id] = new ygDDSlot(id, "studio");
}else{
dyn_field_count++;
}
return name;
}
function removeFieldFromTable(field, table)
{
var table = document.getElementById(table);
var rows = table.rows;
for(i = 0 ; i < rows.length; i++){
cells = rows[i].cells;
for(j = 0; j < cells.length; j++){
cell = rows[i].cells[j];
children = cell.childNodes;
for(k = 0; k < children.length; k++){
child = children[k];
if(child.nodeType == 1){
if(child.getAttribute('id') == 'slot_' + field){
table.deleteRow(i);
return;
}
}
}
}
}
}
function setMouseOverForField(field, on){
if(on){
field.onmouseover = function(){
return overlib(document.getElementById(this.id + 'b').innerHTML, FGCLASS, 'olFgClass',
CGCLASS, 'olCgClass', BGCLASS, 'olBgClass', TEXTFONTCLASS, 'olFontClass', CAPTIONFONTCLASS, 'olCapFontClass');
};
field.onmouseout = function(){
return nd();
};
}else{
field.onmouseover = function(){};
field.onmouseout = function(){};
}
}
var lastIDClick = '';
var lastIDClickTime = 0;
var dblDelay = 500;
function wasDoubleClick(id) {
var d = new Date();
var now = d.getTime();
if (lastIDClick == id && (now - lastIDClickTime) < dblDelay) {
lastIDClick = '';
return true;
}
lastIDClickTime = now;
lastIDClick = id;
return false;
}
function confirmNoSave(){
return confirm(SUGAR.language.get('Studio', 'LBL_CONFIRM_UNSAVE'));
}
var labelEdit = false;
SUGAR.Studio = function(){
this.labelEdit = false;
this.lastLabel = false;
}
SUGAR.Studio.prototype.endLabelEdit = function(id){
if(id == 'undefined')return;
document.getElementById('span' + id).style.display = 'none';
jstransaction.record('studioLabelEdit', {'id':id, 'new': document.getElementById(id).value , 'old':document.getElementById('label' + id).innerHTML});
document.getElementById('label' + id).innerHTML = document.getElementById(id).value;
document.getElementById('label_' + id).value = document.getElementById(id).value;
document.getElementById('label' + id).style.display = '';
this.labelEdit = false;
YAHOO.util.DragDropMgr.unlock();
};
SUGAR.Studio.prototype.undoLabelEdit = function (transaction){
var id = transaction['id'];
document.getElementById('span' + id).style.display = 'none';
document.getElementById('label' + id).innerHTML = transaction['old'];
document.getElementById('label_' + id).value = transaction['old'];
};
SUGAR.Studio.prototype.redoLabelEdit= function (transaction){
var id = transaction['id'];
document.getElementById('span' + id).style.display = 'none';
document.getElementById('label' + id).innerHTML = transaction['new'];
document.getElementById('label_' + id).value = transaction['new'];
};
SUGAR.Studio.prototype.handleLabelClick = function(id, count){
if(this.lastLabel != ''){
//endLabelEdit(lastLabel);
}
if(wasDoubleClick(id) || count == 1){
document.getElementById('span' + id).style.display = '';
document.getElementById(id).focus();
document.getElementById(id).select();
document.getElementById('label' + id).style.display = 'none';
this.lastLabel = id;
YAHOO.util.DragDropMgr.lock();
}
}
jstransaction.register('studioLabelEdit', SUGAR.Studio.prototype.undoLabelEdit, SUGAR.Studio.prototype.redoLabelEdit);
SUGAR.Studio.prototype.save = function(formName, publish){
ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVING'));
var formObject = document.forms[formName];
YAHOO.util.Connect.setForm(formObject);
var cObj = YAHOO.util.Connect.asyncRequest('POST','index.php',
{success: SUGAR.Studio.prototype.saved, failure: SUGAR.Studio.prototype.saved,timeout:5000, argument: publish});
}
SUGAR.Studio.prototype.saved= function(o){
if(o){
ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVED'));
window.setTimeout('ajaxStatus.hideStatus();', 2000);
if(o.argument){
studiojs.publish();
}else{
document.location.reload();
}
}else{
ajaxStatus.showStatus(SUGAR.language.get('Studio', 'LBL_FAILED_TO_SAVE'));
window.setTimeout('ajaxStatus.hideStatus();', 2000);
}
}
SUGAR.Studio.prototype.publish = function(){
ajaxStatus.showStatus(SUGAR.language.get('Studio', 'LBL_PUBLISHING'));
var cObj = YAHOO.util.Connect.asyncRequest('GET','index.php?to_pdf=1&module=Studio&action=Publish',
{success: SUGAR.Studio.prototype.published, failure: SUGAR.Studio.prototype.published}, null);
}
SUGAR.Studio.prototype.published= function(o){
if(o){
ajaxStatus.showStatus(SUGAR.language.get('Studio', 'LBL_PUBLISHED'));
window.setTimeout('ajaxStatus.hideStatus();', 2000);
document.location.reload();
}else{
ajaxStatus.showStatus(SUGAR.language.get('Studio', 'LBL_FAILED_PUBLISHED'));
window.setTimeout('ajaxStatus.hideStatus();', 2000);
}
}
var studiopopup = function() {
return {
// covers the page w/ white overlay
display: function() {
if(studiojs.popupVisible)return false;
studiojs.popupVisible = true;
var cObj = YAHOO.util.Connect.asyncRequest('GET','index.php?to_pdf=1&module=Studio&action=wizard&wizard=EditCustomFieldsWizard&option=CreateCustomFields&popup=true',
{success: studiopopup.render, failure: studiopopup.render}, null);
},
destroy:function(){
studiojs.popup.hide();
},
evalScript:function(text){
SUGAR.util.evalScript(text);
},
render: function(obj){
if(obj){
studiojs.popup = new YAHOO.widget.Dialog("dlg", { effect:{effect:YAHOO.widget.ContainerEffect.SLIDE,duration:.5}, fixedcenter: false, constraintoviewport: false, underlay:"shadow",modal:true, close:true, visible:false, draggable:true, monitorresize:true} );
studiojs.popup.setBody(obj.responseText);
studiojs.popupAvailable = true;
studiojs.popup.render(document.body);
studiojs.popup.center();
studiojs.popup.beforeHideEvent.fire = function(e){
studiojs.popupVisible = false;
}
studiopopup.evalScript(obj.responseText);
}
}
};
}();
var studiojs = new SUGAR.Studio();
studiojs.popupAvailable = false;
studiojs.popupVisible = false;
var popupSave = function(o){
var errorIndex = o.responseText.indexOf('[ERROR]');
if(errorIndex > -1){
var error = o.responseText.substr(errorIndex + 7, o.responseText.length);
ajaxStatus.showStatus(error);
window.setTimeout('ajaxStatus.hideStatus();', 2000);
return;
}
var typeIndex = o.responseText.indexOf('[TYPE]') ;
var labelIndex = o.responseText.indexOf('[LABEL]') ;
var dataIndex = o.responseText.indexOf('[DATA]');
var errorIndex = o.responseText.indexOf('[ERROR]');
var name = o.responseText.substr(6, typeIndex - 6);
var type = o.responseText.substr(typeIndex + 6,labelIndex - (typeIndex + 6));
var label = o.responseText.substr(labelIndex + 7,dataIndex - (labelIndex + 7));
var data = o.responseText.substr(dataIndex + 6, o.responseText.length);
addNewField('dyn_field_' + field_count_MSI, name, label, data, type, 1, 'studio_fields', true)
};
function submitCustomFieldForm(isPopup){
if(typeof(document.popup_form.presave) != 'undefined'){
document.popup_form.presave();
}
if(!check_form('popup_form'))return;
if(isPopup){
var callback =
{
success: popupSave ,
failure: popupSave ,
argument: ''
}
YAHOO.util.Connect.setForm('popup_form');
var cObj = YAHOO.util.Connect.asyncRequest('POST', 'index.php', callback);
studiopopup.destroy();
}else{
document.popup_form.submit();
}
}
function deleteCustomFieldForm(isPopup){
if(confirm("WARNING\nDeleting a custom field will delete all data related to that custom field. \nYou will still need to remove the field from any layouts you have added it to.")){
document.popup_form.option.value = 'DeleteCustomField';
document.popup_form.submit();
}
}
function dropdownChanged(value){
if(typeof(app_list_strings[value]) == 'undefined')return;
var select = document.getElementById('default_value').options;
select.length = 0;
var count = 0;
for(var key in app_list_strings[value]){
select[count] = new Option(app_list_strings[value][key], key);
count++;
}
}
function customFieldChanged(){
}
var populateCustomField = function(response){
var div = document.getElementById('customfieldbody');
if(response.status = 0){
div.innerHTML = 'Server Connection Failed';
}else{
validate['popup_form'] = new Array();
inputsWithErrors = new Array();
div.innerHTML = response.responseText;
studiopopup.evalScript(response.responseText);
if(studiojs.popupAvailable){
var region = YAHOO.util.Dom.getRegion('custom_field_table') ;
studiojs.popup.cfg.setProperty('width', region.right - region.left + 30 + 'px');
studiojs.popup.cfg.setProperty('height', region.bottom - region.top + 30 + 'px');
studiojs.popup.render(document.body);
studiojs.popup.center();
studiojs.popup.show();
}
}
};
var populateCustomFieldCallback = {
success: populateCustomField ,
failure: populateCustomField,
argument: 1
};
var COBJ = false;
function changeTypeData(type){
document.getElementById('customfieldbody').innerHTML = '<h2>Loading...</h2>';
COBJ = YAHOO.util.Connect.asyncRequest('GET','index.php?module=Studio&popup=true&action=index&&ajax=editcustomfield&to_pdf=true&type=' + type,populateCustomFieldCallback,null);
}
function typeChanged(obj)
{
changeTypeData(obj.options[obj.selectedIndex].value);
}
function handle_duplicate(){
document.popup_form.action.value = 'EditView';
document.popup_form.duplicate.value = 'true';
document.popup_form.submit();
}
function forceRange(field, min, max){
field.value = parseInt(field.value);
if(field.value == 'NaN')field.value = max;
if(field.value > max) field.value = max;
if(field.value < min) field.value = min;
}
function changeMaxLength(field, length){
field.maxLength = parseInt(length);
field.value = field.value.substr(0, field.maxLength);
}

View File

@@ -0,0 +1,218 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/*Portions Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
/**
* @class a ygDDFramed implementation like ygDDMy, but the content channels are
* not restricted to one column, and we drag a miniature representation of the
* content channel rather than a frame of the channel.
*
* @extends YAHOO.util.DDProxy
* @constructor
* @param {String} id the id of the linked element
* @param {String} sGroup the group of related DragDrop objects
*/
function ygDDSlot(id, sGroup) {
if (id) {
this.init(id, sGroup);
this.initFrame();
}
// Change the style of the frame to be a miniature representation of a
// content channel
var s = this.getDragEl().style;
s.borderColor = "transparent";
s.backgroundColor = "#f6f5e5";
s.opacity = 0.76;
s.filter = "alpha(opacity=76)";
// Specify that we do not want to resize the drag frame... we want to keep
// the drag frame the size of our miniature content channel image
this.resizeFrame = true;
if(id == 's_field_delete'){
this.isValidHandle = false;
}
// Specify that we want the drag frame centered around the cursor rather
// than relative to the click location so that the miniature content
// channel appears in the location that was clicked
//this.centerFrame = true;
}
ygDDSlot.prototype = new YAHOO.util.DDProxy();
ygDDSlot.prototype.handleDelete = function(cur, curb){
var parentID = (typeof(cur.parentID) == 'undefined')?cur.id.substr(4,cur.id.length):cur.parentID ;
if(parentID.indexOf('field') == 0){
return false;
}
var myfieldcount = field_count_MSI;
addNewField('dyn_field_' + field_count_MSI, 'delete', '&nbsp;', '&nbsp;', 'deleted', 0, 'studio_fields')
yahooSlots["dyn_field_" + myfieldcount] = new ygDDSlot("dyn_field_" + myfieldcount, "studio");
ygDDSlot.prototype.handleSwap(cur, curb, document.getElementById("dyn_field_" + myfieldcount), document.getElementById("dyn_field_" + myfieldcount+ 'b'), true);
}
ygDDSlot.prototype.undo = function(transaction){
ygDDSlot.prototype.handleSwap(document.getElementById(transaction['el']),document.getElementById(transaction['elb']), document.getElementById(transaction['cur']), document.getElementById(transaction['curb']), false);
}
ygDDSlot.prototype.redo = function(transaction){
ygDDSlot.prototype.handleSwap(document.getElementById(transaction['el']),document.getElementById(transaction['elb']), document.getElementById(transaction['cur']), document.getElementById(transaction['curb']), false);
}
ygDDSlot.prototype.handleSwap = function(cur, curb,el, elb, record ){
if(record){
if(curb){
jstransaction.record('studioSwap', {'cur': cur.id, 'curb': curb.id, 'el':el.id, 'elb':elb.id});
}else{
jstransaction.record('studioSwap', {'cur': cur.id, 'curb': null, 'el':el.id, 'elb':null});
}
}
var parentID1 = (typeof(el.parentID) == 'undefined')?el.id.substr(4,el.id.length):el.parentID ;
var parentID2 = (typeof(cur.parentID) == 'undefined')?cur.id.substr(4,cur.id.length):cur.parentID ;
var slot1 = YAHOO.util.DDM.getElement("slot_" + parentID1);
var slot2 = YAHOO.util.DDM.getElement("slot_" + parentID2);
var temp = slot1.value;
slot1.value = slot2.value;
slot2.value = temp;
YAHOO.util.DDM.swapNode(cur, el);
if(curb){
YAHOO.util.DDM.swapNode(curb, elb);
}
//swap ids also or else form swaps don't work properly since the actual div is swapped
cur.parentID = parentID1;
el.parentID = parentID2;
if(parentID1.indexOf('field') == 0){
if(curb)curb.style.display = 'none';
setMouseOverForField(cur, true);
}else{
if(curb)curb.style.display = 'inline';
setMouseOverForField(cur, false);
}
if(parentID2.indexOf('field') == 0){
if(elb)elb.style.display = 'none';
setMouseOverForField(el, true);
}else{
if(elb)elb.style.display = 'inline';
setMouseOverForField(el, false);
}
}
ygDDSlot.prototype.onDragDrop = function(e, id) {
var cur = this.getEl();
var curb;
if ("string" == typeof id) {
curb = YAHOO.util.DDM.getElement(cur.id + "b");
} else {
curb = YAHOO.util.DDM.getBestMatch(cur.id + "b").getEl();
}
if(id == 's_field_delete'){
id = ygDDSlot.prototype.handleDelete(cur, curb);
if(!id)return false;
}
var el;
if ("string" == typeof id) {
el = YAHOO.util.DDM.getElement(id);
} else {
el = YAHOO.util.DDM.getBestMatch(id).getEl();
}
id2 = el.id + "b";
if ("string" == typeof id) {
elb =YAHOO.util.DDM.getElement(id2);
} else {
elb =YAHOO.util.DDM.getBestMatch(id2).getEl();
}
ygDDSlot.prototype.handleSwap(cur, curb, el, elb, true)
var dragEl = this.getDragEl();
dragEl.innerHTML = '';
};
ygDDSlot.prototype.startDrag = function(x, y) {
var dragEl = this.getDragEl();
var clickEl = this.getEl();
dragEl.innerHTML = clickEl.innerHTML;
dragEl.className = clickEl.className;
dragEl.style.color = clickEl.style.color;
dragEl.style.border = "2px solid #aaa";
// save the style of the object
this.clickContent = clickEl.innerHTML;
this.clickBorder = clickEl.style.border;
this.clickHeight = clickEl.style.height;
clickElRegion = YAHOO.util.Dom.getRegion(clickEl);
dragEl.style.height = clickEl.style.height;
dragEl.style.width = (clickElRegion.right - clickElRegion.left) + 'px';
clickEl.style.height = (clickElRegion.bottom - clickElRegion.top) + 'px';
//clickEl.innerHTML = '&nbsp;';
clickEl.style.border = '2px dashed #cccccc';
clickEl.style.opacity = .5;
clickEl.style.filter = "alpha(opacity=10)";
};
ygDDSlot.prototype.endDrag = function(e) {
// disable moving the linked element
var clickEl = this.getEl();
//clickEl.innerHTML = this.clickContent
if(this.clickHeight)
clickEl.style.height = this.clickHeight;
else
clickEl.style.height = '';
if(this.clickBorder)
clickEl.style.border = this.clickBorder;
else
clickEl.style.border = '';
clickEl.style.opacity = 1;
clickEl.style.filter = "alpha(opacity=100)";
};
jstransaction.register('studioSwap',ygDDSlot.prototype.undo, ygDDSlot.prototype.redo);

View File

@@ -0,0 +1,141 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
var subtabCount = [];
var subtabModules = [];
var tabLabelToValue = [];
StudioTabGroup = function(){
this.lastEditTabGroupLabel = -1;
};
StudioTabGroup.prototype.editTabGroupLabel = function (id, done){
if(!done){
if(this.lastEditTabGroupLabel != -1)StudioTabGroup.prototype.editTabGroupLabel(this.lastEditTabGroupLabel, true);
document.getElementById('tabname_'+id).style.display = 'none';
document.getElementById('tablabel_'+id).style.display = '';
document.getElementById('tabother_'+id).style.display = 'none';
//#28274, I think this is a simple way when a element can't accept focus()
try{
document.getElementById('tablabel_'+id).focus();
}
catch(er){
//TODO
}
this.lastEditTabGroupLabel = id;
YAHOO.util.DragDropMgr.lock();
}else{
this.lastEditTabGroupLabel = -1;
document.getElementById('tabname_'+id).innerHTML =document.getElementById('tablabel_'+id).value;
document.getElementById('tabname_'+id).style.display = '';
document.getElementById('tablabel_'+id).style.display = 'none';
document.getElementById('tabother_'+id).style.display = '';
YAHOO.util.DragDropMgr.unlock();
}
}
StudioTabGroup.prototype.generateForm = function(formname){
var form = document.getElementById(formname);
for(var j = 0; j < slotCount; j++){
var ul = document.getElementById('ul' + j);
var items = ul.getElementsByTagName('li');
for(var i = 0; i < items.length; i++) {
if(typeof(subtabModules[items[i].id]) != 'undefined'){
var input = document.createElement('input');
input.type='hidden';
input.name= j + '_'+ i;
input.value = tabLabelToValue[subtabModules[items[i].id]];
form.appendChild(input);
}
}
}
//set the slotcount in the form.
form.slot_count.value = slotCount;
};
StudioTabGroup.prototype.generateGroupForm = function(formname){
var form = document.getElementById(formname);
for(j = 0; j < slotCount; j++){
var ul = document.getElementById('ul' + j);
items = ul.getElementsByTagName('li');
for(i = 0; i < items.length; i++) {
if(typeof(subtabModules[items[i].id]) != 'undefined'){
var input = document.createElement('input');
input.type='hidden'
input.name= 'group_'+ j + '[]';
input.value = tabLabelToValue[subtabModules[items[i].id]];
form.appendChild(input);
}
}
}
};
StudioTabGroup.prototype.deleteTabGroup = function(id){
if(document.getElementById('delete_' + id).value == 0){
document.getElementById('ul' + id).style.display = 'none';
document.getElementById('tabname_'+id).style.textDecoration = 'line-through'
document.getElementById('delete_' + id).value = 1;
}else{
document.getElementById('ul' + id).style.display = '';
document.getElementById('tabname_'+id).style.textDecoration = 'none'
document.getElementById('delete_' + id).value = 0;
}
}
var lastField = '';
var lastRowCount = -1;
var undoDeleteDropDown = function(transaction){
deleteDropDownValue(transaction['row'], document.getElementById(transaction['id']), false);
}
jstransaction.register('deleteDropDown', undoDeleteDropDown, undoDeleteDropDown);
function deleteDropDownValue(rowCount, field, record){
if(record){
jstransaction.record('deleteDropDown',{'row':rowCount, 'id': field.id });
}
//We are deleting if the value is 0
if(field.value == '0'){
field.value = '1';
document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'line-through';
}else{
field.value = '0';
document.getElementById('slot' + rowCount + '_value').style.textDecoration = 'none';
}
}
var studiotabs = new StudioTabGroup();

View File

@@ -0,0 +1,239 @@
/*********************************************************************************
* SugarCRM is a customer relationship management program developed by
* SugarCRM, Inc. Copyright (C) 2004-2010 SugarCRM Inc.
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License version 3 as published by the
* Free Software Foundation with the addition of the following permission added
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along with
* this program; if not, see http://www.gnu.org/licenses or write to the Free
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
*
* The interactive user interfaces in modified source and object code versions
* of this program must display Appropriate Legal Notices, as required under
* Section 5 of the GNU Affero General Public License version 3.
*
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
/**
* @class a YAHOO.util.DDProxy implementation. During the drag over event, the
* dragged element is inserted before the dragged-over element.
*
* @extends YAHOO.util.DDProxy
* @constructor
* @param {String} id the id of the linked element
* @param {String} sGroup the group of related DragDrop objects
*/
var addListStudioCount = 0;
var moduleTabs = [];
function ygDDListStudio(id, sGroup, fromOnly) {
if (id) {
if(id == 'trashcan' || id.indexOf('noselect') ==0){
this.initTarget(id, sGroup);
}else{
this.init(id, sGroup);
}
this.initFrame();
this.fromOnly = fromOnly;
}
var s = this.getDragEl().style;
s.borderColor = "transparent";
s.backgroundColor = "#f6f5e5";
s.opacity = 0.76;
s.filter = "alpha(opacity=76)";
}
ygDDListStudio.prototype = new YAHOO.util.DDProxy();
ygDDListStudio.prototype.clickContent = '';
ygDDListStudio.prototype.clickBorder = '';
ygDDListStudio.prototype.clickHeight = '';
ygDDListStudio.prototype.lastNode = false;
ygDDListStudio.prototype.startDrag
ygDDListStudio.prototype.startDrag = function(x, y) {
var dragEl = this.getDragEl();
var clickEl = this.getEl();
this.parentID = clickEl.parentNode.id;
dragEl.innerHTML = clickEl.innerHTML;
dragElObjects = dragEl.getElementsByTagName('object');
dragEl.className = clickEl.className;
dragEl.style.color = clickEl.style.color;
dragEl.style.border = "1px solid #aaa";
// save the style of the object
this.clickContent = clickEl.innerHTML;
this.clickBorder = clickEl.style.border;
this.clickHeight = clickEl.style.height;
clickElRegion = YAHOO.util.Dom.getRegion(clickEl);
clickEl.style.height = (clickElRegion.bottom - clickElRegion.top) + 'px';
clickEl.style.opacity = .5;
clickEl.style.filter = "alpha(opacity=10)";
clickEl.style.border = '2px dashed #cccccc';
};
ygDDListStudio.prototype.updateTabs = function(){
moduleTabs = [];
for(j = 0; j < slotCount; j++){
var ul = document.getElementById('ul' + j);
moduleTabs[j] = [];
items = ul.getElementsByTagName("li");
for(i = 0; i < items.length; i++) {
if(items.length == 1){
items[i].innerHTML = SUGAR.language.get('app_strings', 'LBL_DROP_HERE');
}else{
if(items[i].innerHTML == SUGAR.language.get('app_strings', 'LBL_DROP_HERE')){
items[i].innerHTML='';
}
}
moduleTabs[ul.id.substr(2, ul.id.length)][subtabModules[items[i].id]] = true;
}
}
};
ygDDListStudio.prototype.endDrag = function(e) {
var clickEl = this.getEl();
clickEl.innerHTML = this.clickContent
var p = clickEl.parentNode;
if(p.id == 'trash'){
p.removeChild(clickEl);
this.lastNode = false;
this.updateTabs();
return;
}
if(this.clickHeight) {
clickEl.style.height = this.clickHeight;
if(this.lastNode)this.lastNode.style.height=this.clickHeight;
}
else{
clickEl.style.height = '';
if(this.lastNode)this.lastNode.style.height='';
}
if(this.clickBorder){
clickEl.style.border = this.clickBorder;
if(this.lastNode)this.lastNode.style.border=this.clickBorder;
}
else {
clickEl.style.border = '';
if(this.lastNode)this.lastNode.style.border='';
}
clickEl.style.opacity = 1;
clickEl.style.filter = "alpha(opacity=100)";
if(this.lastNode){
this.lastNode.id = 'addLS' + addListStudioCount;
subtabModules[this.lastNode.id] = this.lastNode.module;
yahooSlots[this.lastNode.id] = new ygDDListStudio(this.lastNode.id, 'subTabs', false);
addListStudioCount++;
this.lastNode.style.opacity = 1;
this.lastNode.style.filter = "alpha(opacity=100)";
}
this.lastNode = false;
this.updateTabs();
};
ygDDListStudio.prototype.onDrag = function(e, id) {
};
ygDDListStudio.prototype.onDragOver = function(e, id) {
// this.logger.debug(this.id.toString() + " onDragOver " + id);
var el;
if(this.lastNode){
this.lastNode.parentNode.removeChild(this.lastNode);
this.lastNode = false;
}
if(id.substr(0, 7) == 'modSlot'){
return;
}
if ("string" == typeof id) {
el = YAHOO.util.DDM.getElement(id);
} else {
el = YAHOO.util.DDM.getBestMatch(id).getEl();
}
dragEl = this.getDragEl();
elRegion = YAHOO.util.Dom.getRegion(el);
var mid = YAHOO.util.DDM.getPosY(el) + (Math.floor((elRegion.bottom - elRegion.top) / 2));
var el2 = this.getEl();
var p = el.parentNode;
if( (this.fromOnly || ( el.id != 'trashcan' && el2.parentNode.id != p.id && el2.parentNode.id == this.parentID)) ){
if(typeof(moduleTabs[p.id.substr(2,p.id.length)][subtabModules[el2.id]]) != 'undefined')return;
}
if(this.fromOnly && el.id != 'trashcan'){
el2 = el2.cloneNode(true);
el2.module = subtabModules[el2.id];
el2.id = 'addListStudio' + addListStudioCount;
this.lastNode = el2;
this.lastNode.clickContent = el2.clickContent;
this.lastNode.clickBorder = el2.clickBorder;
this.lastNode.clickHeight = el2.clickHeight
}
if (YAHOO.util.DDM.getPosY(dragEl) < mid ) { // insert on top triggering item
p.insertBefore(el2, el);
}
if (YAHOO.util.DDM.getPosY(dragEl) >= mid ) { // insert below triggered item
p.insertBefore(el2, el.nextSibling);
}
};
ygDDListStudio.prototype.onDragEnter = function(e, id) {
};
ygDDListStudio.prototype.onDragOut = function(e, id) {
}
/////////////////////////////////////////////////////////////////////////////
function ygDDListStudioBoundary(id, sGroup) {
if (id) {
this.init(id, sGroup);
this.isBoundary = true;
}
}
ygDDListStudioBoundary.prototype = new YAHOO.util.DDTarget();