Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
jugyo committed Jan 26, 2012
1 parent 7cc6807 commit 26fdd09
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 34 deletions.
34 changes: 0 additions & 34 deletions views/index.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,6 @@

<script type="text/javascript" charset="utf-8">
$(function(){
$.mobile.page.prototype.options.domCache = true; // 一覧に戻った時に prefetch しないようにしている

$.archiveBookmark = function(id) {
$.mobile.changePage("/", {transition: 'none'});
$("#bookmark-" + id).fadeOut();
$.ajax({
url: '/archive',
type: 'post',
data: {id: id}
});
}

$.prefetch = function() {
$("a.bookmark").each(function() {
var that = $(this);
var url = that.attr('href');
// console.log("loadPage: " + url);
$.mobile.loadPage(url).done(function() {
// console.log(url);
that.removeClass("unloaded");
that.addClass("loaded");
});
});
}

$.refreshList = function() {
$.mobile.showPageLoadingMsg();
$("#bookmarks").load('/u', function() {
$("#bookmarks").listview('refresh');
$.mobile.hidePageLoadingMsg();
$.prefetch();
});
}

setTimeout($.refreshList, 500);
});
</script>
37 changes: 37 additions & 0 deletions views/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,43 @@
font-size: 140%;
}
</style>
<script type="text/javascript" charset="utf-8">
$(function(){
$.mobile.page.prototype.options.domCache = true; // 一覧に戻った時に prefetch しないようにしている

$.archiveBookmark = function(id) {
$.mobile.changePage("/", {transition: 'none'});
$("#bookmark-" + id).fadeOut();
$.ajax({
url: '/archive',
type: 'post',
data: {id: id}
});
}

$.prefetch = function() {
$("a.bookmark").each(function() {
var that = $(this);
var url = that.attr('href');
// console.log("loadPage: " + url);
$.mobile.loadPage(url).done(function() {
// console.log(url);
that.removeClass("unloaded");
that.addClass("loaded");
});
});
}

$.refreshList = function() {
$.mobile.showPageLoadingMsg();
$("#bookmarks").load('/u', function() {
$("#bookmarks").listview('refresh');
$.mobile.hidePageLoadingMsg();
$.prefetch();
});
}
});
</script>
</head>
<body>
<%== yield %>
Expand Down

0 comments on commit 26fdd09

Please sign in to comment.