Javascript-форум (https://javascript.ru/forum/)
-   Events/DOM/Window (https://javascript.ru/forum/events/)
-   -   Проблема с панелью пользователя (https://javascript.ru/forum/events/31461-problema-s-panelyu-polzovatelya.html)

zevilz 10.09.2012 16:13

хром. на ie у меня нет возможности на линуксе проверить
Вот разметка в сокращенном виде:
<div id="toppanel" tabindex="-1">
	<div id="panel">
		<div class="content_panel clearfix_panel">
			<input type='text' id='fld1' size='10' name='req_username' value=''>
			<input type='password' id='fld2' size='10' name='req_password' value=''>
		</div>
	</div>

	<div class="login_tab">
		<span id="toggle">
			<a id="open" class="open">Открыть панель</a>
			<a id="close" style="display: none;" class="close">Закрыть панель</a>
		</span>
	</div> 
</div>

bes 10.09.2012 16:20

ну в хроме мой пример работает, в IE несколько другое восприятие nextSibling (решаемо)

cyber 10.09.2012 16:24

а ну я понял, попробуйте так
function Focus_and_Blur(opt){
      
      var elem = opt.elem, focusForElem;
        
       var body = document.body;
        
       body.setAttribute('tabindex',-1); 
      
      if (elem.addEventListener){ 
      
      elem.addEventListener('focus' , onFocus,true);
      
      body.addEventListener('focus',onDocumentFocus,true); 
    
      } else {
      
      elem.onfocusin = onFocus;
      body.onfocusin = onDocumentFocus;
    
      }
      
      function onFocus(e) {
      
        focusForElem = true;
        event.cancelBubble = true;
        opt.focus.call(this,e);
      }
      
        function onDocumentFocus (e) {
        
          if (focusForElem) {
            focusForElem = false;
            opt.blur.call(elem,e)
          }
        }
      
      };

zevilz 10.09.2012 16:54

даже панель просто не открывается

zevilz 10.09.2012 16:58

<!DOCTYPE HTML>
<html>
<head>
<style>
#toppanel {
	position:fixed;
	z-index: 999;
	margin:0px;}
#toppanel a {cursor:pointer;}
#toppanel:focus {outline: none;}
#panel {
	position: relative;
	z-index: 3;
	display: none;}
#toppanel .login_tab {
	position: relative;
	top: 0;
	z-index: 999;}
</style>
</head>
<body>

<div id="toppanel" tabindex="-1">
	<div id="panel">
		<div class="content_panel clearfix_panel">
			<input type='text' id='fld1' size='10' name='req_username' value=''>
			<input type='password' id='fld2' size='10' name='req_password' value=''>
		</div>
	</div>

	<div class="login_tab">
		<span id="toggle">
			<a id="open" class="open">Открыть панель</a>
			<a id="close" style="display: none;" class="close">Закрыть панель</a>
		</span>
	</div> 
</div>

<script>
function Focus_and_Blur(opt){
      
      var elem = opt.elem, focusForElem;
        
       var body = document.body;
        
       body.setAttribute('tabindex',-1); 
      
      if (elem.addEventListener){ 
      
      elem.addEventListener('focus' , onFocus,true);
      
      body.addEventListener('focus',onDocumentFocus,true); 
    
      } else {
      
      elem.onfocusin = onFocus;
      body.onfocusin = onDocumentFocus;
    
      }
      
      function onFocus(e) {
      
        focusForElem = true;
        event.cancelBubble = true;
        opt.focus.call(this,e);
      }
      
        function onDocumentFocus (e) {
        
          if (focusForElem) {
            focusForElem = false;
            opt.blur.call(elem,e)
          }
        }
      
      };
      Focus_and_Blur({
        elem:document.getElementById('toppanel'),
        focus:function () {
		$("div#panel").slideDown("slow");
		$("#toggle a").toggle();},
        blur: function () {
		$("div#panel").slideUp("slow");
		$("#toggle a").toggle();},}
      });
</script>
</body>
</html>

cyber 10.09.2012 17:04

хех, а вы функцию вызывать не пробывали?:lol:

zevilz 10.09.2012 17:09

Цитата:

Сообщение от cyber (Сообщение 203980)
хех, а вы функцию вызывать не пробывали?:lol:

Вот так вот:
$(document).ready(function() {...
:)

cyber 10.09.2012 17:10

а в примере выше?

zevilz 10.09.2012 17:33

Отредактировал предыдущий. Не работает. Или я чего забыл?:blink:

cyber 10.09.2012 17:35

короче я понял в чем прикол, когда вернусь с треши покажу, если не засну:)


Часовой пояс GMT +3, время: 18:07.