[5143] | 1 | /******************************************************************************\ |
---|
| 2 | |************************** CALENDAR MODULE *******************************| |
---|
| 3 | |********** PLUGIN USING AJAX EXPRESSOMAIL COMPONENT - OVERWRITE FUNCTIONS **| |
---|
| 4 | \******************************************************************************/ |
---|
| 5 | |
---|
| 6 | /******************************************************************************\ |
---|
| 7 | |** Function : emQuickSearch *********************************************| |
---|
| 8 | |** Original File : <expressoMail_module>/js/common_functions.js **************| |
---|
| 9 | \******************************************************************************/ |
---|
| 10 | window.onresize = function(){}; |
---|
| 11 | function emQuickSearch(el){ |
---|
| 12 | |
---|
| 13 | var emailList = el.value; |
---|
| 14 | var field = el.id; |
---|
| 15 | var ex_participants = Element("ex_participants"); |
---|
| 16 | var quickSearchKeyBegin; |
---|
| 17 | var quickSearchKeyEnd; |
---|
| 18 | |
---|
| 19 | var handler_emQuickSearch = function(data){ |
---|
| 20 | window_DropDownContacts = Element('tipDiv'); |
---|
| 21 | if (window_DropDownContacts.style.visibility != 'hidden'){ |
---|
| 22 | window_DropDownContacts.style.visibility = 'hidden'; |
---|
| 23 | } |
---|
| 24 | //if ((!data.status) && (data.error == "many results")){ |
---|
| 25 | if (data != null && data.length >= data.maxResult){ |
---|
| 26 | alert(get_lang('More than %1 results. Please, try to refine your search',data.maxResult)); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | if (data != null && data.length > 0){ |
---|
| 30 | QuickCatalogSearch.showList(data, quickSearchKeyBegin, quickSearchKeyEnd); |
---|
| 31 | } |
---|
| 32 | else |
---|
| 33 | alert(document.getElementById('txt_none_result').value); |
---|
| 34 | return true; |
---|
| 35 | } |
---|
| 36 | ex_participants.focus(); //mecessary for IE. |
---|
| 37 | var i = getPosition(ex_participants); //inputBox.selectionStart; |
---|
| 38 | var j = --i; |
---|
| 39 | |
---|
| 40 | while ((j >= 0) && (emailList.charAt(j) != ',')){j--}; |
---|
| 41 | quickSearchKeyBegin = ++j; |
---|
| 42 | |
---|
| 43 | while ((i <= emailList.length) && (emailList.charAt(i) != ',')){i++}; |
---|
| 44 | quickSearchKeyEnd = i; |
---|
| 45 | |
---|
| 46 | var search_for = trim(emailList.substring(quickSearchKeyBegin, quickSearchKeyEnd)); |
---|
| 47 | |
---|
| 48 | if (search_for.length < 4){ |
---|
| 49 | alert(document.getElementById('txt_min_search').value); |
---|
| 50 | return false; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | cExecute ("expressoMail1_2.ldap_functions.quicksearch&search_for="+search_for+"&field="+field, handler_emQuickSearch); |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | /******************************************************************************\ |
---|
| 57 | |** Function : emQuickCatalogSearch.prototype.transfer_result ************| |
---|
| 58 | |** Original File : <expressoMail_module>/js/QuickCatalogSearch.js ************| |
---|
| 59 | \******************************************************************************/ |
---|
| 60 | emQuickCatalogSearch.prototype.transfer_result = function (field, ID, begin, end){ |
---|
| 61 | cm = document.getElementById('select_QuickCatalogSearch'); |
---|
| 62 | option_selected = cm.options[cm.selectedIndex].value + ", "; |
---|
| 63 | emailList = Element("ex_participants").value; |
---|
| 64 | new_emailList = emailList.substring(0, begin) + option_selected + emailList.substring((parseInt(end) + 2), emailList.length); |
---|
| 65 | document.getElementById("ex_participants").value = new_emailList; |
---|
| 66 | document.getElementById("ex_participants").focus(); |
---|
| 67 | this.arrayWin['window_QuickCatalogSearch'].close(); |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | /******************************************************************************\ |
---|
| 71 | |** Function : emQuickCatalogSearch.prototype.close_QuickSearch_window ***| |
---|
| 72 | |** Original File : <expressoMail_module>/js/QuickCatalogSearch.js ************| |
---|
| 73 | \******************************************************************************/ |
---|
| 74 | emQuickCatalogSearch.prototype.close_QuickSearch_window = function (){ |
---|
| 75 | document.getElementById("ex_participants").focus(); |
---|
| 76 | this.arrayWin['window_QuickCatalogSearch'].close(); |
---|
| 77 | } |
---|
| 78 | |
---|
| 79 | /******************************************************************************\ |
---|
| 80 | |** Function : emQuickCatalogSearch.prototype.showWindow *****************| |
---|
| 81 | |** Original File : <expressoMail_module>/js/QuickCatalogSearch.js ************| |
---|
| 82 | \******************************************************************************/ |
---|
| 83 | emQuickCatalogSearch.prototype.showWindow = function (div) |
---|
| 84 | { |
---|
| 85 | if(! div) { |
---|
| 86 | alert(get_lang('The list has no participant.')); |
---|
| 87 | return; |
---|
| 88 | } |
---|
| 89 | |
---|
| 90 | if(! this.arrayWin[div.id]) { |
---|
| 91 | div.style.width = "700px"; |
---|
| 92 | div.style.height = "230px"; |
---|
| 93 | var title = get_lang('The results were found in the Global Catalog')+':'; |
---|
| 94 | var wHeight = div.offsetHeight + "px"; |
---|
| 95 | var wWidth = div.offsetWidth + "px"; |
---|
| 96 | div.style.width = div.offsetWidth - 5; |
---|
| 97 | |
---|
| 98 | win = new dJSWin({ |
---|
| 99 | id: 'QuickCatalogSearch_'+div.id, |
---|
| 100 | content_id: div.id, |
---|
| 101 | width: wWidth, |
---|
| 102 | height: wHeight, |
---|
| 103 | y:'300px', |
---|
| 104 | top: '300px', |
---|
| 105 | title_color: '#3978d6', |
---|
| 106 | bg_color: '#eee', |
---|
| 107 | title: title, |
---|
| 108 | title_text_color: 'white', |
---|
| 109 | button_x_img: 'phpgwapi/images/winclose.gif', |
---|
| 110 | border: true }); |
---|
| 111 | |
---|
| 112 | this.arrayWin[div.id] = win; |
---|
| 113 | win.draw(); |
---|
| 114 | } |
---|
| 115 | else { |
---|
| 116 | win = this.arrayWin[div.id]; |
---|
| 117 | } |
---|
| 118 | |
---|
| 119 | win.open(); |
---|
| 120 | document.getElementById('select_QuickCatalogSearch').focus(); |
---|
| 121 | } |
---|
| 122 | /******************************************************************************\ |
---|
| 123 | |** Function : emQuickCatalogSearch.prototype.showList *****************| |
---|
| 124 | |** Original File : <expressoMail_module>/js/QuickCatalogSearch.js ************| |
---|
| 125 | \******************************************************************************/ |
---|
| 126 | |
---|
| 127 | emQuickCatalogSearch.prototype.showList = function(data, begin, end){ |
---|
| 128 | id = '1'; |
---|
| 129 | _this = this; |
---|
| 130 | var el = document.createElement("DIV"); |
---|
| 131 | el.style.visibility = "hidden"; |
---|
| 132 | el.style.position = "absolute"; |
---|
| 133 | el.style.left = "0px"; |
---|
| 134 | el.style.top = "0px"; |
---|
| 135 | el.style.width = "0px"; |
---|
| 136 | el.style.height = "0px"; |
---|
| 137 | el.id = 'window_QuickCatalogSearch'; |
---|
| 138 | document.body.appendChild(el); |
---|
| 139 | el.innerHTML = ""; |
---|
| 140 | |
---|
| 141 | if (document.getElementById('select_QuickCatalogSearch') == null){ |
---|
| 142 | |
---|
| 143 | var title_innerHTML = get_lang('Select a name') + ':'; |
---|
| 144 | if (data.quickSearch_only_in_userSector) |
---|
| 145 | title_innerHTML += "<font color='BLACK' nowrap> ("+get_lang('Showing only the results found in your organization')+".)</font>" |
---|
| 146 | |
---|
| 147 | var title = document.createElement("SPAM"); |
---|
| 148 | title.id = 'window_QuickCatalogSearch_title'; |
---|
| 149 | title.innerHTML = " <b><font color='BLUE' nowrap>"+title_innerHTML+"</font></b><br> "; |
---|
| 150 | el.appendChild(title); |
---|
| 151 | |
---|
| 152 | var cmb = document.createElement("SELECT"); |
---|
| 153 | cmb.id = "select_QuickCatalogSearch"; |
---|
| 154 | cmb.style.width = "685px"; |
---|
| 155 | cmb.size = "12"; |
---|
| 156 | cmb.ondblclick = function (e) { |
---|
| 157 | QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end); |
---|
| 158 | } |
---|
| 159 | cmb.onkeypress = function (e) |
---|
| 160 | { |
---|
| 161 | if (is_ie) |
---|
| 162 | { |
---|
| 163 | if ((window.event.keyCode) == 13) |
---|
| 164 | { |
---|
| 165 | QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end); |
---|
| 166 | } |
---|
| 167 | else if ((window.event.keyCode) == 27) |
---|
| 168 | { |
---|
| 169 | QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID); |
---|
| 170 | } |
---|
| 171 | } |
---|
| 172 | else |
---|
| 173 | { |
---|
| 174 | if ((e.keyCode) == 13) |
---|
| 175 | { |
---|
| 176 | QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end); |
---|
| 177 | } |
---|
| 178 | else if ((e.keyCode) == 27) |
---|
| 179 | { |
---|
| 180 | QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID); |
---|
| 181 | } |
---|
| 182 | } |
---|
| 183 | }; |
---|
| 184 | el.appendChild(cmb); |
---|
| 185 | |
---|
| 186 | var space = document.createElement('SPAN'); |
---|
| 187 | space.innerHTML = "<BR> "; |
---|
| 188 | el.appendChild(space); |
---|
| 189 | |
---|
| 190 | var butt = document.createElement('BUTTON'); |
---|
| 191 | var buttext = document.createTextNode('OK'); |
---|
| 192 | butt.id = "QuickCatalogSearch_button_ok"; |
---|
| 193 | butt.appendChild(buttext); |
---|
| 194 | butt.onclick = function () { |
---|
| 195 | QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end); |
---|
| 196 | }; |
---|
| 197 | el.appendChild(butt); |
---|
| 198 | |
---|
| 199 | var space = document.createElement('SPAN'); |
---|
| 200 | space.innerHTML = " "; |
---|
| 201 | el.appendChild(space); |
---|
| 202 | |
---|
| 203 | var butt = document.createElement('BUTTON'); |
---|
| 204 | butt.id = "QuickCatalogSearch_button_close"; |
---|
| 205 | var buttext = document.createTextNode(get_lang('Close')); |
---|
| 206 | butt.appendChild(buttext); |
---|
| 207 | butt.onclick = function () { QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID);}; |
---|
| 208 | el.appendChild(butt); |
---|
| 209 | } |
---|
| 210 | else{ |
---|
| 211 | var title_innerHTML = get_lang('Select a name') + ':'; |
---|
| 212 | if (data.quickSearch_only_in_userSector) |
---|
| 213 | title_innerHTML += "<font color='BLACK' nowrap> ("+get_lang('Showing only the results found in your organization')+".)</font>" |
---|
| 214 | |
---|
| 215 | var title = Element('window_QuickCatalogSearch_title'); |
---|
| 216 | title.innerHTML = " <b><font color='BLUE' nowrap>"+title_innerHTML+"</font></b><br> "; |
---|
| 217 | |
---|
| 218 | var cmb = document.getElementById('select_QuickCatalogSearch'); |
---|
| 219 | cmb.ondblclick = function (e) { |
---|
| 220 | QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end); |
---|
| 221 | } |
---|
| 222 | cmb.onkeypress = function (e) |
---|
| 223 | { |
---|
| 224 | if (is_ie) |
---|
| 225 | { |
---|
| 226 | if ((window.event.keyCode) == 13) |
---|
| 227 | { |
---|
| 228 | QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end); |
---|
| 229 | } |
---|
| 230 | else if ((window.event.keyCode) == 27) |
---|
| 231 | { |
---|
| 232 | QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID); |
---|
| 233 | } |
---|
| 234 | } |
---|
| 235 | else |
---|
| 236 | { |
---|
| 237 | if ((e.keyCode) == 13) |
---|
| 238 | { |
---|
| 239 | QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end); |
---|
| 240 | } |
---|
| 241 | else if ((e.keyCode) == 27) |
---|
| 242 | { |
---|
| 243 | QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID); |
---|
| 244 | } |
---|
| 245 | } |
---|
| 246 | }; |
---|
| 247 | |
---|
| 248 | for (i=0; i<cmb.length; i++) |
---|
| 249 | cmb.options[i--] = null; |
---|
| 250 | |
---|
| 251 | var butt_ok = document.getElementById("QuickCatalogSearch_button_ok"); |
---|
| 252 | var butt_close = document.getElementById("QuickCatalogSearch_button_close"); |
---|
| 253 | butt_ok.onclick = function () {QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end);}; |
---|
| 254 | butt_close.onclick = function () {QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID);}; |
---|
| 255 | } |
---|
| 256 | |
---|
| 257 | for (i=0; i<data.length; i++){ |
---|
| 258 | var Op = document.createElement("OPTION"); |
---|
| 259 | Op.text = data[i].cn + ' (' + data[i].mail + ')'; |
---|
| 260 | if (data[i].phone != '') |
---|
| 261 | Op.text += ' - ' + data[i].phone; |
---|
| 262 | if (data[i].ou != '') |
---|
| 263 | Op.text += ' - ' + data[i].ou; // adicionado "data[i].ou" para exibir setor (F9) |
---|
| 264 | Op.value = '"' + data[i].cn + '" ' + '<' + data[i].mail + '>'; |
---|
| 265 | cmb.options.add(Op); |
---|
| 266 | } |
---|
| 267 | cmb.options[0].selected = true; |
---|
| 268 | _this.showWindow(el); |
---|
| 269 | } |
---|
| 270 | /******************************************************************************\ |
---|
| 271 | |** Function : DRAG *****************************************************| |
---|
| 272 | |** Original File : phpgwapi/js/wz_dragdrop/wz_dragdrop.js ********************| |
---|
| 273 | \******************************************************************************/ |
---|
| 274 | var over_fn_DRAG = DRAG; |
---|
| 275 | DRAG = function (event){ |
---|
| 276 | |
---|
| 277 | if(is_ie) |
---|
| 278 | return false; |
---|
| 279 | else |
---|
| 280 | over_fn_DRAG(event); |
---|
| 281 | } |
---|