contentview_Memo.js 10.7 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')
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 106
		//if(CONTENTVIEW_MEMO.memoCallbackFunc){
		//	CONTENTVIEW_MEMO.memoCallbackFunc();
		//}
		
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 147 148 149 150 151 152
CONTENTVIEW_MEMO.AddMemo = function(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.memoCallbackFunc = callback;
153
	
154 155
	CONTENTVIEW_MEMO.createMemoDialog();
	CONTENTVIEW_MEMO.saveMode = 'New';
156 157
	$('#Memo_btnDel').css('display','none');
	
158 159
	//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');
160
	$("#overlay").show();
161 162
	CONTENTVIEW.disableControlsCopyMemo();
	CONTENTVIEW_MEMO.targetDiv.css('z-index','1005');
163 164
	
	//START TRB00097
165 166 167
	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 ));
168 169 170
	    
	}
	else{
171 172
		CONTENTVIEW_MEMO.targetDiv.css('top',CONTENTVIEW_MEMO.targetY);
		CONTENTVIEW_MEMO.targetDiv.css('left',CONTENTVIEW_MEMO.targetX - ($('#memoWrapper').width() /2 ));
173 174 175 176 177
	}
	//END TRB00097
	
	
	
178 179
	CONTENTVIEW_MEMO.targetDiv.draggable({ handle: "h1" });
	//CONTENTVIEW_MEMO.editJqueryUIDialog();
180 181
};

182 183 184 185
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;
186
	
187 188
	CONTENTVIEW_MEMO.EditIndex = index;
	CONTENTVIEW_MEMO.memoCallbackFunc = callback;
189
	
190 191 192
	CONTENTVIEW_MEMO.createMemoDialog();
	CONTENTVIEW_MEMO.getMemoForEdit();
	CONTENTVIEW_MEMO.saveMode = 'Edit';
193 194
	$('#Memo_btnDel').css('display','block');
	
195 196
	//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');
197
	$("#overlay").show();
198 199
	CONTENTVIEW.disableControlsCopyMemo();
	CONTENTVIEW_MEMO.targetDiv.css('z-index','1005');
200
		
201
	var pt = CONTENTVIEW.imageToScreen(CONTENTVIEW_MEMO.targetX, CONTENTVIEW_MEMO.targetY);	
202 203 204
	
   //START TRB00097
    if(pt.y >= $('#wrapper').height()/2){
205 206
    	CONTENTVIEW_MEMO.targetDiv.css('top', $('#wrapper').height()/3);
    	CONTENTVIEW_MEMO.targetDiv.css('left',pt.x - ($('#memoWrapper').width() /2 ));       
207 208
    }
    else{
209 210
    	CONTENTVIEW_MEMO.targetDiv.css('top',pt.y);
    	CONTENTVIEW_MEMO.targetDiv.css('left',pt.x - ($('#memoWrapper').width() /2 ));
211 212 213
    }
    //END TRB00097
	
214 215
    CONTENTVIEW_MEMO.targetDiv.draggable({ handle: "h1" });
	//CONTENTVIEW_MEMO.editJqueryUIDialog();
216 217
};

218 219 220 221 222 223 224 225
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;
226
	
227 228
	CONTENTVIEW_MEMO.createMemoDialog();
	//CONTENTVIEW_MEMO.getMemoForEdit();
229
	$('#txaMemoContent').val(index);
230
	CONTENTVIEW_MEMO.saveMode = 'Copy';
231
	$('#Memo_btnDel').css('display','none');
232 233
	//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');
234
	$("#overlay").show();
235 236 237 238
	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 ));
239
	
240 241
	CONTENTVIEW_MEMO.targetDiv.draggable({ handle: "h1" });
	//CONTENTVIEW_MEMO.editJqueryUIDialog();
242 243
};

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

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

	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.
260
	arrTemp[CONTENTVIEW_MEMO.EditIndex] = tempEntity;
261 262
	ClientData.MemoData(arrTemp);
	
263 264
	if(CONTENTVIEW_MEMO.memoCallbackFunc){
		CONTENTVIEW_MEMO.memoCallbackFunc();
265 266 267
	}	
	
	/*refresh memo*/																	
268
	//CONTENTVIEW.drawCanvas();	
269 270
};

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

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

300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316
$(function () {
	//CONTENTVIEW_MEMO.ready();
});

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;
	
};