Fórum »  Programovanie a webdesign »  uprava JS
Utorok 7.9.2010, 1:54:27

uprava JS

Odpovedať na tému
  Odpovedať s citátom
  - Karma 1 +

Nováčik
Nováčik
Default avatar Neprihlásený
Založený: 29.11.2006
Príspevky: 10
Karma: 1


Zdravim,
zrovna 2x sa v javascriptoch nevyznam, ale chcel by som upravit ten co mam na stranke tak aby sa mi nezobrazoval zlava zdola, ale zprava zhruba niekde v strede. Je to na www.jm-design.sk/index.php (Facebook). Samotny script:
Kód:

(function (){

  var container, close, content, frame, label;
  var moveBottom, moveInterval;
 
  function init(){
 
    function Get_Cookie(name){
      var start = document.cookie.indexOf( name + "=" );
      var len = start + name.length + 1;
      if ((!start) && (name != document.cookie.substring( 0, name.length ))){
        return null;
      }
      if (start == -1) return null;
      var end = document.cookie.indexOf( ";", len );
      if (end == -1) end = document.cookie.length;
      return unescape( document.cookie.substring( len, end ) );
    }
   
    function Set_Cookie(name, value, expires, path, domain, secure){
      var today = new Date();
      today.setTime(today.getTime());
      if (expires){
        expires = expires * 1000;
      }
      var expires_date = new Date(today.getTime() + (expires));
      document.cookie = name + "=" +escape( value ) +
      ((expires) ? ";expires=" + expires_date.toGMTString() : "" ) +
      ((path) ? ";path=" + path : "" ) +
      ((domain) ? ";domain=" + domain : "" ) +
      ((secure) ? ";secure" : "" );
    }
   
    var ad = parseInt(Get_Cookie("ad"));
    if (ad == 1){
      Set_Cookie("ad", "2", 0);
    }
    if (ad == 2){
      return;
    }
 
    container = document.createElement("DIV");
    frame = document.createElement("DIV");
    close = document.createElement("DIV");
    content = document.createElement("DIV");
    label = document.createElement("SPAN");
   
    container.style.background = "transparent";
    container.style.border = "0 none";
    container.style.bottom = "0px";
    container.style.display = "none";
    container.style.height = "188px";
    container.style.margin = "0";
    container.style.padding = "0";
    container.style.position = "fixed";
    container.style.right = "0px";
    container.style.width = "166px";
   
    frame.style.background = "url('http://www.jm-design.sk/images/window.png') no-repeat";
    frame.style.border = "0 none";
    frame.style.height = "188px";
    frame.style.left = "0";
    frame.style.margin = "0";
    frame.style.opacity = "0.7";
    frame.style.filter = "alpha(opacity=70)";
    frame.style.padding = "0";
    frame.style.position = "absolute";
    frame.style.top = "0px";
    frame.style.width = "166px";
   
    close.style.background = "transparent url('http://www.jm-design.sk/images/close.png') no-repeat 0 0";
    close.style.border = "0 none";
    close.style.cursor = "pointer";
    close.style.height = "17px";
    close.style.position = "absolute";
    close.style.right = "10px";
    close.style.top = "10px";
    close.style.width = "31px";
   
   content.style.background = "black url('http://www.jm-design.sk/images/facebook.png') no-repeat 0 0px";
    content.style.border = "0 none";
    content.style.color = "lime";
    content.style.cursor = "pointer";
    content.style.height = "150px";
    content.style.left = "8px";
    content.style.margin = "0";
    content.style.padding = "0";
    content.style.position = "absolute";
    content.style.top = "30px";
    content.style.width = "150px";
   
 label.style.background = "url('http://www.jm-design.sk/images/bullet.png') no-repeat 0 4px";
    label.style.border = "0 none";
    label.style.color = "#dddddd";
    label.style.paddingLeft = "8px";
    label.style.position = "absolute";
    label.style.left = "10px";
    label.style.top = "8px";
    label.style.font = "normal 14px Arial"
    label.innerHTML = "Podporte nás";
   
    close.onmouseover = function (){
      this.style.backgroundPosition = "0 -17px";
    }
    close.onmouseout = function (){
      this.style.backgroundPosition = "0 0";
    }
    close.onclick = function (){
      Set_Cookie("ad", "2", 600);
      unmoveStart();
    }
   
    content.onclick = function (){
     location.href = "http://www.facebook.com/group.php?gid=118123922126";
    
    }
   
    container.appendChild(frame);
    container.appendChild(close);
    container.appendChild(content);
    container.appendChild(label);
   
    if (document.body == null){
      if (window.addEventListener){
        window.addEventListener("load", show, false);
      }
      else if (window.attachEvent){
        window.attachEvent("onload", show)
      }
    }
    else{
      show();
    }
   
  }
 
  function show(){
    document.body.appendChild(container);
    moveStart();
  }
 
  function moveStart(){
    moveBottom = -200;
    moveInterval = window.setInterval(move, 20);
    container.style.bottom = "-200px";
    container.style.display = "block";
  }
 
  function move(){
    if (moveBottom < 0){
      moveBottom ++;
      container.style.bottom = moveBottom + "px";
    }
    else{
      moveStop();
    }
  }
 
  function moveStop(){
    window.clearInterval(moveInterval);
    moveInterval = null;
  }
 
  function unmoveStart(){
    if (moveInterval != null){
      window.clearInterval(moveInterval);
    }
    moveInterval = window.setInterval(unmove, 20);
  }
 
  function unmove(){
    if (moveBottom > -200){
      moveBottom --;
      container.style.bottom = moveBottom + "px";
    }
    else{
      unmoveStop();
    }
  }
 
  function unmoveStop(){
    window.clearInterval(moveInterval);
    document.body.removeChild(container);
    container = null;
    frame = null;
    close = null;
    content = null;
    label = null;
  }
 
  init();
 
})();


