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

Revision 23230, 6.9 KB checked in by m_uehara, 11 years ago (diff)

#2363 r23177, r23181 - r23186, r23188 - r23191, r23194, r23197, r23199 - r23218, r23220, r23223 - r23225 をマージ

  • 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
RevLine 
[19661]1<!--{*
2 * This file is part of EC-CUBE
3 *
[22206]4 * Copyright(c) 2000-2013 LOCKON CO.,LTD. All Rights Reserved.
[19661]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 *}-->
[21533]22
[21050]23<!-- ▼新着情報 -->
24<section id="news_area">
[21533]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 />
[22583]31                <span class="news_date"><!--{$arrNews[data].cast_news_date|date_format:"%Y年 %m月 %d日"}--></span>
[21533]32            </li>
33        <!--{/section}-->
34    </ul>
[19661]35
[21533]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}-->
[21050]41</section>
42<!-- ▲新着情報 -->
[19661]43
44
[21050]45<script>
[21533]46    var newsPageNo = 2;
[19661]47
[21533]48    function getNews(limit) {
49        $.mobile.showPageLoadingMsg();
50        var i = limit;
[21126]51
[21533]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                $.mobile.hidePageLoadingMsg();
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++;
[19661]73
[21533]74                            //件名をセット
75                            $($("#news_area ul.newslist li a span.news_title").get(maxCnt)).text(news.news_title);
[21126]76
[21533]77                            //リンクをセット
78                            $($("#news_area ul.newslist li a").get(maxCnt)).attr("href", "javascript:getNewsDetail(" + news.news_id + ");");
[21126]79
[21533]80                            //年月をセット
[22583]81                            var newsDateDispArray = news.cast_news_date.split("-"); //ハイフンで年月日を分解
[21533]82                            var newsDateDisp = newsDateDispArray[0] + "年 " + newsDateDispArray[1] + "月 " + newsDateDispArray[2] + "日";
83                            $($("#news_area ul.newslist li span.news_date").get(maxCnt)).text(newsDateDisp);
84                        }
85                    }
[21126]86
[22960]87                    //全ての新着情報を表示したか判定
[21533]88                    var newsPageCount = result.news_page_count;
89                    if (parseInt(newsPageCount) <= newsPageNo) {
90                        $("#btn_more_news").hide();
91                    }
[21126]92
[21533]93                    newsPageNo++;
94                }
95                $.mobile.hidePageLoadingMsg();
96            }
97        });
98    }
[19661]99
[21533]100    var loadingState = 0;
101    function getNewsDetail(newsId) {
102        if (loadingState == 0) {
[22839]103            loadingState = 1;
[21533]104            $.mobile.showPageLoadingMsg();
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                    $.mobile.hidePageLoadingMsg();
115                    loadingState = 0;
116                },
117                success: function(result){
118                    if (result.error) {
119                        alert(result.error);
120                        $.mobile.hidePageLoadingMsg();
121                        loadingState = 0;
122                    }
[22839]123                    else if (result != null) {
124                        var news = result;
[21533]125                        var maxCnt = 0;
[21064]126
[21533]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 {
[21635]132                            $($("#windowcolumn dl.view_detail dt a").get(maxCnt)).attr("href", "#");
[21533]133                        }
[21126]134
[21533]135                        //年月をセット
[22583]136                        //var newsDateDispArray = news.cast_news_date.split("-"); //ハイフンで年月日を分解
[21533]137                        //var newsDateDisp = newsDateDispArray[0] + "年 " + newsDateDispArray[1] + "月 " + newsDateDispArray[2] + "日";
138                        //$($("#windowcolumn dl.view_detail dt").get(maxCnt)).text(newsDateDisp);
[21126]139
[21533]140                        //コメントをセット(iphone4の場合、innerHTMLの再描画が行われない為、タイマーで無理やり再描画させる)
141                        setTimeout( function() {
[23230]142                            news.news_comment == null ? $("#newsComment").html("") : $("#newsComment").html(news.news_comment.replace(/\n/g,"<br />"));
[21533]143                        }, 10);
144                        $.mobile.changePage('#windowcolumn', {transition: "slideup"});
145                        //ダイアログが開き終わるまで待機
146                        setTimeout( function() {
[22839]147                            $.mobile.hidePageLoadingMsg();
[21533]148                            loadingState = 0;
149                        }, 1000);
150                    }
[22839]151                    else {
152                        $.mobile.hidePageLoadingMsg();
153                        loadingState = 0;
154                        alert('取得できませんでした。');
155                    }
[21533]156                }
157            });
158        }
[21064]159    }
[21126]160</script>
Note: See TracBrowser for help on using the repository browser.