contentview_Anket.js 6.36 KB
Newer Older
1 2 3 4

//名前空間用のオブジェクトを用意する
var CONTENTVIEW_ANKET = {};

5
// show dialog anket content
6
CONTENTVIEW_ANKET.showAnket = function(url, fullscreen, objectId) {
7 8
    var $container = $('#dialog');

9
    //url = url + "?sid=" + CONTENTVIEW.getSessionId();
10 11 12 13 14 15 16 17

    $container.html('');
    $container.addClass('anket-dialog');

    var canvas = document.getElementById('main');

    var width = fullscreen == true ? canvas.width : 340;

18 19
    var anketCommandsKey = canvas.getAttribute('anket-commands');

20 21 22 23 24 25
    if (fullscreen == true) {
        $container.attr('style', 'width:' + width + 'px; left:10px;right:auto;');
    }
    else {
        $container.attr('style', 'width:' + width + 'px; right:10px;left:auto;'); // !important
    }
26

27 28 29 30 31 32 33 34 35
    if(anketCommandsKey == 'anket-transparent'){
        $('#dialog,#dialog iframe,#anket-commands,#anket-commands input').removeClass('anket-opacity anket-transparent anket-translucent anket-transparent-content').addClass('anket-transparent');
        $('#anket-container').removeClass('anket-opacity anket-transparent anket-translucent anket-transparent-content').addClass('anket-transparent-content');
    }else if(anketCommandsKey == 'anket-translucent'){
        $('#dialog,#dialog iframe,#anket-commands,#anket-commands input,#anket-container').removeClass('anket-opacity anket-transparent anket-translucent anket-transparent-content').addClass('anket-translucent');
    }else if(anketCommandsKey == 'anket-opacity'){
        $('#dialog,#dialog iframe,#anket-commands,#anket-commands input,#anket-container').removeClass('anket-opacity anket-transparent anket-translucent anket-transparent-content').addClass('anket-opacity');
    }

36 37
    $container.draggable({ handle: "h1" });
    $container.html(
38
      '<h1>'+I18N.i18nText('txtEnqueteTitle')
39 40 41 42
    + '<img src="img/viewer/x.png" style="margin:3px 3px 0px 21px" id="btnClose" class="align_right" ></img>'
    + '</h1>'
    + '<div class="anket-container" id="anket-container"><iframe width="' + width + '" height="100%" frameborder="0" scrolling="auto" src="' + url + '">'
    + '</iframe></div>'
43
    + '<div class="anket-commands" id="anket-commands"><input type="button" value="' + I18N.i18nText('txtTransparent') + '" id="btnFullOpacity"/> <input type="button" value="' + I18N.i18nText('txtSemiTransparent') + '" id="btnApartOpacity"/> <input type="button" value="' + I18N.i18nText('txtNoTransparent') + '" id="btnNoOpacity"/></div><div style="clear:both;"></div>'
44
    );
45

Masaru Abe committed
46
    $("#btnClose").on({
Masaru Abe committed
47
    	'click touchend': function(ev){
48

Masaru Abe committed
49 50 51 52 53
    		//時間記録
    		var dateEnd = new Date();
    		var actionTime = dateEnd.subtractBySeconds(dateStart);
    		//alert("actionTime:" + actionTime);
    		COMMON.SetObjectLogActionTime( CONTENTVIEW_GENERAL.contentID, objectId, actionTime );
54

Masaru Abe committed
55 56
    		$container.removeAttr('style');
    		CONTENTVIEW_GENERAL.hideDialog();
57 58
            //dialog透明解除
            $('#dialog,#dialog iframe,#anket-commands,#anket-commands input,#anket-container').removeClass('anket-opacity anket-transparent anket-translucent anket-transparent-content');
59

Masaru Abe committed
60 61 62 63 64 65
    		return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
66 67
    });

Masaru Abe committed
68 69 70
	//時間記録
    var dateStart = new Date();

71 72 73
    var avwUserEnvObj = new UserEnvironment();

    // set overflow for container iframe
Masaru Abe committed
74
    if (avwUserEnvObj.isIos()) {
75
        $('#dialog .anket-container').css('overflow', 'scroll');
Masaru Abe committed
76 77
        //$('#dialog .anket-container').css('-webkit-overflow-scrolling', 'touch');
        //$('#dialog .anket-container').css('position', 'relative');
78

79 80 81 82
        if (fullscreen == true) {
            $container.attr('style', 'width:' + width + 'px; left:10px;right:auto;'); // !important on ipad can't move dialog
        }
        else {
Masaru Abe committed
83 84 85 86 87
            if (avwUserEnvObj.isIpad()) {
            	$container.attr('style', 'width:' + width + 'px; right:20px;left:auto;');
            } else {
            	$container.attr('style', 'width:' + width + 'px; right:3px;left:auto;');
            }
88 89 90 91 92 93
        }
    }

    // click on button change transparent
    $('#dialog .anket-commands input').click(
        function () {
94
            //START TRB00092 - EDITOR: Long - Date: 09/26/2013 - Summary : Fix opacity
95 96 97 98 99

            if ($(this).index() == 0) {
                //set transparent
                $('#dialog,#dialog iframe,#anket-commands,#anket-commands input').removeClass('anket-opacity anket-transparent anket-translucent anket-transparent-content').addClass('anket-transparent');
                $('#anket-container').removeClass('anket-opacity anket-transparent anket-translucent anket-transparent-content').addClass('anket-transparent-content');
100
                canvas.setAttribute('anket-commands','anket-transparent');
101 102 103 104 105 106
            }
            else if ($(this).index() == 1) {

                // set translucent
                //END TRB00092 - EDITOR: Long - Date: 09/26/2013 - Summary : Fix opacity
                $('#dialog,#dialog iframe,#anket-commands,#anket-commands input,#anket-container').removeClass('anket-opacity anket-transparent anket-translucent anket-transparent-content').addClass('anket-translucent');
107
                canvas.setAttribute('anket-commands','anket-translucent');
108 109 110 111
            }
            else {
                //set opacity
                $('#dialog,#dialog iframe,#anket-commands,#anket-commands input,#anket-container').removeClass('anket-opacity anket-transparent anket-translucent anket-transparent-content').addClass('anket-opacity');
112
                canvas.setAttribute('anket-commands','anket-opacity');
113 114 115 116
            }
        }
    );
        // resize anket
117 118 119
    CONTENTVIEW_ANKET.resizeAnket();

};
120

121 122
// resize dialog anket
CONTENTVIEW_ANKET.resizeAnket = function() {
123

124 125 126
    // get canvas main
    var canvas = document.getElementById('main');
    var height = canvas.height;
127

128
    var top = (CONTENTVIEW_GENERAL.isFullScreen?0:$('#header_toolbar').height()) + 4; // get top position for dialog 4 for space
129

130 131
    // set top dialog
    $('#dialog').height(height).css('top', top);
132

133
    var iframeHeight = height - $('#dialog h1').height() - $('#dialog .anket-commands').height() - 8;  // 8 for 2xspace
134

135 136
    // set height for iframe
    $('#dialog iframe').attr('height', iframeHeight);
137

138 139
    // set height for anket container
    $('#dialog .anket-container').css('height', iframeHeight);
140

141 142 143
};

CONTENTVIEW_ANKET.ready = function(){
144
};
145