http://blogs.sitepointstatic.com/examples/tech/filedrag/1/index.html

'JavaScript' 카테고리의 다른 글

Simple JavaScript Inheritance  (2) 2012.01.02
JSONP로 데이타 처리하기.  (1) 2011.12.12
callback.call()에 대해서  (0) 2011.11.10
Posted by altvirus
,

Mouse Wheel

JavaScript/jQuery 2012. 11. 27. 21:02

http://brandonaaron.net/code/mousewheel/demos

'JavaScript > jQuery' 카테고리의 다른 글

jQuery Carousel - modular  (2) 2012.11.27
has(), is()  (0) 2012.07.22
jQuery 플러그인과 그 메서드들을 만들기 위한 기본구조..  (0) 2012.01.01
jQuery 플러그인들 수집  (0) 2011.12.28
jQuery Template  (0) 2011.12.27
jQuery() 함수 인자들 정리  (0) 2011.11.07
Posted by altvirus
,





http://www.gougouzian.fr/projects/jquery/moodular/



moodular_carousel.html




<ul id="demo">
   
<li>
       
<img src="img/photo01.jpg" />
       
   
</li>
   
<li>
       
<img src="img/photo02.jpg" />
       
   
</li>
   
<li>
       
<img src="img/photo03.jpg" />
       
   
</li>
   
<li>
       
<img src="img/photo04.jpg" />
       
   
</li>
   
<li>
       
<img src="img/photo05.jpg" />
       
   
</li>
   
<li>
       
<img src="img/photo06.jpg" />
       
   
</li>
</ul>

The CSS is :

#demo, #demo li { margin:0; padding:0; width:900px; height:495px; list-style:none; }
#demo { overflow: hidden; }
       
#demo li { float:left; }

The JavaScript is :

jQuery('#demo').moodular({
        effects
: 'left',
        controls
: '',
       
auto: true,
        easing
: '',
        speed
: 1000,
        dispTimeout
: 3000      
});

'JavaScript > jQuery' 카테고리의 다른 글

Mouse Wheel  (0) 2012.11.27
has(), is()  (0) 2012.07.22
jQuery 플러그인과 그 메서드들을 만들기 위한 기본구조..  (0) 2012.01.01
jQuery 플러그인들 수집  (0) 2011.12.28
jQuery Template  (0) 2011.12.27
jQuery() 함수 인자들 정리  (0) 2011.11.07
Posted by altvirus
,

has(), is()

JavaScript/jQuery 2012. 7. 22. 14:07

.has(selector)

자식요소로 selector를 가진 것들로 선택범위 축소

ex) $('.title').has($(this))


http://api.jquery.com/has/





.is(selector)

선택요소의 성질이 맞는지 boolean 리턴

ex) $('#container').is(':visible')


http://api.jquery.com/is/


'JavaScript > jQuery' 카테고리의 다른 글

Mouse Wheel  (0) 2012.11.27
jQuery Carousel - modular  (2) 2012.11.27
jQuery 플러그인과 그 메서드들을 만들기 위한 기본구조..  (0) 2012.01.01
jQuery 플러그인들 수집  (0) 2011.12.28
jQuery Template  (0) 2011.12.27
jQuery() 함수 인자들 정리  (0) 2011.11.07
Posted by altvirus
,
아.. 일단 본것중에 가장 심플한 상속구현방법.. 역시 레식옹.. ;;;;

http://ejohn.org/blog/simple-javascript-inheritance/ 

(function(){

  var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;

  // The base Class implementation (does nothing)

  this.Class = function(){};

  

  // Create a new Class that inherits from this class

  Class.extend = function(prop) {

    var _super = this.prototype;

    

    // Instantiate a base class (but only create the instance,

    // don't run the init constructor)

    initializing = true;

    var prototype = new this();

    initializing = false;

    

    // Copy the properties over onto the new prototype

    for (var name in prop) {

      // Check if we're overwriting an existing function

      prototype[name] = typeof prop[name] == "function" && 

        typeof _super[name] == "function" && fnTest.test(prop[name]) ?

        (function(name, fn){

          return function() {

            var tmp = this._super;

            

            // Add a new ._super() method that is the same method

            // but on the super-class

            this._super = _super[name];

            

            // The method only need to be bound temporarily, so we

            // remove it when we're done executing

            var ret = fn.apply(this, arguments);        

            this._super = tmp;

            

            return ret;

          };

        })(name, prop[name]) :

        prop[name];

    }

    

    // The dummy class constructor

    function Class() {

      // All construction is actually done in the init method

      if ( !initializing && this.init )

        this.init.apply(this, arguments);

    }

    

    // Populate our constructed prototype object

    Class.prototype = prototype;

    

    // Enforce the constructor to be what we expect

    Class.prototype.constructor = Class;


    // And make this class extendable

    Class.extend = arguments.callee;

    

    return Class;

  };

})();


요로케 쓰자....

var Person = Class.extend({

  init: function(isDancing){

    this.dancing = isDancing;

  },


  dance: function(){

    return this.dancing;

  }

});



