View | Details | Raw Unified | Return to bug 10522
Collapse All | Expand All

(-)file_not_specified_in_diff (-3 / +2 lines)
Line  Link Here
not defined
not defined
1
1
if( typeof(YAHOO) === "object"){
2
    (function() {
2
    (function() {
3
    var Dom = YAHOO.util.Dom;
3
    var Dom = YAHOO.util.Dom;
Lines 234-240 YAHOO.extend(DDList, YAHOO.util.DDProxy, { Link Here
234
        }
234
        }
235
    });
235
    });
236
    })();
236
    })();
237
237
}
238
--
239
koha-tmpl/intranet-tmpl/prog/en/js/acq.js | 280 +++++++++++++++---------------
238
koha-tmpl/intranet-tmpl/prog/en/js/acq.js | 280 +++++++++++++++---------------
240
1 file changed, 140 insertions(+), 140 deletions(-)
239
1 file changed, 140 insertions(+), 140 deletions(-)
(-)a/koha-tmpl/intranet-tmpl/prog/en/js/acq.js (-141 / +140 lines)
Lines 60-240 function isNum(v,maybenull) { Link Here
60
//=======================================================================
60
//=======================================================================
61
// Functions for drag-and-drop functionality
61
// Functions for drag-and-drop functionality
62
62
63
if( typeof(YAHOO) === "object"){
64
    (function() {
63
65
64
(function() {
66
    var Dom = YAHOO.util.Dom;
65
67
    var Event = YAHOO.util.Event;
66
var Dom = YAHOO.util.Dom;
68
    var DDM = YAHOO.util.DragDropMgr;
67
var Event = YAHOO.util.Event;
69
68
var DDM = YAHOO.util.DragDropMgr;
70
    DDApp = {
69
71
        init: function() {
70
DDApp = {
72
        var uls = document.getElementsByTagName('ul');
71
    init: function() {
73
        var i,j;
72
    var uls = document.getElementsByTagName('ul');
74
        var ddtarget;
73
    var i,j;
75
        for (i=0; i<uls.length;i=i+1) {
74
    var ddtarget;
76
            if (uls[i].className == "draglist" || uls[i].className == "draglist_alt") {
75
    for (i=0; i<uls.length;i=i+1) {
77
                ddtarget = YAHOO.util.DragDropMgr.getDDById(uls[i].id);
76
        if (uls[i].className == "draglist" || uls[i].className == "draglist_alt") {
78
    // The yahoo drag and drop is written (broken or not) in such a way, that if an element is subscribed as a target multiple times,
77
            ddtarget = YAHOO.util.DragDropMgr.getDDById(uls[i].id);
79
    // it has to be unlinked multiple times, so we need to test whether it is allready a target, otherwise we'll have a problem when closing the group
78
// The yahoo drag and drop is written (broken or not) in such a way, that if an element is subscribed as a target multiple times,
79
// it has to be unlinked multiple times, so we need to test whether it is allready a target, otherwise we'll have a problem when closing the group
80
            if( ! ddtarget ) {
81
                new YAHOO.util.DDTarget(uls[i].id);
82
            }
83
            var children = uls[i].getElementsByTagName('li');
84
            for( j=0; j<children.length; j=j+1) {
85
// The yahoo drag and drop is (broken or not) in such a way, that if an element is subscribed as a target multiple times,
86
// it has to be unlinked multiple times, so we need to test whether it is allready a target, otherwise we'll have a problem when closing the group
87
                ddtarget = YAHOO.util.DragDropMgr.getDDById(children[j].id);
88
                if( ! ddtarget ) {
80
                if( ! ddtarget ) {
89
                    new DDList(children[j].id);
81
                    new YAHOO.util.DDTarget(uls[i].id);
82
                }
83
                var children = uls[i].getElementsByTagName('li');
84
                for( j=0; j<children.length; j=j+1) {
85
    // The yahoo drag and drop is (broken or not) in such a way, that if an element is subscribed as a target multiple times,
86
    // it has to be unlinked multiple times, so we need to test whether it is allready a target, otherwise we'll have a problem when closing the group
87
                    ddtarget = YAHOO.util.DragDropMgr.getDDById(children[j].id);
88
                    if( ! ddtarget ) {
89
                        new DDList(children[j].id);
90
                    }
90
                }
91
                }
91
            }
92
            }
92
        }
93
        }
93
    }
94
        }
94
    }
95
    };
95
};
96
96
97
97
98
// drag and drop implementation
98
    // drag and drop implementation
99
99
100
DDList = function(id, sGroup, config) {
100
    DDList = function(id, sGroup, config) {
101
101
102
    DDList.superclass.constructor.call(this, id, sGroup, config);
102
        DDList.superclass.constructor.call(this, id, sGroup, config);
103
103
104
    this.logger = this.logger || YAHOO;
104
        this.logger = this.logger || YAHOO;
105
    var el = this.getDragEl();
105
        var el = this.getDragEl();
106
    Dom.setStyle(el, "opacity", 0.67); // The proxy is slightly transparent
106
        Dom.setStyle(el, "opacity", 0.67); // The proxy is slightly transparent
107
107
108
    this.goingUp = false;
108
        this.goingUp = false;
109
    this.lastY = 0;
109
        this.lastY = 0;
110
};
110
    };
111
111
112
YAHOO.extend(DDList, YAHOO.util.DDProxy, {
112
    YAHOO.extend(DDList, YAHOO.util.DDProxy, {
113
113
114
    startDrag: function(x, y) {
114
        startDrag: function(x, y) {
115
        this.logger.log(this.id + " startDrag");
115
            this.logger.log(this.id + " startDrag");
116
116
117
        // make the proxy look like the source element
117
            // make the proxy look like the source element
118
        var dragEl = this.getDragEl();
118
            var dragEl = this.getDragEl();
119
        var clickEl = this.getEl();
119
            var clickEl = this.getEl();
120
        Dom.setStyle(clickEl, "visibility", "hidden");
120
            Dom.setStyle(clickEl, "visibility", "hidden");
121
121
122
        dragEl.innerHTML = clickEl.innerHTML;
122
            dragEl.innerHTML = clickEl.innerHTML;
123
123
124
        Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
124
            Dom.setStyle(dragEl, "color", Dom.getStyle(clickEl, "color"));
125
        Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor"));
125
            Dom.setStyle(dragEl, "backgroundColor", Dom.getStyle(clickEl, "backgroundColor"));
126
        Dom.setStyle(dragEl, "border", "2px solid gray");
126
            Dom.setStyle(dragEl, "border", "2px solid gray");
127
    },
127
        },
128
128
129
    endDrag: function(e) {
129
        endDrag: function(e) {
130
130
131
        var srcEl = this.getEl();
131
            var srcEl = this.getEl();
132
        var proxy = this.getDragEl();
132
            var proxy = this.getDragEl();
133
133
134
        // Show the proxy element and animate it to the src element's location
134
            // Show the proxy element and animate it to the src element's location
135
        Dom.setStyle(proxy, "visibility", "");
135
            Dom.setStyle(proxy, "visibility", "");
136
        var a = new YAHOO.util.Motion(
136
            var a = new YAHOO.util.Motion(
137
            proxy, {
137
                proxy, {
138
                points: {
138
                    points: {
139
                    to: Dom.getXY(srcEl)
139
                        to: Dom.getXY(srcEl)
140
                }
140
                    }
141
            },
141
                },
142
            0.2,
142
                0.2,
143
            YAHOO.util.Easing.easeOut
143
                YAHOO.util.Easing.easeOut
144
        )
144
            )
145
        var proxyid = proxy.id;
145
            var proxyid = proxy.id;
146
        var thisid = this.id;
146
            var thisid = this.id;
147
147
148
        // Hide the proxy and show the source element when finished with the animation
148
            // Hide the proxy and show the source element when finished with the animation
149
        a.onComplete.subscribe(function() {
150
                Dom.setStyle(proxyid, "visibility", "hidden");
151
                Dom.setStyle(thisid, "visibility", "");
152
            });
153
        a.animate();
154
// if we are in basketgrouping page, when finished moving, edit the basket's info to reflect new status
155
        if(typeof(basketgroups) != 'undefined') {
156
            a.onComplete.subscribe(function() {
149
            a.onComplete.subscribe(function() {
157
                var reg = new RegExp("[-]+", "g");
150
                    Dom.setStyle(proxyid, "visibility", "hidden");
158
// add a changed input to each moved basket, so we know which baskets to modify,
151
                    Dom.setStyle(thisid, "visibility", "");
159
// and so we don't need to modify each and every basket and basketgroup each time the page is loaded
152
                });
160
// FIXME: we shouldn't use getElementsByTagName, it's not explicit enough :-(
153
            a.animate();
161
                srcEl.getElementsByTagName('input')[1].value = "1";
154
    // if we are in basketgrouping page, when finished moving, edit the basket's info to reflect new status
162
                if ( srcEl.parentNode.parentNode.className == "workarea" ) {
155
            if(typeof(basketgroups) != 'undefined') {
163
                    var dstbgroupid = srcEl.parentNode.parentNode.getElementsByTagName('input')[srcEl.parentNode.parentNode.getElementsByTagName('input').length-2].name.split(reg)[1];
156
                a.onComplete.subscribe(function() {
164
                    srcEl.className="grouped";
157
                    var reg = new RegExp("[-]+", "g");
165
                    srcEl.getElementsByTagName('input')[0].value = dstbgroupid;
158
    // add a changed input to each moved basket, so we know which baskets to modify,
166
//FIXME: again, we shouldn't be using getElementsByTagName!!
159
    // and so we don't need to modify each and every basket and basketgroup each time the page is loaded
167
                    srcEl.parentNode.parentNode.getElementsByTagName('input')[srcEl.parentNode.parentNode.getElementsByTagName('input').length-1].value = 1;
160
    // FIXME: we shouldn't use getElementsByTagName, it's not explicit enough :-(
168
                }
161
                    srcEl.getElementsByTagName('input')[1].value = "1";
169
                else if ( srcEl.parentNode.parentNode.className == "workarea_alt" ){
162
                    if ( srcEl.parentNode.parentNode.className == "workarea" ) {
170
                        srcEl.className="ungrouped";
163
                        var dstbgroupid = srcEl.parentNode.parentNode.getElementsByTagName('input')[srcEl.parentNode.parentNode.getElementsByTagName('input').length-2].name.split(reg)[1];
171
                        srcEl.getElementsByTagName('input')[0].value = "0";
164
                        srcEl.className="grouped";
172
                }
165
                        srcEl.getElementsByTagName('input')[0].value = dstbgroupid;
173
            });
166
    //FIXME: again, we shouldn't be using getElementsByTagName!!
174
        }
167
                        srcEl.parentNode.parentNode.getElementsByTagName('input')[srcEl.parentNode.parentNode.getElementsByTagName('input').length-1].value = 1;
175
    },
168
                    }
169
                    else if ( srcEl.parentNode.parentNode.className == "workarea_alt" ){
170
                            srcEl.className="ungrouped";
171
                            srcEl.getElementsByTagName('input')[0].value = "0";
172
                    }
173
                });
174
            }
175
        },
176
176
177
    onDragDrop: function(e, id) {
177
        onDragDrop: function(e, id) {
178
178
179
        // If there is one drop interaction, the li was dropped either on the list,
179
            // If there is one drop interaction, the li was dropped either on the list,
180
        // or it was dropped on the current location of the source element.
180
            // or it was dropped on the current location of the source element.
181
        if (DDM.interactionInfo.drop.length === 1) {
181
            if (DDM.interactionInfo.drop.length === 1) {
182
182
183
            // The position of the cursor at the time of the drop (YAHOO.util.Point)
183
                // The position of the cursor at the time of the drop (YAHOO.util.Point)
184
            var pt = DDM.interactionInfo.point;
184
                var pt = DDM.interactionInfo.point;
185
185
186
            // The region occupied by the source element at the time of the drop
186
                // The region occupied by the source element at the time of the drop
187
            var region = DDM.interactionInfo.sourceRegion;
187
                var region = DDM.interactionInfo.sourceRegion;
188
188
189
            // Check to see if we are over the source element's location.  We will
189
                // Check to see if we are over the source element's location.  We will
190
            // append to the bottom of the list once we are sure it was a drop in
190
                // append to the bottom of the list once we are sure it was a drop in
191
            // the negative space (the area of the list without any list items)
191
                // the negative space (the area of the list without any list items)
192
            if (!region.intersect(pt)) {
192
                if (!region.intersect(pt)) {
193
                var destEl = Dom.get(id);
193
                    var destEl = Dom.get(id);
194
                var destDD = DDM.getDDById(id);
194
                    var destDD = DDM.getDDById(id);
195
                destEl.appendChild(this.getEl());
195
                    destEl.appendChild(this.getEl());
196
                destDD.isEmpty = false;
196
                    destDD.isEmpty = false;
197
                DDM.refreshCache();
197
                    DDM.refreshCache();
198
                }
198
            }
199
            }
199
        }
200
        },
200
    },
201
201
202
    onDrag: function(e) {
202
        onDrag: function(e) {
203
203
204
        // Keep track of the direction of the drag for use during onDragOver
204
            // Keep track of the direction of the drag for use during onDragOver
205
        var y = Event.getPageY(e);
205
            var y = Event.getPageY(e);
206
206
207
        if (y < this.lastY) {
207
            if (y < this.lastY) {
208
            this.goingUp = true;
208
                this.goingUp = true;
209
        } else if (y > this.lastY) {
209
            } else if (y > this.lastY) {
210
            this.goingUp = false;
210
                this.goingUp = false;
211
        }
211
            }
212
        this.lastY = y;
212
            this.lastY = y;
213
    },
213
        },
214
214
215
    onDragOver: function(e, id) {
215
        onDragOver: function(e, id) {
216
216
217
        var srcEl = this.getEl();
217
            var srcEl = this.getEl();
218
        var destEl = Dom.get(id);
218
            var destEl = Dom.get(id);
219
219
220
        // We are only concerned with list items, we ignore the dragover
220
            // We are only concerned with list items, we ignore the dragover
221
        // notifications for the list.
221
            // notifications for the list.
222
        if (destEl.nodeName.toLowerCase() == "li") {
222
            if (destEl.nodeName.toLowerCase() == "li") {
223
            var orig_p = srcEl.parentNode;
223
                var orig_p = srcEl.parentNode;
224
            var p = destEl.parentNode;
224
                var p = destEl.parentNode;
225
225
226
            if (this.goingUp) {
226
                if (this.goingUp) {
227
                p.insertBefore(srcEl, destEl); // insert above
227
                    p.insertBefore(srcEl, destEl); // insert above
228
            } else {
228
                } else {
229
                p.insertBefore(srcEl, destEl.nextSibling); // insert below
229
                    p.insertBefore(srcEl, destEl.nextSibling); // insert below
230
            }
230
                }
231
231
232
            DDM.refreshCache();
232
                DDM.refreshCache();
233
            }
233
        }
234
        }
234
    }
235
    });
235
});
236
    })();
236
})();
237
}
237
238
238
239
239
240
240
241
- 

Return to bug 10522