2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2013 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 ********************************************************************************/
39 <div id="{$source_id}_add_tables" class="sources_table_div">
40 {foreach from=$display_data key=module item=data}
41 <table border="0" cellspacing="1" cellpadding="1" name="{$module}" id="{$module}">
43 <td colspan="2"><span><font size="3">{sugar_translate label=$module}</font></span></td>
46 <td><b>{$mod.LBL_DEFAULT}</b></td>
47 <td><b>{$mod.LBL_AVAILABLE}</b></td>
51 <div class="enabled_workarea" id="{$source_id}:{$module}:enabled_div">
52 <ul class="draglist" id="{$source_id}:{$module}:enabled_ul">
53 {foreach from=$data.enabled key=enabled_id item=enabled_value}
54 <li class="noBullet2" id="{$source_id}:{$module}:{$enabled_id}">{$enabled_value}</li>
60 <div class="disabled_workarea" id="{$source_id}:{$module}:disabled_div">
61 <ul class="draglist" id="{$source_id}:{$module}:disabled_ul">
62 {foreach from=$data.disabled key=disabled_id item=disabled_value}
63 <li class="noBullet2" id="{$source_id}:{$module}:{$disabled_id}">{$disabled_value}</li>
74 <script type="text/javascript">
77 var Dom = YAHOO.util.Dom;
78 var Event = YAHOO.util.Event;
79 var DDM = YAHOO.util.DragDropMgr;
83 YAHOO.example.DDApp = {
86 {foreach from=$modules_sources key=module item=field_defs}
87 new YAHOO.util.DDTarget("{$source_id}:{$module}:enabled_ul", "{$source_id}:{$module}");
88 new YAHOO.util.DDTarget("{$source_id}:{$module}:disabled_ul", "{$source_id}:{$module}");
89 {foreach from=$field_defs key=index item=field}
90 new YAHOO.example.DDList("{$source_id}:{$module}:{$index}", "{$source_id}:{$module}");
97 YAHOO.example.DDList = function(id, sGroup, config) {
98 YAHOO.example.DDList.superclass.constructor.call(this, id, sGroup, config);
99 var el = this.getDragEl();
100 Dom.setStyle(el, "opacity", 0.67);
101 this.goingUp = false;
106 YAHOO.extend(YAHOO.example.DDList, YAHOO.util.DDProxy, {
107 startDrag: function(x, y) {
108 // make the proxy look like the source element
109 var dragEl = this.getDragEl();
110 var clickEl = this.getEl();
111 Dom.setStyle(clickEl, "visibility", "hidden");
112 dragEl.innerHTML = clickEl.innerHTML;
113 Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
114 Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor"));
115 Dom.setStyle(dragEl, "border", "2px solid gray");
116 Dom.setStyle(dragEl, "cursor", "pointer");
119 endDrag: function(e) {
121 var srcEl = this.getEl();
122 var proxy = this.getDragEl();
124 // Show the proxy element and animate it to the src element's location
125 Dom.setStyle(proxy, "visibility", "");
126 var a = new YAHOO.util.Motion(
133 YAHOO.util.Easing.easeOut
135 var proxyid = proxy.id;
136 var thisid = this.id;
138 // Hide the proxy and show the source element when finished with the animation
139 a.onComplete.subscribe(function() {
140 Dom.setStyle(proxyid, "visibility", "hidden");
141 Dom.setStyle(thisid, "visibility", "");
146 onDragDrop: function(e, id) {
147 // If there is one drop interaction, the li was dropped either on the list,
148 // or it was dropped on the current location of the source element.
149 if (typeof(DDM.interactionInfo) != 'undefined' && DDM.interactionInfo.drop.length === 1) {
151 // The position of the cursor at the time of the drop (YAHOO.util.Point)
152 var pt = DDM.interactionInfo.point;
154 // The region occupied by the source element at the time of the drop
155 var region = DDM.interactionInfo.sourceRegion;
156 // Check to see if we are over the source element's location. We will
157 // append to the bottom of the list once we are sure it was a drop in
158 // the negative space (the area of the list without any list items)
159 if (!region.intersect(pt)) {
160 var destEl = Dom.get(id);
161 var destDD = DDM.getDDById(id);
162 destEl.appendChild(this.getEl());
163 destDD.isEmpty = false;
170 onDrag: function(e) {
172 // Keep track of the direction of the drag for use during onDragOver
173 var y = Event.getPageY(e);
175 if (y < this.lastY) {
177 } else if (y > this.lastY) {
178 this.goingUp = false;
184 onDragOver: function(e, id) {
185 var srcEl = this.getEl();
186 var destEl = Dom.get(id);
188 if (destEl.nodeName.toLowerCase() == "li") {
189 var orig_p = srcEl.parentNode;
190 var p = destEl.parentNode;
192 p.insertBefore(srcEl, destEl); // insert above
194 p.insertBefore(srcEl, destEl.nextSibling); // insert below
197 } else if(destEl.nodeName.toLowerCase() == "ul") {
198 var p = destEl.parentNode;
199 blank_list = p.lastChild;
201 destEl.appendChild(srcEl);
203 blank_list.insertBefore(srcEl, destEl.nextSibling);
211 YAHOO.util.Event.onDOMReady(function(){
212 YAHOO.example.DDApp.init();
219 {if $no_searchdefs_defined}
220 <h3>{$mod.ERROR_NO_SEARCHDEFS_DEFINED}</h3>