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

Revision 21514, 6.2 KB checked in by Seasoft, 12 years ago (diff)

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

  • 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        return false;
55    },
56    // show loading page
57    show_loading: function() {
58        //if IE 6
59        if (typeof document.body.style.maxHeight === 'undefined') {
60            $('body','html').css({height: "100%", width: "100%"});
61            $('html').css('overflow','hidden');
62            //iframe to hide select elements in ie6
63            if (document.getElementById('TB_HideSelect') === null) {
64                $('body').append("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>");
65                $('#TB_overlay').click(this.remove);
66            }
67        //all others
68        } else {
69            if (document.getElementById('TB_overlay') === null) {
70                $('body').append("<div id='TB_overlay'></div><div id='TB_window'></div>");
71                $('#TB_overlay').click(this.remove);
72            }
73        }
74
75        if (this.detectMacFF()) {
76            //use png overlay so hide flash
77            $('#TB_overlay').addClass('TB_overlayMacFFBGHack');
78        } else {
79            //use background and opacity
80            $('#TB_overlay').addClass('TB_overlayBG');
81        }
82
83        //add and show loader to the page
84        $('body').append(
85              "<div id='TB_load'>"
86            + "  <p style='color:#ffffff'>" + loading_message + "</p>"
87            + "  <img src='" + loading_img.src + "' />"
88            + '</div>'
89        );
90        $('#TB_load').show();
91    },
92
93    // show results
94    show_result: function(resp, status, product_id) {
95        var title    = resp.status || 'ERROR';
96        var contents = resp.msg || '';
97
98        var TB_WIDTH = 400;
99        var TB_HEIGHT = 300;
100        var ajaxContentW = TB_WIDTH - 20;
101        var ajaxContentH = TB_HEIGHT - 45;
102
103        if ($('#TB_window').css('display') != 'block') {
104            $('#TB_window').append(
105                "<div id='TB_title'>"
106              + "  <div id='TB_ajaxWindowTitle'></div>"
107              + "  <div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' onclick='OwnersStore.remove();'>close</a></div>"
108              + '</div>'
109              + "<div id='TB_ajaxContent' style='width:" + ajaxContentW + "px;height:" + ajaxContentH + "px'>"
110              + '</div>'
111            );
112         //this means the window is already up, we are just loading new content via ajax
113        } else {
114            $('#TB_ajaxContent')[0].style.width = ajaxContentW +'px';
115            $('#TB_ajaxContent')[0].style.height = ajaxContentH +'px';
116            $('#TB_ajaxContent')[0].scrollTop = 0;
117        }
118
119        $('#TB_load').remove();
120        $('#TB_window').css({marginLeft: '-' + parseInt((TB_WIDTH / 2),10) + 'px', width: TB_WIDTH + 'px'});
121
122        // take away IE6
123        if (!(jQuery.browser.msie && jQuery.browser.version < 7)) {
124            $('#TB_window').css({marginTop: '-' + parseInt((TB_HEIGHT / 2),10) + 'px'});
125        }
126
127        $('#TB_ajaxWindowTitle').html(title);
128        $('#TB_ajaxContent').html(contents);
129        $('#TB_window').css({display:'block'});
130
131        // DL成功時に設定ボタンを表示
132        if (resp.status == 'SUCCESS' && product_id) {
133            $('#ownersstore_settings_default' + product_id).hide(); // --を非表示
134            $('#ownersstore_settings' + product_id).show();         // 設定ボタン表示
135            $('#ownersstore_download' + product_id).html('\u30C0\u30A6\u30F3\u30ED\u30FC\u30C9');     // アップデートボタンを「ダウンロード」へ変換
136            $('#ownersstore_version' + product_id).html(resp.data.version);
137        }
138    },
139
140    // exexute install or update
141    download: function(product_id) {
142        this.show_loading();
143        var show = this.show_result;
144        $.post(
145            upgrade_url,
146            {mode: 'download', product_id: product_id},
147            function(resp, status) {
148                show(resp, status, product_id);
149            },
150            'json'
151        )
152    },
153
154    // get products list
155    products_list: function() {
156        this.show_loading();
157        var show = this.show_result;
158        var remove = this.remove;
159        $().ajaxError(this.show_result);
160        $.post(
161            upgrade_url,
162            {mode: 'products_list'},
163            function(resp, status) {
164                if (resp.status == 'SUCCESS') {
165                    remove();
166                    $('#ownersstore_index').hide();
167                    $('#ownersstore_products_list').html(resp.msg);
168                } else {
169                    show(resp, status);
170                }
171            },
172            'json'
173        )
174    }
175}
176window.OwnersStore = new OwnersStore();
177})();
Note: See TracBrowser for help on using the repository browser.