Za kazdu odpoved vopred Dakujem :Very Happy
Re: uprava JS
  Odpovedať s citátom
  - Karma 27 +

Veteran
Veteran
Liero avatar Neprihlásený
Založený: 17.04.2006
Príspevky: 638
Karma: 27
Bydlisko: Lipt. Mikulas

skus riadok:
container.style.right = "0px";
nahradit:
container.style.left =  document.documentElement.offsetWidth+document.documentElement.scrollLeft-166+'px';

edited 2.6. 2010 20:28
Re: uprava JS
  Odpovedať s citátom
  - Karma 125 +

Webmaster
Webmaster
XShady avatar Neprihlásený
Založený: 11.01.2005
Príspevky: 3820
Karma: 125
Bydlisko: Glasgow - West End

Ozaj pekne riesenie, Liero, ja som ale lenivec a najprv by som skusil, ci nepomoze pridat riadok:
Kód:
 container.style.float = "right";
When God made me, he was just showing off!
Let us declare nature to be legitimate. All plants should be declared legal, and all animals for that matter. The notion of illegal plants and animals is obnoxious and ridiculous.—Terence McKenna
If you’re the type who doesn’t want to take the time to read the documentation, you’ll probably find that others won’t find the time to help you out when you have problems. RTFM.
  Odpovedať s citátom
  - Karma 1 +

Nováčik
Nováčik
Default avatar Neprihlásený
Založený: 29.11.2006
Príspevky: 10
Karma: 1


po tejto uprave sa moc nezmenilo.. mal som namysli aby sa to vysuvalo z praveho kraja smerom dolava... ale dakujem za snahu beztak.. priklad co sa zmenilo je tu:
http://jm-design.sk/obchodne_podmienky.php
Re: uprava JS
  Odpovedať s citátom
  - Karma 125 +

Webmaster
Webmaster
XShady avatar Neprihlásený
Založený: 11.01.2005
Príspevky: 3820
Karma: 125
Bydlisko: Glasgow - West End

No vpravo dole sa nachadza, ako vidim, len sa vysuva zdola hore. Skus zmenit
Kód:
    container.style.bottom = "-200px";
na
Kód:
    container.style.right = "-200px";
a
Kód:
    container.style.bottom = moveBottom + "px";
na
Kód:
    container.style.right = moveBottom + "px";
Pre prehladnost kodu este mozes zmenit vsetky vyskyty slova moveBottom na moveRight.
Teda, ak si teda pouzil riesenie float = right, u zarovnania dolava podla Lierovho vzorca musis vyssie upravit podla toho.
When God made me, he was just showing off!
Let us declare nature to be legitimate. All plants should be declared legal, and all animals for that matter. The notion of illegal plants and animals is obnoxious and ridiculous.—Terence McKenna
If you’re the type who doesn’t want to take the time to read the documentation, you’ll probably find that others won’t find the time to help you out when you have problems. RTFM.
  Odpovedať s citátom
  - Karma 1 +

