contentview_Pen.js 12.7 KB
Newer Older
1 2 3 4
/// ===============================================================================================
/// Pen group [start]
/// ===============================================================================================

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

8 9
CONTENTVIEW_PEN.ShowPen = function(targetId) {
	CONTENTVIEW_PEN.pen_targetDiv = targetId;
10
	I18N.i18nReplaceText();
11 12
	$('#dlgPen').show();
	$('#dlgPen').draggable({ revert: false});
13
	CONTENTVIEW_PEN.Pen_handleColorPickerEvent();
14 15 16 17
			
	$('#dlgPen').center();		
};

18
CONTENTVIEW_PEN.touchStart_BtnOk_Pen = function(e){
19
	e.preventDefault();
20
	CONTENTVIEW_PEN.pen_targetDiv.draggable("destroy");
21
	
22
	CONTENTVIEW_PEN.Pen_dspOK_click();
23 24
};

25
CONTENTVIEW_PEN.touchStart_BtnCancel_Pen = function(e){
26
	e.preventDefault();
27
	CONTENTVIEW_PEN.pen_targetDiv.draggable("destroy");
28
	
29
	CONTENTVIEW_PEN.Pen_dspCancel_click();
30 31
};

32
CONTENTVIEW_PEN.Pen_handleColorPickerEvent = function() {
33
 
Masaru Abe committed
34
	if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() || CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()){
35 36 37
	 	$('#dlgPen .colorpicker').unbind('mouseenter');
    	$('#dlgPen .colorpicker').unbind('mouseleave');
    	$('#penColorwrapper').unbind('mouseleave');
38 39
    	 document.getElementById('Pen_btnOk').addEventListener('touchstart',CONTENTVIEW_PEN.touchStart_BtnOk_Pen,false);
    	 document.getElementById('Pen_btnCancel').addEventListener('touchstart',CONTENTVIEW_PEN.touchStart_BtnCancel_Pen,false);
40 41 42 43 44 45 46
	}
	else{
		
	 	$('#dlgPen .colorpicker').unbind('mouseenter');
    	$('#dlgPen .colorpicker').unbind('mouseleave');
    	$('#penColorwrapper').unbind('mouseleave');
    	
47 48 49
	 	$('#dlgPen .colorpicker').bind('mouseenter', CONTENTVIEW_PEN.Pen_colorPickerMouseEnterFunction);
    	$('#dlgPen .colorpicker').bind('mouseleave', CONTENTVIEW_PEN.Pen_colorPickerMouseLeaveFunction);
    	$('#penColorwrapper').bind('mouseleave', CONTENTVIEW_PEN.Pen_colorWrapperMouseLeaveFunction);
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 75
	//$('#Pen_btnOk').live('click', CONTENTVIEW_PEN.Pen_dspOK_click);
    $("#Pen_btnOk").on({
    	'click touchend': function(ev){
    		CONTENTVIEW_PEN.Pen_dspOK_click(ev);
    		return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
    });
	
	//$('#Pen_btnCancel').live('click', CONTENTVIEW_PEN.Pen_dspCancel_click);
    $("#Pen_btnCancel").on({
    	'click touchend': function(ev){
    		CONTENTVIEW_PEN.Pen_dspCancel_click(ev);
    		return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
    });
	
76

77
	CONTENTVIEW_PEN.Pen_SetDefaultValue();
78
	
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
	//$('#pen-small-text').live('click', CONTENTVIEW_PEN.penSmallTextClick);
    $("#pen-small-text").on({
    	'click touchend': function(ev){
    		CONTENTVIEW_PEN.penSmallTextClick(ev);
    		return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
    });
	
	
	//$('#pen-medium-text').live('click', CONTENTVIEW_PEN.penMediumTextClick);
    $("#pen-medium-text").on({
    	'click touchend': function(ev){
    		CONTENTVIEW_PEN.penMediumTextClick(ev);
    		return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
    });
	
	//$('#pen-large-text').live('click', CONTENTVIEW_PEN.penLargeTextClick);
    $("#pen-large-text").on({
    	'click touchend': function(ev){
    		CONTENTVIEW_PEN.penLargeTextClick(ev);
    		return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
    });
	
	//$('#pen-oversize-text').live('click', CONTENTVIEW_PEN.penOversizeTextClick);
    $("#pen-oversize-text").on({
    	'click touchend': function(ev){
    		CONTENTVIEW_PEN.penOversizeTextClick(ev);
    		return false;
    	},
    	'touchstart touchmove': function(){
    		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    		return false;
    	}
    });
127

128
	$('#dlgPen .colorpicker').die();
129
	$('#dlgPen .colorpicker').live('click', CONTENTVIEW_PEN.Pen_colorPickerClickFunction);
130 131 132 133 134 135 136 137 138 139 140
    //$("#dlgPen .colorpicker").on({
    //	'click touchend': function(ev){
    //		CONTENTVIEW_PEN.Pen_colorPickerClickFunction(ev);
    //		return false;
    //	},
    //	'touchstart touchmove': function(){
    //		//これを入れないと次にダイアログを開くと表示位置が大きくズレる
    //		return false;
    //	}
    //});
	
141 142
};

143
CONTENTVIEW_PEN.penSmallTextClick = function(){
144 145 146 147
	$('#pen-size-small').attr('checked','checked');
	$('#pen-size-medium').removeAttr('checked');
	$('#pen-size-large').removeAttr('checked');
	$('#pen-size-oversize').removeAttr('checked');
148
	CONTENTVIEW_PEN.Pen_rdo1_click();
149 150
};

151
CONTENTVIEW_PEN.penMediumTextClick = function(){
152 153 154 155
	$('#pen-size-small').removeAttr('checked');
	$('#pen-size-medium').attr('checked','checked');
	$('#pen-size-large').removeAttr('checked');
	$('#pen-size-oversize').removeAttr('checked');
156
	CONTENTVIEW_PEN.Pen_rdo2_click();
157 158
};

159
CONTENTVIEW_PEN.penLargeTextClick = function(){
160 161 162 163
	$('#pen-size-small').removeAttr('checked');
	$('#pen-size-medium').removeAttr('checked');
	$('#pen-size-large').attr('checked','checked');
	$('#pen-size-oversize').removeAttr('checked');
164
	CONTENTVIEW_PEN.Pen_rdo3_click();
165 166
};

167
CONTENTVIEW_PEN.penOversizeTextClick = function(){
168 169 170 171
	$('#pen-size-small').removeAttr('checked');
	$('#pen-size-medium').removeAttr('checked');
	$('#pen-size-large').removeAttr('checked');
	$('#pen-size-oversize').attr('checked','checked');
172
	CONTENTVIEW_PEN.Pen_rdo4_click();
173 174 175
};

// Choose type of eraser, and draw to canvas
176
CONTENTVIEW_PEN.Pen_chooseType = function(typeValue, color) {
177
	var fillColor;
178
	CONTENTVIEW_PEN.pen_Size = typeValue;
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207
	var canvas = document.getElementById('Pen_cvPreviewPen');

	if (color == null || color == 'undefined') {
		fillColor="#fe0000";
	}
	else{
	    fillColor = '#' + color;
	}
	
    if (canvas.getContext) {
        
        // use getContext to use the canvas for drawing
        var ctx = canvas.getContext('2d');

        // Draw shapes

        ctx.clearRect(0, 0, canvas.width, canvas.height);
        
        ctx.beginPath();

        ctx.arc(canvas.width/2, canvas.height/2, typeValue, 0, 2 * Math.PI, true);
        ctx.fillStyle = fillColor;
        ctx.strokeStyle = fillColor;
        ctx.fill();
        ctx.stroke();
    }
};

// Set default value for Pen.
208
CONTENTVIEW_PEN.Pen_SetDefaultValue = function() {
209 210 211
    var typeValue = undefined;
    var penColor = ClientData.penOpt_color();
    typeValue = ClientData.penOpt_size();
212
    CONTENTVIEW_PEN.pen_Size = typeValue;
213 214
    
    if(penColor != null || penColor != undefined){
215
    	CONTENTVIEW_PEN.pen_chooseColor = penColor;
216 217
    }
    else{
218
    	CONTENTVIEW_PEN.pen_chooseColor = 'fe0000';
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
    	penColor = 'fe0000';
    }
    
    if (typeValue == 5) {
        $("#pen-size-small").attr('checked', 'checked');
        $("#pen-size-small").focus();
    }
    else if (typeValue == 12.5) {
        $("#pen-size-medium").attr('checked', 'checked');
        $("#pen-size-medium").focus();
    }
    else if (typeValue == 25) {
        $("#pen-size-large").attr('checked', 'checked');
        $("#pen-size-large").focus();
    }
    else if (typeValue == 50) {
        $("#pen-size-oversize").attr('checked', 'checked');
        $("#pen-size-oversize").focus();
    }
    else {
        typeValue = 5;
        $("#pen-size-small").attr('checked', 'checked');
        $("#pen-size-small").focus();
    }
    
244
    CONTENTVIEW_PEN.Pen_chooseType(typeValue, penColor);
Vo Duc Thang committed
245 246 247 248 249
    //START FIXCSS
    //$('#dlgPen .colorpicker[colorId="'+penColor+'"]').css('border','1px solid #e6e6e6');
    $('#dlgPen .colorpicker[colorId="'+penColor+'"]').addClass('picker-choose-on');
    $('#dlgPen .colorpicker[colorId="'+penColor+'"]').removeClass('picker-choose-off');
    //END FIXCSS
250 251
};

252
CONTENTVIEW_PEN.Pen_colorPickerMouseLeaveFunction = function() {
Vo Duc Thang committed
253 254 255 256 257 258

	//START FIXCSS
    //$(this).css('border','1px solid white');    
    //$('#dlgMaker .colorpicker[colorId="'+makerColor+'"]').css('border','1px solid #e6e6e6');
    $(this).addClass('picker-choose-off');
    $(this).removeClass('picker-choose-on');
259 260
    $('#dlgPen .colorpicker[colorId="' + CONTENTVIEW_PEN.pen_chooseColor + '"]').addClass('picker-choose-on');
    $('#dlgPen .colorpicker[colorId="' + CONTENTVIEW_PEN.pen_chooseColor + '"]').removeClass('picker-choose-off');
Vo Duc Thang committed
261
    //END FIXCSS
262 263
};

264
CONTENTVIEW_PEN.Pen_colorPickerMouseEnterFunction = function() {
Vo Duc Thang committed
265 266 267 268 269
	//START FIXCSS
    //$(this).css('border','1px solid #e6e6e6');
    $(this).removeClass('picker-choose-off');
    $(this).addClass('picker-choose-on');
    //END FIXCSS
270
	var color = $(this).attr('colorId');
271
	CONTENTVIEW_PEN.Pen_chooseType(CONTENTVIEW_PEN.pen_Size, color);
272 273
};

274
CONTENTVIEW_PEN.Pen_colorPickerClickFunction = function() {
Vo Duc Thang committed
275
	//START FIXCSS
276
    //$('#dlgMaker .colorpicker[colorId="' + CONTENTVIEW_MAKER.maker_chooseColor + '"]').css('border', '1px solid white');
Vo Duc Thang committed
277
    //$(this).css('border','1px solid #e6e6e6');
278 279
    $('#dlgPen .colorpicker[colorId="' + CONTENTVIEW_PEN.pen_chooseColor + '"]').addClass('picker-choose-off');
    $('#dlgPen .colorpicker[colorId="' + CONTENTVIEW_PEN.pen_chooseColor + '"]').removeClass('picker-choose-on');
Vo Duc Thang committed
280 281 282
    $(this).addClass('picker-choose-on');
    $(this).removeClass('picker-choose-off');
    //END FIXCSS
283 284
    CONTENTVIEW_PEN.pen_chooseColor = $(this).attr('colorId');
    CONTENTVIEW_PEN.Pen_chooseType(CONTENTVIEW_PEN.pen_Size, CONTENTVIEW_PEN.pen_chooseColor);
285 286
};

287 288
CONTENTVIEW_PEN.Pen_rdo1_click = function() {
	CONTENTVIEW_PEN.Pen_chooseType(5, CONTENTVIEW_PEN.pen_chooseColor);  
289
};
290 291
CONTENTVIEW_PEN.Pen_rdo2_click = function() {
	CONTENTVIEW_PEN.Pen_chooseType(12.5, CONTENTVIEW_PEN.pen_chooseColor);
292
};
293 294
CONTENTVIEW_PEN.Pen_rdo3_click = function() {
	CONTENTVIEW_PEN.Pen_chooseType(25, CONTENTVIEW_PEN.pen_chooseColor);
295
};
296 297
CONTENTVIEW_PEN.Pen_rdo4_click = function() {
	CONTENTVIEW_PEN.Pen_chooseType(50, CONTENTVIEW_PEN.pen_chooseColor);
298 299 300
};

// Event of button OK
301
CONTENTVIEW_PEN.Pen_dspOK_click = function() {	
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
    // Set selected value to local storage
    var typeValue = undefined;

    if ($("#pen-size-small").attr('checked') == 'checked') {
        typeValue = 5;
    }
    else if ($("#pen-size-medium").attr('checked') == 'checked') {
        typeValue = 12.5;
    }
    else if ($("#pen-size-large").attr('checked') == 'checked') {
        typeValue = 25;
    }
    else if ($("#pen-size-oversize").attr('checked') == 'checked') {
        typeValue = 50;
    }

    // Set value to local
    ClientData.penOpt_size(typeValue);
320 321 322
    ClientData.penOpt_color(CONTENTVIEW_PEN.pen_chooseColor);
    CONTENTVIEW_PEN.pen_Size = typeValue;
    //c = CONTENTVIEW_PEN.pen_chooseColor;    
323 324
    
    /*enable button */
325
	CONTENTVIEW_MARKING.enableButtonMarking();
326
	ClientData.IsAddingMarking(true);
327 328 329
	CONTENTVIEW_GENERAL.isAddingMarking = ClientData.IsAddingMarking();
	CONTENTVIEW_GENERAL.penSize = ClientData.penOpt_size();
	CONTENTVIEW_GENERAL.penColor = ClientData.penOpt_color();
330 331
    
    // Close dialog
332
	CONTENTVIEW_PEN.pen_targetDiv.hide();
333 334 335 336 337 338 339 340 341
	
	/* unlock dialog overlay */
	$("#overlay").hide();
	
	$('#dlgMarking_imgPenOption').removeClass();
	$('#dlgMarking_imgPenOption').addClass('pen_option_hover');
};

// Event of button cancel
342
CONTENTVIEW_PEN.Pen_dspCancel_click = function() {
343
  	/*enable button */
344
	CONTENTVIEW_MARKING.enableButtonMarking();
345
	ClientData.IsAddingMarking(true);
346
	CONTENTVIEW_GENERAL.isAddingMarking = ClientData.IsAddingMarking();
347 348
	
    // Close dialog 
349
	CONTENTVIEW_PEN.pen_targetDiv.hide();
350 351 352 353 354 355 356 357 358
    
    /* unlock dialog overlay */
	$("#overlay").hide();
	
	$('#dlgMarking_imgPenOption').removeClass();
	$('#dlgMarking_imgPenOption').addClass('pen_option_hover');
  
};

359 360 361
CONTENTVIEW_PEN.Pen_colorWrapperMouseLeaveFunction = function() {
	CONTENTVIEW_PEN.Pen_chooseType(CONTENTVIEW_PEN.pen_Size, CONTENTVIEW_PEN.pen_chooseColor);
    //$('#dlgPen .colorpicker[colorId="' + CONTENTVIEW_PEN.pen_chooseColor + '"]').css('border', '1px solid #e6e6e6');
Vo Duc Thang committed
362
	//START FIXCSS
363 364 365
    //$('#dlgMaker .colorpicker[colorId="' + CONTENTVIEW_MAKER.maker_chooseColor + '"]').css('border', '1px solid #e6e6e6');
    $('#dlgPen .colorpicker[colorId="' + CONTENTVIEW_PEN.pen_chooseColor + '"]').addClass('picker-choose-on');
    $('#dlgPen .colorpicker[colorId="' + CONTENTVIEW_PEN.pen_chooseColor + '"]').removeClass('picker-choose-off');
Vo Duc Thang committed
366
    //END FIXCSS
367
};
368

369 370 371 372 373 374 375 376 377 378
$(function () {
	//CONTENTVIEW_PEN.ready();
});

CONTENTVIEW_PEN.ready = function(){
	CONTENTVIEW_PEN.pen_Size = undefined;
	CONTENTVIEW_PEN.pen_targetDiv = undefined;
	CONTENTVIEW_PEN.pen_chooseColor = undefined;
};