source: branches/version-2_13-dev/html/user_data/packages/admin/js/ownersstore.js.php @ 22856

Revision 22856, 6.2 KB checked in by Seasoft, 11 years ago (diff)

#2043 (typo修正・ソース整形・ソースコメントの改善 for 2.13.0)

  • 主に空白・空白行の調整。もう少し整えたいが、一旦現状コミット。
  • Property svn:eol-style set to LF
  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-httpd-php; charset=UTF-8
Line 
1<?php
2require_once '../../../../require.php';
3header('Content-Type: application/x-javascript');
4?>
5/*
6 * Thickbox 3.1 - One Box To Rule Them All.
7 * By Cody Lindley (http://www.codylindley.com)
8 * Copyright (c) 2007 cody lindley
9 * Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
10*/
11
12/*
13 * ownersstore.js
14 *
15 * オーナーズストア通信用ライブラリ.
16 * CSSやjavascriptのオーバーレイ処理はThickboxのものを使っています.
17 *
18*/
19
20(function() {
21// オーナーズストア通信スクリプトのパス
22var upgrade_url = '<?php echo ROOT_URLPATH ?>upgrade/<?php echo DIR_INDEX_PATH; ?>';
23
24// ロード中メッセージ「サーバーと通信中です」
25var loading_message = '\u30b5\u30fc\u30d0\u30fc\u3068\u901a\u4fe1\u4e2d\u3067\u3059';
26
27// ロード中画像の先読み
28var loading_img = new Image();
29loading_img.src = '<?php echo ROOT_URLPATH . USER_DIR ?>packages/default/img/ajax/loading.gif';
30
31var OwnersStore = function() {}
32OwnersStore.prototype = {
33    // detect Mac and Firefox use.
34    detectMacFF: function() {
35        var ua = navigator.userAgent.toLowerCase();
36        if (ua.indexOf('mac') != -1 && ua.indexOf('firefox') != -1) {
37            return true;
38        }
39    },
40    // remove ajax window
41    remove: function() {
42        $("#TB_window").fadeOut(
43            'fast',
44            function(){
45                $('#TB_window,#TB_overlay,#TB_HideSelect').trigger('unload').unbind().remove();
46            }
47        );
48        $("#TB_load").remove();
49        //if IE 6
50        if (typeof document.body.style.maxHeight == 'undefined') {
51            $('body', 'html').css({height: 'auto', width: 'auto'});
52            $('html').css('overflow', "");
53        }
54
55        return false;
56    },
57    // show loading page
58    show_loading: function() {
59        //if IE 6
60        if (typeof document.body.style.maxHeight === 'undefined') {
61            $('body','html').css({height: "100%", width: "100%"});
62            $('html').css('overflow','hidden');
63            //iframe to hide select elements in ie6
64            if (document.getElementById('TB_HideSelect') === null) {
65                $('body').append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
66                $("#TB_overlay").click(this.remove);
67            }
68        //all others
69        } else {
70            if (document.getElementById('TB_overlay') === null) {
71                $('body').append("<div id='TB_overlay'></div><div id='TB_window'></div>");
72                $("#TB_overlay").click(this.remove);
73            }
74        }
75
76        if (this.detectMacFF()) {
77            //use png overlay so hide flash
78            $("#TB_overlay").addClass('TB_overlayMacFFBGHack');
79        } else {
80            //use background and opacity
81            $("#TB_overlay").addClass('TB_overlayBG');
82        }
83
84        //add and show loader to the page
85        $('body').append(
86              "<div id='TB_load'>"
87            + "  <p style='color:#ffffff'>" + loading_message + "</p>"
88            + "  <img src='" + loading_img.src + "' />"
89            + "</div>"
90        );
91        $('#TB_load').show();
92    },
93
94    // show results
95    show_result: function(resp, status, product_id) {
96        var title    = resp.status || 'ERROR';
97        var contents = resp.msg || '';
98
99        var TB_WIDTH = 400;
100        var TB_HEIGHT = 300;
101        var ajaxContentW = TB_WIDTH - 20;
102        var ajaxContentH = TB_HEIGHT - 45;
103
104        if ($("#TB_window").css('display') != 'block') {
105            $("#TB_window").append(
106                "<div id='TB_title'>"
107              + "  <div id='TB_ajaxWindowTitle'></div>"
108              + "  <div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' onclick='OwnersStore.remove();'>close</a></div>"
109              + "</div>"
110              + "<div id='TB_ajaxContent' style='width:" + ajaxContentW + "px;height:" + ajaxContentH + "px'>"
111              + "</div>"
112            );
113         //this means the window is already up, we are just loading new content via ajax
114        } else {
115            $("#TB_ajaxContent")[0].style.width = ajaxContentW +'px';
116            $("#TB_ajaxContent")[0].style.height = ajaxContentH +'px';
117            $("#TB_ajaxContent")[0].scrollTop = 0;
118        }
119
120        $("#TB_load").remove();
121        $("#TB_window").css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
122
123        // take away IE6
124        if (!(jQuery.browser.msie && jQuery.browser.version < 7)) {
125            $("#TB_window").css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
126        }
127
128        $("#TB_ajaxWindowTitle").html(title);
129        $("#TB_ajaxContent").html(contents);
130        $("#TB_window").css({display:'block'});
131
132        // DL成功時に設定ボタンを表示
133        if (resp.status == 'SUCCESS' && product_id) {
134            $('#ownersstore_settings_default' + product_id).hide(); // --を非表示
135            $('#ownersstore_settings' + product_id).show();         // 設定ボタン表示
136            $('#ownersstore_download' + product_id).html('\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9');     // アップデートボタンを「ダウンロード」へ変換
137            $('#ownersstore_version' + product_id).html(resp.data.version);
138        }
139    },
140
141    // exexute install or update
142    download: function(product_id) {
143        this.show_loading();
144        var show = this.show_result;
145        $.post(
146            upgrade_url,
147            {mode: 'download', product_id: product_id},
148            function(resp, status) {
149                show(resp, status, product_id);
150            },
151            'json'
152        )
153    },
154
155    // get products list
156    products_list: function() {
157        this.show_loading();
158        var show = this.show_result;
159        var remove = this.remove;
160        $().ajaxError(this.show_result);
161        $.post(
162            upgrade_url,
163            {mode: 'products_list'},
164            function(resp, status) {
165                if (resp.status == 'SUCCESS') {
166                    remove();
167                    $('#ownersstore_index').hide();
168                    $('#ownersstore_products_list').html(resp.msg);
169                } else {
170                    show(resp, status);
171                }
172            },
173            'json'
174        )
175    }
176}
177window.OwnersStore = new OwnersStore();
178})();
Note: See TracBrowser for help on using the repository browser.