source: branches/version-2_13-dev/data/Smarty/templates/sphone/frontparts/bloc/news.tpl @ 23419

Revision 23419, 6.8 KB checked in by pineray, 10 years ago (diff)

#2549 jQuery Mobile への依存を無くす

ローディング画像の表示をオリジナルのものへ変更.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-smarty-template; charset=UTF-8
Line 
1<!--{*
2 * This file is part of EC-CUBE
3 *
4 * Copyright(c) 2000-2013 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 news = result;
125                        var maxCnt = 0;
126
127                        //件名をセット
128                        $($("#windowcolumn dl.view_detail dt a").get(maxCnt)).text(news.news_title);
129                        if (news.news_url != null) {
130                            $($("#windowcolumn dl.view_detail dt a").get(maxCnt)).attr("href", news.news_url);
131                        } else {
132                            $($("#windowcolumn dl.view_detail dt a").get(maxCnt)).attr("href", "#");
133                        }
134
135                        //年月をセット
136                        //var newsDateDispArray = news.cast_news_date.split("-"); //ハイフンで年月日を分解
137                        //var newsDateDisp = newsDateDispArray[0] + "年 " + newsDateDispArray[1] + "月 " + newsDateDispArray[2] + "日";
138                        //$($("#windowcolumn dl.view_detail dt").get(maxCnt)).text(newsDateDisp);
139
140                        //コメントをセット(iphone4の場合、innerHTMLの再描画が行われない為、タイマーで無理やり再描画させる)
141                        setTimeout( function() {
142                            news.news_comment == null ? $("#newsComment").html("") : $("#newsComment").html(news.news_comment.replace(/\n/g,"<br />"));
143                        }, 10);
144                        $.mobile.changePage('#windowcolumn', {transition: "slideup"});
145                        //ダイアログが開き終わるまで待機
146                        setTimeout( function() {
147                            eccube.hideLoading();
148                            loadingState = 0;
149                        }, 1000);
150                    }
151                    else {
152                        eccube.hideLoading();
153                        loadingState = 0;
154                        alert('取得できませんでした。');
155                    }
156                }
157            });
158        }
159    }
160</script>
Note: See TracBrowser for help on using the repository browser.