/********************************************************************************* * SugarCRM Community Edition is a customer relationship management program developed by * SugarCRM, Inc. Copyright (C) 2004-2012 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"); Studio2.scrollZones = {} for (var i = 0; Dom.get("ul" + i); i++){ Studio2.scrollZones["ul" + i] = Studio2.getScrollZones("ul" + i); } for (i=0;i"; if(drop_value.value == ""){ html += "[" + SUGAR.language.get('ModuleBuilder', 'LBL_BLANK') + "]"; }else{ html += "["+YAHOO.lang.escapeHTML(drop_value.value)+"]"; } html += ""; html += ""; html += ""+SimpleList.editImage+""; html += " "+SimpleList.deleteImage+""; html += ""; 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