1 | <!--{* |
---|
2 | * This file is part of EC-CUBE |
---|
3 | * |
---|
4 | * Copyright(c) 2000-2014 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 id="windowcolumn<!--{$smarty.section.data.index}-->" 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].cast_news_date|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:;" 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 | eccube.showLoading(); |
---|
50 | var i = limit; |
---|
51 | |
---|
52 | $.ajax({ |
---|
53 | url: "<!--{$smarty.const.ROOT_URLPATH}-->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 | eccube.hideLoading(); |
---|
61 | }, |
---|
62 | success: function(result){ |
---|
63 | if (result.error) { |
---|
64 | alert(result.error); |
---|
65 | } else { |
---|
66 | for (var j = 0; j < i; j++) { |
---|
67 | if (result[j] != null) { |
---|
68 | var news = result[j]; |
---|
69 | var maxCnt = $("#news_area ul.newslist li").length - 1; |
---|
70 | var newsEl = $("#news_area ul.newslist li").get(maxCnt); |
---|
71 | newsEl = $(newsEl).clone(true).insertAfter(newsEl); |
---|
72 | maxCnt++; |
---|
73 | |
---|
74 | //件名をセット |
---|
75 | $($("#news_area ul.newslist li a span.news_title").get(maxCnt)).text(news.news_title); |
---|
76 | |
---|
77 | //リンクをセット |
---|
78 | $($("#news_area ul.newslist li a").get(maxCnt)).attr("href", "javascript:getNewsDetail(" + news.news_id + ");"); |
---|
79 | |
---|
80 | //年月をセット |
---|
81 | var newsDateDispArray = news.cast_news_date.split("-"); //ハイフンで年月日を分解 |
---|
82 | var newsDateDisp = newsDateDispArray[0] + "年 " + newsDateDispArray[1] + "月 " + newsDateDispArray[2] + "日"; |
---|
83 | $($("#news_area ul.newslist li span.news_date").get(maxCnt)).text(newsDateDisp); |
---|
84 | } |
---|
85 | } |
---|
86 | |
---|
87 | //全ての新着情報を表示したか判定 |
---|
88 | var newsPageCount = result.news_page_count; |
---|
89 | if (parseInt(newsPageCount) <= newsPageNo) { |
---|
90 | $("#btn_more_news").hide(); |
---|
91 | } |
---|
92 | |
---|
93 | newsPageNo++; |
---|
94 | } |
---|
95 | eccube.hideLoading(); |
---|
96 | } |
---|
97 | }); |
---|
98 | } |
---|
99 | |
---|
100 | var loadingState = 0; |
---|
101 | function getNewsDetail(newsId) { |
---|
102 | if (loadingState == 0) { |
---|
103 | loadingState = 1; |
---|
104 | eccube.showLoading(); |
---|
105 | $.ajax({ |
---|
106 | url: "<!--{$smarty.const.ROOT_URLPATH}-->frontparts/bloc/news.php", |
---|
107 | type: "GET", |
---|
108 | data: "mode=getDetail&news_id="+newsId, |
---|
109 | cache: false, |
---|
110 | async: false, |
---|
111 | dataType: "json", |
---|
112 | error: function(XMLHttpRequest, textStatus, errorThrown){ |
---|
113 | alert(textStatus); |
---|
114 | eccube.hideLoading(); |
---|
115 | loadingState = 0; |
---|
116 | }, |
---|
117 | success: function(result){ |
---|
118 | if (result.error) { |
---|
119 | alert(result.error); |
---|
120 | eccube.hideLoading(); |
---|
121 | loadingState = 0; |
---|
122 | } |
---|
123 | else if (result != null) { |
---|
124 | var dialog = $("#news-dialog"); |
---|
125 | |
---|
126 | //件名をセット |
---|
127 | $("#news-dialog-title").remove(); |
---|
128 | if (result.news_url != null) { |
---|
129 | dialog.find(".dialog-content").append( |
---|
130 | $('<h3 id="news-dialog-title">').append( |
---|
131 | $('<a>') |
---|
132 | .attr('href', result.news_url) |
---|
133 | .attr('rel', "external") |
---|
134 | .attr('target', "_blank") |
---|
135 | .text(result.news_title) |
---|
136 | ) |
---|
137 | ); |
---|
138 | } else { |
---|
139 | dialog.find(".dialog-content").append( |
---|
140 | $('<h3 id="news-dialog-title">').text(result.news_title) |
---|
141 | ); |
---|
142 | } |
---|
143 | |
---|
144 | //本文をセット |
---|
145 | $("#news-dialog-body").remove(); |
---|
146 | if (result.news_comment != null) { |
---|
147 | dialog.find(".dialog-content").append( |
---|
148 | $('<div id="news-dialog-body">').html(result.news_comment.replace(/\n/g,"<br />")) |
---|
149 | ); |
---|
150 | } |
---|
151 | |
---|
152 | //ダイアログをモーダルウィンドウで表示 |
---|
153 | $.colorbox({inline: true, href: dialog, onOpen: function(){ |
---|
154 | dialog.show().css('width', String($('body').width() * 0.9) + 'px'); |
---|
155 | }, onComplete: function(){ |
---|
156 | eccube.hideLoading(); |
---|
157 | loadingState = 0; |
---|
158 | }, onClosed: function(){ |
---|
159 | dialog.hide(); |
---|
160 | }}); |
---|
161 | } |
---|
162 | else { |
---|
163 | eccube.hideLoading(); |
---|
164 | loadingState = 0; |
---|
165 | alert('取得できませんでした。'); |
---|
166 | } |
---|
167 | } |
---|
168 | }); |
---|
169 | } |
---|
170 | } |
---|
171 | </script> |
---|
172 | |
---|
173 | <!--{include file="`$smarty.const.SMARTPHONE_TEMPLATE_REALDIR`frontparts/dialog_modal.tpl" dialog_id="news-dialog" dialog_title="新着情報"}--> |
---|