Ignore:
Timestamp:
2013/08/15 20:05:17 (11 years ago)
Author:
h_yoshimoto
Message:

#2342 基本情報管理>SHOPマスターにてJSエラーで登録処理が動かなかったので一旦戻します

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13_0/html/user_data/packages/sphone/js/eccube_sphone.js

    r23067 r23071  
    2121 */ 
    2222 
    23 (function( window, undefined ){ 
     23function setTopButton(topURL) { 
     24    if(!topURL){ 
     25        topURL = "/"; 
     26    } 
     27    var buttonText = "TOPへ"; 
     28    var buttonId = "btn-top"; 
    2429 
    25     // 名前空間の重複を防ぐ 
    26     if (window.eccube === undefined) { 
    27         window.eccube = {}; 
    28     } 
     30    //ボタンの生成・設定 
     31    var btn = document.createElement('div'); 
     32    var a = document.createElement('a'); 
     33    btn.id = buttonId; 
     34    btn.onclick = function(){location=topURL;}; 
     35    a.href = topURL; 
     36    a.innerText = buttonText; 
    2937 
    30     var eccube = window.eccube; 
     38    /* 背景色の設定 ---------------------*/ 
     39    //最初の見出しの背景色を取得、設定 
     40    var obj = document.getElementsByTagName('h2')[0]; 
     41    var col = document.defaultView.getComputedStyle(obj,null).getPropertyValue('background-color'); 
     42    btn.style.backgroundColor = col; 
    3143 
    32     eccube.smartRollover = function() { 
    33         if (document.getElementsByTagName) { 
    34             var images = document.getElementsByTagName("img"); 
     44    //省略表示用テキストの生成 
     45    var spn = document.createElement('span'); 
     46    spn.innerText = obj.innerText; 
     47    obj.innerText = ""; 
     48    spn.style.display = "inline-block"; 
     49    spn.style.maxWidth = "50%"; 
     50    spn.style.overflow = "hidden"; 
     51    spn.style.textOverflow = "ellipsis"; 
     52    obj.appendChild(spn); 
    3553 
    36             for (var i=0; i < images.length; i++) { 
    37                 if (images[i].getAttribute("src").match("_off.")) { 
    38                     images[i].onmouseover = function() { 
    39                         this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on.")); 
    40                     }; 
    41                     images[i].onmouseout = function() { 
    42                         this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off.")); 
    43                     }; 
     54    //ボタンを追加 
     55    btn.appendChild(a); 
     56    document.getElementsByTagName('body')[0].appendChild(btn);; 
     57} 
     58 
     59function smartRollover() { 
     60    if (document.getElementsByTagName) { 
     61        var images = document.getElementsByTagName("img"); 
     62 
     63        for (var i=0; i < images.length; i++) { 
     64            if (images[i].getAttribute("src").match("_off.")) { 
     65                images[i].onmouseover = function() { 
     66                    this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on.")); 
     67                } 
     68                images[i].onmouseout = function() { 
     69                    this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off.")); 
    4470                } 
    4571            } 
    4672        } 
    47     }; 
     73    } 
     74} 
    4875 
    49     if (window.addEventListener) { 
    50         window.addEventListener("load", eccube.smartRollover, false); 
    51     } else if (window.attachEvent) { 
    52         window.attachEvent("onload", eccube.smartRollover); 
    53     } 
     76if (window.addEventListener) { 
     77    window.addEventListener("load", smartRollover, false); 
     78} else if (window.attachEvent) { 
     79    window.attachEvent("onload", smartRollover); 
     80} 
    5481 
    55     /*------------------------------------------ 
    56      お気に入りを登録する 
    57      ------------------------------------------*/ 
    58     eccube.addFavoriteSphone = function(favoriteProductId) { 
    59         $.mobile.showPageLoadingMsg(); 
    60         //送信データを準備 
    61         var postData = {}; 
    62         var form = $("#form1"); 
    63         form.find(':input').each(function(){ 
    64             postData[$(this).attr('name')] = $(this).val(); 
    65         }); 
    66         postData["mode"] = "add_favorite_sphone"; 
    67         postData["favorite_product_id"] = favoriteProductId; 
     82/*------------------------------------------ 
     83 お気に入りを登録する 
     84 ------------------------------------------*/ 
     85function fnAddFavoriteSphone(favoriteProductId) { 
     86    $.mobile.showPageLoadingMsg(); 
     87    //送信データを準備 
     88    var postData = {}; 
     89    $("#form1").find(':input').each(function(){ 
     90        postData[$(this).attr('name')] = $(this).val(); 
     91    }); 
     92    postData["mode"] = "add_favorite_sphone"; 
     93    postData["favorite_product_id"] = favoriteProductId; 
    6894 
    69         $.ajax({ 
    70             type: "POST", 
    71             url: form.attr('action'), 
    72             data: postData, 
    73             cache: false, 
    74             dataType: "text", 
    75             error: function(XMLHttpRequest, textStatus, errorThrown){ 
    76                 alert(textStatus); 
    77                 $.mobile.hidePageLoadingMsg(); 
    78             }, 
    79             success: function(result){ 
    80                 if (result == "true") { 
    81                     alert("お気に入りに登録しました"); 
    82                     $(".btn_favorite").html("<p>お気に入り登録済み</p>"); 
    83                 } else { 
    84                     alert("お気に入りの登録に失敗しました"); 
    85                 } 
    86                 $.mobile.hidePageLoadingMsg(); 
     95    $.ajax({ 
     96        type: "POST", 
     97        url: $("#form1").attr('action'), 
     98        data: postData, 
     99        cache: false, 
     100        dataType: "text", 
     101        error: function(XMLHttpRequest, textStatus, errorThrown){ 
     102            alert(textStatus); 
     103            $.mobile.hidePageLoadingMsg(); 
     104        }, 
     105        success: function(result){ 
     106            if (result == "true") { 
     107                alert("お気に入りに登録しました"); 
     108                $(".btn_favorite").html("<p>お気に入り登録済み</p>"); 
     109            } else { 
     110                alert("お気に入りの登録に失敗しました"); 
    87111            } 
    88         }); 
    89     }; 
     112            $.mobile.hidePageLoadingMsg(); 
     113        } 
     114    }); 
     115} 
    90116 
    91     // グローバルに使用できるようにする 
    92     window.eccube = eccube; 
    93  
    94     /*------------------------------------------ 
    95      初期化 
    96      ------------------------------------------*/ 
    97     $(function(){ 
    98         //level?クラスを持つノード全てを走査し初期化 
    99         $("#categorytree li").each(function(){ 
    100             if ($(this).children("ul").length) { 
    101                 //▶を表示し、リストオープンイベントを追加 
    102                 var tgt = $(this).children('span.category_header'); 
    103                 var linkObj = $("<a>"); 
    104                 linkObj.text('+'); 
    105                 tgt 
    106                     .click(function(){ 
    107                         $(this).siblings("ul").toggle('fast', function(){ 
    108                             if ($(this).css('display') === 'none') { 
    109                                 tgt.children('a').text('+'); 
    110                             } else { 
    111                                 tgt.children('a').text('-'); 
    112                             } 
    113                         }); 
    114                     }) 
    115                     .addClass('plus') 
    116                     .append(linkObj); 
    117             } 
    118         }); 
     117/*------------------------------------------ 
     118 初期化 
     119 ------------------------------------------*/ 
     120$(function(){ 
     121    //level?クラスを持つノード全てを走査し初期化 
     122    $("#categorytree li").each(function(){ 
     123        if ($(this).children("ul").length) { 
     124            //▶を表示し、リストオープンイベントを追加 
     125            var tgt = $(this).children('span.category_header'); 
     126            var linkObj = $("<a>"); 
     127            linkObj.text('+'); 
     128            tgt 
     129                .click(function(){ 
     130                    $(this).siblings("ul").toggle('fast', function(){ 
     131                        if ($(this).css('display') === 'none') { 
     132                            tgt.children('a').text('+'); 
     133                        } else { 
     134                            tgt.children('a').text('-'); 
     135                        } 
     136                    }); 
     137                }) 
     138                .addClass('plus') 
     139                .append(linkObj); 
     140        } 
    119141    }); 
    120 })(window); 
     142}); 
Note: See TracChangeset for help on using the changeset viewer.