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

최근에 올라온 글

최근에 달린 댓글

최근에 받은 트랙백

글 보관함

카테고리


반응형

툴바를 생성하는 것은 jQuery method들을 사용합니다. 그리고 별도의 utility method들도 jQuery Mobile에 의해 추가 됐습니다. 예를 들어 네비게이션 바의 관리를 좀 더 용이하게 하기 위해 navbar () method를 추가했죠. Navigation bars 들은 표준 navbar component와 연계 돼 있습니다.



Dynamically create a toolbar


툴바에는 두가지 타입이 있습니다. 바로 header (top of the window) and footer (bottom of the window) 가 있죠. toolbar를 dynamic  하게 생성하는 footer typeheader toolbars 들은 HTML 안에 포함이 되게 되는데요 header toolbars 에는 이전 페이지로 돌아가도록 하는 Back button 이 있을 수 있습니다.


Dynamic creation of a footer toolbar


<!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 </p>

  </div>

</div>


</body>

</html>


<script>


var html = "";

html += "<div data-role=footer data-position=fixed>";

html +=   "<h1> Footer part </h1>";

html += "</div>";


$("#home").append (html);


</script>


tistory563_01.html






반응형


반응형

이제 대선도 끝났고..

한국 소식 보다 제가 살고 있는 지역 소식에 더 관심을 가지려고 합니다.


오늘은 Providence Journal 인터넷 판에 로드 아일랜드의 일자리에 대한 기사가 탑으로 실렸네요.




Reinvent RI: Where the young people go


December 23, 2012 9:53 am
By G. Wayne Miller



PROVIDENCE, R.I. -- Lauren Lapolla, 26, has traveled to Italy, Ireland, Belgium and France. During college, she spent a semester in England. After graduation, she found a job in Washington, working for an Ohio congressman, which brought her into her chosen field, public policy. She had a steady paycheck. She made many friends. Life was good. Two years ago, while visiting her parents at the family's Narragansett summer place, she decided to quit her job.


Lauren Lapolla, 26 는 이태리, 아일랜드, 벨기에 그리고 프랑드 등을 여행해 봤다. 대학생활 동안 한 학기를 영국에서 보내기도 했다. 졸업 후 그녀는 워싱턴에 일자리를 얻었다. 그녀가 공공정책 분야와 관련된 일자리를 찾았었는데 오하이오 의원실에서 근무하는 기회를 잡은 거였다. 수입도 안정적이었다. 친구들도 많이 만들고 생활은 좋았다. 2년 후, 여름에 부모를 보려고 부모가 사는 Narragansett 을 방문했을 때 일을 그만 두기로 마음 먹었다.


The Providence Journal / Bob Breidenbach

Lauren Lapolla, a health-care policy specialist in the office of Lt. Gov. Elizabeth Roberts, is an Ocean State native and decided to return to R.I. after college and a stint in D.C. But Rhode Island's poor economy has prompted some young people to leave their native state, despite their desire to stay. See more photos.



"I need to go back," she told her boss in Washington. She wanted to return to the state where she was born and raised.

She did not have a job waiting in Rhode Island, which in 2010 had entered the third year of a recession, with double-digit unemployment and an economy undergoing a painful transition from traditional manufacturing to an uncertain future.

"It was a calculated risk," Lapolla says. "And it was terrifying."

But the emotional pull was stronger than fear.

Four Rhode Island natives in their 20s who recently shared their stories struck a common theme: the Ocean State was a desirable place to grow up and remains a terrific place to live. But one way or another, their home state's economy has proved decisive in where they have planted their adult roots.


"고향으로 돌아가야 겠습니다. " 그녀는 워싱턴의 상관에게 말했다. 그녀가 태어나고 자란 주로 돌아가기를 원한거였다. 로드 아일랜드에 그녀가 일할 일자리가 정해진것은 아니었다. 2010년은 경제 불황이 일어난지 3년째 되는 해였다. 실업률이 두자리 숫자였고 경제상황은 안 좋았다. 전통적인 생산직 일자리부터 모두 미래가 불투명했다.