var Ninja = Person.extend({

  init: function(){

    this._super( false );

  },

  dance: function(){

    // Call the inherited version of dance()

    return this._super();

  },

  swingSword: function(){

    return true;

  }

});




var p = new Person(true);

p.dance(); // => true


var n = new Ninja();

n.dance(); // => false

n.swingSword(); // => true


// Should all be true

p instanceof Person && p instanceof Class &&

n instanceof Ninja && n instanceof Person && n instanceof Class



http://codefactory.kr/2011/12/18/jquerys-best-friends/ 

 

'JavaScript' 카테고리의 다른 글

HTML5 File Drag & Drop API  (0) 2013.10.30
JSONP로 데이타 처리하기.  (1) 2011.12.12
callback.call()에 대해서  (0) 2011.11.10
Posted by altvirus
,
그냥 내 마음대로 만들어본거다. $('#id')처럼대상객체가 하나라면 상관없겠지만 $('.class')처럼 여러개라면 내부에서 적당히 루프를 돌려줘야하고 그 각각의 레퍼런스를 유지하는것도 꽤나 성가시다.

일단 이렇게 기본을 시작해보자.
분명히 다듬어야 할 부분이 많이 생길꺼다.. -_-; 적어도 다음 코드만 봤을때는 의도대로 동작이 되는구나..

<div class="test" id="XX"></div>

<div class="test" id="YY"></div>

<script>

$.fn.plug = function(){

var o = this;

o.html("AA");

o.aa = function(){

alert(o===this); // true

o.each(function(i, k){

$(k).html(i+"th : "+k.id);

});

}

return o;

}


var x = $('.test').plug();

</script>

<input type="button" onclick="x.aa()">






 

'JavaScript > jQuery' 카테고리의 다른 글

Mouse Wheel  (0) 2012.11.27
jQuery Carousel - modular  (2) 2012.11.27
has(), is()  (0) 2012.07.22
jQuery 플러그인들 수집  (0) 2011.12.28
jQuery Template  (0) 2011.12.27
jQuery() 함수 인자들 정리  (0) 2011.11.07
Posted by altvirus
,

'JavaScript > jQuery' 카테고리의 다른 글

Mouse Wheel  (0) 2012.11.27
jQuery Carousel - modular  (2) 2012.11.27
has(), is()  (0) 2012.07.22
jQuery 플러그인과 그 메서드들을 만들기 위한 기본구조..  (0) 2012.01.01
jQuery Template  (0) 2011.12.27
jQuery() 함수 인자들 정리  (0) 2011.11.07
Posted by altvirus
,

jQuery Template

JavaScript/jQuery 2011. 12. 27. 18:41

http://api.jquery.com/category/plugins/templates/ 



<!DOCTYPE html>

<html>

<head>

  <script src="http://code.jquery.com/jquery-latest.min.js"></script>

  <script src="http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js"></script>

</head>

<body>

  

<script id="movieTemplate" type="text/x-jquery-tmpl"> 

    <li>

        Title: ${Name} ${index}

        {{each Languages}}

            ${$index + 1}: <em>${$value}. </em>

        {{/each}}

    </li>

</script>


<ul id="movieList"></ul>


<script>

var movies = [

    { Name: "Meet Joe Black", Languages: ["French"] },

    { Name: "The Mighty", Languages: [] },

    { Name: "City Hunter", Languages: ["Mandarin", "Cantonese"] }

];


/* Render the template with the movies data */

$( "#movieTemplate" ).tmpl( movies )

    .appendTo( "#movieList" );

</script>


</body>

</html>





'JavaScript > jQuery' 카테고리의 다른 글

Mouse Wheel  (0) 2012.11.27
jQuery Carousel - modular  (2) 2012.11.27
has(), is()  (0) 2012.07.22
jQuery 플러그인과 그 메서드들을 만들기 위한 기본구조..  (0) 2012.01.01
jQuery 플러그인들 수집  (0) 2011.12.28
jQuery() 함수 인자들 정리  (0) 2011.11.07
Posted by altvirus
,
크로스 도메인 문제로 다른 도메인간 AJAX(json)사용이 안된다. 이때 JSONP를 쓰자.
그냥 PHP코드를 예로 들어서..

서버1

jQuery.getJSON("http://altvirus.com/jsonp.php?callback=?", 

function(data) {

alert(data.b);

});

 

서버2 - altvirus.com/jsonp.php

<?

$arr = array('a'=>'XX', 'b'=>100);

$jsonData = json_encode($arr);

echo $_GET['callback'] . '(' . $jsonData . ');';

?>


이렇게 하고 서버 1쪽을 실행하면 된다.
 

'JavaScript' 카테고리의 다른 글

HTML5 File Drag & Drop API  (0) 2013.10.30
Simple JavaScript Inheritance  (2) 2012.01.02
callback.call()에 대해서  (0) 2011.11.10
Posted by altvirus
,
http://builds.appcelerator.com.s3.amazonaws.com/index.html

 

그냥 여기 가서 최신의 Titanium SDK를 받자. -_-;
이거 설정 짜증나 죽는줄 알았다. ;; ㅠ

그리고 IDE를 재실행해주자~~ 
Posted by altvirus
,