1 | <!--{* |
---|
2 | * This file is part of EC-CUBE |
---|
3 | * |
---|
4 | * Copyright(c) 2000-2011 LOCKON CO.,LTD. All Rights Reserved. |
---|
5 | * |
---|
6 | * http://www.lockon.co.jp/ |
---|
7 | * |
---|
8 | * This program is free software; you can redistribute it and/or |
---|
9 | * modify it under the terms of the GNU General Public License |
---|
10 | * as published by the Free Software Foundation; either version 2 |
---|
11 | * of the License, or (at your option) any later version. |
---|
12 | * |
---|
13 | * This program is distributed in the hope that it will be useful, |
---|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
16 | * GNU General Public License for more details. |
---|
17 | * |
---|
18 | * You should have received a copy of the GNU General Public License |
---|
19 | * along with this program; if not, write to the Free Software |
---|
20 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
21 | *}--> |
---|
22 | <!-- ▼新着情報 --> |
---|
23 | |
---|
24 | <section id="news_area"> |
---|
25 | <h2 class="title_block">新着情報</h2> |
---|
26 | <ul class="newslist"> |
---|
27 | <!--{section name=data loop=$arrNews max=3}--> |
---|
28 | <li> |
---|
29 | <a #windowcolumn href="javascript:getNewsDetail(<!--{$arrNews[data].news_id}-->);"> |
---|
30 | <span class="news_title"><!--{$arrNews[data].news_title|h}--></span></a><br /> |
---|
31 | <span class="news_date"><!--{$arrNews[data].news_date_disp|date_format:"%Y年 %m月 %d日"}--></span> |
---|
32 | </li> |
---|
33 | <!--{/section}--> |
---|
34 | </ul> |
---|
35 | |
---|
36 | <!--{if $newsCount > 3}--> |
---|
37 | <div class="btn_area"> |
---|
38 | <p><a href="javascript: void(0);" class="btn_more" id="btn_more_news" onClick="getNews(3); return false;">もっとみる(+3件)</a></p> |
---|
39 | </div> |
---|
40 | <!--{/if}--> |
---|
41 | </section> |
---|
42 | <!-- ▲新着情報 --> |
---|
43 | |
---|
44 | |
---|
45 | <script> |
---|
46 | var newsPageNo = 2; |
---|
47 | |
---|
48 | function getNews(limit) { |
---|
49 | $.mobile.pageLoading(); |
---|
50 | var i = limit; |
---|
51 | |
---|
52 | $.ajax({ |
---|
53 | url: "<!--{$smarty.const.HTTP_URL}-->frontparts/bloc/news.php", |
---|
54 | type: "POST", |
---|
55 | data: "mode=getList&pageno="+newsPageNo+"&disp_number="+i, |
---|
56 | cache: false, |
---|
57 | dataType: "json", |
---|
58 | error: function(XMLHttpRequest, textStatus, errorThrown){ |
---|
59 | alert(textStatus); |
---|
60 | $.mobile.pageLoading(true); |
---|
61 | }, |
---|
62 | success: function(result){ |
---|
63 | for (var j = 0; j < i; j++) { |
---|
64 | if (result[j] != null) { |
---|
65 | var news = result[j]; |
---|
66 | var maxCnt = $("#news_area ul.newslist li").length - 1; |
---|
67 | var newsEl = $("#news_area ul.newslist li").get(maxCnt); |
---|
68 | newsEl = $(newsEl).clone(true).insertAfter(newsEl); |
---|
69 | maxCnt++; |
---|
70 | |
---|
71 | //件名をセット |
---|
72 | $($("#news_area ul.newslist li a span.news_title").get(maxCnt)).text(news.news_title); |
---|
73 | |
---|
74 | //リンクをセット |
---|
75 | $($("#news_area ul.newslist li a").get(maxCnt)).attr("href", "javascript:getNewsDetail(" + news.news_id + ");"); |
---|
76 | |
---|
77 | //年月をセット |
---|
78 | var newsDateDispArray = news.news_date_disp.split("-"); //ハイフンで年月日を分解 |
---|
79 | var newsDateDisp = newsDateDispArray[0] + "年 " + newsDateDispArray[1] + "月 " + newsDateDispArray[2] + "日"; |
---|
80 | $($("#news_area ul.newslist li span.news_date").get(maxCnt)).text(newsDateDisp); |
---|
81 | } |
---|
82 | } |
---|
83 | |
---|
84 | //すべての新着情報を表示したか判定 |
---|
85 | var newsPageCount = result.news_page_count; |
---|
86 | if (parseInt(newsPageCount) <= newsPageNo) { |
---|
87 | $("#btn_more_news").hide(); |
---|
88 | } |
---|
89 | |
---|
90 | newsPageNo++; |
---|
91 | |
---|
92 | $.mobile.pageLoading(true); |
---|
93 | } |
---|
94 | }); |
---|
95 | } |
---|
96 | |
---|
97 | var loadingState = 0; |
---|
98 | function getNewsDetail(newsId) { |
---|
99 | if (loadingState == 0) { |
---|
100 | $.mobile.pageLoading(); |
---|
101 | loadingState = 1; |
---|
102 | $.ajax({ |
---|
103 | url: "<!--{$smarty.const.HTTP_URL}-->frontparts/bloc/news.php", |
---|
104 | type: "GET", |
---|
105 | data: "mode=getDetail&news_id="+newsId, |
---|
106 | cache: false, |
---|
107 | async: false, |
---|
108 | dataType: "json", |
---|
109 | error: function(XMLHttpRequest, textStatus, errorThrown){ |
---|
110 | alert(textStatus); |
---|
111 | $.mobile.pageLoading(true); |
---|
112 | loadingState = 0; |
---|
113 | }, |
---|
114 | success: function(result){ |
---|
115 | if (result[0] != null) { |
---|
116 | var news = result[0]; |
---|
117 | var maxCnt = 0; |
---|
118 | |
---|
119 | //件名をセット |
---|
120 | $($("#windowcolumn dl.view_detail dt a").get(maxCnt)).text(news.news_title); |
---|
121 | if (news.news_url != null) { |
---|
122 | $($("#windowcolumn dl.view_detail dt a").get(maxCnt)).attr("href", news.news_url); |
---|
123 | } else { |
---|
124 | $($("#windowcolumn dl.view_detail dt a").get(maxCnt)).attr("href", "#"); |
---|
125 | } |
---|
126 | |
---|
127 | //年月をセット |
---|
128 | //var newsDateDispArray = news.news_date_disp.split("-"); //ハイフンで年月日を分解 |
---|
129 | //var newsDateDisp = newsDateDispArray[0] + "年 " + newsDateDispArray[1] + "月 " + newsDateDispArray[2] + "日"; |
---|
130 | //$($("#windowcolumn dl.view_detail dt").get(maxCnt)).text(newsDateDisp); |
---|
131 | |
---|
132 | //コメントをセット |
---|
133 | $("#newsComment").text(news.news_comment); |
---|
134 | } |
---|
135 | |
---|
136 | $.mobile.changePage('#windowcolumn', 'slideup'); |
---|
137 | //ダイアログが開き終わるまで待機 |
---|
138 | setTimeout( function() { |
---|
139 | loadingState = 0; |
---|
140 | $.mobile.pageLoading(true); |
---|
141 | }, 1000); |
---|
142 | |
---|
143 | } |
---|
144 | }); |
---|
145 | } |
---|
146 | } |
---|
147 | </script> |
---|