"그 결정은 확실히 리스크를 감수해야 했어요. 아주 겁났었죠." 라고 Lapolla 는 말한다.

하지만 그 두려움 보다 그리움이 더 앞섰다.

로드 아일랜드 출생의 20대가 최근 그들의 공통의 주제에 대해 얘기를 나눴다. 이 Ocean State (로드 아일랜드 주의 별명)는 자라기에도 좋은 곳이고 여생을 보내기에 정말 훌륭한 곳입니다. 그리고 그들은 어떠한 이유로 그들의 성년기를 이곳에서 보내기로 결정을 했습니다.


IN THE PAPER (종이판 신문)

SUNDAY: We profile four 20-something Rhode Island natives who love the Ocean State. But one way or another, the state’s economy has proved decisive in where they've planted their adult roots. A1.

4명의 로드아일랜드 출신이면서 이곳에서 살고 있는 20대를 만나봤습니다. 그리고 그들은 나름대로의 이유로 이곳에서 성년기를 뿌리 내리겠다고 결심했습니다. A1



======= o ============ o ============= o ===========


어제 기사에는 작년에 로드 아일랜드를 떠난 사람이 들어온 사람들보다 훨씬 더 많아는 기사가 났습니다. 그리고 떠난 사람들의 평균 수입이 들어온 사람들의 평균 수입보다 훨씬 더 높다는 통계도 소개 했구요.

로드 아일랜드의 경제 상황이 안 좋은 인식이 너무 퍼지니까 지역 신문에서 떠나지 않고 이곳에 계속 살고 있는 젊은 이들을 소개하는 기획 기사를 준비 했나 봅니다.

댓글을 보니까 이곳 로드 아일랜드가 타 주에 비해서 세금이나 공과금이 너무 비싸다는 불만의 글 들이 많네요.


반응형

accordion menu 생성 예제들

2012. 12. 23. 22:20 | Posted by 솔웅


반응형
Examples of manipulation of accordion menus



Load the contents of an accordion menu by Ajax


메뉴를 오픈할 때 Ajax에 의해 각 accordion menu 의 내용을 retrieve 하는 예제를 만들겠습니다. 만약 현재 content 가 empty 일 경우 retrieve 됩니다. 그러니까 매번 메뉴가 open 될 때마다 이 로직이 동작하는 건 아니죠.


Get the contents of the accordion menus by Ajax


<!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>

    <div id=id1 data-role=collapsible data-collapsed=true>

      <h1>Menu 1 : Click to open / close</h1>

    </div>

    <div id=id2 data-role=collapsible data-collapsed=true>

      <h1>Menu 2 : Click to open / close</h1>

    </div>

  </div>

</div>


</body>

</html>


<script>


$("#id1, #id2").bind ("collapsiblecreate", function ()

{

  $("a.ui-collapsible-heading-toggle", this).bind ("click", function (event)

  {

    var h1 = $(this).closest ("h1");

    var content = h1.siblings (".ui-collapsible-content");

    var div = $(this).closest (".ui-collapsible");

    if (content.is (".ui-collapsible-content-collapsed") && 

        $.trim (content.html ()) == "")

    {

      $.ajax (

      

        url : "action.php", 

        data : { menu : div.attr ("id") },

        complete : function (xhr, result)

        {

          if (result != "success") return;

          var response = xhr.responseText;

          $(content).append (response);

        }

      });     

    }

  });

});


</script>


각 메뉴는 HTML 안에 내용이 비어져 있는 상태로 생성됩니다. 그리고  ui-collapsible-heading-toggle class 의 <a> element 있어서 menu 타이틀을 클릭 할 수 있습니다. 이 element 에서 content (of ui-collapsible-content class) 에 해당하는 <div> element retrieve 하기 위해 DOM 을 살펴 보게 되죠. 그리고 나서 <div>는 메뉴 타이틀과 content 를 포함하게 됩니다. 이 때 menu 의 id 로 접근을 하게 됩니다.


