반응형
블로그 이미지
개발자로서 현장에서 일하면서 새로 접하는 기술들이나 알게된 정보 등을 정리하기 위한 블로그입니다. 운 좋게 미국에서 큰 회사들의 프로젝트에서 컬설턴트로 일하고 있어서 새로운 기술들을 접할 기회가 많이 있습니다. 미국의 IT 프로젝트에서 사용되는 툴들에 대해 많은 분들과 정보를 공유하고 싶습니다.
솔웅

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리


반응형

Construction of the window by the PHP server


이전 글에서 다룬 예제에서 조금 더 나아가서 디스플레이 될 윈도우를 생성하는 소스를 가지고 있는 (같은 서버 내에서) PHP page로 링크럴 걸 경우에 대해 알아보겠습니다.


Index.html file that contains the first window


<!DOCTYPE html>

<html> 

<head> 

  <meta name=viewport content="user-scalable=no,width=device-width" />

  <link rel=stylesheet href=jquery.mobile/jquery.mobile.css />

  <script src=jquery.js></script>

  <script src=jquery.mobile/jquery.mobile.js></script>

</head> 


<body> 


<div data-role=page id=home>

  <div data-role=header>

    <h1>Home</h1>

  </div>


  <div data-role=content>

    <p> Window content 1 </p>

    <a href=action.php> Goto window 2 built with action.php </a>

  </div>

</div>


</body>

</html>



action.php file constructing the second window


<?
  $html = "";
  $html .= "<div data-role=page data-add-back-btn=true>";
  $html .=   "<div data-role=header>";
  $html .=     "<h1>Window 2</h1>";
  $html .=   "</div>";
  $html .=   "<div data-role=content>Window content 2</div>";
  $html .= "</div>";
  echo utf8_encode ($html);
?>


jQuery Mobile은 action.php file안에 include 된 두번째 윈도우를 retrieve 하기 위해 Ajax를 사용할 겁니다. 이를 위해 우리는 반드시 utf8_encode ()를 사용해야 합니다.


만약 server 코드가 여러개의 윈도우를 return 한다면 오직 첫번째 윈도우만 윈도우들의 stream 안에 놓여지게 될 겁니다.


action2.php


convention14.html



Link to another HTML page located on another server


