contentview_Memo.js 10.8 KB
Newer Older
1

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

CONTENTVIEW_MEMO.createMemoDialog = function(){
	CONTENTVIEW_MEMO.targetDiv.show();
	CONTENTVIEW_MEMO.targetDiv.html('');
	CONTENTVIEW_MEMO.targetDiv.append(
9
	'<aside id="memoWrapper" class="MemoIndexBox">'
10
	+ '	<h1 class="indexBoxHd">' + I18N.i18nText('txtMemo')
Masaru Abe committed
11
	+'		<a id="memoClosing2" class="delete"></a>'
12 13 14 15
	+'	</h1>'
	+'	<div id="memoArea" class="indexBoxBody_on">'
	+'		<textarea id="txaMemoContent" style="resize: none; height: 302px; width: 452px; margin-bottom: 10px"></textarea>'
	+'		<div style="width: 450px;">'
16 17 18
	+ '			<a id="Memo_btnCancel" style="float:right" class="lang cancelbtn" lang="dspCancel">' + I18N.i18nText('dspCancel') + '</a>'
	+ '			<a id="Memo_btnDel" style="float:right" class="lang cancelbtn" lang="dspDelete">' + I18N.i18nText('dspDelete') + '</a>'
	+ '			<a id="Memo_btnSave" style="float:right" class="lang cancelbtn" lang="dspSave">' + I18N.i18nText('dspSave') + '</a>'
19 20 21 22 23 24
	+'		</div>'
	+'	</div>'
	+'</aside>');
	
	$('#txaMemoContent').focus();
	
25
	CONTENTVIEW_MEMO.handleMemoEventFunction();
26 27
};

28 29 30 31
CONTENTVIEW_MEMO.handleMemoEventFunction = function(){
	$('#Memo_btnSave').click(CONTENTVIEW_MEMO.buttonSaveFunction);
	$('#Memo_btnDel').click(CONTENTVIEW_MEMO.MemoDelFunction);
	$('#Memo_btnCancel').click(CONTENTVIEW_MEMO.MemoCancelFunction);
32 33 34 35 36 37 38 39 40 41 42 43
	//$('.delete').click(CONTENTVIEW_MEMO.MemoCancelFunction);
	$("#memoClosing2").on({
		'click touchend': function(ev){
			CONTENTVIEW_MEMO.MemoCancelFunction(ev);
			return false;
		},
		'touchstart touchmove': function(){
			//これを入れないと次にダイアログを開くと表示位置が大きくズレる
			return false;
		}
	});
	
44 45
};

46
CONTENTVIEW_MEMO.memoSaveFunction = function(){
47 48 49 50

	var tempArr = [];	
	
	var memoObj = new MemoEntity();
51 52
	memoObj.pageNo = CONTENTVIEW_MEMO.pageid;
	memoObj.contentid = CONTENTVIEW_MEMO.conid;
53
	memoObj.Text = $('#txaMemoContent').val();
54
	var imagePt = CONTENTVIEW.screenToImage(CONTENTVIEW_MEMO.targetX, CONTENTVIEW_MEMO.targetY);
55 56 57 58
	
    //#11478 逆に縮める対応
    var canvasWidth = $('#offscreen').width();
    var canvasHeight = $('#offscreen').height();
59 60
    //var tempRatioWidth = canvasWidth / CONTENTVIEW_GENERAL.widthEachPageApi;
    var tempRatioWidth = CONTENTVIEW_GENERAL.widthEachPageApi / canvasWidth;
61 62 63
    if( tempRatioWidth > 1 ){
        tempRatioWidth = 1;
    }
64
    var tempRatioHeight = CONTENTVIEW_GENERAL.heightEachPageApi / canvasHeight;
65 66 67 68 69 70 71 72
    if( tempRatioHeight > 1 ){
        tempRatioHeight = 1;
    }
    memoObj.posX = Math.round(imagePt.x * tempRatioWidth);
    memoObj.posY = Math.round(imagePt.y * tempRatioHeight);
    //memoObj.posX = imagePt.x;
    //memoObj.posY = imagePt.y;
    
73
	//=== Start Function : No.17    Editor : Long   Date: 07/30/2013   Summary : Set UTC time and UUID when create new memo.
Masaru Abe committed
74
	memoObj.memoid = COMMON.getUUID();
75 76 77 78 79 80
	memoObj.registerDate = new Date();
	//=== End Function : No.17    Editor : Long   Date: 07/30/2013   Summary : Set UTC time and UUID when create new memo.
	tempArr = ClientData.MemoData();	
	tempArr.push(memoObj);	
	ClientData.MemoData(tempArr);
	
81 82
	if(CONTENTVIEW_MEMO.memoCallbackFunc){
		CONTENTVIEW_MEMO.memoCallbackFunc();
83 84 85
	}
};

