2009-12-09 4 views
0

저는 cssglobe에서 easyslider 1.7 플러그인을 구현하려고했습니다. 새 사용자이기 때문에 죄송합니다. 하이퍼 링크를 게시 할 수 없습니다.Easyslider 1.7 구현 문제

다운로드 내에 테스트 파일을 업로드했는데 예상대로 모든 것이 잘 수행되었습니다. 그런 다음 테스트 사이트에서 구현하기 시작했습니다. 나는 모든 파일을 포함하고 나의 위치 내의 머리말 "나의 일"의 밑에 슬라이더 ID를 추가했다. 마치 초기화 된 스크립트가없는 것처럼 보입니다. 나는 아무런 도움없이 많은 변형을 시도했다. 신선한 눈 세트가 좋을 것입니다.

내가 한 유일한 차이점은 "jquery.js"의 이름을 "jqueryslider.js"로 변경 한 것입니다. 다른 플러그인과 충돌하지 않도록이 작업을 수행했습니다. 데모 사이트에서도이 변경 작업을 수행했으며 제대로 작동했습니다.

나는 다른 모든 스크립트와 스타일을 easyslider 1.7 스타일과 스크립트 만 사용하여 스트라이핑 해 보았습니다.

여기 여기 내 테스트 site

입니다 easyslider에 대한 데모입니다. www.symplebytes.com/sliderdemo/01.html

주셔서 감사합니다,

여기

의 모습을 지르고에서 easySlider1.7.js

(function($) { 

$.fn.easySlider = function(options){ 

    // default configuration properties 
    var defaults = {    
     prevId:   'prevBtn', 
     prevText:  'Previous', 
     nextId:   'nextBtn', 
     nextText:  'Next', 
     controlsShow: true, 
     controlsBefore: '', 
     controlsAfter: '', 
     controlsFade: true, 
     firstId:  'firstBtn', 
     firstText:  'First', 
     firstShow:  false, 
     lastId:   'lastBtn', 
     lastText:  'Last', 
     lastShow:  false,    
     vertical:  false, 
     speed:   800, 
     auto:   false, 
     pause:   2000, 
     continuous:  false, 
     numeric:  false, 
     numericId:  'controls' 
    }; 

    var options = $.extend(defaults, options); 

    this.each(function() { 
     var obj = $(this);    
     var s = $("li", obj).length; 
     var w = $("li", obj).width(); 
     var h = $("li", obj).height(); 
     var clickable = true; 
     obj.width(w); 
     obj.height(h); 
     obj.css("overflow","hidden"); 
     var ts = s-1; 
     var t = 0; 
     $("ul", obj).css('width',s*w);   

     if(options.continuous){ 
      $("ul", obj).prepend($("ul li:last-child", obj).clone().css("margin-left","-"+ w +"px")); 
      $("ul", obj).append($("ul li:nth-child(2)", obj).clone()); 
      $("ul", obj).css('width',(s+1)*w); 
     };    

     if(!options.vertical) $("li", obj).css('float','left'); 

     if(options.controlsShow){ 
      var html = options.controlsBefore;    
      if(options.numeric){ 
       html += '<ol id="'+ options.numericId +'"></ol>'; 
      } else { 
       if(options.firstShow) html += '<span id="'+ options.firstId +'"><a href=\"javascript:void(0);\">'+ options.firstText +'</a></span>'; 
       html += ' <span id="'+ options.prevId +'"><a href=\"javascript:void(0);\">'+ options.prevText +'</a></span>'; 
       html += ' <span id="'+ options.nextId +'"><a href=\"javascript:void(0);\">'+ options.nextText +'</a></span>'; 
       if(options.lastShow) html += ' <span id="'+ options.lastId +'"><a href=\"javascript:void(0);\">'+ options.lastText +'</a></span>';    
      }; 

      html += options.controlsAfter;      
      $(obj).after(html);          
     }; 

     if(options.numeric){          
      for(var i=0;i<s;i++){      
       $(document.createElement("li")) 
        .attr('id',options.numericId + (i+1)) 
        .html('<a rel='+ i +' href=\"javascript:void(0);\">'+ (i+1) +'</a>') 
        .appendTo($("#"+ options.numericId)) 
        .click(function(){       
         animate($("a",$(this)).attr('rel'),true); 
        });             
      };       
     } else { 
      $("a","#"+options.nextId).click(function(){  
       animate("next",true); 
      }); 
      $("a","#"+options.prevId).click(function(){  
       animate("prev",true);    
      }); 
      $("a","#"+options.firstId).click(function(){   
       animate("first",true); 
      });    
      $("a","#"+options.lastId).click(function(){  
       animate("last",true);    
      });    
     }; 

     function setCurrent(i){ 
      i = parseInt(i)+1; 
      $("li", "#" + options.numericId).removeClass("current"); 
      $("li#" + options.numericId + i).addClass("current"); 
     }; 

     function adjust(){ 
      if(t>ts) t=0;  
      if(t<0) t=ts; 
      if(!options.vertical) { 
       $("ul",obj).css("margin-left",(t*w*-1)); 
      } else { 
       $("ul",obj).css("margin-left",(t*h*-1)); 
      } 
      clickable = true; 
      if(options.numeric) setCurrent(t); 
     }; 

     function animate(dir,clicked){ 
      if (clickable){ 
       clickable = false; 
       var ot = t;    
       switch(dir){ 
        case "next": 
         t = (ot>=ts) ? (options.continuous ? t+1 : ts) : t+1;      
         break; 
        case "prev": 
         t = (t<=0) ? (options.continuous ? t-1 : 0) : t-1; 
         break; 
        case "first": 
         t = 0; 
         break; 
        case "last": 
         t = ts; 
         break; 
        default: 
         t = dir; 
         break; 
       }; 
       var diff = Math.abs(ot-t); 
       var speed = diff*options.speed;      
       if(!options.vertical) { 
        p = (t*w*-1); 
        $("ul",obj).animate(
         { marginLeft: p }, 
         { queue:false, duration:speed, complete:adjust } 
        );    
       } else { 
        p = (t*h*-1); 
        $("ul",obj).animate(
         { marginTop: p }, 
         { queue:false, duration:speed, complete:adjust } 
        );     
       }; 

       if(!options.continuous && options.controlsFade){      
        if(t==ts){ 
         $("a","#"+options.nextId).hide(); 
         $("a","#"+options.lastId).hide(); 
        } else { 
         $("a","#"+options.nextId).show(); 
         $("a","#"+options.lastId).show();     
        }; 
        if(t==0){ 
         $("a","#"+options.prevId).hide(); 
         $("a","#"+options.firstId).hide(); 
        } else { 
         $("a","#"+options.prevId).show(); 
         $("a","#"+options.firstId).show(); 
        };     
       };    

       if(clicked) clearTimeout(timeout); 
       if(options.auto && dir=="next" && !clicked){; 
        timeout = setTimeout(function(){ 
         animate("next",false); 
        },diff*options.speed+options.pause); 
       }; 

      }; 

     }; 
     // init 
     var timeout; 
     if(options.auto){; 
      timeout = setTimeout(function(){ 
       animate("next",false); 
      },options.pause); 
     };  

     if(options.numeric) setCurrent(0); 

     if(!options.continuous && options.controlsFade){      
      $("a","#"+options.prevId).hide(); 
      $("a","#"+options.firstId).hide();    
     };    

    }); 

}; 

})(jQuery); 

