contentview_Gomu.js 9.48 KB
Newer Older
1 2 3 4 5
/// コンテンツ閲覧画面_消しゴム書式オーバーレイ
/// ===============================================================================================
/// Eraser group [start]
/// ===============================================================================================

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

9
// Show eraser
10
CONTENTVIEW_GOMU.ShowEraser = function(targetDiv) {   
11 12
    $('#dlgGomu').show();
    $('#dlgGomu').draggable();
13
    CONTENTVIEW_GOMU.Eraser_SetDefaultValue();
14 15 16 17
    $('#dlgGomu').center();
};

// Set default value for easer.
18
CONTENTVIEW_GOMU.Eraser_SetDefaultValue = function() {
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
    var typeValue = undefined;
    typeValue = ClientData.erase_size();
    if (typeValue == 5) {
        $("#dlgGomu_rdo1").attr('checked', 'checked');
        $("#dlgGomu_rdo1").focus();
    }
    else if (typeValue == 12.5) {
        $("#dlgGomu_rdo2").attr('checked', 'checked');
        $("#dlgGomu_rdo2").focus();
    }
    else if (typeValue == 25) {
        $("#dlgGomu_rdo3").attr('checked', 'checked');
        $("#dlgGomu_rdo3").focus();
    }
    else if (typeValue == 50) {
        $("#dlgGomu_rdo4").attr('checked', 'checked');
        $("#dlgGomu_rdo4").focus();
    }
    else {
        typeValue = 5;
        $("#dlgGomu_rdo1").attr('checked', 'checked');
        $("#dlgGomu_rdo1").focus();
    }
42
    CONTENTVIEW_GOMU.dlgGomu_chooseType(typeValue);
43 44
};
// Choose type of eraser, and draw to canvas
45
CONTENTVIEW_GOMU.dlgGomu_chooseType = function(typeValue) {
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74

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

    if (canvas.getContext) {
        
        // use getContext to use the canvas for drawing
        var context = canvas.getContext('2d');
 
        //Start : Apply new Css - Editor : Long - Date : 09/06/2013 - Summary : Edit for new gomu panel
        context.clearRect(0, 0, canvas.width, canvas.height);
        var imageObj = new Image();
            imageObj.onload = function() {
                var pattern = context.createPattern(imageObj, 'repeat');
        
                context.rect(0, 0, canvas.width, canvas.height);
                context.fillStyle = pattern;
                context.fill();
                
                context.beginPath();
                     
                context.arc(canvas.width/2, canvas.height/2, typeValue, 0, 2 * Math.PI, true);
                context.stroke();               
            };
         imageObj.src = 'img/viewer/canvas_l.png';
        //End : Apply new Css - Editor : Long - Date : 09/06/2013 - Summary : Edit for new gomu panel

    }
};

75 76
CONTENTVIEW_GOMU.dlgGomu_rdo1_click = function() {
	CONTENTVIEW_GOMU.dlgGomu_chooseType(5);
77
};
78 79
CONTENTVIEW_GOMU.dlgGomu_rdo2_click = function() {
	CONTENTVIEW_GOMU.dlgGomu_chooseType(12.5);
80
};
81 82
CONTENTVIEW_GOMU.dlgGomu_rdo3_click = function() {
	CONTENTVIEW_GOMU.dlgGomu_chooseType(25);
83
};
84 85
CONTENTVIEW_GOMU.dlgGomu_rdo4_click = function() {
	CONTENTVIEW_GOMU.dlgGomu_chooseType(50);
86 87 88
};

