2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
6 * This program is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Affero General Public License version 3 as published by the
8 * Free Software Foundation with the addition of the following permission added
9 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
13 * This program is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
18 * You should have received a copy of the GNU Affero General Public License along with
19 * this program; if not, see http://www.gnu.org/licenses or write to the Free
20 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
26 * The interactive user interfaces in modified source and object code versions
27 * of this program must display Appropriate Legal Notices, as required under
28 * Section 5 of the GNU Affero General Public License version 3.
30 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31 * these Appropriate Legal Notices must retain the display of the "Powered by
32 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33 * technical reasons, the Appropriate Legal Notices must display the words
34 * "Powered by SugarCRM".
35 ********************************************************************************/
38 {if !empty($external)}
39 <input type="checkbox" value="1" name="{$source_id}_external" id="{$source_id}_external"{$externalChecked}> <label for="{$source_id}_external">{$mod.LBL_EXTERNAL} {if !empty($externalHasProperties)}{$mod.LBL_EXTERNAL_SET_PROPERTIES}{/if}</label><br/>
42 {if empty($externalOnly)}
43 <table id="{$source_id}" class="sources_table" border="0" cellspacing="1" cellpadding="1">
46 <span><b>{$mod.LBL_ENABLED}</b></span>
49 <span><b>{$mod.LBL_DISABLED}</b></span>
51 <td width="33%"> </td>
55 <div id="{$source_id}:enabled_div" class="enabled_module_workarea">
56 <ul id="{$source_id}:enabled_ul" class="module_draglist">
57 {foreach from=$enabled_modules item=module}
58 <li id="{$source_id}:{$module}" class="noBullet2">{sugar_translate label=$module}</li>
64 <div id="{$source_id}:disabled_div" class="disabled_module_workarea">
65 <ul id="{$source_id}:disabled_ul" class="module_draglist">
66 {foreach from=$disabled_modules item=module}
67 <li id="{$source_id}:{$module}" class="noBullet2">{sugar_translate label=$module}</li>
76 <script type="text/javascript">
79 var Dom = YAHOO.util.Dom;
80 var Event = YAHOO.util.Event;
81 var DDM = YAHOO.util.DragDropMgr;
85 YAHOO.example.DDApp = {
88 new YAHOO.util.DDTarget("{$source_id}:enabled_ul");
89 new YAHOO.util.DDTarget("{$source_id}:disabled_ul");
91 {foreach from=$enabled_modules item=module}
92 new YAHOO.example.DDList("{$source_id}:{$module}");
95 {foreach from=$disabled_modules item=module}
96 new YAHOO.example.DDList("{$source_id}:{$module}");
103 YAHOO.example.DDList = function(id, sGroup, config) {
104 YAHOO.example.DDList.superclass.constructor.call(this, id, sGroup, config);
105 var el = this.getDragEl();
106 Dom.setStyle(el, "opacity", 0.67);
107 this.goingUp = false;
112 YAHOO.extend(YAHOO.example.DDList, YAHOO.util.DDProxy, {
113 startDrag: function(x, y) {
114 // make the proxy look like the source element
115 var dragEl = this.getDragEl();
116 var clickEl = this.getEl();
117 Dom.setStyle(clickEl, "visibility", "hidden");
118 dragEl.innerHTML = clickEl.innerHTML;
119 Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
120 Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor"));
121 Dom.setStyle(dragEl, "border", "2px solid gray");
124 endDrag: function(e) {
126 var srcEl = this.getEl();
127 var proxy = this.getDragEl();
129 // Show the proxy element and animate it to the src element's location
130 Dom.setStyle(proxy, "visibility", "");
131 var a = new YAHOO.util.Motion(
138 YAHOO.util.Easing.easeOut
140 var proxyid = proxy.id;
141 var thisid = this.id;
143 // Hide the proxy and show the source element when finished with the animation
144 a.onComplete.subscribe(function() {
145 Dom.setStyle(proxyid, "visibility", "hidden");
146 Dom.setStyle(thisid, "visibility", "");
151 onDragDrop: function(e, id) {
152 // If there is one drop interaction, the li was dropped either on the list,
153 // or it was dropped on the current location of the source element.
154 if (typeof(DDM.interactionInfo) != 'undefined' && DDM.interactionInfo.drop.length === 1) {
156 // The position of the cursor at the time of the drop (YAHOO.util.Point)
157 var pt = DDM.interactionInfo.point;
159 // The region occupied by the source element at the time of the drop
160 var region = DDM.interactionInfo.sourceRegion;
161 // Check to see if we are over the source element's location. We will
162 // append to the bottom of the list once we are sure it was a drop in
163 // the negative space (the area of the list without any list items)
164 if (!region.intersect(pt)) {
165 var destEl = Dom.get(id);
166 var destDD = DDM.getDDById(id);
167 destEl.appendChild(this.getEl());
168 destDD.isEmpty = false;
175 onDrag: function(e) {
177 // Keep track of the direction of the drag for use during onDragOver
178 var y = Event.getPageY(e);
180 if (y < this.lastY) {
182 } else if (y > this.lastY) {
183 this.goingUp = false;
189 onDragOver: function(e, id) {
190 var srcEl = this.getEl();
191 var destEl = Dom.get(id);
193 if (destEl.nodeName.toLowerCase() == "li") {
194 var orig_p = srcEl.parentNode;
195 var p = destEl.parentNode;
197 p.insertBefore(srcEl, destEl); // insert above
199 p.insertBefore(srcEl, destEl.nextSibling); // insert below
207 Event.onDOMReady(YAHOO.example.DDApp.init, YAHOO.example.DDApp, true);
214 <table id="{$source_id}" class="sources_table" border="0" cellspacing="1" cellpadding="1" style="display: none"></table>