Nováčik
Nováčik
Default avatar Neprihlásený
Založený: 29.11.2006
Príspevky: 10
Karma: 1


Teraz sa tam proste len tak zjavi.. :Confused Pre istotu: vyzera to teraz takto:
Kód:

(function (){

  var container, close, content, frame, label;
  var moveBottom, moveInterval;
 
  function init(){
 
    function Get_Cookie(name){
      var start = document.cookie.indexOf( name + "=" );
      var len = start + name.length + 1;
      if ((!start) && (name != document.cookie.substring( 0, name.length ))){
        return null;
      }
      if (start == -1) return null;
      var end = document.cookie.indexOf( ";", len );
      if (end == -1) end = document.cookie.length;
      return unescape( document.cookie.substring( len, end ) );
    }
   
    function Set_Cookie(name, value, expires, path, domain, secure){
      var today = new Date();
      today.setTime(today.getTime());
      if (expires){
        expires = expires * 1000;
      }
      var expires_date = new Date(today.getTime() + (expires));
      document.cookie = name + "=" +escape( value ) +
      ((expires) ? ";expires=" + expires_date.toGMTString() : "" ) +
      ((path) ? ";path=" + path : "" ) +
      ((domain) ? ";domain=" + domain : "" ) +
      ((secure) ? ";secure" : "" );
    }
   
    var ad = parseInt(Get_Cookie("ad"));
    if (ad == 1){
      Set_Cookie("ad", "2", 0);
    }
    if (ad == 2){
      return;
    }
 
    container = document.createElement("DIV");
    frame = document.createElement("DIV");
    close = document.createElement("DIV");
    content = document.createElement("DIV");
    label = document.createElement("SPAN");
   
    container.style.background = "transparent";
    container.style.border = "0 none";
    container.style.bottom = "0px";
    container.style.display = "none";
    container.style.height = "188px";
    container.style.margin = "0";
    container.style.padding = "0";
    container.style.position = "fixed";
    container.style.left =  document.documentElement.offsetWidth+document.documentElement.scrollLeft-166+'px';
    container.style.width = "166px";
   
    frame.style.background = "url('http://www.jm-design.sk/images/window.png') no-repeat";
    frame.style.border = "0 none";
    frame.style.height = "188px";
    frame.style.left = "0";
    frame.style.margin = "0";
    frame.style.opacity = "0.7";
    frame.style.filter = "alpha(opacity=70)";
    frame.style.padding = "0";
    frame.style.position = "absolute";
    frame.style.top = "0px";
    frame.style.width = "166px";
   
    close.style.background = "transparent url('http://www.jm-design.sk/images/close.png') no-repeat 0 0";
    close.style.border = "0 none";
    close.style.cursor = "pointer";
    close.style.height = "17px";
    close.style.position = "absolute";
    close.style.right = "10px";
    close.style.top = "10px";
    close.style.width = "31px";
   
   content.style.background = "black url('http://www.jm-design.sk/images/facebook.png') no-repeat 0 0px";
    content.style.border = "0 none";
    content.style.color = "lime";
    content.style.cursor = "pointer";
    content.style.height = "150px";
    content.style.left = "8px";
    content.style.margin = "0";
    content.style.padding = "0";
    content.style.position = "absolute";
    content.style.top = "30px";
    content.style.width = "150px";
   
 label.style.background = "url('http://www.jm-design.sk/images/bullet.png') no-repeat 0 4px";
    label.style.border = "0 none";
    label.style.color = "#dddddd";
    label.style.paddingLeft = "8px";
    label.style.position = "absolute";
    label.style.left = "10px";
    label.style.top = "8px";
    label.style.font = "normal 14px Arial"
    label.innerHTML = "Podporte nás";
   
    close.onmouseover = function (){
      this.style.backgroundPosition = "0 -17px";
    }
    close.onmouseout = function (){
      this.style.backgroundPosition = "0 0";
    }
    close.onclick = function (){
      Set_Cookie("ad", "2", 600);
      unmoveStart();
    }
   
    content.onclick = function (){
     location.href = "http://www.facebook.com/group.php?gid=118123922126";
    
    }
   
    container.appendChild(frame);
    container.appendChild(close);
    container.appendChild(content);
    container.appendChild(label);
   
    if (document.body == null){
      if (window.addEventListener){
        window.addEventListener("load", show, false);
      }
      else if (window.attachEvent){
        window.attachEvent("onload", show)
      }
    }
    else{
      show();
    }
   
  }
 
  function show(){
    document.body.appendChild(container);
    moveStart();
  }
 
  function moveStart(){
    moveBottom = -200;
    moveInterval = window.setInterval(move, 20);
    container.style.right = "-200px";
    container.style.display = "block";
  }
 
  function move(){
    if (moveBottom < 0){
      moveBottom ++;
      container.style.right = moveBottom + "px";
    }
    else{
      moveStop();
    }
  }
 
  function moveStop(){
    window.clearInterval(moveInterval);
    moveInterval = null;
  }
 
  function unmoveStart(){
    if (moveInterval != null){
      window.clearInterval(moveInterval);
    }
    moveInterval = window.setInterval(unmove, 20);
  }
 
  function unmove(){
    if (moveBottom > -200){
      moveBottom --;
      container.style.right = moveBottom + "px";
    }
    else{
      unmoveStop();
    }
  }
 
  function unmoveStop(){
    window.clearInterval(moveInterval);
    document.body.removeChild(container);
    container = null;
    frame = null;
    close = null;
    content = null;
    label = null;
  }
 
  init();
 
})();


