Add JS files
This commit is contained in:
78
modules/ModuleBuilder/javascript/JSTransaction.js
Executable file
78
modules/ModuleBuilder/javascript/JSTransaction.js
Executable 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']);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
1035
modules/ModuleBuilder/javascript/ModuleBuilder.js
Executable file
1035
modules/ModuleBuilder/javascript/ModuleBuilder.js
Executable file
File diff suppressed because it is too large
Load Diff
304
modules/ModuleBuilder/javascript/SimpleList.js
Executable file
304
modules/ModuleBuilder/javascript/SimpleList.js
Executable file
@@ -0,0 +1,304 @@
|
||||
/*********************************************************************************
|
||||
* 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".
|
||||
********************************************************************************/
|
||||
if(typeof(SimpleList) == 'undefined'){
|
||||
var Dom = YAHOO.util.Dom;
|
||||
SimpleList = function(){
|
||||
var editImage;
|
||||
var deleteImage;
|
||||
var ul_list;
|
||||
var jstransaction;
|
||||
var lastEdit;
|
||||
var isIE = isSupportedIE();
|
||||
return {
|
||||
init: function(editImage, deleteImage) {
|
||||
var ul = document.getElementById('ul1', 'drpdwn');
|
||||
SimpleList.lastEdit = null; // Bug 14662
|
||||
SimpleList.editImage = editImage;
|
||||
SimpleList.deleteImage = deleteImage;
|
||||
new YAHOO.util.DDTarget("ul1");
|
||||
|
||||
for (i=0;i<SimpleList.ul_list.length;i++){
|
||||
if ( typeof SimpleList.ul_list[i] != "number" && SimpleList.ul_list[i] == "" ) {
|
||||
SimpleList.ul_list[i] = SUGAR.language.get('ModuleBuilder', 'LBL_BLANK');
|
||||
}
|
||||
new Studio2.ListDD(SimpleList.ul_list[i], 'drpdwn', false);
|
||||
}
|
||||
YAHOO.util.Event.on("dropdownaddbtn", "click", this.addToList, 'dropdown_form');
|
||||
SimpleList.jstransaction = new JSTransaction();
|
||||
SimpleList.jstransaction.register('deleteDropDown', SimpleList.undoDeleteDropDown, SimpleList.undoDeleteDropDown);
|
||||
SimpleList.jstransaction.register('changeDropDownValue', SimpleList.undoDropDownChange, SimpleList.redoDropDownChange);
|
||||
|
||||
},
|
||||
isValidDropDownKey : function(value){
|
||||
if(value.match(/^[\w\d \.]+$/i) || value == "")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
},
|
||||
isBlank : function(value){
|
||||
return value == SUGAR.language.get('ModuleBuilder', 'LBL_BLANK')
|
||||
|| (typeof value != "number" && value == "");
|
||||
},
|
||||
addToList : function(event, form){
|
||||
var drop_name = document.getElementById('drop_name');
|
||||
var drop_value = document.getElementById('drop_value');
|
||||
//Validate the dropdown key manually
|
||||
removeFromValidate('dropdown_form', 'drop_name');
|
||||
if(!SimpleList.isValidDropDownKey(drop_name.value)) {
|
||||
addToValidate('dropdown_form', 'drop_name', 'error', false, SUGAR.language.get("ModuleBuilder", "LBL_JS_VALIDATE_KEY"));
|
||||
}
|
||||
|
||||
if (!check_form("dropdown_form")) return;
|
||||
|
||||
var ul1=YAHOO.util.Dom.get("ul1");
|
||||
|
||||
var items = ul1.getElementsByTagName("li");
|
||||
for (i=0;i<items.length;i=i+1) {
|
||||
if((SimpleList.isBlank(items[i].id) && SimpleList.isBlank(drop_name.value)) || items[i].id == drop_name.value){
|
||||
alert("Key already exists in list");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
liObj = document.createElement('li');
|
||||
liObj.className = "draggable";
|
||||
if(drop_name.value == '' || !drop_name.value){
|
||||
liObj.id = SUGAR.language.get('ModuleBuilder', 'LBL_BLANK');
|
||||
}else{
|
||||
liObj.id = drop_name.value;
|
||||
}
|
||||
|
||||
var text1 = document.createElement('input');
|
||||
text1.type = 'hidden';
|
||||
text1.id = 'value_' + liObj.id;
|
||||
text1.name = 'value_' + liObj.id;
|
||||
text1.value = drop_value.value;
|
||||
|
||||
var html = "<table width='100%'><tr><td><b>"+liObj.id+"</b><input id='value_"+liObj.id+"' value=\""+drop_value.value+"\" type = 'hidden'><span class='fieldValue' id='span_"+liObj.id+"'>";
|
||||
if(drop_value.value == ""){
|
||||
html += "[" + SUGAR.language.get('ModuleBuilder', 'LBL_BLANK') + "]";
|
||||
}else{
|
||||
html += "["+drop_value.value+"]";
|
||||
}
|
||||
html += "</span>";
|
||||
html += "<span class='fieldValue' id='span_edit_"+liObj.id+"' style='display:none'>";
|
||||
html += "<input type='text' id='input_"+liObj.id+"' value=\""+drop_value.value+"\" onchange='SimpleList.setDropDownValue(\""+liObj.id+"\", unescape(this.value), true)' >";
|
||||
html += "</span>";
|
||||
html += "</td><td align='right'><a href='javascript:void(0)' onclick='SimpleList.editDropDownValue(\""+liObj.id+"\", true)'>"+SimpleList.editImage+"</a>";
|
||||
html += " <a href='javascript:void(0)' onclick='SimpleList.deleteDropDownValue(\""+liObj.id+"\", true)'>"+SimpleList.deleteImage+"</a>";
|
||||
html += "</td></tr></table>";
|
||||
|
||||
liObj.innerHTML = html;
|
||||
ul1.appendChild(liObj);
|
||||
new Studio2.ListDD(liObj, 'drpdwn', false);
|
||||
drop_value.value = "";
|
||||
drop_name.value = "";
|
||||
drop_name.focus();
|
||||
|
||||
SimpleList.jstransaction.record('deleteDropDown',{'id': liObj.id });
|
||||
|
||||
},
|
||||
|
||||
sortAscending: function ()
|
||||
{
|
||||
// now sort using a Shellsort - do this rather than by using the inbuilt sort function as we need to sort a complex DOM inplace
|
||||
var parent = YAHOO.util.Dom.get("ul1");
|
||||
var items = parent.getElementsByTagName("li") ;
|
||||
var increment = Math.floor ( items.length / 2 ) ;
|
||||
|
||||
function swapItems(itemA, itemB) {
|
||||
var placeholder = document.createElement ( "li" ) ;
|
||||
Dom.insertAfter(placeholder, itemA);
|
||||
Dom.insertBefore(itemA, itemB);
|
||||
Dom.insertBefore(itemB, placeholder);
|
||||
|
||||
//Cleanup the placeholder element
|
||||
parent.removeChild(placeholder);
|
||||
}
|
||||
|
||||
while ( increment > 0 )
|
||||
{
|
||||
for (var i = increment; i < items.length; i++)
|
||||
{
|
||||
var j = i;
|
||||
var id = items[i].id;
|
||||
var iValue = document.getElementById( 'input_' + id ).value.toLowerCase() ;
|
||||
|
||||
while ( ( j >= increment ) && ( document.getElementById( 'input_' + items [j-increment].id ).value.toLowerCase() > iValue ) )
|
||||
{
|
||||
// logically, this is what we need to do: items [j] = items [j - increment];
|
||||
// but we're working with the DOM through a NodeList (items) which is readonly, so things aren't that simple
|
||||
// A placeholder will be used to keep track of where in the DOM the swap needs to take place
|
||||
// especially with IE which enforces the prohibition on duplicate Ids, so copying nodes is problematic
|
||||
swapItems(items [j], items [j - increment]);
|
||||
j = j - increment;
|
||||
}
|
||||
}
|
||||
|
||||
if (increment == 2)
|
||||
increment = 1;
|
||||
else
|
||||
increment = Math.floor (increment / 2.2);
|
||||
}
|
||||
},
|
||||
sortDescending: function ()
|
||||
{
|
||||
this.sortAscending();
|
||||
var reverse = function ( children )
|
||||
{
|
||||
var parent = children [ 0 ] . parentNode ;
|
||||
var start = 0;
|
||||
if ( children [ 0 ].id == '-blank-' ) // don't include -blank- element in the sort
|
||||
start = 1 ;
|
||||
for ( var i = children.length - 1 ; i >= start ; i-- )
|
||||
{
|
||||
parent.appendChild ( children [ i ] ) ;
|
||||
}
|
||||
};
|
||||
reverse ( YAHOO.util.Dom.get("ul1").getElementsByTagName("li") ) ;
|
||||
},
|
||||
handleSave:function(){
|
||||
var parseList = function(ul, title) {
|
||||
var items = ul.getElementsByTagName("li");
|
||||
var out = [];
|
||||
for (i=0;i<items.length;i=i+1) {
|
||||
var name = items[i].id;
|
||||
var value = document.getElementById('input_'+name).value;
|
||||
out[i] = [ name , value ];
|
||||
}
|
||||
return YAHOO.lang.JSON.stringify(out);
|
||||
};
|
||||
var ul1=YAHOO.util.Dom.get("ul1");
|
||||
var hasDeletedItem = false;
|
||||
for(j = 0; j < SimpleList.jstransaction.JSTransactions.length; j++){
|
||||
var liEl = new YAHOO.util.Element(SimpleList.jstransaction.JSTransactions[j]['data']['id']);
|
||||
if(liEl && liEl.hasClass('deleted'))
|
||||
hasDeletedItem = true;
|
||||
break;
|
||||
}
|
||||
if(hasDeletedItem) {
|
||||
if(!confirm(SUGAR.language.get('ModuleBuilder', 'LBL_CONFIRM_SAVE_DROPDOWN')))
|
||||
return false;
|
||||
}
|
||||
|
||||
for(j = 0; j < SimpleList.jstransaction.JSTransactions.length; j++){
|
||||
if(SimpleList.jstransaction.JSTransactions[j]['transaction'] == 'deleteDropDown'){
|
||||
var liEl = new YAHOO.util.Element(SimpleList.jstransaction.JSTransactions[j]['data']['id']);
|
||||
if(liEl && liEl.hasClass('deleted'))
|
||||
ul1.removeChild(liEl.get("element"));
|
||||
}
|
||||
}
|
||||
var list = document.getElementById('list_value');
|
||||
|
||||
var out = parseList(ul1, "List 1");
|
||||
list.value = out;
|
||||
ModuleBuilder.refreshDD_name = document.getElementById('dropdown_name').value;
|
||||
if (document.forms.popup_form)
|
||||
{
|
||||
ModuleBuilder.handleSave("dropdown_form", ModuleBuilder.refreshDropDown);
|
||||
}
|
||||
else
|
||||
{
|
||||
ModuleBuilder.handleSave("dropdown_form", ModuleBuilder.refreshGlobalDropDown);
|
||||
}
|
||||
},
|
||||
deleteDropDownValue : function(id, record){
|
||||
var field = new YAHOO.util.Element(id);
|
||||
if(record){
|
||||
SimpleList.jstransaction.record('deleteDropDown',{'id': id });
|
||||
}
|
||||
if (field.hasClass('deleted'))
|
||||
field.removeClass('deleted');
|
||||
else
|
||||
field.addClass('deleted');
|
||||
},
|
||||
editDropDownValue : function(id, record){
|
||||
//Close any other dropdown edits
|
||||
if (SimpleList)
|
||||
SimpleList.endCurrentDropDownEdit();
|
||||
var dispSpan = document.getElementById('span_'+id);
|
||||
var editSpan = document.getElementById('span_edit_'+id);
|
||||
dispSpan.style.display = 'none';
|
||||
|
||||
if(SimpleList.isIE){
|
||||
editSpan.style.display = 'inline-block';
|
||||
}else{
|
||||
editSpan.style.display = 'inline';
|
||||
}
|
||||
var textbox = document.getElementById('input_'+id);
|
||||
textbox.focus();
|
||||
SimpleList.lastEdit = id;
|
||||
},
|
||||
endCurrentDropDownEdit : function() {
|
||||
if (SimpleList.lastEdit != null)
|
||||
{
|
||||
var valueLastEdit = unescape(document.getElementById('input_'+SimpleList.lastEdit).value);
|
||||
SimpleList.setDropDownValue(SimpleList.lastEdit,valueLastEdit,true);
|
||||
}
|
||||
},
|
||||
setDropDownValue : function(id, val, record){
|
||||
|
||||
if(record){
|
||||
SimpleList.jstransaction.record('changeDropDownValue', {'id':id, 'new':val, 'old':document.getElementById('value_'+ id).value});
|
||||
}
|
||||
var dispSpan = document.getElementById('span_'+id);
|
||||
var editSpan = document.getElementById('span_edit_'+id);
|
||||
var textbox = document.getElementById('input_'+id);
|
||||
|
||||
dispSpan.style.display = 'inline';
|
||||
editSpan.style.display = 'none';
|
||||
dispSpan.innerHTML = "["+val+"]";
|
||||
document.getElementById('value_'+ id).value = val;
|
||||
SimpleList.lastEdit = null; // Bug 14662 - clear the last edit point behind us
|
||||
},
|
||||
undoDeleteDropDown : function(transaction){
|
||||
|
||||
SimpleList.deleteDropDownValue(transaction['id'], false);
|
||||
},
|
||||
undoDropDownChange : function(transaction){
|
||||
SimpleList.setDropDownValue(transaction['id'], transaction['old'], false);
|
||||
},
|
||||
redoDropDownChange : function(transaction){
|
||||
SimpleList.setDropDownValue(transaction['id'], transaction['new'], false);
|
||||
},
|
||||
undo : function(){
|
||||
SimpleList.jstransaction.undo();
|
||||
},
|
||||
redo : function(){
|
||||
SimpleList.jstransaction.redo();
|
||||
}
|
||||
}//return
|
||||
}();
|
||||
}
|
||||
840
modules/ModuleBuilder/javascript/studio2.js
Executable file
840
modules/ModuleBuilder/javascript/studio2.js
Executable file
@@ -0,0 +1,840 @@
|
||||
/*********************************************************************************
|
||||
* 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".
|
||||
********************************************************************************/
|
||||
|
||||
if(typeof('console') == 'undefined'){
|
||||
console = {
|
||||
log: function(message) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
var _debug_ = false;
|
||||
var _write_ = function( message ){ if(_debug_){ console.log(message);} }
|
||||
|
||||
|
||||
|
||||
Studio2 = {
|
||||
|
||||
init: function() {
|
||||
var Dom = YAHOO.util.Dom,
|
||||
DDTarget = YAHOO.util.DDTarget,
|
||||
DDM = YAHOO.utilDragDropMgr;
|
||||
|
||||
Studio2.maxColumns = parseInt(document.getElementById('maxColumns').value);
|
||||
Studio2.setStartId(parseInt(document.getElementById('idCount').value));
|
||||
Studio2.setStartId(1000);
|
||||
Studio2.fieldwidth = parseInt(document.getElementById('fieldwidth').value);
|
||||
Studio2.panelNumber = parseInt(document.getElementById('nextPanelId').value);
|
||||
Studio2.isIE = SUGAR.isIE;
|
||||
Studio2.expandableFields = [];
|
||||
|
||||
// Activate the layout panels
|
||||
var panels = document.getElementById('panels');
|
||||
Dom.setStyle(panels, "visibility", "hidden");
|
||||
//new Studio2.PanelDD(panels.id,'studio2.panels'); // add the main layout area into PANELS to allow for panel drags to empty areas
|
||||
new DDTarget(panels.id, 'studio2.panels');
|
||||
for (var i=0;i<panels.childNodes.length;i++) {
|
||||
var panel = panels.childNodes[i];
|
||||
if (panel.nodeName == 'DIV') { // a valid panel
|
||||
|
||||
// add the panel into the ROWS drag-and-drop group to allow for drags to empty areas of the panels
|
||||
new DDTarget(panel.id,'studio2.rows');
|
||||
|
||||
for (var j=0;j<panel.childNodes.length;j++) {
|
||||
var row = panel.childNodes[j];
|
||||
if(typeof(row.id)!='undefined' && row.id!=null)
|
||||
|
||||
if (row.nodeName == 'DIV' && row.className == 'le_row' ) { // a valid row
|
||||
|
||||
// Convert all (empty) fields into variable width fields
|
||||
var leftSibling = null;
|
||||
var foundEmpty = 0;
|
||||
|
||||
for (var k=0;k<row.childNodes.length;k++) {
|
||||
var field = row.childNodes[k];
|
||||
var ranOnce = false;
|
||||
if (field.nodeName == 'DIV') { // field
|
||||
|
||||
for (var l=0;l<field.childNodes.length;l++) {
|
||||
var property = field.childNodes[l];
|
||||
|
||||
if (property.className && (property.className.indexOf('field_name') != -1) && property.firstChild) {
|
||||
if (property.firstChild.nodeValue.indexOf('(empty)') != -1) {
|
||||
//register field to be expandable
|
||||
_write_("(empty) found");
|
||||
Studio2.setSpecial(field);
|
||||
Studio2.registerExpandableField( Studio2.prevField(field) || Studio2.nextField( field ) );
|
||||
break;
|
||||
}else if (property.firstChild.nodeValue.indexOf('(filler)') != -1){
|
||||
var sibling = Studio2.prevField( field ) || Studio2.nextField( field );
|
||||
Studio2.setSpecial( field );
|
||||
var swapFields = Studio2.nextField( field ) != null;
|
||||
Studio2.registerExpandableField( sibling);
|
||||
this.toggleFieldWidth (sibling );
|
||||
ranOnce = true;
|
||||
if( swapFields ){
|
||||
//swap (filler) with the sibling
|
||||
field = Studio2.nextField (sibling ) || Studio2.prevField( sibling );
|
||||
|
||||
this.swapElements( sibling , field)
|
||||
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if( ranOnce ){break;}
|
||||
}
|
||||
|
||||
Studio2.activateElement(row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Studio2.activateElement(panels);
|
||||
Dom.setStyle(panels, "visibility", '');
|
||||
|
||||
// Activate the fields in the availablefields list
|
||||
var availablefields = document.getElementById('availablefields');
|
||||
Studio2.activateElement(availablefields);
|
||||
|
||||
// Setup Delete area in the toolbox (the Trash icon)
|
||||
var d = document.getElementById('delete');
|
||||
Studio2.setSpecial(d);
|
||||
var delDD = new DDTarget('delete', 'studio2.panels');
|
||||
delDD.addToGroup('studio2.rows');
|
||||
delDD.addToGroup('studio2.fields');
|
||||
|
||||
var fillerProxy = Studio2.newField();
|
||||
Studio2.setSpecial(fillerProxy);
|
||||
var hanger = document.getElementById('fillerproxy');
|
||||
hanger.parentNode.insertBefore(fillerProxy,hanger.nextSibling);
|
||||
Studio2.activateElement(fillerProxy);
|
||||
|
||||
rowProxy = Studio2.newRow(true);
|
||||
Studio2.setSpecial(rowProxy);
|
||||
var hanger = document.getElementById('rowproxy');
|
||||
hanger.parentNode.insertBefore(rowProxy,hanger.nextSibling);
|
||||
Studio2.activateElement(rowProxy);
|
||||
|
||||
var hanger = document.getElementById('panelproxy');
|
||||
if (hanger != null) // if no panelproxy then don't display a new panel option: needed for portal layouts which have only one panel
|
||||
{
|
||||
panelProxy = Studio2.newPanel();
|
||||
Studio2.setSpecial(panelProxy);
|
||||
hanger.parentNode.insertBefore(panelProxy,hanger.nextSibling);
|
||||
Studio2.activateElement(panelProxy);
|
||||
}
|
||||
|
||||
Studio2.resizeDivs();
|
||||
|
||||
ModuleBuilder.helpRegisterByID('layoutEditor','div');
|
||||
ModuleBuilder.helpRegisterByID('layoutEditorButtons','input');
|
||||
ModuleBuilder.helpSetup('layoutEditor','default');
|
||||
|
||||
},
|
||||
|
||||
resizeDivs : function () {
|
||||
var Dom = YAHOO.util.Dom;
|
||||
var body = document.getElementById('mbtabs');
|
||||
var targetHeight = body.clientHeight - (Dom.getY('panels') - Dom.getY(body)) - 30;
|
||||
if (Studio2.isIE) targetHeight -= 10;
|
||||
Dom.setStyle('panels', "height", targetHeight + "px");
|
||||
Dom.setStyle('panels', "width" , ((Studio2.fieldwidth * 2) + 112) + "px");
|
||||
Dom.setStyle('toolbox', "height", targetHeight + "px");
|
||||
},
|
||||
|
||||
/**
|
||||
* SIGNATURE
|
||||
* array = Studio2.expandableFields
|
||||
* element = id of the element to unregister.
|
||||
* RETURN
|
||||
* element is removed from Studio2.expandableFields if found.
|
||||
*/
|
||||
|
||||
unregisterExpandableField:function( field ){
|
||||
//_write_("received for unregister: "+field.id);
|
||||
if(field==null || typeof(field) == 'undefined'){ return; }
|
||||
if ( this.isExpandable(field) ) {
|
||||
if (this.getColumnWidth( field ) > 1) { this.reduceFieldWidth( field ); }
|
||||
_write_("Unregistered:"+field.id);
|
||||
field.removeChild( field.childNodes[1] );
|
||||
field.removeAttribute("expandable");
|
||||
field.removeAttribute("state");
|
||||
}
|
||||
},
|
||||
isExpandable:function( field ){
|
||||
return field.getAttribute("expandable")!=null && !this.isSpecial(field);//&& field.getAttribute("expandable") == "true";
|
||||
},
|
||||
swapStates:function( src, dest ){
|
||||
var old_src= {state:src.getAttribute("state"), img: src.childNodes[1].src};
|
||||
src.setAttribute("state", dest.getAttribute("state"));
|
||||
src.childNodes[1].src = dest.childNodes[1].src;
|
||||
dest.childNodes[1].src = old_src.img;
|
||||
dest.setAttribute("state", old_src.state);
|
||||
},
|
||||
|
||||
getImageElement:function(default_toggle){
|
||||
var img = document.createElement('img');
|
||||
if(!default_toggle)
|
||||
img.src = 'index.php?entryPoint=getImage&themeName='+SUGAR.themes.theme_name+'&imageName=minus_inline.gif';
|
||||
else
|
||||
img.src = 'index.php?entryPoint=getImage&themeName='+SUGAR.themes.theme_name+'&imageName=plus_inline.gif';
|
||||
img.className = 'le_edit';
|
||||
img.style.paddingRight = 2;
|
||||
img.style.cssFloat = 'left';
|
||||
img.name = 'expandable_field_icon';
|
||||
return img;
|
||||
},
|
||||
|
||||
|
||||
toggleFieldWidth:function(id){
|
||||
|
||||
var field = YAHOO.util.Dom.get(id);
|
||||
if ( typeof(field) == 'undefined' || field === null ) return;
|
||||
var img = field.childNodes[1];
|
||||
|
||||
if( field.getAttribute("state") && field.getAttribute("state")=='reduced' ){
|
||||
field.parentNode.removeChild( Studio2.nextField(field) || Studio2.prevField(field) );
|
||||
Studio2.setColumnWidth(id,2);
|
||||
img.src = 'index.php?entryPoint=getImage&themeName='+SUGAR.themes.theme_name+'&imageName=minus_inline.gif';
|
||||
this.setExpanded( field );
|
||||
|
||||
|
||||
}else if( field.getAttribute("state") && field.getAttribute("state")=='expanded' ){
|
||||
Studio2.setColumnWidth(id,1);
|
||||
var newField = Studio2.newField();
|
||||
Studio2.setSpecial(newField);
|
||||
Studio2.activateElement(newField);
|
||||
field.parentNode.appendChild(newField);
|
||||
this.setReduced( field );
|
||||
img.src='index.php?entryPoint=getImage&themeName='+SUGAR.themes.theme_name+'&imageName=plus_inline.gif';
|
||||
|
||||
}
|
||||
},
|
||||
setExpanded: function( field ){
|
||||
field.setAttribute("expandable","true");
|
||||
field.setAttribute("state","expanded");
|
||||
_write_("Expanded: "+field.id);
|
||||
},
|
||||
setReduced: function( field ){
|
||||
field.setAttribute("expandable","true");
|
||||
field.setAttribute("state","reduced");
|
||||
_write_("Recued: "+field.id);
|
||||
},
|
||||
isExpanded: function (field ){
|
||||
return field.getAttribute('state') == 'expanded';
|
||||
},
|
||||
isReduced:function (field ){
|
||||
return field.getAttribute('state') == 'reduced';
|
||||
},
|
||||
registerExpandableField: function( field ) {//field = HTML element
|
||||
if( Studio2.maxColumns < 2 || field == null || typeof(field) == 'undefined' || this.isSpecial (field) ) { return; }
|
||||
if( !this.isExpandable( field ) ) {
|
||||
var next = this.nextField ( field ) ;
|
||||
var prev = this.prevField ( field ) ;
|
||||
var removeMe = next || prev ;
|
||||
if( this.isSpecial( next) || this.isSpecial( prev ) || this.isEmpty( next ) || this.isEmpty( prev ) || removeMe == null ){ //Always Expanded
|
||||
_write_("remove me is :"+removeMe);
|
||||
if (removeMe != null) { field.parentNode.removeChild(removeMe); }
|
||||
var img = this.getImageElement ( false );
|
||||
img.onclick = function () { Studio2.toggleFieldWidth ( field.id ) };
|
||||
field.insertBefore ( img, field.childNodes[1] );
|
||||
this.setColumnWidth( field.id, 2 );
|
||||
this.setExpanded( field );
|
||||
_write_("registered field");
|
||||
}
|
||||
}else{ _write_("Could not Register field:"+field.id); }
|
||||
},
|
||||
setStartId: function(id) {
|
||||
Studio2.idStack = [id];
|
||||
},
|
||||
|
||||
nextId: function() {
|
||||
if (Studio2.idStack.length == 1) { // if down to our last id, allocate another
|
||||
Studio2.idStack[0]++;
|
||||
Studio2.idStack.push(Studio2.idStack[0]);
|
||||
}
|
||||
return Studio2.idStack.pop();
|
||||
},
|
||||
|
||||
setNextId: function(id) {
|
||||
Studio2.idStack.push(id);
|
||||
},
|
||||
|
||||
isSpecial: function(element) {
|
||||
if(element==null || typeof(element) == 'undefined'){return false;};
|
||||
return YAHOO.util.Dom.hasClass(element,'special');
|
||||
},
|
||||
|
||||
setSpecial: function(el) {
|
||||
YAHOO.util.Dom.addClass(el, 'special');
|
||||
},
|
||||
|
||||
unsetSpecial: function(el) {
|
||||
YAHOO.util.Dom.removeClass(el, 'special');
|
||||
},
|
||||
isEmpty: function( element ){
|
||||
if (element == null || typeof(element) == 'undefined') {return false;};
|
||||
return YAHOO.util.Dom.hasClass(element, 'le_field special');
|
||||
},
|
||||
count: function(element) {
|
||||
var count = 0;
|
||||
for (var j=0;j<element.childNodes.length;j++) {
|
||||
var child = element.childNodes[j];
|
||||
if (child.nodeName == 'DIV') { // a valid child
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
},
|
||||
|
||||
newField: function(){ // TODO: use properties to set field contents
|
||||
//This object must exists on the page
|
||||
var newField = document.createElement('div');
|
||||
newField.className ='le_field';
|
||||
newField.id = Studio2.nextId();
|
||||
newField.innerHTML = '<span>'+SUGAR.language.get('ModuleBuilder', 'LBL_FILLER')+'</span>' + // the displayed label
|
||||
'<span class=\'field_name\'>(filler)</span>'; // the hidden field that identifies this as something to be saved by prepareForSave()
|
||||
return newField;
|
||||
},
|
||||
|
||||
newRow: function(titleRequired) {
|
||||
var newRow = document.createElement('div');
|
||||
if (titleRequired) {
|
||||
var child = document.createElement('span');
|
||||
child.className = 'panel_name';
|
||||
child.appendChild(document.createTextNode(SUGAR.language.get('ModuleBuilder', 'LBL_NEW_ROW') ) );
|
||||
newRow.appendChild(child);
|
||||
}
|
||||
newRow.className='le_row';
|
||||
newRow.id = Studio2.nextId();
|
||||
for(var i=0;i<Studio2.maxColumns;i++) {
|
||||
var newField = Studio2.newField();
|
||||
Studio2.setSpecial(newField);
|
||||
newRow.appendChild(newField);
|
||||
}
|
||||
return newRow;
|
||||
},
|
||||
|
||||
newPanel: function() {
|
||||
var newPanel = document.createElement('div');
|
||||
newPanel.className='le_panel';
|
||||
newPanel.id = Studio2.nextId();
|
||||
// get the panelid for this panel - must be unique in the layout, even across saves
|
||||
// our dynamically assigned DOM ids won't work as any panel given one of these DOM ids could find itself in conflict with a panel created in a later session
|
||||
//var panelIdentifier = 'lbl_panel'+(Studio2.panelNumber ++) ;
|
||||
var panelNumber = (Studio2.panelNumber ++) ;
|
||||
var view = document.getElementById('prepareForSave').view.value;
|
||||
var panelLabel = 'lbl_' + view + '_panel' + panelNumber;
|
||||
|
||||
var div = document.createElement('div');
|
||||
div.id = 'le_panellabel_' + newPanel.id;
|
||||
|
||||
var child = document.createElement('span');
|
||||
child.id = 'le_panelname_' + newPanel.id;
|
||||
child.className = 'panel_name';
|
||||
child.appendChild(document.createTextNode(SUGAR.language.get('ModuleBuilder', 'LBL_NEW_PANEL') ) );
|
||||
div.appendChild(child);
|
||||
var child = document.createElement('span');
|
||||
child.id = 'le_panelid_' + newPanel.id;
|
||||
child.className = 'panel_id';
|
||||
child.appendChild(document.createTextNode(panelLabel));
|
||||
div.appendChild(child);
|
||||
newPanel.appendChild(div);
|
||||
|
||||
var img = document.createElement('img');
|
||||
img.src='index.php?entryPoint=getImage&themeName='+SUGAR.themes.theme_name+'&imageName=edit_inline.gif';
|
||||
img.className = 'le_edit';
|
||||
img.style.cursor="pointer;";
|
||||
var editModule = document.getElementById('prepareForSave').view_module.value;
|
||||
var editString = 'module=ModuleBuilder&action=editProperty&view_module='+editModule+'&view='+view+'&id_label=le_panelname_'+newPanel.id+'&name_label=label_'+panelLabel+'&title_label='+SUGAR.language.get('ModuleBuilder', 'LBL_LABEL_TITLE') ;
|
||||
if (document.getElementById('prepareForSave').view_package)
|
||||
editString += '&view_package='+document.getElementById('prepareForSave').view_package.value ;
|
||||
var view = document.prepareForSave.view.value;
|
||||
img.onclick = function() { var value_label = document.getElementById('le_panelname_'+newPanel.id).innerHTML;ModuleBuilder.asyncRequest( editString + '&value_label=' + value_label, ModuleBuilder.updateContent ); }
|
||||
newPanel.appendChild(img);
|
||||
return newPanel;
|
||||
},
|
||||
|
||||
establishLocation: function(element) {
|
||||
var location = null;
|
||||
while(element.parentNode != 'body') {
|
||||
location = element.id;
|
||||
if ((location == 'panels') || (location == 'toolbox') || (location == 'delete')){
|
||||
break;
|
||||
}
|
||||
element = element.parentNode;
|
||||
}
|
||||
if (location == null) {
|
||||
alert("Studio2:establishLocation: badly formed document");
|
||||
die();
|
||||
}
|
||||
return location;
|
||||
},
|
||||
|
||||
reclaimIds: function(element) {
|
||||
// return the ids in this element to the available pool
|
||||
// do not reclaim field IDs as they never really disappear - they just move between toolbox and panel
|
||||
if (element.className.indexOf('le_field') == -1) {
|
||||
Studio2.setNextId(element.id);
|
||||
for (var i=0;i<element.childNodes.length;i++) {
|
||||
var child = element.childNodes[i];
|
||||
if (child.nodeName == 'DIV') { // a subelement
|
||||
Studio2.reclaimIds(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
reclaimFields: function(element) {
|
||||
if (element.className.indexOf('le_field') != -1) {
|
||||
if (! Studio2.isSpecial(element)) {
|
||||
var destination = document.getElementById('availablefields');
|
||||
// destination.appendChild(element.parentNode.removeChild(element));
|
||||
destination.appendChild(element);
|
||||
Studio2.resetFieldWidth(element);
|
||||
} else {
|
||||
element.parentNode.removeChild(element);
|
||||
}
|
||||
} else {
|
||||
for (var i=0;i<element.childNodes.length;i++) {
|
||||
var child = element.childNodes[i];
|
||||
if (child.nodeName == 'DIV') { // a subelement
|
||||
Studio2.reclaimFields(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
highlightElement: function(field) {
|
||||
YAHOO.util.Dom.setStyle(field,'visibility','hidden');
|
||||
},
|
||||
|
||||
/* FIELD WIDTH FUNCTIONS */
|
||||
|
||||
getSpacing: function(field) {
|
||||
var Field = new YAHOO.util.Element(field);
|
||||
var leftMargin = parseInt(Field.getStyle('margin-left'));
|
||||
var rightMargin = parseInt(Field.getStyle('margin-right'));
|
||||
var leftPadding = parseInt(Field.getStyle('padding-left'));
|
||||
var rightPadding = parseInt(Field.getStyle('padding-right'));
|
||||
if (Studio2.isIE) {
|
||||
return (leftMargin + rightMargin);
|
||||
} else {
|
||||
return (leftMargin + rightMargin + leftPadding + rightPadding + 2);
|
||||
}
|
||||
},
|
||||
|
||||
resetFieldWidth: function(field) {
|
||||
YAHOO.util.Dom.setStyle(field,'width',Studio2.fieldwidth + 'px');
|
||||
//Dom.setStyle(field,'width',Studio2.fieldwidth + 'px' );
|
||||
},
|
||||
|
||||
/* a hack function, purely because Firefox has a problem with field widths during the init function */
|
||||
/* so rather than relying on the style values we just set the width directly to the final value */
|
||||
adjustWidth: function(field,columns) {
|
||||
var newWidth = columns * (Studio2.fieldwidth + Studio2.getSpacing(field));
|
||||
YAHOO.util.Dom.setStyle(field,'width',newWidth + 'px' );
|
||||
},
|
||||
|
||||
increaseFieldWidth: function(field) {
|
||||
var newWidth;
|
||||
// var currentWidth = parseInt(field.clientWidth);
|
||||
var currentWidth = Studio2.getFieldWidth(field);
|
||||
newWidth = currentWidth + Studio2.fieldwidth + Studio2.getSpacing(field);
|
||||
// field.style.width = newWidth+'px';
|
||||
YAHOO.util.Dom.setStyle(field,'width',newWidth + 'px' );
|
||||
},
|
||||
|
||||
reduceFieldWidth: function(field) {
|
||||
var newWidth;
|
||||
var currentWidth = Studio2.getFieldWidth(field);
|
||||
newWidth = currentWidth - Studio2.fieldwidth - Studio2.getSpacing(field);
|
||||
YAHOO.util.Dom.setStyle(field,'width',newWidth + 'px' );
|
||||
},
|
||||
|
||||
getFieldWidth: function(field) {
|
||||
var width = parseInt(YAHOO.util.Dom.getStyle(field, 'width')); // computed style value of the field width (or currentStyle in IE - same result)
|
||||
if (isNaN(width)) {
|
||||
width = Studio2.fieldwidth; // if field width is set to something like 'auto' we need to take a better guess
|
||||
}
|
||||
return width;
|
||||
},
|
||||
|
||||
setFieldWidth: function(field,width) {
|
||||
YAHOO.util.Dom.setStyle(field,'width',width);
|
||||
},
|
||||
|
||||
getColumnWidth: function(field) {
|
||||
return Math.floor(Studio2.getFieldWidth(field)/Studio2.fieldwidth);
|
||||
},
|
||||
|
||||
setColumnWidth: function(field,columns) {
|
||||
var spacing = Studio2.getSpacing(field);
|
||||
var newWidth = columns * (Studio2.fieldwidth + spacing) - spacing;
|
||||
YAHOO.util.Dom.setStyle(field,'width',newWidth + 'px' );
|
||||
},
|
||||
|
||||
firstField: function(row) {
|
||||
var firstfield = row.firstChild;
|
||||
while (firstfield.nodeName != 'DIV') {
|
||||
firstfield = firstfield.nextSibling;
|
||||
}
|
||||
return firstfield;
|
||||
},
|
||||
|
||||
getColumn: function(field) {
|
||||
var firstfield = Studio2.firstField(field.parentNode);
|
||||
return Math.ceil((YAHOO.util.Dom.getX(field) - YAHOO.util.Dom.getX(firstfield) / Studio2.fieldwidth));
|
||||
},
|
||||
|
||||
getRow: function(field) {
|
||||
// find our parent row
|
||||
// find how many previous siblings we have that are also rows
|
||||
// our row is that + 1
|
||||
var row = field.parentNode;
|
||||
var count = 1;
|
||||
while ((row = row.previousSibling) !== null) {
|
||||
if (row.nodeName == 'DIV') {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
},
|
||||
|
||||
prevField: function(field){
|
||||
var prev = field.previousSibling;
|
||||
while( (null !== prev) && (prev.nodeName != 'DIV')){
|
||||
prev = prev.previousSibling;
|
||||
}
|
||||
return prev;
|
||||
},
|
||||
nextField: function(field) {
|
||||
var next = field.nextSibling;
|
||||
while (typeof(next)!='undefined' && (next !== null) && (next.nodeName != 'DIV')) {
|
||||
next = next.nextSibling;
|
||||
}
|
||||
return next;
|
||||
},
|
||||
|
||||
|
||||
/* ELEMENT FUNCTIONS */
|
||||
|
||||
// TODO: rewrite tidyPanels, tidyRows and tidyFields as a recursive tidy
|
||||
tidyPanels: function() {
|
||||
var panels = document.getElementById('panels');
|
||||
if (Studio2.count(panels) <= 0) {
|
||||
var newPanel = Studio2.newPanel();
|
||||
newPanel.appendChild(Studio2.newRow(false));
|
||||
panels.appendChild(newPanel);
|
||||
Studio2.activateElement(newPanel);
|
||||
}
|
||||
},
|
||||
|
||||
tidyRows: function(panel) {
|
||||
if (Studio2.count(panel) <= 0) { // no rows left
|
||||
if (Studio2.count(panel.parentNode)>1) {
|
||||
Studio2.removeElement(panel);
|
||||
Studio2.tidyPanels();
|
||||
} else {
|
||||
// add a blank row back in
|
||||
var newRow = Studio2.newRow(false);
|
||||
panel.appendChild(newRow);
|
||||
Studio2.activateElement(newRow);
|
||||
// debugger;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
tidyFields: function(row) {
|
||||
if (Studio2.count(row) <= 0) { // no fields left
|
||||
var panel = row.parentNode;
|
||||
Studio2.removeElement(row);
|
||||
Studio2.tidyRows(panel);
|
||||
}
|
||||
},
|
||||
|
||||
removeElement: function(element) {
|
||||
Studio2.reclaimIds(element);
|
||||
Studio2.reclaimFields(element);
|
||||
if (element.className.indexOf('le_field') == -1) {
|
||||
// all fields have been moved to availablefields in Studio2.reclaimFields
|
||||
element.parentNode.removeChild(element);
|
||||
}
|
||||
},
|
||||
|
||||
swapElements: function(el1,el2) {
|
||||
// TODO: record this swap in TRANSACTION
|
||||
var el1Width = Studio2.getFieldWidth(el1);
|
||||
var el2Width = Studio2.getFieldWidth(el2);
|
||||
YAHOO.util.DragDropMgr.swapNode(el1, el2);
|
||||
Studio2.setFieldWidth(el1,el2Width);
|
||||
Studio2.setFieldWidth(el2,el1Width);
|
||||
},
|
||||
|
||||
activateElement: function(element) {
|
||||
if (!document.getElementById(element.id)) {
|
||||
document.body.appendChild(element);
|
||||
}
|
||||
if (element.className.indexOf('le_panel') != -1) {
|
||||
new Studio2.PanelDD(element.id,'studio2.panels');
|
||||
new YAHOO.util.DDTarget(element.id,'studio2.rows'); // add so a background for row moves
|
||||
}
|
||||
if (element.className.indexOf('le_row') != -1) {
|
||||
new Studio2.RowDD(element.id,'studio2.rows');
|
||||
}
|
||||
if (element.className.indexOf('le_field') != -1) {
|
||||
new Studio2.FieldDD(element,'studio2.fields');
|
||||
}
|
||||
for (var i=0;i<element.childNodes.length;i++) {
|
||||
var child = element.childNodes[i];
|
||||
if (child.nodeName == 'DIV') { // a valid child
|
||||
Studio2.activateElement(child);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* A substitute for cloneNode that is Yahoo Drag-and-Drop compatible.
|
||||
* Using document.cloneNode causes Yahoo DnD to fail as the ID is also cloned, leading to duplicate IDs in the document
|
||||
* This substitute doesn't copy the ID
|
||||
*/
|
||||
|
||||
copyElement: function(element) {
|
||||
var copy = document.createElement(element.tagName);
|
||||
if (element.attributes.length > 0) {
|
||||
var attrs = element.attributes;
|
||||
for(var i=0;i<attrs.length;i++) {
|
||||
if (attrs[i].name != 'id') {
|
||||
// check to see if this attribute is actually set in the document, or just a default - IE's attributes array contains both, and we only want the specified attributes
|
||||
var a = element.getAttributeNode(attrs[i].name);
|
||||
if (a && a.specified) {
|
||||
if (attrs[i].name == 'class') { // Needed for IE
|
||||
copy.className = attrs[i].value;
|
||||
}
|
||||
copy.setAttribute(attrs[i].name,attrs[i].value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Studio2.copyChildren(element, copy);
|
||||
copy.id = Studio2.nextId();
|
||||
return copy;
|
||||
},
|
||||
|
||||
copyChildren : function(original, clone)
|
||||
{
|
||||
var children = original.childNodes
|
||||
for (var i in children)
|
||||
{
|
||||
if (children[i])
|
||||
{
|
||||
if (children[i].tagName && children[i].tagName.substr(0,1) != "#"){
|
||||
clone.appendChild(Studio2.copyElement(children[i]));
|
||||
}
|
||||
else if (children[i].nodeName && children[i].nodeName == "#text")
|
||||
{
|
||||
clone.innerHTML += children[i].data;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
setCopy: function(copy) {
|
||||
Studio2.copyId = copy.id;
|
||||
},
|
||||
|
||||
copy: function() {
|
||||
if (Studio2.copyId != null) {
|
||||
return document.getElementById(Studio2.copyId);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
activateCopy: function() {
|
||||
Studio2.activateElement(document.getElementById(Studio2.copyId));
|
||||
},
|
||||
|
||||
removeCopy: function() {
|
||||
if (Studio2.copyId != null) {
|
||||
Studio2.removeElement(Studio2.copy());
|
||||
}
|
||||
Studio2.copyId = null;
|
||||
},
|
||||
|
||||
// Copy all the slot content across to a temporary form table for submitting to the backend for the save
|
||||
// We could have made all the slots be hidden fields within a form, (ala the original Portal editor), but then we'd have to do a lot of work during
|
||||
// editing that really only needs to be done once per save
|
||||
|
||||
prepareForSave: function() {
|
||||
// create a new saveForm
|
||||
var panels = document.getElementById('panels');
|
||||
var saveForm = document.getElementById('prepareForSave');
|
||||
if (! saveForm) {
|
||||
saveForm = document.createElement('form');
|
||||
saveForm.id = 'prepareForSave';
|
||||
YAHOO.util.Dom.setStyle(saveForm,"visibility", "hidden");
|
||||
panels.parentNode.appendChild(saveForm);
|
||||
}
|
||||
// remove any existing slot information, but importantly, preserve any non-slot stuff needed for form submittal
|
||||
var length = saveForm.childNodes.length;
|
||||
var index = 0;
|
||||
for( var i=0; i<length; i++) {
|
||||
if (saveForm.childNodes[index].nodeName != 'INPUT') {
|
||||
index++;
|
||||
} else {
|
||||
if (saveForm.childNodes[index].getAttribute('name').substr(0,4) == "slot") {
|
||||
saveForm.removeChild(saveForm.childNodes[index]);
|
||||
} else {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// convert to input name='slot-{panel}-{slot}-{type}' value={value}
|
||||
var panelid = 0;
|
||||
var panels = document.getElementById('panels');
|
||||
|
||||
for( var i=0;i<panels.childNodes.length;i++) {
|
||||
var panel = panels.childNodes[i];
|
||||
|
||||
if (panel.nodeName == 'DIV') { // a panel
|
||||
panelid++;
|
||||
var fieldid = -1;
|
||||
|
||||
for (var j=0;j<panel.childNodes.length;j++) {
|
||||
var row = panel.childNodes[j];
|
||||
|
||||
// save the panel name and label
|
||||
if (row.id && row.id.indexOf('le_panellabel') != -1) {
|
||||
// a panel label
|
||||
var inputField = document.createElement('input');
|
||||
inputField.setAttribute('type','hidden');
|
||||
inputField.setAttribute('name','panel-'+panelid+'-name');
|
||||
inputField.setAttribute('value',document.getElementById('le_panelname_'+row.id.substr(14,row.id.length)).innerHTML);
|
||||
saveForm.appendChild(inputField);
|
||||
var inputField = document.createElement('input');
|
||||
inputField.setAttribute('type','hidden');
|
||||
inputField.setAttribute('name','panel-'+panelid+'-label');
|
||||
inputField.setAttribute('value',document.getElementById('le_panelid_'+row.id.substr(14,row.id.length)).innerHTML);
|
||||
saveForm.appendChild(inputField);
|
||||
}
|
||||
|
||||
// now for the rows
|
||||
if (row.nodeName == 'DIV') { // a row
|
||||
for (var k=0;k<row.childNodes.length;k++) {
|
||||
var field = row.childNodes[k];
|
||||
|
||||
|
||||
if (field.nodeName == 'DIV') { // a field
|
||||
fieldid++;
|
||||
for ( var l=0; l < field.childNodes.length; l++ ) {
|
||||
var property = field.childNodes[l];
|
||||
|
||||
if (property.nodeName == 'SPAN') { // a property of a field
|
||||
if (property.attributes.length > 0) {
|
||||
// if (property.hasAttributes) {
|
||||
var type = property.className;
|
||||
if ((type.length>5) && (type.substr(0,5) == 'field') && (property.childNodes.length != 0)) {
|
||||
var value = property.firstChild.nodeValue;
|
||||
var inputField = document.createElement('input');
|
||||
inputField.setAttribute('type','hidden');
|
||||
inputField.setAttribute('name','slot-'+panelid+'-'+fieldid+'-'+type.substr(6,type.length));
|
||||
inputField.setAttribute('value',value);
|
||||
saveForm.appendChild(inputField);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// check fieldwidth in the layout; if more than one, then add an (empty) for each (so the parser can keep track of the slots)
|
||||
var endId = fieldid+Studio2.getColumnWidth(field)-1;
|
||||
while (fieldid<endId) {
|
||||
fieldid++;
|
||||
var inputField = document.createElement('input');
|
||||
inputField.setAttribute('type','hidden');
|
||||
inputField.setAttribute('name','slot-'+panelid+'-'+fieldid+'-name');
|
||||
inputField.setAttribute('value','(empty)');
|
||||
saveForm.appendChild(inputField);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
handleSave: function() {
|
||||
ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVING'));
|
||||
ModuleBuilder.state.isDirty=false;
|
||||
this.prepareForSave();
|
||||
// set <input type='hidden' name='action' value='saveLayout'>
|
||||
var saveForm = document.forms['prepareForSave'];
|
||||
var inputField = document.createElement('input');
|
||||
inputField.setAttribute('type','hidden');
|
||||
inputField.setAttribute('name','action');
|
||||
inputField.setAttribute('value','saveLayout');
|
||||
saveForm.appendChild(inputField);
|
||||
ModuleBuilder.submitForm('prepareForSave');
|
||||
ajaxStatus.flashStatus('Save complete',5000);
|
||||
},
|
||||
|
||||
handlePublish: function() {
|
||||
ajaxStatus.showStatus(SUGAR.language.get('app_strings', 'LBL_SAVING'));
|
||||
ModuleBuilder.state.isDirty=false;
|
||||
this.prepareForSave();
|
||||
// set <input type='hidden' name='action' value='saveAndPublishLayout'>
|
||||
var saveForm = document.forms['prepareForSave'];
|
||||
var inputField = document.createElement('input');
|
||||
inputField.setAttribute('type','hidden');
|
||||
inputField.setAttribute('name','action');
|
||||
inputField.setAttribute('value','saveAndPublishLayout');
|
||||
saveForm.appendChild(inputField);
|
||||
ModuleBuilder.submitForm('prepareForSave');
|
||||
ajaxStatus.flashStatus(SUGAR.language.get('ModuleBuilder','LBL_DEPLOYE_COMPLETE'),5000);
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
314
modules/ModuleBuilder/javascript/studio2FieldDD.js
Executable file
314
modules/ModuleBuilder/javascript/studio2FieldDD.js
Executable file
@@ -0,0 +1,314 @@
|
||||
/*********************************************************************************
|
||||
* 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".
|
||||
********************************************************************************/
|
||||
|
||||
Studio2.FieldDD = function(id, sGroup) {
|
||||
Studio2.FieldDD.superclass.constructor.call(this, id, sGroup);
|
||||
};
|
||||
|
||||
|
||||
YAHOO.extend(Studio2.FieldDD, YAHOO.util.DDProxy, {
|
||||
|
||||
startDrag: function(x, y) {
|
||||
// make the proxy look like the source element
|
||||
var dragEl = this.getDragEl();
|
||||
var clickEl = this.getEl();
|
||||
dragEl.innerHTML = clickEl.innerHTML;
|
||||
dragEl.className = clickEl.className;
|
||||
Studio2.copyId = null;
|
||||
this.showAnimation = true;
|
||||
|
||||
if (Studio2.isSpecial(clickEl) && (Studio2.establishLocation(clickEl) == 'toolbox')) {
|
||||
var copy = Studio2.copyElement(clickEl);
|
||||
Studio2.setCopy(copy);
|
||||
clickEl.parentNode.insertBefore(copy,clickEl.nextSibling);
|
||||
YAHOO.util.Dom.setStyle(clickEl, "display", "none"); // don't want it to take up any space
|
||||
} else {
|
||||
YAHOO.util.Dom.setStyle(clickEl, "visibility", "hidden"); // want a empty space as we're dragging it away from this place
|
||||
}
|
||||
},
|
||||
|
||||
endDrag: function(e) {
|
||||
ModuleBuilder.state.isDirty=true;
|
||||
var srcEl = this.getEl();
|
||||
var proxy = this.getDragEl();
|
||||
var proxyid = proxy.id;
|
||||
var thisid = this.id;
|
||||
|
||||
if (YAHOO.util.Dom.get(srcEl)) { // if we have a valid srcEl still...hasn't been deleted earlier
|
||||
// Show the proxy element and animate it to the src element's location
|
||||
YAHOO.util.Dom.setStyle(proxy, "visibility", "");
|
||||
YAHOO.util.Dom.setStyle(srcEl, "display", ""); // display!=none for getXY to work
|
||||
//YAHOO.util.Dom.setStyle(proxy).alignTo(srcEl, 'tl', null, {
|
||||
//callback: function(){
|
||||
YAHOO.util.Dom.setStyle(proxyid, "visibility", "hidden");
|
||||
if(typeof(YAHOO.util.Dom.get(thisid)) != 'undefined' && YAHOO.util.Dom.get(thisid)!=null)
|
||||
YAHOO.util.Dom.setStyle(thisid, "visibility", "");
|
||||
}
|
||||
if (Studio2.isSpecial(srcEl) && Studio2.copy()) {
|
||||
Studio2.activateCopy(); // activateCopy makes it active, and removes the flag that says there is a copy
|
||||
}
|
||||
|
||||
proxy.innerHTML = "";
|
||||
},
|
||||
|
||||
onInvalidDrop: function(e) {
|
||||
var dragEl = this.getDragEl();
|
||||
dragEl.innerHTML = '';
|
||||
Studio2.removeCopy();
|
||||
YAHOO.util.Dom.setStyle(this.getEl(), "display", "block");
|
||||
},
|
||||
|
||||
onDragDrop: function(e, id) {
|
||||
var srcEl = this.getEl();
|
||||
var destEl = YAHOO.util.Dom.get(id); // where this element is being dropped
|
||||
|
||||
var srcLocation = Studio2.establishLocation(srcEl);
|
||||
var destLocation = Studio2.establishLocation(destEl);
|
||||
|
||||
// CASE1: Trying to delete an item from the toolbox or move fields within the toolbox - don't allow
|
||||
if ( ((srcLocation == 'toolbox') && (destLocation == 'delete')) ||
|
||||
((srcLocation == 'toolbox') && (destLocation == 'toolbox'))) {
|
||||
Studio2.removeCopy();
|
||||
YAHOO.util.Dom.setStyle(srcEl, "display", "block"); // make it visible again - we made special elements invisible in startDrag
|
||||
return;
|
||||
}
|
||||
// CASE2: Delete a panel element
|
||||
// if source was in a panel (not toolbox) and destination is delete then remove this element
|
||||
if ((srcLocation == 'panels') && (destLocation == 'delete')) {
|
||||
|
||||
if(Studio2.isSpecial(srcEl)) //nsingh- Bug 23057 Disallow deleting a (filler) as it does not make sense to do so.
|
||||
return;
|
||||
var parent = srcEl.parentNode;
|
||||
var sibling = srcEl.previousSibling;
|
||||
while(sibling != null) {
|
||||
if (sibling.className && (sibling.className.indexOf('le_field') != -1)) {
|
||||
break;
|
||||
}
|
||||
sibling = sibling.previousSibling;
|
||||
}
|
||||
if (sibling == null) {
|
||||
sibling = srcEl.nextSibling;
|
||||
while(sibling != null) {
|
||||
if (sibling.className && (sibling.className.indexOf('le_field') != -1)) {
|
||||
break;
|
||||
}
|
||||
sibling = sibling.nextSibling;
|
||||
}
|
||||
}
|
||||
Studio2.removeElement(srcEl);
|
||||
Studio2.unregisterExpandableField( srcEl );
|
||||
// this.showAnimation = false; // can't show animation as the source no longer exists
|
||||
if (sibling == null) {
|
||||
// If we've just deleted the last field from a panel then we need to tidy up
|
||||
Studio2.tidyFields(parent);
|
||||
} else {
|
||||
Studio2.registerExpandableField(sibling);
|
||||
}
|
||||
return;
|
||||
} // end delete
|
||||
|
||||
// CASE3: Simple field swap
|
||||
// Either neither one is special, or they're both special and both in panels
|
||||
if (( ! Studio2.isSpecial(srcEl) && ! Studio2.isSpecial(destEl)) ||
|
||||
( Studio2.isSpecial(srcEl) && Studio2.isSpecial(destEl) && (srcLocation == 'panels') && (destLocation == 'panels')) ) {
|
||||
Studio2.swapElements(srcEl, destEl);
|
||||
this.runSpecialCode(srcEl, destEl);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// CASE4: swapping a special field from the toolbox with a field in a panel
|
||||
if (Studio2.copy() && (destLocation == 'panels')) {
|
||||
// CASE: split a field
|
||||
//Disallow (filler) on (filler)
|
||||
if( Studio2.isSpecial(destEl) ) {Studio2.removeCopy(); return }
|
||||
|
||||
var destSibling = Studio2.nextField( destEl ) || Studio2.prevField( destEl );
|
||||
if( Studio2.isExpandable( destEl ) && destEl.getAttribute("state") == 'expanded' ){
|
||||
Studio2.removeCopy(); return;
|
||||
}
|
||||
if( Studio2.isExpandable( destEl ) && destEl.getAttribute("state") == 'reduced' ){ Studio2.unregisterExpandableField( destEl ); }
|
||||
var copy = Studio2.copyElement(srcEl);
|
||||
Studio2.activateElement(copy);
|
||||
YAHOO.util.Dom.setStyle(copy, "display", "");
|
||||
Studio2.swapElements( Studio2.copy(),destEl );
|
||||
YAHOO.util.Dom.setStyle(srcEl, "display", "");
|
||||
Studio2.registerExpandableField (destSibling );
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// CASE5: moving a plain field from the panel to a special field in the toolbox - just copy
|
||||
if ( ! Studio2.isSpecial(srcEl) && Studio2.isSpecial(destEl) && (destLocation == 'toolbox')) {
|
||||
// make a copy of the destination
|
||||
if(Studio2.isExpandable (srcEl ) && Studio2.isExpanded( srcEl)) {
|
||||
Studio2.toggleFieldWidth(srcEl.id); //bring back the old filler.
|
||||
Studio2.unregisterExpandableField ( srcEl );
|
||||
}
|
||||
//check if srcSibling needs to expand
|
||||
// var srcSibling = ;
|
||||
|
||||
var copy = Studio2.copyElement(destEl);
|
||||
var destination = document.getElementById('availablefields');
|
||||
destination.appendChild(copy);
|
||||
Studio2.swapElements(copy,srcEl);
|
||||
YAHOO.util.Dom.setStyle(srcEl, "display", "");
|
||||
Studio2.activateElement(copy);
|
||||
//if src is expanded, reduce it then unregister
|
||||
|
||||
|
||||
//After Swap Only.
|
||||
Studio2.registerExpandableField( Studio2.nextField( srcEl ) || Studio2.prevField( srcEl ) );
|
||||
return;
|
||||
}
|
||||
|
||||
//CASE6: (filler) droppped on a expandable field.
|
||||
if(Studio2.isSpecial(srcEl) && destLocation == srcLocation ){
|
||||
//Disallow Swap if dropping on a expanded field.
|
||||
if( Studio2.isExpandable( destEl ) && Studio2.isExpanded( destEl )) {return; }
|
||||
var srcSibling = Studio2.prevField( srcEl ) || Studio2.nextField( srcEl );
|
||||
var destSibling = Studio2.prevField( destEl ) || Studio2.nextField( destEl );
|
||||
Studio2.swapElements(srcEl, destEl); //don't change order.
|
||||
if ( !Studio2.isExpandable( destSibling ) && Studio2.isExpandable(srcSibling) && Studio2.isReduced(srcSibling) && !(srcSibling.id == destEl.id && srcEl.id == destSibling.id)) {
|
||||
Studio2.unregisterExpandableField( srcSibling );
|
||||
Studio2.registerExpandableField (destSibling );
|
||||
Studio2.unregisterExpandableField( destEl );
|
||||
}
|
||||
if ( !Studio2.isExpandable( destEl ) && Studio2.isSpecial( destSibling )) {
|
||||
Studio2.registerExpandableField (destEl );
|
||||
}
|
||||
if(!Studio2.isSpecial(destSibling)) {Studio2.registerExpandableField (destSibling )}
|
||||
return;
|
||||
}
|
||||
//CASE 7: A special field swapped with a regular field. Source is not-special, destination is special.
|
||||
if(!Studio2.isSpecial(srcEl) && Studio2.isSpecial(destEl) && destLocation == srcLocation) {
|
||||
/**
|
||||
if destination's left sibling is expandable.
|
||||
unregister left sibling from expandable.
|
||||
if src field's left sibling is not special
|
||||
register left sibling to expandable.
|
||||
*/
|
||||
|
||||
var srcSibling = Studio2.prevField(srcEl) || Studio2.nextField( srcEl ) ;
|
||||
var destSibling = Studio2.prevField(destEl) || Studio2.nextField( destEl );
|
||||
|
||||
var sameRow = (srcSibling!=null && destSibling!=null) ? (srcSibling.id == destEl.id && destSibling.id == srcEl.id) : false;
|
||||
|
||||
if (Studio2.isExpandable( srcEl ) && Studio2.isExpanded( srcEl )) {return;} //disallow dropping expanded fields onto fillers.
|
||||
if (Studio2.isExpandable ( srcEl ) && Studio2.isReduced( srcEl ) && !sameRow) {Studio2.unregisterExpandableField( srcEl );}
|
||||
if (Studio2.isExpandable (destSibling) && !sameRow ){Studio2.unregisterExpandableField( destSibling )}
|
||||
//expand src sibling
|
||||
if( srcEl.id == destSibling.id && srcSibling.id == destEl.id ) {Studio2.registerExpandableField ( srcEl ) }
|
||||
Studio2.swapElements(srcEl, destEl);
|
||||
if (Studio2.isSpecial(destSibling)) {Studio2.registerExpandableField(srcEl)}
|
||||
Studio2.registerExpandableField( srcSibling );
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
if( !Studio2.isSpecial( srcEl ) && Studio2.isSpecial( destEl) && destLocation == 'panels' && srcLocation =='toolbox'){
|
||||
var destSibling = Studio2.nextField( destEl ) || Studio2.prevField ( destEl );
|
||||
Studio2.unregisterExpandableField( destSibling );
|
||||
Studio2.swapElements( srcEl,destEl );
|
||||
Studio2.removeElement( destEl ) ;
|
||||
return;
|
||||
}
|
||||
|
||||
Studio2.swapElements( srcEl,destEl );
|
||||
this.runSpecialCode(srcEl,destEl);
|
||||
if ((srcLocation != destLocation)) {
|
||||
if (Studio2.isSpecial(srcEl) && ! Studio2.isSpecial(destEl)) {
|
||||
Studio2.removeElement(srcEl);
|
||||
// this.showAnimation = false;
|
||||
return;
|
||||
}
|
||||
if (Studio2.isSpecial(destEl) && ! Studio2.isSpecial(srcEl)) {
|
||||
Studio2.removeElement(destEl);
|
||||
// this.showAnimation = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
runSpecialCode: function(srcEl, destEl){
|
||||
var srcLeftSibling = Studio2.prevField(srcEl);
|
||||
var srcRightSibling = Studio2.nextField(srcEl);
|
||||
var destRightSibling = Studio2.nextField(destEl);
|
||||
var destLeftSibling = Studio2.prevField(destEl);
|
||||
|
||||
|
||||
//For every affected element unexpand if needed.
|
||||
//registration vs Transformation.
|
||||
|
||||
if ( Studio2.isExpandable (srcEl ) && Studio2.isExpandable( destEl) ){
|
||||
//src is dest now. copy dest's properties to src.
|
||||
Studio2.swapStates( srcEl, destEl );
|
||||
//srcEl.setAttribute("state", destEl.getAttribute("state"));
|
||||
}
|
||||
var registerSrc = !Studio2.isExpandable( srcEl );
|
||||
var destExpandable = !Studio2.isSpecial(destEl) && ((null==destRightSibling && null==destLeftSibling)
|
||||
|| (null !== destRightSibling) && Studio2.isSpecial(destRightSibling));
|
||||
|
||||
var srcUnexpandable = !Studio2.isSpecial(srcEl) && ((null!==srcLeftSibling && !Studio2.isSpecial(srcLeftSibling))
|
||||
|| ((null !== srcRightSibling) && !Studio2.isSpecial(srcRightSibling)));
|
||||
var destUnexpandable = !Studio2.isSpecial(destEl) && ((null!==destLeftSibling && !Studio2.isSpecial(destLeftSibling))
|
||||
|| ((null!== destRightSibling) && !Studio2.isSpecial(destRightSibling)));
|
||||
|
||||
|
||||
if( registerSrc ){
|
||||
Studio2.registerExpandableField( srcEl );
|
||||
}
|
||||
if(srcUnexpandable){
|
||||
Studio2.unregisterExpandableField( srcEl );
|
||||
}
|
||||
if(destExpandable){
|
||||
Studio2.registerExpandableField(destEl);
|
||||
}
|
||||
if(destUnexpandable){
|
||||
Studio2.unregisterExpandableField( destEl );
|
||||
}
|
||||
if(srcLeftSibling!==null && !Studio2.isSpecial(srcLeftSibling) && !Studio2.isSpecial(srcEl))
|
||||
Studio2.unregisterExpandableField( srcLeftSibling );
|
||||
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
189
modules/ModuleBuilder/javascript/studio2ListDD.js
Executable file
189
modules/ModuleBuilder/javascript/studio2ListDD.js
Executable file
@@ -0,0 +1,189 @@
|
||||
/*********************************************************************************
|
||||
* 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".
|
||||
********************************************************************************/
|
||||
|
||||
Studio2.ListDD = function(el, sGroup, fromOnly) {
|
||||
if (typeof el == 'number') {
|
||||
el = el + "";
|
||||
}
|
||||
if (typeof el == "string") {
|
||||
el = document.getElementById(el);
|
||||
}
|
||||
if (el != null) {
|
||||
var Dom = YAHOO.util.Dom;
|
||||
Studio2.ListDD.superclass.constructor.call(this, el, sGroup);
|
||||
this.addInvalidHandleType("input");
|
||||
this.addInvalidHandleType("a");
|
||||
var dEl = this.getDragEl()
|
||||
Dom.setStyle(dEl, "borderColor", "#FF0000");
|
||||
Dom.setStyle(dEl, "backgroundColor", "#e5e5e5");
|
||||
Dom.setStyle(dEl, "opacity", 0.76);
|
||||
Dom.setStyle(dEl, "filter", "alpha(opacity=76)");
|
||||
this.fromOnly = fromOnly;
|
||||
}
|
||||
};
|
||||
|
||||
YAHOO.extend(Studio2.ListDD, YAHOO.util.DDProxy, {
|
||||
copyStyles : {'opacity':"", 'border':"", 'height':"", 'filter':"", 'zoom':""},
|
||||
startDrag: function(x, y){
|
||||
//We need to make sure no inline editors are in use, as drag.drop can break them
|
||||
if (typeof (SimpleList) != "undefined") {
|
||||
SimpleList.endCurrentDropDownEdit();
|
||||
}
|
||||
|
||||
var Dom = YAHOO.util.Dom;
|
||||
var dragEl = this.getDragEl();
|
||||
var clickEl = this.getEl();
|
||||
|
||||
this.parentID = clickEl.parentNode.id;
|
||||
this.clickContent = clickEl.innerHTML;
|
||||
dragEl.innerHTML = clickEl.innerHTML; /*"<table><tr><td><b>" + clickEl.getElementsByTagName("b")[0].innerHTML + "</b>"
|
||||
+ clickEl.getElementsByTagName("span")[0].innerHTML + "</td></tr></table>";*/
|
||||
|
||||
Dom.addClass(dragEl, clickEl.className);
|
||||
Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
|
||||
Dom.setStyle(dragEl, "height", Dom.getStyle(clickEl, "height"));
|
||||
Dom.setStyle(dragEl, "border", "1px solid #aaa");
|
||||
|
||||
// save the style of the object
|
||||
if (this.clickStyle == null) {
|
||||
this.clickStyle = {};
|
||||
for (var s in this.copyStyles) {
|
||||
this.clickStyle[s] = clickEl.style[s];
|
||||
}
|
||||
if (typeof(this.clickStyle['border']) == 'undefined' || this.clickStyle['border'] == "")
|
||||
this.clickStyle['border'] = "1px solid";
|
||||
}
|
||||
|
||||
Dom.setStyle(clickEl, "opacity", 0.5);
|
||||
Dom.setStyle(clickEl, "filter", "alpha(opacity=10)");
|
||||
Dom.setStyle(clickEl, "border", '2px dashed #cccccc');
|
||||
},
|
||||
|
||||
updateTabs: function(){
|
||||
studiotabs.moduleTabs = [];
|
||||
for (j = 0; j < studiotabs.slotCount; j++) {
|
||||
|
||||
var ul = document.getElementById('ul' + j);
|
||||
studiotabs.moduleTabs[j] = [];
|
||||
items = ul.getElementsByTagName("li");
|
||||
for (i = 0; i < items.length; i++) {
|
||||
if (items.length == 1) {
|
||||
items[i].innerHTML = SUGAR.language.get('ModuleBuilder', 'LBL_DROP_HERE');
|
||||
}
|
||||
else if (items[i].innerHTML == SUGAR.language.get('ModuleBuilder', 'LBL_DROP_HERE')) {
|
||||
items[i].innerHTML = '';
|
||||
}
|
||||
studiotabs.moduleTabs[ul.id.substr(2, ul.id.length)][studiotabs.subtabModules[items[i].id]] = true;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
endDrag: function(e){
|
||||
ModuleBuilder.state.isDirty=true;
|
||||
var clickEl = this.getEl();
|
||||
var clickExEl = new YAHOO.util.Element(clickEl);
|
||||
dragEl = this.getDragEl();
|
||||
dragEl.innerHTML = "";
|
||||
clickEl.innerHTML = this.clickContent;
|
||||
|
||||
var p = clickEl.parentNode;
|
||||
if (p.id == 'trash') {
|
||||
p.removeChild(clickEl);
|
||||
this.lastNode = false;
|
||||
this.updateTabs();
|
||||
return;
|
||||
}
|
||||
|
||||
for(var style in this.clickStyle) {
|
||||
if (typeof(this.clickStyle[style]) != 'undefined')
|
||||
clickExEl.setStyle(style, this.clickStyle[style]);
|
||||
else
|
||||
clickExEl.setStyle(style, '');
|
||||
}
|
||||
|
||||
this.clickStyle = null;
|
||||
|
||||
if (this.lastNode) {
|
||||
this.lastNode.id = 'addLS' + addListStudioCount;
|
||||
studiotabs.subtabModules[this.lastNode.id] = this.lastNode.module;
|
||||
yahooSlots[this.lastNode.id] = new Studio2.ListDD(this.lastNode.id, 'subTabs', false);
|
||||
addListStudioCount++;
|
||||
this.lastNode.style.opacity = 1;
|
||||
this.lastNode.style.filter = "alpha(opacity=100)";
|
||||
}
|
||||
this.lastNode = false;
|
||||
this.updateTabs();
|
||||
|
||||
dragEl.innerHTML = "";
|
||||
},
|
||||
|
||||
onDragOver: function(e, id){
|
||||
var el;
|
||||
if (this.lastNode) {
|
||||
this.lastNode.parentNode.removeChild(this.lastNode);
|
||||
this.lastNode = false;
|
||||
}
|
||||
if (id.substr(0, 7) == 'modSlot') {
|
||||
return;
|
||||
}
|
||||
el = document.getElementById(id);
|
||||
dragEl = this.getDragEl();
|
||||
|
||||
var mid = YAHOO.util.Dom.getY(el) + (el.clientHeight / 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(studiotabs.moduleTabs[p.id.substr(2, p.id.length)][studiotabs.subtabModules[el2.id]]) != 'undefined')
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.fromOnly && el.id != 'trashcan') {
|
||||
el2 = el2.cloneNode(true);
|
||||
el2.module = studiotabs.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.Dom.getY(dragEl) < mid) { // insert on top triggering item
|
||||
p.insertBefore(el2, el);
|
||||
}
|
||||
else { // insert below triggered item
|
||||
p.insertBefore(el2, el.nextSibling);
|
||||
}
|
||||
}
|
||||
});
|
||||
197
modules/ModuleBuilder/javascript/studio2PanelDD.js
Executable file
197
modules/ModuleBuilder/javascript/studio2PanelDD.js
Executable file
@@ -0,0 +1,197 @@
|
||||
/*********************************************************************************
|
||||
* 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".
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
Studio2.PanelDD = function(id, sGroup) {
|
||||
Studio2.PanelDD.superclass.constructor.call(this, id, sGroup);
|
||||
|
||||
var el = this.getDragEl();
|
||||
YAHOO.util.Dom.setStyle(el, "opacity", 0.67) // The proxy is slightly transparent
|
||||
this.goingUp = false;
|
||||
this.lastY = 0;
|
||||
};
|
||||
|
||||
|
||||
YAHOO.extend(Studio2.PanelDD, YAHOO.util.DDProxy, {
|
||||
|
||||
startDrag: function(x, y) {
|
||||
// make the proxy look like the source element
|
||||
var dragEl = this.getDragEl();
|
||||
var clickEl = this.getEl();
|
||||
dragEl.className = clickEl.className;
|
||||
dragEl.innerHTML = "";
|
||||
Studio2.copyChildren(clickEl, dragEl);
|
||||
this.deletePanel = false;
|
||||
Studio2.copyId = null;
|
||||
dragEl.style.width = clickEl.offsetWidth + "px";
|
||||
dragEl.style.height = clickEl.offsetHeight + "px";
|
||||
|
||||
if (Studio2.establishLocation(clickEl) == 'toolbox') {
|
||||
var copy = Studio2.newPanel();
|
||||
Studio2.setCopy(copy);
|
||||
clickEl.parentNode.insertBefore(copy,clickEl.nextSibling);
|
||||
YAHOO.util.Dom.setStyle(copy, 'display','block'); // must make it visible - the css sets rows outside of panel to invisible
|
||||
YAHOO.util.Dom.setStyle(clickEl, "display","none");
|
||||
}
|
||||
|
||||
YAHOO.util.Dom.setStyle(clickEl, "visibility", "hidden");
|
||||
},
|
||||
|
||||
endDrag: function(e) {
|
||||
ModuleBuilder.state.isDirty=true;
|
||||
// alert("endDrag");
|
||||
|
||||
var srcEl = this.getEl();
|
||||
var proxy = this.getDragEl();
|
||||
var proxyid = proxy.id;
|
||||
var thisid = this.id;
|
||||
|
||||
if (this.deletePanel) {
|
||||
Studio2.removeElement(srcEl);
|
||||
// If we've just removed the last panel then we need to put an empty panel back in
|
||||
proxy.innerHTML = '';
|
||||
Studio2.tidyPanels();
|
||||
} else {
|
||||
|
||||
// Show the proxy element and animate it to the src element's location
|
||||
YAHOO.util.Dom.setStyle(proxy, "visibility", "");
|
||||
YAHOO.util.Dom.setStyle(srcEl, "display",""); // display!=none for getXY to work
|
||||
|
||||
//Ext.get(proxy).alignTo(srcEl, 'tl', null, {callback:function(){
|
||||
YAHOO.util.Dom.setStyle(proxyid, "visibility", "hidden");
|
||||
YAHOO.util.Dom.setStyle(thisid, "visibility", "");
|
||||
|
||||
//});
|
||||
|
||||
if (Studio2.isSpecial(srcEl)) {
|
||||
if (Studio2.establishLocation(srcEl) == 'panels') {
|
||||
// dropping on the panels means that the panel is no longer special
|
||||
Studio2.unsetSpecial(srcEl);
|
||||
// add in the template row to the new panel
|
||||
var newRow = Studio2.newRow(false);
|
||||
srcEl.appendChild(newRow);
|
||||
// bug 16470: change the panel title to make it unique
|
||||
var view = document.getElementById('prepareForSave').view.value;
|
||||
var view_module = document.getElementById('prepareForSave').view_module.value
|
||||
var panelLabel = document.getElementById("le_panelid_"+srcEl.id).childNodes[0].nodeValue.toUpperCase() ;
|
||||
var panelLabelNoID = 'lbl_' + view + '_panel';
|
||||
var panelNumber = panelLabel.substring(panelLabelNoID.length) ;
|
||||
var panelDisplay = SUGAR.language.get('ModuleBuilder', 'LBL_NEW_PANEL') + ' ' + panelNumber ;
|
||||
document.getElementById("le_panelname_"+srcEl.id).childNodes[0].nodeValue = panelDisplay ;
|
||||
var params = { module: 'ModuleBuilder' , action: 'saveProperty', view_module: view_module }
|
||||
if (document.getElementById('prepareForSave').view_package)
|
||||
{
|
||||
params ['view_package'] = document.getElementById('prepareForSave').view_package.value ;
|
||||
}
|
||||
params [ 'label_'+panelLabel ] = panelDisplay ;
|
||||
YAHOO.util.Connect.asyncRequest(
|
||||
"POST",
|
||||
'index.php',
|
||||
false,
|
||||
SUGAR.util.paramsToUrl(params)
|
||||
);
|
||||
Studio2.activateElement(newRow);
|
||||
Studio2.setSpecial(Studio2.copy());
|
||||
Studio2.activateCopy();
|
||||
YAHOO.util.Dom.setStyle(Studio2.copy(), "display", "block");
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have a special panel that hasn't been moved to the panels area - invalid drop, so remove the copy if there is one
|
||||
var copy = document.getElementById(Studio2.copyId);
|
||||
copy.parentNode.removeChild(copy);
|
||||
Studio2.copyID = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onInvalidDrop: function(e) {
|
||||
// alert("invalid");
|
||||
var srcEl = this.getEl();
|
||||
var dragEl = this.getDragEl();
|
||||
dragEl.innerHTML = '';
|
||||
},
|
||||
|
||||
onDragDrop: function(e, id) {
|
||||
// alert("ondragdrop");
|
||||
|
||||
var srcEl = this.getEl();
|
||||
var destEl = document.getElementById(id); // where this element is being dropped
|
||||
|
||||
// if source was in a panel (not toolbox) and destination is the delete area then remove this element
|
||||
if ((Studio2.establishLocation(srcEl) == 'panels') && (Studio2.establishLocation(destEl) == 'delete')) {
|
||||
this.deletePanel = true;
|
||||
//Studio2.removeElement(srcEl);
|
||||
}
|
||||
},
|
||||
|
||||
onDrag: function(e) {
|
||||
// Keep track of the direction of the drag for use during onDragOver
|
||||
var y = e.pageY;
|
||||
|
||||
if (y < this.lastY) {
|
||||
this.goingUp = true;
|
||||
} else if (y > this.lastY) {
|
||||
this.goingUp = false;
|
||||
}
|
||||
|
||||
this.lastY = y;
|
||||
},
|
||||
|
||||
onDragOver: function(e, id) {
|
||||
var srcEl = this.getEl();
|
||||
var destEl = YAHOO.util.Dom.get(id);
|
||||
var dragEl = this.getDragEl();
|
||||
|
||||
if ((Studio2.establishLocation(destEl) == 'panels') && (destEl.className.indexOf('le_panel') != -1)) {
|
||||
YAHOO.util.Dom.setStyle(srcEl, 'visibility','hidden');
|
||||
YAHOO.util.Dom.setStyle(srcEl, 'display','block');
|
||||
var orig_p = srcEl.parentNode;
|
||||
var p = destEl.parentNode;
|
||||
|
||||
var mid = YAHOO.util.Dom.getY(destEl) + (destEl.offsetHeight / 2);
|
||||
|
||||
if (YAHOO.util.Dom.getY(dragEl) < mid) {
|
||||
p.insertBefore(srcEl, destEl); // insert above
|
||||
} else {
|
||||
p.insertBefore(srcEl, destEl.nextSibling); // insert below
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
184
modules/ModuleBuilder/javascript/studio2RowDD.js
Executable file
184
modules/ModuleBuilder/javascript/studio2RowDD.js
Executable file
@@ -0,0 +1,184 @@
|
||||
/*********************************************************************************
|
||||
* 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".
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
Studio2.RowDD = function(id, sGroup) {
|
||||
Studio2.RowDD.superclass.constructor.call(this, id, sGroup);
|
||||
|
||||
var el = this.getDragEl();
|
||||
YAHOO.util.Dom.setStyle(el, "opacity", 0.67);
|
||||
this.goingUp = false;
|
||||
this.lastY = 0;
|
||||
};
|
||||
|
||||
|
||||
YAHOO.extend(Studio2.RowDD, YAHOO.util.DDProxy, {
|
||||
|
||||
startDrag: function(x, y) {
|
||||
// make the proxy look like the source element
|
||||
var dragEl = this.getDragEl();
|
||||
var clickEl = this.getEl();
|
||||
dragEl.innerHTML = "";
|
||||
Studio2.copyChildren(clickEl, dragEl);
|
||||
dragEl.className = clickEl.className;
|
||||
this.deleteRow = false;
|
||||
Studio2.copyId = null;
|
||||
|
||||
if (Studio2.isSpecial(clickEl)) {
|
||||
var copy = Studio2.newRow(true);
|
||||
Studio2.setCopy(copy);
|
||||
clickEl.parentNode.insertBefore(copy,clickEl.nextSibling);
|
||||
YAHOO.util.Dom.setStyle(copy, 'display','block');
|
||||
YAHOO.util.Dom.setStyle(clickEl, 'display','none');
|
||||
}
|
||||
|
||||
YAHOO.util.Dom.setStyle(clickEl,'visibility','hidden');
|
||||
},
|
||||
|
||||
endDrag: function(e) {
|
||||
ModuleBuilder.state.isDirty=true;
|
||||
// alert("endDrag");
|
||||
|
||||
var srcEl = this.getEl();
|
||||
var proxy = this.getDragEl();
|
||||
var proxyid = proxy.id;
|
||||
var thisid = this.id;
|
||||
|
||||
if (this.deleteRow) {
|
||||
Studio2.removeElement(srcEl);
|
||||
proxy.innerHTML = '';
|
||||
} else {
|
||||
// Show the proxy element and animate it to the src element's location
|
||||
YAHOO.util.Dom.setStyle(proxy, 'visibility','');
|
||||
YAHOO.util.Dom.setStyle(srcEl, "display","");
|
||||
//Dom.setStyle(proxy, "visibility", "");
|
||||
//Dom.setStyle(srcEl, "display",""); // display!=none for getXY to work
|
||||
|
||||
/*Ext.get(proxy).alignTo(srcEl, 'tl', null, {
|
||||
callback: function(){*/
|
||||
YAHOO.util.Dom.setStyle(proxyid,"visibility","hidden");
|
||||
YAHOO.util.Dom.setStyle(thisid,"visibility","");
|
||||
//}
|
||||
//});
|
||||
|
||||
if (Studio2.isSpecial(srcEl)) {
|
||||
if (Studio2.establishLocation(srcEl) == 'panels') {
|
||||
// dropping on the panels means that the row is no longer special
|
||||
Studio2.unsetSpecial(srcEl);
|
||||
// now remove the title for this new row - only wanted while we were in the toolbox
|
||||
for (var i=0;i<srcEl.childNodes.length;i++) {
|
||||
if (srcEl.childNodes[i].tagName.toUpperCase() == 'SPAN') {
|
||||
srcEl.removeChild(srcEl.childNodes[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
Studio2.setSpecial(Studio2.copy());
|
||||
Studio2.activateCopy();
|
||||
YAHOO.util.Dom.setStyle(Studio2.copy(), "display","block");
|
||||
}
|
||||
else
|
||||
{
|
||||
// we have a special row that hasn't been moved to the panels area - invalid drop, so remove the copy if there is one
|
||||
var copy = document.getElementById(Studio2.copyId);
|
||||
copy.parentNode.removeChild(copy);
|
||||
Studio2.copyID = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If we've just removed the last row from a panel then we need to remove the panel
|
||||
// Brute force approach as can't easily discover where this row came from
|
||||
|
||||
var panels = document.getElementById('panels');
|
||||
|
||||
for (var i=0;i<panels.childNodes.length;i++) {
|
||||
var panel = panels.childNodes[i];
|
||||
if (panel.nodeName == 'DIV') { // a panel
|
||||
Studio2.tidyRows(panel);
|
||||
}
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
onInvalidDrop: function(e) {
|
||||
this.getDragEl().innerHTML = '';
|
||||
},
|
||||
|
||||
onDragDrop: function(e, id) {
|
||||
var srcEl = this.getEl();
|
||||
var destEl = document.getElementById(id); // where this element is being dropped
|
||||
|
||||
// if source was in a panel (not toolbox) and destination is the delete area then remove this element
|
||||
var srcLoc = Studio2.establishLocation(srcEl);
|
||||
var dstLoc = Studio2.establishLocation(destEl);
|
||||
if ((Studio2.establishLocation(srcEl) == 'panels') && (Studio2.establishLocation(destEl) == 'delete')) {
|
||||
this.deleteRow = true;
|
||||
}
|
||||
},
|
||||
|
||||
onDrag: function(e) {
|
||||
// Keep track of the direction of the drag for use during onDragOver
|
||||
var y = e.pageY;
|
||||
|
||||
if (y < this.lastY) {
|
||||
this.goingUp = true;
|
||||
} else if (y > this.lastY) {
|
||||
this.goingUp = false;
|
||||
}
|
||||
|
||||
this.lastY = y;
|
||||
},
|
||||
|
||||
onDragOver: function(e, id) {
|
||||
var srcEl = this.getEl();
|
||||
var destEl = document.getElementById(id);
|
||||
var srcLoc = Studio2.establishLocation(srcEl);
|
||||
var dstLoc = Studio2.establishLocation(destEl);
|
||||
if ((Studio2.establishLocation(destEl) == 'panels') && (destEl.className.indexOf('le_row') != -1)) {
|
||||
|
||||
YAHOO.util.Dom.setStyle(srcEl, "visibility","hidden");
|
||||
YAHOO.util.Dom.setStyle(srcEl, "display" ,"block");
|
||||
var orig_p = srcEl.parentNode;
|
||||
var p = destEl.parentNode;
|
||||
|
||||
if (this.goingUp) {
|
||||
p.insertBefore(srcEl, destEl); // insert above
|
||||
} else {
|
||||
p.insertBefore(srcEl, destEl.nextSibling); // insert below
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
196
modules/ModuleBuilder/javascript/studiotabgroups.js
Executable file
196
modules/ModuleBuilder/javascript/studiotabgroups.js
Executable file
@@ -0,0 +1,196 @@
|
||||
/*********************************************************************************
|
||||
* 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".
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
|
||||
if(typeof('console') == 'undefined'){
|
||||
console = {
|
||||
log: function(message) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
StudioTabGroup = function(){
|
||||
this.fields = {};
|
||||
this.lastEditTabGroupLabel = -1;
|
||||
this.widths = new Object;
|
||||
};
|
||||
|
||||
|
||||
StudioTabGroup.prototype.editTabGroupLabel = function (id, done){
|
||||
if(!done){
|
||||
if(this.lastEditTabGroupLabel != -1)editTabGroupLabel(this.lastEditTabGroupLabel, true);
|
||||
document.getElementById('tabname_'+id).style.display = 'none';
|
||||
document.getElementById('tablabel_'+id).style.display = '';
|
||||
document.getElementById('tabother_'+id).style.display = 'none';
|
||||
document.getElementById('tablabel_'+id).focus();
|
||||
this.lastEditTabGroupLabel = id;
|
||||
//Ext.dd.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 = '';
|
||||
//Ext.dd.DragDropMgr.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
StudioTabGroup.prototype.generateForm = function(formname){
|
||||
var form = document.getElementById(formname);
|
||||
for(j = 0; j < studiotabs.slotCount; j++){
|
||||
var ul = document.getElementById('ul' + j);
|
||||
items = ul.getElementsByTagName('li');
|
||||
for(i = 0; i < items.length; i++) {
|
||||
|
||||
if(typeof(studiotabs.subtabModules[items[i].id]) != 'undefined'){
|
||||
|
||||
var input = document.createElement('input');
|
||||
input.type='hidden'
|
||||
input.name= j + '_'+ i;
|
||||
input.value = studiotabs.tabLabelToValue[studiotabs.subtabModules[items[i].id]];
|
||||
form.appendChild(input);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
StudioTabGroup.prototype.generateGroupForm = function(formname){
|
||||
this.clearGroupForm(formname);
|
||||
var form = document.getElementById(formname);
|
||||
for(j = 0; j < studiotabs.slotCount; j++){
|
||||
var ul = document.getElementById('ul' + j);
|
||||
items = ul.getElementsByTagName('li');
|
||||
for(i = 0; i < items.length; i++) {
|
||||
if(typeof(studiotabs.subtabModules[items[i].id]) != 'undefined'){
|
||||
var input = document.createElement('input');
|
||||
input.type='hidden';
|
||||
input.name= 'group_'+ j + '[]';
|
||||
input.value = studiotabs.tabLabelToValue[studiotabs.subtabModules[items[i].id]];
|
||||
form.appendChild(input);
|
||||
// if(this.widths[items[i].id] != null) {
|
||||
var winput = document.createElement('input');
|
||||
winput.type='hidden';
|
||||
winput.name= input.value + 'width';
|
||||
winput.value = "width=" + document.getElementById(items[i].id+'width').innerHTML;
|
||||
form.appendChild(winput);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
StudioTabGroup.prototype.clearGroupForm = function(formname){
|
||||
var form = document.getElementById(formname);
|
||||
for(j = 0; j < form.elements.length; j++){
|
||||
if (typeof(form.elements[j].name) != 'undefined' && String(form.elements[j].name).indexOf("group") > -1) {
|
||||
form.removeChild(form.elements[j]);
|
||||
j--;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
StudioTabGroup.prototype.editField = function(elem, link) {
|
||||
if (this.widths[elem.id] != null) {
|
||||
ModuleBuilder.getContent(link + '&width=' + this.widths[elem.id]);
|
||||
}else{
|
||||
ModuleBuilder.getContent(link);
|
||||
}
|
||||
}
|
||||
|
||||
StudioTabGroup.prototype.saveField = function(elemID, formname) {
|
||||
var elem = document.getElementById(elemID);
|
||||
var form = document.getElementById(formname);
|
||||
var inputs = form.getElementsByTagName("input");
|
||||
for (i = 0; i < inputs.length; i++) {
|
||||
if (inputs[i].name == "width") {
|
||||
this.widths[elemID] = inputs[i].value;
|
||||
var dispWidth = elem.getElementsByTagName("td")[3];
|
||||
dispWidth.innerHTML = "width:" + inputs[i].value;
|
||||
}
|
||||
if (inputs[i].name == "label") {
|
||||
var title = elem.getElementsByTagName("span")[0];
|
||||
title.innerHTML = inputs[i].value;
|
||||
}
|
||||
}
|
||||
ModuleBuilder.submitForm(formname);
|
||||
ajaxStatus.flashStatus('Field Saved', 1000);
|
||||
}
|
||||
|
||||
StudioTabGroup.prototype.reset = function() {
|
||||
this.subtabCount = {};
|
||||
this.subtabModules = {};
|
||||
this.tabLabelToValue = {};
|
||||
this.widths = new Object;
|
||||
}
|
||||
|
||||
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();
|
||||
studiotabs.subtabCount = {};
|
||||
studiotabs.subtabModules = {};
|
||||
studiotabs.tabLabelToValue = {};
|
||||
36
modules/ModuleBuilder/javascript/wizardTemplate.js
Executable file
36
modules/ModuleBuilder/javascript/wizardTemplate.js
Executable file
@@ -0,0 +1,36 @@
|
||||
/*********************************************************************************
|
||||
* 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".
|
||||
********************************************************************************/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user