답변

0

답장을 보내 주셔서 감사합니다. Google 코드의 프레임 워크를 사용하여 모든 라이브러리 1을 포함 시켰습니다. .

이것은 모든 스크립트를 아무런 문제없이 실행 한 것으로 보입니다.

<script src="http://www.google.com/jsapi"></script> 
    <script type="text/javascript"> 
     // Load jQuery 
     google.load("jquery", "1"); 

       google.setOnLoadCallback(function() { 
       // Your code goes here. 
       }); 
     </script> 
0
$("#slider").easySlider is not a function 

코드입니다 스크립트가 제대로 연결되어 있지 않습니다.

+0

발견해 주셔서 감사합니다. 실제 자바 스크립트를 게시합니다. 이상하지만 동일한 기능이 데모에서 호출되며 문제없이 작동합니다. – Chris

0

이 줄을 title 태그 바로 뒤에 (그리고 jquery 플러그인 앞에) 차 코드에서 당신이 가지고있는 원본을 제거 :

<script src="http://code.jquery.com/jquery-latest.pack.js" type="text/javascript"></script> 

당신은 항상 플러그인 전에 JQuery와 코어 파일을로드해야합니다, 그렇지 않으면 일을 실 거예요.

+0

흠, 이제는 내 다른 스크립트 (트위터/연락처 양식)가 작동하지 않습니다. 팁 고마워. 실행중인 다른 모든 스크립트를 비활성화하는 이유는 무엇입니까? – Chris

+0

어쩌면 당신은 jquery "(function ($) {"같은 이름으로 두 번 인스턴스화했습니다. 그것은 일반적인 오류이며, 모든 것을 날려 버립니다 :) – yoda