BTW: Da sa to pozriet na tom istom linku co naposledy... (obchodne_podmienky)
Re: uprava JS
  Odpovedať s citátom
  - Karma 125 +

Webmaster
Webmaster
XShady avatar Neprihlásený
Založený: 11.01.2005
Príspevky: 3820
Karma: 125
Bydlisko: Glasgow - West End

No to je to co som pisal v poslednej vete, ze ak si to vyriesil tak ako som si to myslel ja - cez float right - tak by to slo (neskor som zistil ze s float right by bolo este treba zmenit position na fixed), ty tam mas Lierove univerzalne riesenie :Razz takze potom by som to skusil upravit nasledovne (namiesto upravy hore s tym right okrejom):
Kód:
 
  function moveStart(){
      begPos = curPos = document.documentElement.offsetWidth + document.documentElement.scrollLeft + 12;
    endPos  = document.documentElement.offsetWidth + document.documentElement.scrollLeft - 188;
      moveInterval = window.setInterval(move, 20); 
      container.style.left =  begPos + 'px';
      container.style.display = "block"; 
  }
 
  function move(){
     if (curPos > endPos){ 
           cuuPos --; 
           container.style.left = curPos + "px";
   } else { 
           moveStop();
   } 

 
  function moveStop(){
      window.clearInterval(moveInterval); 
      moveInterval = null; 
  }
 
When God made me, he was just showing off!
Let us declare nature to be legitimate. All plants should be declared legal, and all animals for that matter. The notion of illegal plants and animals is obnoxious and ridiculous.—Terence McKenna
If you’re the type who doesn’t want to take the time to read the documentation, you’ll probably find that others won’t find the time to help you out when you have problems. RTFM.
  Odpovedať s citátom
  - Karma 27 +

Veteran
Veteran
Liero avatar Neprihlásený
Založený: 17.04.2006
Príspevky: 638
Karma: 27
Bydlisko: Lipt. Mikulas

za ten cas co to tu riesis si sa uz mohol aj naucit pouzivat jQuey
Re: uprava JS
  Odpovedať s citátom
  - Karma 125 +

Webmaster
Webmaster
XShady avatar Neprihlásený
Založený: 11.01.2005
Príspevky: 3820
Karma: 125
Bydlisko: Glasgow - West End

Tiez si myslim. Veci netreba zbytocne komplikovat, a v jQuery si to viem predstavit na jeden riadok :Smile
When God made me, he was just showing off!
Let us declare nature to be legitimate. All plants should be declared legal, and all animals for that matter. The notion of illegal plants and animals is obnoxious and ridiculous.—Terence McKenna
If you’re the type who doesn’t want to take the time to read the documentation, you’ll probably find that others won’t find the time to help you out when you have problems. RTFM.
  Odpovedať s citátom
  - Karma 1 +

Nováčik
Nováčik
Default avatar Neprihlásený
Založený: 29.11.2006
Príspevky: 10
Karma: 1


skuste mi dat blizsie indicie ako to spravit a kde si to mam nastudovat.. :Smile teda nejake postupy pri install a pod..
Re: uprava JS
  Odpovedať s citátom
  - Karma 125 +

Webmaster
Webmaster
XShady avatar Neprihlásený
Založený: 11.01.2005
Príspevky: 3820
Karma: 125
Bydlisko: Glasgow - West End

Postupy pri install? Do
<head>
tvojej stranky vlozis
Kód:

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
K elementom pristupujes cez
Kód:
$('#idckoPrvku') alebo $('.idckoPrvku')
atd, proste cez CSS selektory, k jQuery pristupujes bezne cez $.
A ma to kopec metod, napriklad metodu animate() - ktora napr. pekne  animovane posunie prvok, alebo urobi hociaky iny druh animacie... To vsetko aj priklady najdes v jQuery manuali, pogoogli si CHM verziu, ak si Windows user, dobre sa s nou pracuje (windosacky typ napovedy - stiahnes si jeden subor a mas cely manual s vyhladavanim, atd.).  Inac je dostupny aj online manual a kopec prikladov, ktore staci okopirovat a vyskusat, pripadne si prisposobit, a mas odkial zacat.
When God made me, he was just showing off!
Let us declare nature to be legitimate. All plants should be declared legal, and all animals for that matter. The notion of illegal plants and animals is obnoxious and ridiculous.—Terence McKenna
If you’re the type who doesn’t want to take the time to read the documentation, you’ll probably find that others won’t find the time to help you out when you have problems. RTFM.
Re: uprava JS
  Odpovedať s citátom
  - Karma 27 +

Veteran
Veteran
Liero avatar Neprihlásený
Založený: 17.04.2006
Príspevky: 638
Karma: 27
Bydlisko: Lipt. Mikulas

poroz, nieje $('.idckoPrvku'), ale $('.someCssClass'); bodka hovori, ze hladas elementy s danou triedou, nie s danym idckom.
takyto selector ti vyberie vsetky html elementy, ktore maju atribut class="someCssClass";
napriklad mas
Kód:

<ul class="menu">
<li>Item1
   
<ul>
<li>subutem1</li>
<li>subutem2</li>
<ul>
</li>
<li>Item2
   
<ul>
<li>subutem1</li>
<li>subutem2</li>
<ul>
</li>
</ul>
a takychto menu mozes mat na stranke viac.
Ked zavolas
Kód:
 $('ul.menu li').click(function() {  $(this).children.toggle();  });

tak ti najde na stranke vsetkly elementy li, ktore maju rodica ul s css triedou menu. kazdemu takemuto li prvku priradi funkciu k eventu click. (ako keby si mal vsade
<li onclick="nieco"... >. takto funkcia zoberie vsetky dcerske elementy a ak su zobrazene tak ich skryje, a ak su skryte, tak ich zobrazi. a mas hotove rozbalovacie menu :Smile

do jQuery exituje mnozstvo pluginov, ktore pridas tak, ze na stranku das .js subor, ktory najdes na stranke pluginu. exituje mnozstvo pluginov, ktore robia presne to chces, co ty a stacilo by ti napisal napr. $('nejakyDiv').align('bottomright).slideUp();


pre zaciatok cekni napriklad toto: http://www.webdesignerwall.com/tutorials/jquery-tutorials-for-designers/
Re: uprava JS
  Odpovedať s citátom
  - Karma 125 +

Webmaster
Webmaster
XShady avatar Neprihlásený
Založený: 11.01.2005
Príspevky: 3820
Karma: 125
Bydlisko: Glasgow - West End

Liero Napísal:
poroz, nieje $('.idckoPrvku'), ale $('.someCssClass'); bodka hovori, ze hladas elementy s danou triedou, nie s danym idckom....
No ved jasne, som to pisal v rychlosti, ako som pisal - ze proste CSS selektory, kazdy kto chce robit v jQuery predsa urcite pozna ako funguju selektory v CSS :Smile
When God made me, he was just showing off!
Let us declare nature to be legitimate. All plants should be declared legal, and all animals for that matter. The notion of illegal plants and animals is obnoxious and ridiculous.—Terence McKenna
If you’re the type who doesn’t want to take the time to read the documentation, you’ll probably find that others won’t find the time to help you out when you have problems. RTFM.
  
  
Odpovedať na tému

Oprávnenia

Môžete sťahovať a prezerať priložené súbory Nemôžete odosielať nové témy do tohto fóra
Nemôžete odpovedať na témy v tomto fóre
Nemôžete upravovať svoje príspevky v tomto fóre
Nemôžete mazať svoje príspevky v tomto fóre
Nemôžete hlasovať v tomto fóre
Nemôžete prikladať k príspevkom súbory