[903] | 1 | function DragArea(){ |
---|
| 2 | |
---|
| 3 | this.msg_number = false; |
---|
| 4 | this.subject = false; |
---|
| 5 | this.folder = ''; |
---|
| 6 | this.color_dd = 'red'; |
---|
| 7 | this.from_list = false; |
---|
| 8 | this._mousemove = document.onmousemove; |
---|
| 9 | this._mouseup = document.onmouseup; |
---|
| 10 | this.div_dd = document.createElement("DIV"); |
---|
| 11 | this.id_messages_to_drag = new Array(); |
---|
| 12 | this.div_dd.style.position = 'absolute'; |
---|
| 13 | this.div_dd.style.zIndex = '15'; |
---|
| 14 | this.div_dd.style.border = '1px solid black'; |
---|
| 15 | this.div_dd.style.background ="#EEEEEE"; |
---|
| 16 | var value = "8.5"; |
---|
| 17 | this.div_dd.style.opacity = value/10; |
---|
| 18 | this.div_dd.style.filter = 'alpha(opacity=' + value*10 + ')'; |
---|
| 19 | this.div_dd.id = 'div_sel_messages'; |
---|
| 20 | this.div_dd.style.padding = "3px"; |
---|
| 21 | this.div_dd.style.width = "0px"; |
---|
| 22 | this.div_dd.style.height = "0px"; |
---|
| 23 | this.div_dd.style.display ='none'; |
---|
| 24 | this.envelope = new Image(); |
---|
| 25 | this.envelope.src = "templates/default/images/envelope.png"; |
---|
| 26 | document.body.appendChild(this.div_dd); |
---|
| 27 | |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | DragArea.prototype.makeMenuBox = function(element){ |
---|
| 31 | |
---|
| 32 | element.oncontextmenu = function(e) |
---|
| 33 | { |
---|
| 34 | return false; |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | var _this = this; |
---|
| 38 | |
---|
| 39 | element.onmousedown = function (e) |
---|
| 40 | { |
---|
| 41 | var _button = is_ie ? window.event.button : e.which; |
---|
| 42 | |
---|
| 43 | if(_button == 2 || _button == 3) |
---|
| 44 | { |
---|
| 45 | var boxFolder = element.id.substr(1,element.id.indexOf('tree_folders')-1); |
---|
| 46 | var boxName = element.firstChild.nextSibling.innerHTML; |
---|
| 47 | ConstructBoxMenu(is_ie ? window.event : e,boxName,boxFolder); |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | return true; |
---|
| 51 | }; |
---|
| 52 | |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | DragArea.prototype.makeDragged = function(element, msg_number, subject, from_list, folder){ |
---|
| 56 | element.oncontextmenu = function(e) { |
---|
| 57 | return false; |
---|
| 58 | } |
---|
| 59 | var _this = this; |
---|
| 60 | element.onmousedown = function (e){ |
---|
| 61 | |
---|
| 62 | var _button = is_ie ? window.event.button : e.which; |
---|
| 63 | |
---|
| 64 | if(_button == 2 || _button == 3) { |
---|
| 65 | if (element) |
---|
| 66 | { |
---|
| 67 | if(!element.firstChild.firstChild.checked) { |
---|
| 68 | changeBgColor(is_ie ? window.event : e, element.id); |
---|
| 69 | element.firstChild.firstChild.checked = true; |
---|
| 70 | } |
---|
| 71 | ConstructRightMenu(is_ie ? window.event : e, folder); |
---|
| 72 | } |
---|
| 73 | return false; |
---|
| 74 | } |
---|
| 75 | |
---|
| 76 | if(!_this.msg_number) { |
---|
| 77 | _this.msg_number = msg_number; |
---|
| 78 | |
---|
| 79 | if(!subject) |
---|
| 80 | _this.subject = get_lang("No Subject"); |
---|
| 81 | //else if(subject.length > 40) |
---|
| 82 | // _this.subject = subject.substring(0,40) + '...'; |
---|
| 83 | else |
---|
| 84 | _this.subject = subject; |
---|
| 85 | |
---|
| 86 | _this.from_list = from_list; |
---|
| 87 | _this.div_dd.style.width = "auto"; |
---|
| 88 | _this.div_dd.style.height = "auto"; |
---|
| 89 | _this.folder = folder; |
---|
| 90 | } |
---|
| 91 | return true; |
---|
| 92 | }; |
---|
| 93 | } |
---|
| 94 | DragArea.prototype.showLayerDrag = function(e){ |
---|
| 95 | |
---|
| 96 | var msg_number = _dragArea.from_list ? _dragArea.msg_number : _dragArea.msg_number.replace('_r',''); |
---|
| 97 | if(_dragArea.from_list) { |
---|
| 98 | if((Element("check_box_message_"+msg_number)) && (! Element("check_box_message_"+msg_number).checked)) { |
---|
| 99 | if (is_ie) |
---|
| 100 | changeBgColor(window.event,msg_number); |
---|
| 101 | else |
---|
| 102 | changeBgColor(e,msg_number); |
---|
| 103 | Element(msg_number).firstChild.firstChild.checked = true; |
---|
| 104 | } |
---|
| 105 | if((tr = Element(msg_number+";"+this.folder)) && (!tr.firstChild.firstChild.checked)) { |
---|
| 106 | if (is_ie) |
---|
| 107 | changeBgColor(window.event,tr.id); |
---|
| 108 | else |
---|
| 109 | changeBgColor(e,tr.id); |
---|
| 110 | tr.firstChild.firstChild.checked = true; |
---|
| 111 | } |
---|
| 112 | id_messages_to_drag = get_selected_messages(); |
---|
| 113 | id_messages_to_drag = id_messages_to_drag ? id_messages_to_drag : new Array(); |
---|
| 114 | |
---|
| 115 | if(id_messages_to_drag.length > 1) |
---|
| 116 | this.subject = id_messages_to_drag[0].length +" mensagens selecionadas"; |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | this.div_dd.innerHTML = "<img align='center' src='"+this.envelope.src+"'> <span id='content_dd'><font color='red' weight='bold'><b>"+this.subject+"</b></span></font>"; |
---|
| 120 | this.div_dd.style.display =''; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | DragArea.prototype.onSelectStart = function(value){ |
---|
| 124 | if(!value) { |
---|
| 125 | document.body.onselectstart = function (e){return false;} |
---|
| 126 | document.body.ondragstart = function (e){return false;} |
---|
| 127 | } |
---|
| 128 | else { |
---|
| 129 | document.body.onselectstart = function (e){return true;} |
---|
| 130 | document.body.ondragstart = function (e){return true;} |
---|
| 131 | } |
---|
| 132 | } |
---|
| 133 | |
---|
| 134 | DragArea.prototype.mouseMoveDrag = function(e){ |
---|
| 135 | |
---|
| 136 | var e = is_ie ? window.event : e; |
---|
| 137 | var _target = is_ie ? e.srcElement : e.target; |
---|
| 138 | if(is_ie) |
---|
| 139 | this.onSelectStart(false); |
---|
| 140 | |
---|
| 141 | this.div_dd.style.left = e.clientX + 5 + document.body.scrollLeft; |
---|
| 142 | this.div_dd.style.top = e.clientY + 10 + document.body.scrollTop; |
---|
| 143 | |
---|
| 144 | if(this.div_dd.style.display == 'none') |
---|
| 145 | this.showLayerDrag(e); |
---|
| 146 | |
---|
| 147 | var reg = /^((n|l)(?!root))(.*)tree_folders$/; |
---|
| 148 | var _color = this.color_dd; |
---|
| 149 | |
---|
| 150 | if(reg.test(_target.parentNode.id) ) |
---|
| 151 | _color ='green'; |
---|
| 152 | else |
---|
| 153 | _color ='red'; |
---|
| 154 | |
---|
| 155 | if(this.color_dd != _color) { |
---|
| 156 | Element('content_dd').innerHTML = "<font color='"+_color+"' weight='bold'><b>"+this.subject+"</b></font>"; |
---|
| 157 | this.color_dd = _color; |
---|
| 158 | } |
---|
| 159 | |
---|
| 160 | return false; |
---|
| 161 | } |
---|
| 162 | |
---|
| 163 | var _dragArea = new DragArea(); |
---|
| 164 | |
---|
| 165 | document.onmousemove = function(e) { |
---|
| 166 | var _target = is_ie ? window.event.srcElement : e.target; |
---|
| 167 | if(_dragArea._mousemove) |
---|
| 168 | _dragArea._mousemove(e); |
---|
| 169 | |
---|
| 170 | else if(_dragArea.msg_number && _target.type != 'checkbox') { |
---|
| 171 | _dragArea.mouseMoveDrag(e); |
---|
| 172 | } |
---|
| 173 | }; |
---|
| 174 | |
---|
| 175 | document.onmouseup = function(e) { |
---|
| 176 | |
---|
| 177 | var _event = is_ie ? window.event : e; |
---|
| 178 | var _target = is_ie ? _event.srcElement : _event.target; |
---|
| 179 | var _button = is_ie ? _event.button : _event.which; |
---|
| 180 | |
---|
| 181 | if(_button != 2 && _button != 3) { |
---|
| 182 | |
---|
| 183 | if(Element("div_rightbutton") && Element("div_rightbutton").style.display != 'none') |
---|
| 184 | { |
---|
| 185 | |
---|
| 186 | if(!_target.id.match(/link_rightbutton_(.*)$/)){ |
---|
| 187 | |
---|
| 188 | var id_messages_to_drag = get_selected_messages(); |
---|
| 189 | id_messages_to_drag = id_messages_to_drag ? id_messages_to_drag : 0; |
---|
| 190 | |
---|
| 191 | for(var i = 0; id_messages_to_drag && i < id_messages_to_drag[0].length; i++) |
---|
| 192 | { |
---|
| 193 | if(tr = Element(id_messages_to_drag[0][i])) |
---|
| 194 | { |
---|
| 195 | tr.firstChild.firstChild.checked = false; |
---|
| 196 | changeBgColor(_event , tr.id); |
---|
| 197 | } |
---|
| 198 | if (tr = Element(id_messages_to_drag[0][i]+";"+id_messages_to_drag[1][i])) |
---|
| 199 | { |
---|
| 200 | changeBgColor(_event , tr.id); |
---|
| 201 | tr.firstChild.firstChild.checked = false; |
---|
| 202 | } |
---|
| 203 | } |
---|
| 204 | Element("chk_box_select_all_messages").checked = false; |
---|
| 205 | Element('div_rightbutton').style.display = 'none'; |
---|
| 206 | _dragArea.msg_number = false; |
---|
| 207 | _dragArea.div_dd.style.display ='none'; |
---|
| 208 | return false; |
---|
| 209 | } |
---|
| 210 | } |
---|
| 211 | if(is_ie) |
---|
| 212 | _dragArea.onSelectStart(true); |
---|
| 213 | |
---|
| 214 | if (Element("div_rightbutton_folder") && Element("div_rightbutton_folder").style.display != 'none') |
---|
| 215 | { |
---|
| 216 | Element('div_rightbutton_folder').style.display = 'none'; |
---|
| 217 | } |
---|
| 218 | |
---|
| 219 | } |
---|
| 220 | |
---|
| 221 | |
---|
| 222 | if(_dragArea.msg_number) { |
---|
| 223 | |
---|
| 224 | var reg = /^((n|l)(?!root))(.*)tree_folders$/; |
---|
| 225 | var new_folder; |
---|
| 226 | |
---|
| 227 | if(reg.test(_target.parentNode.id) ){ |
---|
| 228 | new_folder = _target.parentNode.id.substring(1,_target.parentNode.id.length).replace('tree_folders',''); |
---|
| 229 | new_folder_name = new_folder.replace("INBOX"+cyrus_delimiter, ""); |
---|
| 230 | if(new_folder_name == 'INBOX') |
---|
| 231 | new_folder_name = get_lang("Inbox"); |
---|
| 232 | |
---|
| 233 | if(_dragArea.from_list) |
---|
| 234 | //if (currentTab != 0){ |
---|
| 235 | //move_search_msgs("content_id_search_" + numBox, new_folder, new_folder_name);} |
---|
| 236 | //else{ |
---|
| 237 | proxy_mensagens.proxy_move_messages("null", 'selected', 0, new_folder, new_folder_name); //} |
---|
| 238 | |
---|
| 239 | else{ |
---|
| 240 | var msg_number = _dragArea.from_list ? _dragArea.msg_number : _dragArea.msg_number.replace('_r',''); |
---|
| 241 | proxy_mensagens.proxy_move_messages("null", msg_number, msg_number+"_r", new_folder, new_folder_name); |
---|
| 242 | } |
---|
| 243 | } |
---|
| 244 | |
---|
| 245 | else if(_dragArea.from_list && _target.type != 'checkbox' && _dragArea.div_dd.style.display !='none'){ |
---|
| 246 | var id_messages_to_drag = get_selected_messages(); |
---|
| 247 | if(id_messages_to_drag){ |
---|
| 248 | //id_messages_to_drag = id_messages_to_drag.split(','); |
---|
| 249 | |
---|
| 250 | for(var i = 0; id_messages_to_drag && i < id_messages_to_drag[0].length; i++) |
---|
| 251 | { |
---|
| 252 | if(tr = Element(id_messages_to_drag[0][i])) |
---|
| 253 | { |
---|
| 254 | tr.firstChild.firstChild.checked = false; |
---|
| 255 | changeBgColor(_event , tr.id); |
---|
| 256 | } |
---|
| 257 | if (tr = Element(id_messages_to_drag[0][i]+";"+id_messages_to_drag[1][i])) |
---|
| 258 | { |
---|
| 259 | changeBgColor(_event , tr.id); |
---|
| 260 | tr.firstChild.firstChild.checked = false; |
---|
| 261 | } |
---|
| 262 | } |
---|
| 263 | Element("chk_box_select_all_messages").checked = false; |
---|
| 264 | } |
---|
| 265 | } |
---|
| 266 | |
---|
| 267 | _dragArea.msg_number = false; |
---|
| 268 | _dragArea.div_dd.style.display ='none'; |
---|
| 269 | if(is_ie) |
---|
| 270 | _dragArea.onSelectStart(true); |
---|
| 271 | } |
---|
| 272 | |
---|
| 273 | }; |
---|