// Event of button OK
89
CONTENTVIEW_GOMU.dlgGomu_dspOK_click = function() {
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108

    // Set selected value to local storage
    var typeValue = undefined;

    if ($("#dlgGomu_rdo1").attr('checked') == 'checked') {
        typeValue = 5;
    }
    else if ($("#dlgGomu_rdo2").attr('checked') == 'checked') {
        typeValue = 12.5;
    }
    else if ($("#dlgGomu_rdo3").attr('checked') == 'checked') {
        typeValue = 25;
    }
    else if ($("#dlgGomu_rdo4").attr('checked') == 'checked') {
        typeValue = 50;
    }

    // Set value to local
    ClientData.erase_size(typeValue);
109
    CONTENTVIEW_GENERAL.eraseSize = typeValue;
110 111 112 113

    // Close dialog
    //$("#dlgGomu").dialog('close');
	/*$("#dlgGomu").fadeOut('medium', function(){
Masaru Abe committed
114
		//COMMON.unlockLayout();
115 116 117 118
	});*/
	$("#dlgGomu").hide();
	
	/*enable button */
119
	CONTENTVIEW_MARKING.enableButtonMarking();
120
	ClientData.IsAddingMarking(true);
121
	CONTENTVIEW_GENERAL.isAddingMarking = ClientData.IsAddingMarking();
122 123 124 125 126 127 128 129
	
	/* unlock dialog overlay */
	$("#overlay").hide();
	
	$('#dlgMarking_imgEraserOption').removeClass();
	$('#dlgMarking_imgEraserOption').addClass('eraser_option_hover');
};
// Event of button cancel
130
CONTENTVIEW_GOMU.dlgGomu_dspCancel_click = function() {
131 132 133 134 135

    // Close dialog
	$("#dlgGomu").hide();
	
	/*enable button */
136
	CONTENTVIEW_MARKING.enableButtonMarking();
137
	ClientData.IsAddingMarking(true);
138
	CONTENTVIEW_GENERAL.isAddingMarking = ClientData.IsAddingMarking();
139 140 141 142 143 144 145 146
	
	/* unlock dialog overlay */
	$("#overlay").hide();
	
	$('#dlgMarking_imgEraserOption').removeClass();
	$('#dlgMarking_imgEraserOption').addClass('eraser_option_hover');
};

147
CONTENTVIEW_GOMU.dlgGomu_rdo1_text_click = function(){
148 149 150 151
	$('#dlgGomu_rdo1').attr('checked','checked');
	$('#dlgGomu_rdo2').removeAttr('checked');
	$('#dlgGomu_rdo3').removeAttr('checked');
	$('#dlgGomu_rdo4').removeAttr('checked');
152
	CONTENTVIEW_GOMU.dlgGomu_rdo1_click();
153 154
};

155
CONTENTVIEW_GOMU.dlgGomu_rdo2_text_click = function(){
156 157 158 159
	$('#dlgGomu_rdo1').removeAttr('checked');
	$('#dlgGomu_rdo2').attr('checked','checked');
	$('#dlgGomu_rdo3').removeAttr('checked');
	$('#dlgGomu_rdo4').removeAttr('checked');
160
	CONTENTVIEW_GOMU.dlgGomu_rdo2_click();
161 162
};

163
CONTENTVIEW_GOMU.dlgGomu_rdo3_text_click = function(){
164 165 166 167
	$('#dlgGomu_rdo1').removeAttr('checked');
	$('#dlgGomu_rdo2').removeAttr('checked');
	$('#dlgGomu_rdo3').attr('checked','checked');
	$('#dlgGomu_rdo4').removeAttr('checked');
168
	CONTENTVIEW_GOMU.dlgGomu_rdo3_click();
169 170
};

171
CONTENTVIEW_GOMU.dlgGomu_rdo4_text_click = function(){
172 173 174 175
	$('#dlgGomu_rdo1').removeAttr('checked');
	$('#dlgGomu_rdo2').removeAttr('checked');
	$('#dlgGomu_rdo3').removeAttr('checked');
	$('#dlgGomu_rdo4').attr('checked','checked');
176
	CONTENTVIEW_GOMU.dlgGomu_rdo4_click();
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191
};
/*
----------------------------------------------------------------------------
Event groups [start]
----------------------------------------------------------------------------
*/