링크를 같은 서버가 아니라 다른 서버로 즉 href attribute 가 external URL이 되는 경우도 있습니다. 이 경우는 full URL 을 사용하겠죠. (http://로 시작하는). 이 경우에는 이전의 페이지 대신에 새로운 페이지가 display 될 겁니다. (jQuery Mobile 의 windows flow 와 맞지 않게 됩니다.)


Link to http://amazon.com


<!DOCTYPE html>

<html> 

<head> 

  <meta name=viewport content="user-scalable=no,width=device-width" />

  <link rel=stylesheet href=jquery.mobile/jquery.mobile.css />

  <script src=jquery.js></script>

  <script src=jquery.mobile/jquery.mobile.js></script>

</head> 


<body> 


<div data-role=page id=home>

  <div data-role=header>

    <h1>Home</h1>

  </div>


  <div data-role=content>

    <p> Window content 1 </p>

    <a href=http://amazon.com> Goto Amazon </a>

  </div>

</div>


</body>

</html>




convention15.html



이 링크를 클릭하면 Amazon.com page가 open 될 겁니다.





Disable the loading of an HTML page with Ajax



디폴트로 href attribute의 value는 jQuery Mobile이 만드는 Ajax call 에서는 같은 서버의 HTML page를 가리킵니다. 이렇게 해서 어플리케이션 윈도우의 flow 안에서 HTML 페이지들을 표시하게 되고 그래서 두번째 페이지에 있는 Back button을 누르면 다시 첫번째 페이지로 돌아갈 수 있게 됩니다.



It is possible, indicating certain attributes in the link, to change this behavior.

이 behavior를 변경하기 위해 링크의 특정 attribute들을 수정 할 수 있습니다.


  • data-ajax="false"로 하면  Ajax call 을 만들지 않습니다. 새로운 HTML 페이지는 이전의 페이지들을 모두 lost 하게 되죠.
  • rel="external"data-ajax="false" 와 비슷합니다.

  • target="a_value"라고하면 새로운 브라우저를 엽니다.


이런 메카니즘을 이용하는것은 아주 드믑니다. 왜냐하면 여러 페이지들을 Ajax 에 의해서 한 HTML page 처럼 사용하는 디폴트 방법이 훨씬 유용하기 때문입니다.


Dialog windows


여기서는 다른 HTML 페이지에서 layered window 가 정의 될 수 있다는 걸 보여 드리겠습니다.


Index.html file containing the first window


<!DOCTYPE html>

<html> 

<head> 

  <meta name=viewport content="user-scalable=no,width=device-width" />

  <link rel=stylesheet href=jquery.mobile/jquery.mobile.css />

  <script src=jquery.js></script>

  <script src=jquery.mobile/jquery.mobile.js></script>

</head> 


<body> 


<div data-role=page id=home>

  <div data-role=header>

    <h1>Home</h1>

  </div>


  <div data-role=content>

    <p> Window content 1 </p>

    <a href=index2.html data-rel=dialog data-transition=pop> 

      Goto window 2 located in an another HTML page </a>

  </div>

</div>


</body>

</html>



Index2.html file containing the second window


<!DOCTYPE html>

<html> 

<head> 

  <meta http-equiv=Content-Type content=text/html;charset=iso-8859-1 />

  <link rel=stylesheet href=jquery.mobile/jquery.mobile.css />

  <script src=jquery.js></script>

  <script src=jquery.mobile/jquery.mobile.js></script>

</head> 


<body> 


<div data-role=page id=win2>

  <div data-role=header>

    <h1>Window 2</h1>

  </div>


  <div data-role=content>

    <p> Window content 2</p>

  </div>

</div>


</body>

</html>



이 dialog window는 첫번째 윈도우에서 링크를 클릭하면 열립니다.





convention161.html


convention162.html


반응형

큰 바위 얼굴을 찾아서....

2012. 10. 9. 04:31 | Posted by 솔웅


반응형

그동안 개발해오던 모바일 앱이 지지난 주 on production 했거든.


토요일에 나와서 근무했었는데 그 대신 지난주 금요일에 쉬었어.

마침 단풍 시즌이라 단풍으로 유명하다는 뉴 햄프셔의 White Mountains 으로 가기로 했어.


White Mountains 에서 제일 높은 산인 Mt. Washington 에는 세계에서 제일 오래된 산악 관광 열차(cog railways)가 있다고 해서 그걸 타러 갔지.


목표는 거기였지만 내 가슴을 더 설레게 만들었던건...

Mt. Washington 근처에 있는 큰바위 얼굴이야.


어렸을 때 교과서에 나온 짧은 소설인데 그거 읽고 많이 감동 받았지...


그 소설의 제목은 영어로 "The Great Carbuncle" 이라고 하던데 작가는 주홍글씨를 썼던 Nathaniel Hawthorne 이었지 아마...


실제 그 바위의 이름은 Old man of the mountain 이야.


아쉽게도 그 큰바위 얼굴은 2003년도에 무너졌어.





알고는 있었지만 꼭 그 바위가 있어야만 되는건 아니야.

어린 내게 큰 감동과 꿈을 주었던 그 곳에 갈 수 있다는게 설레는 일이지...



지금은 무너져서 그때의 얼굴 형체는 사라졌지만....


한번도 보지도 못했던 그 큰 바위를 상상하면서 뭔가 다짐도 해보고 감동도 받아보고 미래도 그려보게 했던 나의 어린 시절하고 더 가까와 지고 싶어...


그래서 가고 싶었어...




지금은 산 밑에 저런 조형물을 세워서 잘 각도를 맞춰 보면 그 때의 큰 바위 얼굴을 볼 수 있도록 해 놨어....


그날 만났던 한 백인 아줌마는 1990년대에 왔을 때는 그 얼굴이 그대로 있었다고 말하면서 아쉬워 하더라구.


거기 갔더니 이 큰바위 얼굴을 기리는 시 한편이 있더라구.


Daniel Webster

Men hang out their signs
indicative of their respective trades.
Shoemakers hang out a gigantic shoe;
Jewelers, a monster watch;
even the dentist hangs out a gold tooth;

but up in the Franconia Mountains
God Almighty
has hung out a sign to show that in New England,
He makes men.




이제 다시 어렸을 때 처럼 큰 꿈을 꿀 수 있을 것 같애...

반응형


반응형

jQuery Mobile에서는 두가지 방법으로 다른 페이지들과 연결을 하는데요.

첫번째는 <a> links attributes 를 사용해서 다른 페이지들과 연결을 하는 방법이 있구요.

두번째는 $.mobile object 로 정의된 changePatge() 메소드를 사용하는 방법이 있습니다.


이 두가지 방법과 관련해서 공부해 보겠습니다.


Manage the attributes of links



윈도우(페이지)에서 다른 윈도우로 transition 하는 것은 a link 를 통해서 이루어 집니다. 버튼 같은데에 이 a link를 적용해서 사용하거나 하죠. 이 link의 attributes들은 클릭 했을 때 어떤 동작이 일어나도록 합니다.


Link to an email address or phone number


아주 간단한 예제를 보죠. 우리의 애플리케이션 창에서 email, SMS, 전화걸기 등을 할 수 있도록 하겠습니다. <a> link의 href attribute 값을 지정함으로서 이러한 action들이 이루어 지도록 할 수 있습니다.


Links to an email address and telephone number


<!DOCTYPE html>

<html> 

<head> 

  <meta name=viewport content="user-scalable=no,width=device-width" />

  <link rel=stylesheet href=jquery.mobile/jquery.mobile.css />

  <script src=jquery.js></script>

  <script src=jquery.mobile/jquery.mobile.js></script>

</head> 


<body> 


<div data-role=page id=home>

  <div data-role=header>

    <h1>Home</h1>

  </div>


  <div data-role=content>

    <p> Talk to Eric Sarrion : </p>

    <a href=mailto:ericsarrion@gmail.com>By mail</a><br /><br />

    <a href=tel:0625570924>By phone</a><br /><br />

    <a href=sms:0625570924>By SMS</a><br /><br />

  </div>

</div>


</body>





convention11.html


Link to a window in the same HTML page


이건 이전부터 많이 사용하던 고전적인 방법이죠.  링크에 href를 넣는 겁니다. 새로운 윈도우에 대해서는 <div> element의 id 를 사용하구요. 아까 그 href에는 "#" character를 넣습니다. (eg href="#win2")


An HTML page containing two windows


<!DOCTYPE html>

<html> 

<head> 

  <meta name=viewport content="user-scalable=no,width=device-width" />

  <link rel=stylesheet href=jquery.mobile/jquery.mobile.css />

  <script src=jquery.js></script>

  <script src=jquery.mobile/jquery.mobile.js></script>

</head> 


<body> 


<div data-role=page id=home>

  <div data-role=header>

    <h1>Home</h1>

  </div>


  <div data-role=content>

    <p> Window content 1 </p>

    <a href=#win2> Goto window 2 located in the same page </a>

  </div>

</div>


<div data-role=page id=win2 data-add-back-btn=true>

  <div data-role=header>

    <h1>Window 2</h1>

  </div>


  <div data-role=content>

    <p> Window content 2 </p>

  </div>

</div>


</body>

</html>



convention12.html


Link to a window in another HTML page on the same server


다른 HTML 페이지가 같은 서버의 다른 위치에 있다면 jQuery Mobile 은 내부적으로 Ajax call 을 사용해서 다른 HTML 의 내용을 load 합니다. 두개의 파일은 반드시 같은 서버에 있어야 합니다. 그렇지 않으면 jQuery Mobile에 의한 Ajax call 이 제대로 작동되지 않을 겁니다.


Index.html file that contains the first window


<!DOCTYPE html>

<html> 

<head> 

  <meta name=viewport content="user-scalable=no,width=device-width" />

  <link rel=stylesheet href=jquery.mobile/jquery.mobile.css />

  <script src=jquery.js></script>

  <script src=jquery.mobile/jquery.mobile.js></script>

</head> 


<body> 


<div data-role=page id=home>

  <div data-role=header>

    <h1>Home</h1>

  </div>


  <div data-role=content>

    <p> Window content 1 </p>

    <a href=index2.html> Goto window 2 located in index2.html </a>

  </div>

</div>


</body>

</html>


index2.html file containing the second window


<!DOCTYPE html>

<html> 

<head> 

  <meta http-equiv=Content-Type content=text/html;charset=iso-8859-1 />

  <link rel=stylesheet href=jquery.mobile/jquery.mobile.css />

  <script src=jquery.js></script>

  <script src=jquery.mobile/jquery.mobile.js></script>

</head> 


<body> 


<div data-role=page id=win2 data-add-back-btn=true>

  <div data-role=header>

    <h1>Window 2</h1>

  </div>


  <div data-role=content>

    <p> Window content 2</p>

  </div>

</div>


</body>

</html>



convention131.html


convention132.html

(Firefox 브라우저에서 테스트 해 보세요.)


여기서 주의해야 할 점은 Ajax 에 의해 로드되는 페이지의 encoding을 가리키기 위해 <meta> tag를 사용했다는 겁니다. 별도의 HTML 파일에 페이지가 있게 되면 jQuery Mobile에 의해 내부적으로 만들어지는 Ajax request는 디폴트로 UTF-8을 사용합니다. iso-8859-1 encoding을 사용하면 외국어를 사용할 때 활용될 수 있습니다.





링크를 클릭하면 두번째 HTML 페이지가 나타납니다.





어떻게 jQuery Mobile이 새로운 HTML 페이지를 로딩하는지를 이해하기 위해 firfox에 있는 Firebug를 사용해보도록 하겠습니다.


클릭하기 전의 HTML 은 아래와 같습니다.




클릭하고 난 후의 HTML 은 아래와 같습니다.



두번째 <div> element (with id win2)가 HTML 페이지의 DOM tree elements의 한 부분이 되는 것을 볼 수 있습니다. 이것은 index2.html page 안에 포함돼 있는 두번째 윈도우와 연관이있습니다. jQuery Mobile이 사용하는 Ajax technique들에 의해 내부적으로 일어난 일입니다. 그렇기 때문에 첫번째 클릭이 일어나면 내용을 표시하기 위해 약간의 시간이 더 걸리게 되는 겁니다. (서버로부터 새로운 HTML 코드를 새로 retrieve 하고 이것을 현재 표시돼 있는 HTML code에 insert 하기 위한 시간이죠.) 이제 새로운 HTML 코드는 final page로 서 로드 됩니다. 이제 이후에 일어나는 클릭에 대해서는 이러한 시간을 필요로 하지 않습니다. 그러니까 좀 더 빨리 화면이 표시 될 수 있겠죠.


두번째 HTML 페이지 내부에 여러개의 윈도우가 있다면 이 경우에는 첫번째 윈도우만 insert 되게 됩니다.


이제 다시 Back button을 사용해서 이전 페이지로 돌아가 보죠. Firebug에 표시되는 HTML code는 아래와 같습니다.



이제 DOM tree에서 두번째 윈도우가 사라진 걸 볼 수 있습니다. jQuery Mobile은 메모리 공간을 절약하기 위해 그 부분을 메모리로부터 remove 합니다. 만약 이 경우에도 메모리에 계속 저장돼 있게 하려면 <div> element안에 data-dom-cache=true attribute 를 넣어주면 됩니다.


Index2.html file containing the second window, which will be stored in memory despite its disappearance of the display


<!DOCTYPE html>

<html> 

<head> 

  <meta http-equiv=Content-Type content=text/html;charset=iso-8859-1 />

  <link rel=stylesheet href=jquery.mobile/jquery.mobile.css />

  <script src=jquery.js></script>

  <script src=jquery.mobile/jquery.mobile.js></script>

</head> 


<body> 


<div data-role=page id=win2 data-add-back-btn=true data-dom-cache=true>

  <div data-role=header>

    <h1>Window 2</h1>

  </div>


  <div data-role=content>

    <p> Window content 2 </p>

  </div>

</div>


</body>

</html>









반응형