또한 메뉴가 close 된 상태인지 그리고 content 가 empty 인지 아닌지도 알아낼 수 있습니다. Ajax call 은 메뉴가 close 상태 이면서 empty인 상태에서만 만들어 지거든요. ui-collapsible-content-collapsed CSS class 가 있으면 content 가 close 인 상태라는 것을 기억해 두세요. 그 클래스가 없으면 open 인 상태 입니다.


action.php file


<?
$menu = $_REQUEST["menu"];

$html = "";
if ($menu == "id1")
{
  $html .=   "<p> Paragraph 1.1 </p>";
  $html .=   "<p> Paragraph 1.2 </p>";
  $html .=   "<p> Paragraph 1.3 </p>";
}
else
{
  $html .=   "<p> Paragraph 2.1 </p>";
  $html .=   "<p> Paragraph 2.2 </p>";
  $html .=   "<p> Paragraph 2.3 </p>";
}
echo utf8_encode ($html);
?>


action27.php

tistory561_01.html


Dynamically change the accordion menu title


The accordion menu title is currently fixed. It is possible to dynamically change, eg change the title as the menu is open or closed.


Change the menu title as the menu is open or closed


<!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>

    <div id=id1 data-role=collapsible>

      <h1>Menu: closed</h1>

      <p> Paragraph 1.1 </p>

      <p> Paragraph 1.2 </p>

      <p> Paragraph 1.3 </p>

    </div>

    <div id=id2 data-role=collapsible>

      <h1>Menu: closed</h1>

      <p> Paragraph 2.1 </p>

      <p> Paragraph 2.2 </p>

      <p> Paragraph 2.3 </p>

    </div>

  </div>

</div>


</body>

</html>


<script>


$("#id1, #id2").bind ("collapsiblecreate", function ()

{

  $("a.ui-collapsible-heading-toggle").bind ("vclick", function (event)

  {

    var h1 = $(this).closest ("h1");

    if (h1.is (".ui-collapsible-heading-collapsed")) 

      $("span.ui-btn-text", h1).first ().text ("Menu: open");

    else 

      $("span.ui-btn-text", h1).first ().text ("Menu: closed");

  });

});


</script>


tistory561_02.html


menu title은 ui-btn-text class<span> element 에 insert 됩니다. 이것은  title (here <h1>). element 안에 위치하게 되죠. title 안에 여러개의 <span> elements (class ui-btn-text)가 있을 수 있습니다.이 content 는 jQuery 의 text () method에 의해 modify 됩니다.


Producing an effect at the opening and closing the accordion menu


jQuery 를 사용해서 open/closed 에 대해 visual effect를 줄 수 있습니다.  예를 들어 open 할 떄 show (1000)효과를 주고 close 할 때 hide (1000)효과를 줄 수 있습니다.


Effect at the opening and closing accordion menus


<!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>

    <div id=id1 data-role=collapsible data-collapsed=true>

      <h1>Menu 1: Click to open / close</h1>

      <p> Paragraph 1.1 </p>

      <p> Paragraph 1.2 </p>

      <p> Paragraph 1.3 </p>

    </div>

    <div id=id2 data-role=collapsible data-collapsed=true>

      <h1>Menu 2: Click to open / close</h1>

      <p> Paragraph 2.1 </p>

      <p> Paragraph 2.2 </p>

      <p> Paragraph 2.3 </p>

    </div>

  </div>

</div>


</body>

</html>


<script>


$("#id1, #id2").bind ("collapsiblecreate", function ()

{

  $("a.ui-collapsible-heading-toggle").bind ("vclick", function (event)

  {

    var h1 = $(this).closest ("h1");

    var content = h1.siblings (".ui-collapsible-content");

    if (content.is (".ui-collapsible-content-collapsed")) content.show (1000);

    else content.hide (1000);

  });

});


</script>


tistory561_03.html


각 accordion menu 의 title 부분을 클릭할 때 이것을 handle 할 수 있습니다. 특히 title 안에 <a> link 가 있을 때요. 이 <a> link를 통해서 우리는 ui-collapsible-content class의 <div> element 와 연관된 메뉴의 content를 얻기 위해 DOM 을 navigate 할 수 있습니다.

반응형