86 87 88 89
CONTENTVIEW_MEMO.MemoDelFunction = function(){
	if(CONTENTVIEW_MEMO.saveMode == 'Copy'){
		//CONTENTVIEW_MEMO.targetDiv.dialog('close');
		CONTENTVIEW_MEMO.targetDiv.fadeOut('medium', function(){
90 91 92
			
		});
		
93
		CONTENTVIEW_GENERAL.isCopyMemo = false;
94 95
	}
	else{
96
		
97
		var resultArr = ClientData.MemoData();
98
		resultArr.splice(CONTENTVIEW_MEMO.EditIndex, 1);
99 100 101
		
		ClientData.MemoData(resultArr);
	
102
		//CONTENTVIEW_MEMO.targetDiv.dialog('close');	
103 104 105
		//if(CONTENTVIEW_MEMO.memoCallbackFunc){
		//	CONTENTVIEW_MEMO.memoCallbackFunc();
		//}
106
		
107 108
	}
	$("#overlay").hide();
109 110
	CONTENTVIEW_MEMO.targetDiv.children().remove();
	CONTENTVIEW_MEMO.targetDiv.hide();
111 112 113 114
	
	$("#pop_up_memo").hide();
	
	/* draw again */
115
	CONTENTVIEW.drawCanvas();	
116
	//START TRB00054 - EDITOR : Long - Date : 09/19/2013 - Summary : Fix for remove loading icon when del memo 
117
	CONTENTVIEW.drawCanvas(1);
118 119 120
	//END TRB00054 - EDITOR : Long - Date : 09/19/2013 - Summary : Fix for remove loading icon when del memo
	
	/* enable controls after finish copy */
121 122
	CONTENTVIEW.enableControlsCopyMemo();
	
123 124
};

125 126
CONTENTVIEW_MEMO.MemoCancelFunction = function(){
	//CONTENTVIEW_MEMO.targetDiv.dialog('close');
127
	$("#overlay").hide();	
128 129
	CONTENTVIEW_MEMO.targetDiv.children().remove();
	CONTENTVIEW_MEMO.targetDiv.hide();
130
	
131
	CONTENTVIEW_GENERAL.isCopyMemo = false;
132 133 134
	$("#pop_up_memo").hide();
	
	/* enable controls after finish copy */
135
	CONTENTVIEW.enableControlsCopyMemo();
136 137 138 139 140 141 142 143 144 145
	
	if(ClientData.IsAddingMemo() == true){	
		ClientData.IsAddingMemo(false); 	
		
	    //change class
        $('#imgaddmemo').removeClass();
        $('#imgaddmemo').addClass('memoAdd');	
	}	
};

146
CONTENTVIEW_MEMO.AddMemo = function(contentId,pageNo,targetId, posX, posY, callback) {
Masaru Abe committed
147 148 149
	
	//console.log("CONTENTVIEW_MEMO.AddMemo:" + posX + "," + posY);
	
150 151 152 153 154 155
	CONTENTVIEW_MEMO.conid = contentId;
	CONTENTVIEW_MEMO.pageid = pageNo;
	CONTENTVIEW_MEMO.targetDiv = targetId;
	CONTENTVIEW_MEMO.targetX = posX;
	CONTENTVIEW_MEMO.targetY = posY;
	CONTENTVIEW_MEMO.memoCallbackFunc = callback;
156
	
157 158
	CONTENTVIEW_MEMO.createMemoDialog();
	CONTENTVIEW_MEMO.saveMode = 'New';
159 160
	$('#Memo_btnDel').css('display','none');
	
161 162
	//CONTENTVIEW_MEMO.targetDiv.dialog({width: 466, height: 390, modal: true, position: [CONTENTVIEW_MEMO.targetX, CONTENTVIEW_MEMO.targetY], resizable: false});	
	//CONTENTVIEW_MEMO.targetDiv.parent().removeClass('ui-draggable');
163
	$("#overlay").show();
164 165
	CONTENTVIEW.disableControlsCopyMemo();
	CONTENTVIEW_MEMO.targetDiv.css('z-index','1005');
166 167
	
	//START TRB00097
168 169 170
	if(CONTENTVIEW_MEMO.targetY >= $('#wrapper').height()/2){
		CONTENTVIEW_MEMO.targetDiv.css('top', $('#wrapper').height()/3);
		CONTENTVIEW_MEMO.targetDiv.css('left',CONTENTVIEW_MEMO.targetX - ($('#memoWrapper').width() /2 ));
171 172 173
	    
	}
	else{
174 175
		CONTENTVIEW_MEMO.targetDiv.css('top',CONTENTVIEW_MEMO.targetY);
		CONTENTVIEW_MEMO.targetDiv.css('left',CONTENTVIEW_MEMO.targetX - ($('#memoWrapper').width() /2 ));
176 177 178 179 180
	}
	//END TRB00097
	
	
	
181 182
	CONTENTVIEW_MEMO.targetDiv.draggable({ handle: "h1" });
	//CONTENTVIEW_MEMO.editJqueryUIDialog();
183 184
};