/*
----------------------------------------------------------------------------
Event groups [ end ]
----------------------------------------------------------------------------
*/


192
CONTENTVIEW_GOMU.touchStart_BtnOk_Gomu = function(e){
193 194 195
	e.preventDefault();
	$('#dlgGomu').draggable("destroy");
	
196
	CONTENTVIEW_GOMU.dlgGomu_dspOK_click();
197 198 199
	
};

200
CONTENTVIEW_GOMU.touchStart_BtnCancel_Gomu = function(e){
201 202 203
	e.preventDefault();
	$('#dlgGomu').draggable("destroy");
	
204
	CONTENTVIEW_GOMU.dlgGomu_dspCancel_click();
205 206 207 208
};

// Setting dialog
$(function () {
209 210 211 212
	//CONTENTVIEW_GOMU.ready();
});

CONTENTVIEW_GOMU.ready = function(){
213 214 215
    // ---------------------------------
    // Setup for easer [start]
    // ---------------------------------
Masaru Abe committed
216
	if(COMMON.isTouchDevice() == true){
Masaru Abe committed
217 218 219 220 221 222
		if ($('#dlgGomu_dspOK').length) {
			document.getElementById('dlgGomu_dspOK').addEventListener('touchstart',CONTENTVIEW_GOMU.touchStart_BtnOk_Gomu,false);
		}
		if ($('#dlgGomu_dspCancel').length) {
			document.getElementById('dlgGomu_dspCancel').addEventListener('touchstart',CONTENTVIEW_GOMU.touchStart_BtnCancel_Gomu,false);
		}
223 224
	}
		
225 226 227 228 229 230 231 232 233 234 235
    //$("#dlgGomu_dspOK").click(CONTENTVIEW_GOMU.dlgGomu_dspOK_click);
    $("#dlgGomu_dspOK").on({
    	'click touchend': function(ev){
    		CONTENTVIEW_GOMU.dlgGomu_dspOK_click(ev);
            return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
    });
236
    
237 238 239 240 241 242 243 244 245 246 247
    //$("#dlgGomu_dspCancel").click(CONTENTVIEW_GOMU.dlgGomu_dspCancel_click);
    $("#dlgGomu_dspCancel").on({
    	'click touchend': function(ev){
    		CONTENTVIEW_GOMU.dlgGomu_dspCancel_click(ev);
            return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
    });
248
    
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
    
    //$("#text_dlgGomu_rdo1").click(CONTENTVIEW_GOMU.dlgGomu_rdo1_text_click);
    $("#text_dlgGomu_rdo1").on({
    	'click touchend': function(ev){
    		CONTENTVIEW_GOMU.dlgGomu_rdo1_text_click(ev);
            return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
    });
    
    //$("#text_dlgGomu_rdo2").click(CONTENTVIEW_GOMU.dlgGomu_rdo2_text_click);
    $("#text_dlgGomu_rdo2").on({
    	'click touchend': function(ev){
    		CONTENTVIEW_GOMU.dlgGomu_rdo2_text_click(ev);
            return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
    });
    
    //$("#text_dlgGomu_rdo3").click(CONTENTVIEW_GOMU.dlgGomu_rdo3_text_click);
    $("#text_dlgGomu_rdo3").on({
    	'click touchend': function(ev){
    		CONTENTVIEW_GOMU.dlgGomu_rdo3_text_click(ev);
            return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
    });
    
    //$("#text_dlgGomu_rdo4").click(CONTENTVIEW_GOMU.dlgGomu_rdo4_text_click);
    $("#text_dlgGomu_rdo4").on({
    	'click touchend': function(ev){
    		CONTENTVIEW_GOMU.dlgGomu_rdo4_text_click(ev);
            return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
    });
};

299 300 301 302

/// ===============================================================================================
/// Eraser group [ end ]
/// ===============================================================================================