1 2if(!window.dhtmlx) 3 window.dhtmlx = {}; 4 5(function(){ 6 var _dhx_msg_cfg = null; 7 function callback(config, result){ 8 var usercall = config.callback; 9 modality(false); 10 config.box.parentNode.removeChild(config.box); 11 _dhx_msg_cfg = box = config.box = null; 12 if (usercall) 13 usercall(result); 14 } 15 function modal_key(e){ 16 if (_dhx_msg_cfg){ 17 var code = e.which||event.keyCode; 18 if (dhtmlx.message.keyboard){ 19 if (code == 13 || code == 32) 20 callback(_dhx_msg_cfg, true); 21 if (code == 27) 22 callback(_dhx_msg_cfg, false); 23 } 24 if (e.preventDefault) 25 e.preventDefault(); 26 return !(e.cancelBubble = true); 27 } 28 } 29 if (document.attachEvent) 30 document.attachEvent("onkeydown", modal_key); 31 else 32 document.addEventListener("keydown", modal_key, false); 33 34 function modality(mode){ 35 if(!modality.cover){ 36 modality.cover = document.createElement("DIV"); 37 modality.cover.className = "dhx_modal_cover"; 38 document.body.appendChild(modality.cover); 39 } 40 var height = document.body.scrollHeight; 41 modality.cover.style.display = mode?"inline-block":"none"; 42 } 43 44 function button(text, result){ 45 return "<div class='dhtmlx_button' result='"+result+"' ><div>"+text+"</div></div>"; 46 } 47 48 function info(text){ 49 if (!t.area){ 50 t.area = document.createElement("DIV"); 51 t.area.className = "dhtmlx_message_area"; 52 t.area.style[t.position]="5px"; 53 document.body.appendChild(t.area); 54 } 55 56 t.hide(text.id); 57 var message = document.createElement("DIV"); 58 message.innerHTML = "<div>"+text.text+"</div>"; 59 message.className = "dhtmlx-info dhtmlx-" + text.type; 60 message.onclick = function(){ 61 t.hide(text.id); 62 text = null; 63 }; 64 65 if (t.position == "bottom" && t.area.firstChild) 66 t.area.insertBefore(message,t.area.firstChild); 67 else 68 t.area.appendChild(message); 69 70 if (text.expire > 0) 71 t.timers[text.id]=window.setTimeout(function(){ 72 t.hide(text.id); 73 }, text.expire); 74 75 t.pull[text.id] = message; 76 message = null; 77 78 return text.id; 79 } 80 function _boxStructure(config, ok, cancel){ 81 var box = document.createElement("DIV"); 82 box.className = " dhtmlx_modal_box dhtmlx-"+config.type; 83 box.setAttribute("dhxbox", 1); 84 85 var inner = ''; 86 87 if (config.width) 88 box.style.width = config.width; 89 if (config.height) 90 box.style.height = config.height; 91 if (config.title) 92 inner+='<div class="dhtmlx_popup_title">'+config.title+'</div>'; 93 inner+='<div class="dhtmlx_popup_text"><span>'+(config.content?'':config.text)+'</span></div><div class="dhtmlx_popup_controls">'; 94 if (ok) 95 inner += button(config.ok || "OK", true); 96 if (cancel) 97 inner += button(config.cancel || "Cancel", false); 98 if (config.buttons){ 99 for (var i=0; i<config.buttons.length; i++) 100 inner += button(config.buttons[i],i); 101 } 102 inner += '</div>'; 103 box.innerHTML = inner; 104 105 if (config.content){ 106 var node = config.content; 107 if (typeof node == "string") 108 node = document.getElementById(node) 109 box.childNodes[config.title?1:0].appendChild(node); 110 } 111 112 box.onclick = function(e){ 113 e = e ||event; 114 var source = e.target || e.srcElement; 115 if (!source.className) source = source.parentNode; 116 if (source.className == "dhtmlx_button"){ 117 result = source.getAttribute("result"); 118 result = (result == "true")||(result == "false"?false:result); 119 callback(config, result); 120 } 121 }; 122 config.box = box; 123 if (ok||cancel) 124 _dhx_msg_cfg = config; 125 126 return box; 127 } 128 function _createBox(config, ok, cancel){ 129 var box = config.tagName ? config : _boxStructure(config, ok, cancel); 130 131 if (!config.hidden) 132 modality(true); 133 document.body.appendChild(box); 134 var x = Math.abs(Math.floor(((window.innerWidth||document.documentElement.offsetWidth) - box.offsetWidth)/2)); 135 var y = Math.abs(Math.floor(((window.innerHeight||document.documentElement.offsetHeight) - box.offsetHeight)/2)); 136 if (config.position == "top") 137 box.style.top = "-3px"; 138 else 139 box.style.top = y+'px'; 140 box.style.left = x+'px'; 141 142 box.focus(); 143 if (config.hidden) 144 dhtmlx.modalbox.hide(box); 145 146 return box; 147 } 148 149 function alertPopup(config){ 150 return _createBox(config, true, false); 151 } 152 function confirmPopup(config){ 153 return _createBox(config, true, true); 154 } 155 function boxPopup(config){ 156 return _createBox(config); 157 } 158 function box_params(text, type, callback){ 159 if (typeof text != "object"){ 160 if (typeof type == "function"){ 161 callback = type; 162 type = ""; 163 } 164 text = {text:text, type:type, callback:callback }; 165 } 166 return text; 167 } 168 function params(text, type, expire, id){ 169 if (typeof text != "object")
170 text = {text:text, type:type, expire:expire, id:id}; 171 text.id = text.id||t.uid(); 172 text.expire = text.expire||t.expire; 173 return text; 174 } 175 dhtmlx.alert = function(){ 176 text = box_params.apply(this, arguments); 177 text.type = text.type || "confirm"; 178 return alertPopup(text); 179 }; 180 dhtmlx.confirm = function(){ 181 text = box_params.apply(this, arguments); 182 text.type = text.type || "alert"; 183 return confirmPopup(text); 184 }; 185 dhtmlx.modalbox = function(){ 186 text = box_params.apply(this, arguments); 187 text.type = text.type || "alert"; 188 return boxPopup(text); 189 } 190 dhtmlx.modalbox.hide = function(node){ 191 while (node && node.getAttribute && !node.getAttribute("dhxbox")) 192 node = node.parentNode; 193 if (node){ 194 node.parentNode.removeChild(node); 195 modality(false); 196 } 197 } 198 var t = dhtmlx.message = function(text, type, expire, id){ 199 text = params.apply(this, arguments); 200 text.type = text.type||"info"; 201 202 var subtype = text.type.split("-")[0]; 203 switch (subtype){ 204 case "alert": 205 return alertPopup(text); 206 case "confirm": 207 return confirmPopup(text); 208 case "modalbox": 209 return boxPopup(text); 210 default: 211 return info(text); 212 break; 213 } 214 }; 215 216 t.seed = (new Date()).valueOf(); 217 t.uid = function(){return t.seed++;}; 218 t.expire = 4000; 219 t.keyboard = true; 220 t.position = "top"; 221 t.pull = {}; 222 t.timers = {}; 223 224 t.hideAll = function(){ 225 for (var key in t.pull) 226 t.hide(key); 227 }; 228 t.hide = function(id){ 229 var obj = t.pull[id]; 230 if (obj && obj.parentNode){ 231 window.setTimeout(function(){ 232 obj.parentNode.removeChild(obj); 233 obj = null; 234 },2000); 235 obj.className+=" hidden"; 236 237 if(t.timers[id]) 238 window.clearTimeout(t.timers[id]); 239 delete t.pull[id]; 240 } 241 }; 242})();
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.