185 186 187 188
CONTENTVIEW_MEMO.EditMemo = function(index, posXPlus, posYPlus, targetId, callback){
	CONTENTVIEW_MEMO.targetDiv = targetId;
	CONTENTVIEW_MEMO.targetX = ClientData.MemoData()[index].posX + posXPlus;
	CONTENTVIEW_MEMO.targetY = ClientData.MemoData()[index].posY + posYPlus;
189
	
190 191
	CONTENTVIEW_MEMO.EditIndex = index;
	CONTENTVIEW_MEMO.memoCallbackFunc = callback;
192
	
193 194 195
	CONTENTVIEW_MEMO.createMemoDialog();
	CONTENTVIEW_MEMO.getMemoForEdit();
	CONTENTVIEW_MEMO.saveMode = 'Edit';
196 197
	$('#Memo_btnDel').css('display','block');
	
198 199
	//CONTENTVIEW_MEMO.targetDiv.dialog({width: 466, height: 390, modal: true, position: [CONTENTVIEW_MEMO.targetX, CONTENTVIEW_MEMO.targetY], resizable: false});
	//CONTENTVIEW_MEMO.targetDiv.parent().removeClass('ui-draggable');
200
	$("#overlay").show();
201 202
	CONTENTVIEW.disableControlsCopyMemo();
	CONTENTVIEW_MEMO.targetDiv.css('z-index','1005');
203
		
204
	var pt = CONTENTVIEW.imageToScreen(CONTENTVIEW_MEMO.targetX, CONTENTVIEW_MEMO.targetY);	
205 206 207
	
   //START TRB00097
    if(pt.y >= $('#wrapper').height()/2){
208 209
    	CONTENTVIEW_MEMO.targetDiv.css('top', $('#wrapper').height()/3);
    	CONTENTVIEW_MEMO.targetDiv.css('left',pt.x - ($('#memoWrapper').width() /2 ));       
210 211
    }
    else{
212 213
    	CONTENTVIEW_MEMO.targetDiv.css('top',pt.y);
    	CONTENTVIEW_MEMO.targetDiv.css('left',pt.x - ($('#memoWrapper').width() /2 ));
214 215 216
    }
    //END TRB00097
	
217 218
    CONTENTVIEW_MEMO.targetDiv.draggable({ handle: "h1" });
	//CONTENTVIEW_MEMO.editJqueryUIDialog();
219 220
};

221 222 223 224 225 226 227 228
CONTENTVIEW_MEMO.CopyMemo = function(index,contentId,pageNo,targetId, posX, posY, callback){
	CONTENTVIEW_MEMO.conid = contentId;
	CONTENTVIEW_MEMO.pageid = pageNo;
	CONTENTVIEW_MEMO.targetDiv = targetId;
	CONTENTVIEW_MEMO.targetX = posX;
	CONTENTVIEW_MEMO.targetY = posY;
	CONTENTVIEW_MEMO.EditIndex = index;
	CONTENTVIEW_MEMO.memoCallbackFunc = callback;
229
	
230 231
	CONTENTVIEW_MEMO.createMemoDialog();
	//CONTENTVIEW_MEMO.getMemoForEdit();
232
	$('#txaMemoContent').val(index);
233
	CONTENTVIEW_MEMO.saveMode = 'Copy';
234
	$('#Memo_btnDel').css('display','none');
235 236
	//CONTENTVIEW_MEMO.targetDiv.dialog({width: 466, height: 390, modal: true, position: [CONTENTVIEW_MEMO.targetX, CONTENTVIEW_MEMO.targetY], resizable: false});
	//CONTENTVIEW_MEMO.targetDiv.parent().removeClass('ui-draggable');
237
	$("#overlay").show();
238 239 240 241
	CONTENTVIEW.disableControlsCopyMemo();
	CONTENTVIEW_MEMO.targetDiv.css('z-index','1005');
	CONTENTVIEW_MEMO.targetDiv.css('top',CONTENTVIEW_MEMO.targetY);
	CONTENTVIEW_MEMO.targetDiv.css('left',CONTENTVIEW_MEMO.targetX - ($('#memoWrapper').width() /2 ));
242
	
243 244
	CONTENTVIEW_MEMO.targetDiv.draggable({ handle: "h1" });
	//CONTENTVIEW_MEMO.editJqueryUIDialog();
245 246
};

247
CONTENTVIEW_MEMO.getMemoForEdit = function(){
248
	var arrTemp = ClientData.MemoData();
249
	var tempEntity = arrTemp[CONTENTVIEW_MEMO.EditIndex];
250 251 252
	$('#txaMemoContent').val(tempEntity.Text);
};

253
CONTENTVIEW_MEMO.editMemoFunction = function(){
254
	var arrTemp = ClientData.MemoData();
255
	var tempEntity = arrTemp[CONTENTVIEW_MEMO.EditIndex];
256 257 258 259 260 261 262

	var editContent = $('#txaMemoContent').val();
	
	tempEntity.Text = editContent;	
	//=== Start Function : No.17    Editor : Long   Date: 07/30/2013   Summary : Set UTC time when edit memo.
	tempEntity.registerDate = new Date();	
	//=== End Function : No.17    Editor : Long   Date: 07/30/2013   Summary : Set UTC time when edit memo.
263
	arrTemp[CONTENTVIEW_MEMO.EditIndex] = tempEntity;
264 265
	ClientData.MemoData(arrTemp);
	
266 267
	if(CONTENTVIEW_MEMO.memoCallbackFunc){
		CONTENTVIEW_MEMO.memoCallbackFunc();
268 269 270
	}	
	
	/*refresh memo*/																	
271
	//CONTENTVIEW.drawCanvas();	
272 273
};

274
CONTENTVIEW_MEMO.buttonSaveFunction = function(){
275
	
276 277
	if(CONTENTVIEW_MEMO.saveMode == 'Edit'){
		CONTENTVIEW_MEMO.editMemoFunction();
278
	}
279 280 281 282
	else if(CONTENTVIEW_MEMO.saveMode == 'New'){
		CONTENTVIEW_MEMO.memoSaveFunction();
	}else if(CONTENTVIEW_MEMO.saveMode == 'Copy'){
		CONTENTVIEW_MEMO.memoSaveFunction();
283
	}
284
	//CONTENTVIEW_MEMO.targetDiv.dialog('close');
285
	$("#overlay").hide();
286 287
	CONTENTVIEW_MEMO.targetDiv.children().remove();
	CONTENTVIEW_MEMO.targetDiv.hide();
288
	
289
	CONTENTVIEW_GENERAL.isCopyMemo = false;
290 291 292
	$("#pop_up_memo").hide();
	
	/* enable controls after finish copy */
293
	CONTENTVIEW.enableControlsCopyMemo();	
294 295
};

296 297
//未使用
CONTENTVIEW_MEMO.editJqueryUIDialog = function(){
298
	$('.ui-dialog-titlebar').hide();
299 300
	CONTENTVIEW_MEMO.targetDiv.addClass('memoDialogImportantCss');
	CONTENTVIEW_MEMO.targetDiv.parent().addClass('parentMemoDialogImportantCss');
301
};
302

303
$(function () {
Masaru Abe committed
304
	//CONTENTVIEW_MEMO.ready();
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319
});

CONTENTVIEW_MEMO.ready = function(){
	
	CONTENTVIEW_MEMO.targetDiv = undefined;
	CONTENTVIEW_MEMO.targetX = undefined;
	CONTENTVIEW_MEMO.targetY = undefined;
	CONTENTVIEW_MEMO.EditIndex = undefined;
	CONTENTVIEW_MEMO.saveMode = undefined;
	CONTENTVIEW_MEMO.memoCallbackFunc = undefined;
	CONTENTVIEW_MEMO.conid = undefined;
	CONTENTVIEW_MEMO.pageid = undefined;
	
};