contentview.js 277 KB
Newer Older
1
/// コンテンツ詳細画面
2 3 4 5 6

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

$(document).mouseup(function (e) {
7
    if (e.which == 1){
8
        CONTENTVIEW_GENERAL.isPressLeftMouse = false;
9
    }
10
});
11 12

/* change size */
13
CONTENTVIEW.sizingScreen = function() {
14

Masaru Abe committed
15 16
    var w = $(window).width();
    var h = $(window).height();
17

Masaru Abe committed
18
    if (COMMON.isTouchDevice() == true) {
Masaru Abe committed
19
        if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
20 21 22 23 24 25 26 27 28 29 30 31 32
            var tempRatio = document.documentElement.clientWidth / window.innerWidth;
            if (tempRatio <= 1) {
                w = window.innerWidth;
                h = window.innerHeight;
            }
            else {
                w = $(window).width();
                h = $(window).height();
            }
        }
    }

    // Adjust the size of the View
33
    if (CONTENTVIEW_GENERAL.isFullScreen == true) {
34
        CONTENTVIEW.sizingFullSize(w, h);
35
    } else {
36
        CONTENTVIEW.sizingNotFull(w, h);
37 38 39 40 41
    }

};

/* memo */
42
CONTENTVIEW.handleMemo = function() {
43 44 45 46
    $('#pop_up_memo').hide();

    if (ClientData.IsDisplayMemo() == true) {
        ClientData.IsDisplayMemo(false);
47
        CONTENTVIEW_GENERAL.isCopyMemo = false;
48

49
        CONTENTVIEW.drawCanvas();
50

51
        //Start Function : No.4
52
        if(CONTENTVIEW_GETDATA.getContent().hasNextPage()){
53
            CONTENTVIEW.drawCanvas(1);
54
        }
55

56
        if(CONTENTVIEW_GETDATA.getContent().hasPreviousPage()){
57
            CONTENTVIEW.drawCanvas(2);
58
        }
59 60 61 62
        //End Function : No.4

        //change class
        $('#imgmemo').removeClass();
Masaru Abe committed
63
        if (COMMON.isTouchDevice() == true) {
64 65 66 67 68 69 70 71 72 73
            $('#imgmemo').addClass('memoDisplay_device');
        } else {
            $('#imgmemo').addClass('memoDisplay');
        }

        /*handle image add memo */
        ClientData.IsAddingMemo(false);

        //change class
        $('#imgaddmemo').removeClass();
Masaru Abe committed
74
        if (COMMON.isTouchDevice() == true) {
75 76 77 78 79
            $('#imgaddmemo').addClass('memoAdd_device');
        } else {
            $('#imgaddmemo').addClass('memoAdd');
        }

80
    }
81 82
    else {
        ClientData.IsDisplayMemo(true);
83
        CONTENTVIEW_GENERAL.isCopyMemo = false;
84

85
        CONTENTVIEW.drawMemoOnScreen();
86

87
        //Start Function : No.4
88
        if(CONTENTVIEW_GETDATA.getContent().hasNextPage()){
89
            CONTENTVIEW.drawMemoOnScreen(1);
90
        }
91

92
        if(CONTENTVIEW_GETDATA.getContent().hasPreviousPage()){
93
            CONTENTVIEW.drawMemoOnScreen(2);
94
        }
95 96 97 98 99 100 101 102 103 104 105
        //End Function : No.4

        //change class
        $('#imgmemo').removeClass();
        $('#imgmemo').addClass('memoDisplay_hover');

    }
};


/* display canvas draw*/
106
CONTENTVIEW.displayCanvasDraw = function() {
107
    /*set flag no image */
108
    CONTENTVIEW_GENERAL.isDrawing = false;
109 110

    /* clear canvas */
111
    CONTENTVIEW_GENERAL.context_draw.clearRect(0, 0, CONTENTVIEW_GENERAL.canvas_draw.width, CONTENTVIEW_GENERAL.canvas_draw.height);
112

113
    CONTENTVIEW_GENERAL.context_draw.save();
114 115 116 117 118

    /* set draw image if exist */
    var dataMarking = ClientData.MarkingData();

    for (var nIndex = 0; nIndex < dataMarking.length; nIndex++) {
119 120
        if (dataMarking[nIndex].contentid == CONTENTVIEW_GENERAL.contentID
        && dataMarking[nIndex].pageNo == CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex())) {
121 122
            var img = new Image();
            img.onload = function () {
123

124
                CONTENTVIEW_GENERAL.context_draw.drawImage(img, 0, 0, CONTENTVIEW_GENERAL.canvas_draw.width, CONTENTVIEW_GENERAL.canvas_draw.height);
125 126

                /*set flag has image */
127
                CONTENTVIEW_GENERAL.isDrawing = true;
128 129 130 131 132
            };
            img.src = dataMarking[nIndex].content;
        }
    }

133
    CONTENTVIEW_GENERAL.context_draw.restore();
134 135 136 137 138 139 140

    /* visible canvas using for draw */
    $('#draw_canvas').css('display', 'block');
};


/* handle draw canvas */
141
CONTENTVIEW.handleDrawCanvas = function() {
142
    CONTENTVIEW_MARKING.disableButtonMarking();
143 144 145 146 147
    if (ClientData.IsAddingMarking() == true) {
        if (ClientData.IsHideToolbar() == true) {
            ClientData.IsAddingMarking(true);
            ClientData.IsDisplayMarking(true);
            ClientData.IsHideToolbar(false);
148
            CONTENTVIEW_MARKING.ShowMarking();
149 150 151 152 153 154 155 156 157 158 159

            $('#imgmarking').removeClass();
            $('#imgmarking').addClass('marking_off');
        }
    }
    else {
        ClientData.IsAddingMarking(true);
        ClientData.IsDisplayMarking(true);
        ClientData.IsHideToolbar(false);

        /* fit page */
160
        CONTENTVIEW.screenFit();
161 162

        /* show marking */
163
        CONTENTVIEW_MARKING.ShowMarking();
164 165

        /* display fullscreen */
166
        CONTENTVIEW.handleDisplayToolbar();
167 168 169 170

        /* invisible button fullscreen */
        $('#footer_toolbar_2').hide();
        $('#control_screen_2').hide();
171 172


173 174
        //START TRB00032 - EDITOR : Long - DATE: 09/10/2013 - Summary : For Content Type None
        /* draw again */
175
        //CONTENTVIEW.drawCanvas();
176
        //END TRB00032 - EDITOR : Long - DATE: 09/10/2013 - Summary : For Content Type None
177

178
        CONTENTVIEW.displayCanvasDraw();
179
        CONTENTVIEW_GENERAL.disableAllControl();
180 181 182
    }

    /* get data from local */
183
    CONTENTVIEW_GETDATA.getDataClientStorage();
184 185 186 187

};

/* bookmark page */
188
CONTENTVIEW.bookmarkPage = function() {
189
    ClientData.isChangedBookmark(true);
190
    var nBookmarkId = CONTENTVIEW.isExistBookmark();
191 192 193
    if (nBookmarkId == -1) {
        //case not exist
        var enBookmark = new BookMarkEntity();
194 195 196 197 198
        enBookmark.contentid = CONTENTVIEW_GENERAL.contentID;
        enBookmark.pageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex());
        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image){
            enBookmark.contentTitle = CONTENTVIEW_GENERAL.imageTypeData.contentName;
            enBookmark.contentTitleKana = CONTENTVIEW_GENERAL.imageTypeData.contentNameKana;
199 200
        }
        else{
201 202
            enBookmark.contentTitle = CONTENTVIEW_GENERAL.dataWebContentPage.contentTitle;
            enBookmark.contentTitleKana = CONTENTVIEW_GENERAL.dataWebContentPage.contentTitleKana;
203
        }
204

205
        //=== Start Function : No.17    Editor : Long   Date: 07/30/2013   Summary : Set UTC time and UUID when create new bookmark.
Masaru Abe committed
206
        enBookmark.bookmarkid = COMMON.getUUID();
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229
        enBookmark.registerDate = new Date();
        //=== Start Function : No.17    Editor : Long   Date: 07/30/2013   Summary : Set UTC time and UUID when create new bookmark.
        var listBM = [];

        if (ClientData.BookMarkData().length > 0) {
            listBM = ClientData.BookMarkData();
        }
        listBM.push(enBookmark);
        ClientData.BookMarkData(listBM);

        //change class
        $('#imgbookmark').removeClass();
        $('#imgbookmark').addClass('bmAdd_hover');

    } else {
        //delete bookmark page
        var listBM = [];
        listBM = ClientData.BookMarkData();
        listBM.splice(nBookmarkId, 1);
        ClientData.BookMarkData(listBM);

        //change class
        $('#imgbookmark').removeClass();
Masaru Abe committed
230
        if (COMMON.isTouchDevice() == true) {
231 232 233 234 235 236 237 238 239
            $('#imgbookmark').addClass('bmAdd_device');
        } else {
            $('#imgbookmark').addClass('bmAdd');
        }

    }
};

/* function changePage Index->pageno */
240
CONTENTVIEW.changePageIndex = function(page_index) {
241
    //Start: Function No.12
242
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image){
243 244
        return 1;
    }
245
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
246 247 248 249
        return page_index + 1;
    }
    //End: Function No.12
    else{
250 251 252 253
        //最後のページのメモを削除するとエラーになる暫定対応
        if( CONTENTVIEW_GENERAL.dataWebContentPage.pages[page_index] ){
            return CONTENTVIEW_GENERAL.dataWebContentPage.pages[page_index].pageNo;
        } else {
254
            return page_index - 1;
255
        }
256 257 258 259
    }
};

/* function change PageNo -> pageIndex */
260
CONTENTVIEW.changePageNo = function(page_no) {
261

262 263
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
        var dataContent = CONTENTVIEW_GENERAL.dataWebContentPage.pages;
264 265 266 267 268 269 270
        for (var nIndex = 0; nIndex < dataContent.length; nIndex++) {
            if (dataContent[nIndex].pageNo == page_no) {
                return nIndex;
            }
        }
    }
    //START : TRB00032 - Editor : Long - Date : 09/10/2013 - Summary : Process Type None
271
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
272 273 274 275 276
        page_no = page_no - 1;
        return page_no;
    }
   //END : TRB00032 - Editor : Long - Date : 09/10/2013 - Summary : Process Type None
    return -1;
277

278 279 280
};

/* check page had bookmark */
281
CONTENTVIEW.isExistBookmark = function() {
282 283 284 285 286 287 288
    var nIndexBookmark = -1;
    var listBM = [];
    if (ClientData.BookMarkData().length > 0) {
        //get list bookmark
        listBM = ClientData.BookMarkData();

        for (var nIndex = 0; nIndex < listBM.length; nIndex++) {
289
            //check bookmark belong contentID
290
            if (listBM[nIndex].contentid == CONTENTVIEW_GENERAL.contentID && listBM[nIndex].pageNo == CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex())) {
291 292 293 294 295 296 297 298
                return nIndex;
            }
        }
    }
    return nIndexBookmark;
};

/*get API WebContentPage */
299
CONTENTVIEW.handleAPIWebContentPage = function(dataJson, pos) {
300
    var bmList = [];
301 302
    bmList = CONTENTVIEW_GETDATA.getBookMarkListByContentID();
    var dataStored = CONTENTVIEW_GENERAL.arrThumbnailsLoaded;
303 304 305 306 307 308 309

    var sPageNo = [];
    var nIndexBookMark = -1;
    var lstPageNoBookMark = [];

    $('#bookmarkBoxHdBM').children().remove();
    $('#bookmarkBoxHdBM').html('<a id="bookmarkClosing" class="delete" > </a>');
310 311
    //$("#bookmarkClosing").click(CONTENTVIEW_EVENTS.closeBookmarkBox);
    $("#bookmarkClosing").on({
312 313 314 315 316 317 318 319
        'click touchend': function(ev){
            CONTENTVIEW_EVENTS.closeBookmarkBox(ev);
            return false;
        },
        'touchstart touchmove': function(){
            //これを入れないと次にダイアログを開くと表示位置が大きくズレる
            return false;
        }
320
    });
321

322
    $('#bookmarkBoxHdBM').append(I18N.i18nText('txtShioriCtnLs'));
323 324 325 326 327 328 329 330 331 332 333

    $('#boxBookMark').css('z-index', '101');
    $('#boxBookMark').css('display', 'block');
    $('#boxBookMark').draggable({ handle: "h1" });
    $("#boxBookMark").offset({ left: pos[0], top: pos[1] });
    $("#divListBookmark").show();
    $("#divListBookmark").offset({ left: pos[0], top: (pos[1] + $('#bookmarkBoxHdBM').height()) });
    $('#divListBookmark').children().remove();


    //Start Function : No.4 - Editor : Long - Date : 08/20/2013
334
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
335 336 337
        for (var nIndex = 0; nIndex < bmList.length; nIndex++) {
            nIndexBookMark = -1;
            var contentPage = dataJson.pages;
338

339 340 341 342 343 344
            for (var nIndexJson = 0; nIndexJson < contentPage.length; nIndexJson++) {
                if (contentPage[nIndexJson].pageNo == bmList[nIndex].pageNo) {
                    nIndexBookMark = nIndexJson;
                    break;
                }
            }
345

346
            if (nIndexBookMark != -1) { /* page exist */
347
                var nStored = CONTENTVIEW.checkDataLoaded(bmList[nIndex].pageNo, dataStored);
348 349
                if (nStored != -1) { /* data loaded */
                    $('#divListBookmark').append(
350 351
                        '   <li id="' + CONTENTVIEW.changePageNo(bmList[nIndex].pageNo) + '">' +
                        '       <img id="img_bookmark_' + bmList[nIndex].pageNo + '" class="imgbox" src="' + COMMON.formatStringBase64(dataStored[nStored].pageThumbnail) + '"/>' +
352
                        '       <span class="mdltext">' +
353
                                    I18N.i18nText('txtPage') + (CONTENTVIEW.changePageNo(bmList[nIndex].pageNo) + 1) + '<br /> ' +
Masaru Abe committed
354
                                    COMMON.truncate(COMMON.htmlEncode(contentPage[nIndexBookMark].pageText), 20) +
355 356 357
                        '       </span>' +
                        '   </li>'
                        );
358

359 360
                    //Resize Image
                    var imgTemp = new Image();
361

362
                    imgTemp.onload = function () {
363

364
                        if (imgTemp.width > imgTemp.height) {
365

366 367 368 369 370 371 372 373 374 375
                            $("img.imgbox").attr('height', '');
                            $("img.imgbox").removeAttr('height');
                            $("img.imgbox").attr('width', '43');
                        }
                        else {
                            $("img.imgbox").attr('width', '');
                            $("img.imgbox").removeAttr('width');
                            $("img.imgbox").attr('height', '43');
                        }
                    };
376

377
                    imgTemp.src = COMMON.formatStringBase64(dataStored[nStored].pageThumbnail);
378 379

                }
380 381
                else { /* data not loaded*/
                    $('#divListBookmark').append(
382
                        '   <li id="' + CONTENTVIEW.changePageNo(bmList[nIndex].pageNo) + '">' +
383 384
                        '       <img id="img_bookmark_' + bmList[nIndex].pageNo + '" class="imgbox" src="img/view_loading.gif" />' +
                        '       <span class="mdltext">' +
385
                                    I18N.i18nText('txtPage') + (CONTENTVIEW.changePageNo(bmList[nIndex].pageNo) + 1) + '<br /> ' +
Masaru Abe committed
386
                                    COMMON.truncate(COMMON.htmlEncode(contentPage[nIndexBookMark].pageText), 20) +
387 388 389
                        '       </span>' +
                        '   </li>'
                        );
390

391 392
                    //Resize Image
                    var imgTemp = new Image();
393

394
                    imgTemp.onload = function () {
395

396
                        if (imgTemp.width > imgTemp.height) {
397

398 399 400 401 402 403 404 405 406 407
                            $("img.imgbox").attr('height', '');
                            $("img.imgbox").removeAttr('height');
                            $("img.imgbox").attr('width', '43');
                        }
                        else {
                            $("img.imgbox").attr('width', '');
                            $("img.imgbox").removeAttr('width');
                            $("img.imgbox").attr('height', '43');
                        }
                    };
408

409
                    imgTemp.src = "img/view_loading.gif";
410

411 412
                    lstPageNoBookMark.push(bmList[nIndex].pageNo);
                }
413 414 415


            }
416 417
            else { /* page deleted */
                $('#divListBookmark').append(
418
                        '   <li id="' + CONTENTVIEW.changePageNo(bmList[nIndex].pageNo) + '">' +
419
                        '       <span class="mdltext">' +
420

421
                        '           <span>' + I18N.i18nText('txtPage') + bmList[nIndex].pageNo + '</span> <br /> ' +
422 423 424 425
                        '       </span>' +
                        '   </li>' +
                        '   <li>' +
                        '       <span class="mdltext">' +
426
                        '           <span class="error">' + I18N.i18nText('msgShioriDeleted') + '</span>' +
427 428 429 430 431 432
                        '       </span>' +
                        '   </li>'
                    );
            }
        }
    }
433
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Image ){
434

435 436
        for (var nIndex = 0; nIndex < bmList.length; nIndex++) {
            nIndexBookMark = -1;
437
            var contentPage = CONTENTVIEW_GENERAL.imageTypeData;
438

439 440 441 442 443 444 445 446 447 448 449

            if (contentPage.pageNo == bmList[nIndex].pageNo) {
                nIndexBookMark = nIndexJson;
            }

            if (nIndexBookMark != -1) { /* page exist */

                    $('#divListBookmark').append(
                        '   <li id="' + 0 + '">' +
                        '       <img id="img_bookmark_' + bmList[nIndex].pageNo + '" class="imgbox" src="img/view_loading.gif" />' +
                        '       <span class="mdltext">' +
450
                                    I18N.i18nText('txtPage') + 1 + '<br /> ' +
Masaru Abe committed
451
                                    COMMON.truncate(COMMON.htmlEncode(contentPage.contentName), 20) +
452 453 454
                        '       </span>' +
                        '   </li>'
                        );
455

456 457 458
                    //Resize Image
                    var imgTemp = new Image();
                    var imageContent = new Image();
459
                    var imageUrl = CONTENTVIEW.downloadResourceById(CONTENTVIEW_GENERAL.contentID);
460

461
                    imgTemp.onload = function () {
462

463
                        if (imgTemp.width > imgTemp.height) {
464

465 466 467 468 469 470 471 472 473
                            $("img.imgbox").attr('height', '');
                            $("img.imgbox").removeAttr('height');
                            $("img.imgbox").attr('width', '43');
                        }
                        else {
                            $("img.imgbox").attr('width', '');
                            $("img.imgbox").removeAttr('width');
                            $("img.imgbox").attr('height', '43');
                        }
474

475 476 477
                        imageContent.onload = function(){
                            $("img.imgbox").attr('src', imageUrl);
                        };
478

479 480
                        imageContent.src = imageUrl;
                    };
481

482
                    imgTemp.src = "img/view_loading.gif";
483 484 485 486

                    lstPageNoBookMark.push(bmList[nIndex].pageNo);

            }
487 488 489 490
            else { /* page deleted */
                $('#divListBookmark').append(
                        '   <li id="' + 0 + '">' +
                        '       <span class="mdltext">' +
491

492
                        '           <span>' + I18N.i18nText('txtPage') + bmList[nIndex].pageNo + '</span> <br /> ' +
493 494 495 496
                        '       </span>' +
                        '   </li>' +
                        '   <li>' +
                        '       <span class="mdltext">' +
497
                        '           <span class="error">' + I18N.i18nText('msgShioriDeleted') + '</span>' +
498 499 500 501 502 503
                        '       </span>' +
                        '   </li>'
                    );
            }
        }
    }
504
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
505
        for (var nIndex = 0; nIndex < bmList.length; nIndex++) {
506

507
            $('#divListBookmark').append(
508
                '   <li id="' + CONTENTVIEW.changePageNo(bmList[nIndex].pageNo) + '">' +
509 510
                '       <img id="img_bookmark_' + bmList[nIndex].pageNo + '" class="imgbox" src="img/view_loading.gif" />' +
                '       <span class="mdltext">' +
511
                            I18N.i18nText('txtPage') + bmList[nIndex].pageNo + '<br /> ' +
Masaru Abe committed
512
                            //COMMON.truncate(COMMON.htmlEncode(contentPage.contentName), 20) +
513 514 515
                '       </span>' +
                '   </li>'
            );
516

517 518 519
            //Resize Image
            var imgTemp = new Image();
            var imageContent = new Image();
520
            var imageUrl = CONTENTVIEW_GENERAL.pageImages;
521 522 523 524 525 526 527 528 529 530 531 532 533
            imgTemp.onload = function () {

                if (imgTemp.width > imgTemp.height) {

                    $("img.imgbox").attr('height', '');
                    $("img.imgbox").removeAttr('height');
                    $("img.imgbox").attr('width', '43');
                }
                else {
                    $("img.imgbox").attr('width', '');
                    $("img.imgbox").removeAttr('width');
                    $("img.imgbox").attr('height', '43');
                }
534

535 536 537
                imageContent.onload = function(){
                    $("img.imgbox").attr('src', imageUrl);
                };
538

539 540 541 542
                imageContent.src = imageUrl;
            };

            imgTemp.src = "img/view_loading.gif";
543

544
            lstPageNoBookMark.push(bmList[nIndex].pageNo);
545

546 547
        }
    }
548 549


550
    //End Function : No.4 - Editor : Long - Date : 08/20/2013
551
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
552
        if (lstPageNoBookMark.length > 0) {
553 554
            CONTENTVIEW_GENERAL.isSendingData = true;
            CONTENTVIEW_CALLAPI.loadDataBookmark(lstPageNoBookMark);
555 556 557 558 559
        }
    }
};

/* check data has load */
560
CONTENTVIEW.checkDataLoaded = function(nPageNo, arrData) {
561 562 563 564 565 566 567 568 569 570 571
    var nIndex = -1;
    for (var n = 0; n < arrData.length; n++) {
        if (arrData[n].pageNo == nPageNo) {
            nIndex = n;
            break;
        }
    }
    return nIndex;
};

/* sort list bookmark */
572
CONTENTVIEW.sortBookmarkList = function() {
573 574 575 576 577 578 579 580 581 582 583
    var bmList = [];
    bmList = ClientData.BookMarkData();
    bmList.sort(function (a, b) {
        var a1 = a.pageNo, b1 = b.pageNo;
        if (a1 == b1) return 0;
        return a1 > b1 ? 1 : -1;
    });
    ClientData.BookMarkData(bmList);
};

/* create child node for list page index */
584
CONTENTVIEW.AddChidrenNode = function(nodeParent, data) {
585 586 587 588 589 590 591 592 593 594 595
    var dataChild = [];
    $.each(data, function (index, value) {
        if (data[index].parentID == nodeParent.id) {
            dataChild.push(data[index]);
        }
    });

    $.each(dataChild, function (i, value) {
        //add child node
        var item = new TreeNode();
        item.IsCategory = false;
Masaru Abe committed
596
        //item.Text = COMMON.htmlEncode(COMMON.truncateByBytes(dataChild[i].title,30));
597
        /* check data text */
Masaru Abe committed
598 599
        if (COMMON.getBytes(dataChild[i].title) > 30) {
            item.Text = COMMON.htmlEncode(COMMON.truncateByBytes(dataChild[i].title, 30)) + '...';
600
        } else {
Masaru Abe committed
601
            item.Text = COMMON.htmlEncode(dataChild[i].title);
602 603 604 605 606 607 608 609 610 611 612
        }
        item.id = dataChild[i].ID;
        item.Value = dataChild[i].destPageNumber;

        for (var nIndex = 0; nIndex < data.length; nIndex++) {
            if (data[nIndex].parentID == item.id) {
                item.IsCategory = true;
                break;
            }
        }

613
        CONTENTVIEW.AddChidrenNode(item, data);
614 615 616 617 618
        nodeParent.ChildNodes.push(item);

    });
};

619
CONTENTVIEW.copyText = function() {
620 621 622 623
    var w = window.open('contentview_textcopy.html');
};

/* handle data copy text */
624
CONTENTVIEW.handleCopyTextData = function(data, pos) {
625 626 627 628 629 630 631
    /* init var page text */
    var sPageText = '';
    var w = $("#wrapper").width() / 2 - $('#boxCopyText').width() / 2;
    var h = $("#wrapper").height() / 2 - $('#boxCopyText').height() / 2;

    for (var nIndex = 0; nIndex < data.length; nIndex++) {
        /* get text of current page */
632
        if (data[nIndex].pageNo == CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex())) {
Masaru Abe committed
633
            sPageText = COMMON.htmlEncode(data[nIndex].pageText);
634 635 636 637 638 639 640
            break;
        }
    }

    if (sPageText == '') {
        /* create data on dialog */
        $('#divCopyText').children().remove();
641
        $('#divCopyText').append('<li class="last">' + I18N.i18nText('txtNoTextCopy') + '</li>');
642 643 644 645

        //title start
        $('#bookmarkBoxHdCT').children().remove();
        $('#bookmarkBoxHdCT').html('<a id="copyTextClosing" class="delete" style="padding-top:0px;"> </a>');
646 647
        //$("#copyTextClosing").click(CONTENTVIEW_EVENTS.closeCopyTextBox);
        $("#copyTextClosing").on({
648 649 650 651 652 653 654 655
            'click touchend': function(ev){
                CONTENTVIEW_EVENTS.closeCopyTextBox(ev);
                return false;
            },
            'touchstart touchmove': function(){
                //これを入れないと次にダイアログを開くと表示位置が大きくズレる
                return false;
            }
656
        });
657

658
        $('#bookmarkBoxHdCT').append(I18N.i18nText('txtTextCopy'));
659 660
        //title end

Masaru Abe committed
661
        //COMMON.lockLayout();
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681
        $('#boxCopyText').css('z-index', '101');
        $('#boxCopyText').css('display', 'block');
        $('#boxCopyText').draggable({ handle: "h1" });
        $("#boxCopyText").offset({ left: w, top: h });
        $("#divCopyText").show();

    } else {
        /* create data on dialog */
        $('#divCopyText').children().remove();

        var strPattern = "\n";
        var strTemp = sPageText;
        strTemp = strTemp.replaceAll(strPattern, "<br/>");
        strTemp += "<br/>";

        $('#divCopyText').append('<div class="last" id="txtTextCopy" style="word-wrap:break-word;line-height: 20px">' + strTemp + '</div>');

        //title start
        $('#bookmarkBoxHdCT').children().remove();
        $('#bookmarkBoxHdCT').html('<a id="copyTextClosing" class="delete" style="padding-top:0px;"> </a>');
682 683
        //$("#copyTextClosing").click(CONTENTVIEW_EVENTS.closeCopyTextBox);
        $("#copyTextClosing").on({
684 685 686 687 688 689 690 691
            'click touchend': function(ev){
                CONTENTVIEW_EVENTS.closeCopyTextBox(ev);
                return false;
            },
            'touchstart touchmove': function(){
                //これを入れないと次にダイアログを開くと表示位置が大きくズレる
                return false;
            }
692
        });
693

694
        $('#bookmarkBoxHdCT').append(I18N.i18nText('txtTextCopy'));
695 696
        //title end

Masaru Abe committed
697
        //COMMON.lockLayout();
698 699
        $('#boxCopyText').css('z-index', '101');
        $('#boxCopyText').css('display', 'block');
700
        //$('#boxCopyText').draggable({ handle: "h1" });
701 702 703
        $("#boxCopyText").offset({ left: w, top: h });
        $("#divCopyText").show();

Masaru Abe committed
704
        if (COMMON.isTouchDevice() == true) {
705 706
            document.getElementById('bookmarkBoxHdCT').addEventListener('touchstart', CONTENTVIEW.eventStart_CopyText, false);
            document.getElementById('bookmarkBoxHdCT').addEventListener('touchend', CONTENTVIEW.eventEnd_CopyText, false);
707
        } else {
708 709
            document.getElementById('bookmarkBoxHdCT').addEventListener('mousedown', CONTENTVIEW.eventStart_CopyText, false);
            document.getElementById('bookmarkBoxHdCT').addEventListener('mouseup', CONTENTVIEW.eventEnd_CopyText, false);
710 711 712 713 714
        }
    }
};

/* event touch start header copytext */
715
CONTENTVIEW.eventStart_CopyText = function(e) {
716 717 718 719 720
    e.preventDefault();
    $('#boxCopyText').draggable({ handle: "h1" });
};

/* event touch end header copytext */
721
CONTENTVIEW.eventEnd_CopyText = function(e) {
722 723 724 725 726 727
    e.preventDefault();
    $("#boxCopyText").draggable("destroy");

};

/* search content */
728
CONTENTVIEW.searchHandle = function() {
729
    var w = $("#main").width() - $(".hdRcolumn").width();
730
    var searchText;
731
    var pos = [w, CONTENTVIEW.marginY];
732 733 734 735 736 737

    if($('#txtSearch').val().length > 200){
		alert('200字以下のテキストを入力してください');
		return;
    }

738
    if ($('#txtSearch').val() != '' && $('#txtSearch').val() != '\"\"') {
739 740 741 742 743 744 745 746
            var dataStored = CONTENTVIEW_GENERAL.arrThumbnailsLoaded;
            var contentPage = CONTENTVIEW_GENERAL.dataWebContentPage.pages;
            var sPageNo = [];
            var lstPageNo = [];

            //seperate string 
            var myRegexp = /[^\s"]+|"([^"]*)"/gi;
            var myArray = [];
747
            var myQuery;
748
            var myRegExpArr = [];
749
            var count = 0;          
750
            var textReg = $('#txtSearch').val().replace(/\(/g," \( ").replace(/\)/g," \) ");
751

752 753 754 755
            //)(check
            var dummyArray = [];
			var dummytextReg = $('#txtSearch').val().replace(/\"/g,"'\"'");

756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799
            if($('#txtSearch').val() == '"("'){
                myRegExpArr[0] = new RegExp("[\(]");
                for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
                    if (myRegExpArr[0].test(contentPage[nIndex].pageText)) {
                        sPageNo.push(contentPage[nIndex]);
                    }
                }    
            }else if($('#txtSearch').val() == '")"'){
                myRegExpArr[0] = new RegExp("[\)]");
                for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
                    if (myRegExpArr[0].test(contentPage[nIndex].pageText)) {
                        sPageNo.push(contentPage[nIndex]);
                    }
                }    
            }else if($('#txtSearch').val() == '"or"'){
                myRegExpArr[0] = new RegExp("or");
                for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
                    if (myRegExpArr[0].test(contentPage[nIndex].pageText)) {
                        sPageNo.push(contentPage[nIndex]);
                    }
                }    
            }else if($('#txtSearch').val() == '"Or"'){
                myRegExpArr[0] = new RegExp("Or");
                for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
                    if (myRegExpArr[0].test(contentPage[nIndex].pageText)) {
                        sPageNo.push(contentPage[nIndex]);
                    }
                }    
            }else if($('#txtSearch').val() == '"oR"'){
                myRegExpArr[0] = new RegExp("oR");
                for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
                    if (myRegExpArr[0].test(contentPage[nIndex].pageText)) {
                        sPageNo.push(contentPage[nIndex]);
                    }
                }    
            }else if($('#txtSearch').val() == '"OR"'){
                myRegExpArr[0] = new RegExp("OR");
                for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
                    if (myRegExpArr[0].test(contentPage[nIndex].pageText)) {
                        sPageNo.push(contentPage[nIndex]);
                    }
                }    
            }else{
            
800
        try{
801 802 803 804 805 806 807 808 809 810

            do {
				var match = myRegexp.exec(dummytextReg);
				if (match != null)
				{
					dummyArray.push(match[1] ? match[1] : match[0]);
				}
            } while (match != null);
            
			for(var i = 0; i < dummyArray.length; i++){
811
                if(dummyArray[i].indexOf(")(") > 0 && dummyArray[i].charAt(0) != "'" && dummyArray[i].charAt(dummyArray.length - 1) != "'"){
812
					throw new Error('quotes error!');
813 814 815
				}
			}

816
            do {
817
                var match = myRegexp.exec(textReg);
818 819
                if (match != null)
                {
820
                    myArray.push(match[1] ? match[1].replace(/ \( /g,"[\(]").replace(/ \) /g,"[\)]") : match[0].replace(/ \( /g,"[\(]").replace(/ \) /g,"[\)]"));
821 822
                }
            } while (match != null);
823

824 825 826 827 828 829 830 831 832 833 834 835
            for(var i = 0; i < myArray.length; i++){
				if(myArray[i] != "OR" && myArray[i] != "or" && myArray[i] != "Or" && myArray[i] != "oR" && myArray[i] != "(" && myArray[i] != ")"){
					count++;
				}
			}

            if(count > 5){
				alert('語句数は最大5つです');
				return;        
			}

            if(myArray[0] == "("){
836
                if(myArray[0]  == "("){
837 838 839 840
                    if(myArray[1]  != "("){
                        myRegExpArr[1] = new RegExp(myArray[1]);
                    }
                    myQuery = '( ';
841 842 843 844
                }
            }else{
                myRegExpArr[0] = new RegExp(myArray[0]);
                myQuery = 'myRegExpArr[0].test(contentPage[nIndex].pageText)';
845 846 847
                if(myArray[0] == "OR" || myArray[0] == "or" || myArray[0] == "Or" || myArray[0] == "oR"){
					myQuery = ' || ';
				}
848 849
            }

850
            for (var i = 1; i < myArray.length; i++){
851
                if(myArray[i] == "OR" || myArray[i] == "or" || myArray[i] == "Or" || myArray[i] == "oR"){
852
                    myRegExpArr[i] = new RegExp(myArray[i]);
853
                }else if(myArray[i] == "(" || myArray[i] == "("){
854
                    if(myArray[i]  == "("){
855
                        if(myArray[i - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){
856
                            myQuery += ' || (';
857
                        }else if(myArray[i - 1] != "("){
858
                            myQuery += ' && (';
859 860 861
                        }else{
							myQuery += ' (';
						}
862
                    }else{
863
                        if(myArray[i - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){
864 865 866 867 868 869
                            myRegExpArr[i] = new RegExp(myArray[i].slice(1));
                            myQuery += ' || ( myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';
                        }else{
                            myRegExpArr[i] = new RegExp(myArray[i].slice(1));
                            myQuery += ' && ( myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';
                        }
870
                    }
871 872 873
                }else if(myArray[i].charAt(myArray[i].length - 1) == ")" || myArray[i]  == ")"){
                    if(myArray[i]  == ")"){
                        myQuery += ' )';
874
                    }else{
875
                        if(myArray[i - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){
876
                            myRegExpArr[i] = new RegExp(myArray[i].slice(0, -1));
877 878 879 880 881
                            myQuery += ' || myRegExpArr[' + i + '].test(contentPage[nIndex].pageText) )';
                        }else{
                            myRegExpArr[i] = new RegExp(myArray[i].slice(0, -1));
                            myQuery += ' && myRegExpArr[' + i + '].test(contentPage[nIndex].pageText) )';
                        }
882 883
                    }
                }else{
884
                    if(myArray[i - 1] == "OR" || myArray[i - 1] == "or" || myArray[i - 1] == "Or" || myArray[i - 1] == "oR"){
885
                        myRegExpArr[i] = new RegExp(myArray[i]);
886
                        myQuery += ' || myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';
887
                    }else{
888 889
                        if(myArray[i - 1] == "("){
                            myRegExpArr[i] = new RegExp(myArray[i]);
890
                            myQuery += ' myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';  
891 892
                        }else{
                            myRegExpArr[i] = new RegExp(myArray[i]);
893
                            myQuery += ' && myRegExpArr[' + i + '].test(contentPage[nIndex].pageText)';   
894
                        }
895 896 897 898
                    }
                }
            }

899
            if($('#txtSearch').val() == "or" || $('#txtSearch').val() == "Or" || $('#txtSearch').val() == "oR" || $('#txtSearch').val() == "OR" || $('#txtSearch').val() == " " || $('#txtSearch').val() == ""){
900 901 902
                myQuery = ' ||';
            }

903 904 905 906
            for (var nIndex = 0; nIndex < contentPage.length; nIndex++) {
                if (eval(myQuery)) {
                    sPageNo.push(contentPage[nIndex]);
                }
907
            }
908

909
        }catch(error){
910
	    	searchText = "invaildsearchtextzeroresultfound";
911
        }
912
    }
913 914 915 916
        if (sPageNo.length > 0) {
            //title start
            $('#bookmarkBoxHdSearching').children().remove();
            $('#bookmarkBoxHdSearching').html('<a id="searchingResultClosing" class="delete" > </a>');
917
            $("#searchingResultClosing").click(CONTENTVIEW_EVENTS.closeSearchingBox);
918
            $('#bookmarkBoxHdSearching').append(I18N.i18nText('txtSearchResult'));
919 920
            //title end

Masaru Abe committed
921
            //COMMON.lockLayout();
922 923 924 925 926 927 928 929 930 931
            $('#boxSearching').css('z-index', '101');
            $('#boxSearching').css('display', 'block');
            $('#boxSearching').draggable({ handle: "h1" });
            $("#boxSearching").offset({ left: pos[0], top: pos[1] });
            $("#divSearchResult").show();
            $("#divSearchResult").offset({ left: pos[0], top: (pos[1] + $('#bookmarkBoxHdSearching').height() - 2) });

            $('#divSearchResult').children().remove();

            for (var i = 0; i < sPageNo.length; i++) {
932
                var nStored = CONTENTVIEW.checkDataLoaded(sPageNo[i].pageNo, dataStored);
933 934
                if (nStored != -1) { /* data loaded */
                    $('#divSearchResult').append(
935 936
                        '   <li id="' + CONTENTVIEW.changePageNo(sPageNo[i].pageNo) + '">' +
                        '       <img id="img_search_' + sPageNo[i].pageNo + '" class="imgbox" src="' + COMMON.formatStringBase64(dataStored[nStored].pageThumbnail) + '"/>' +
Vo Duc Thang committed
937
                        '       <span class="mdltext">' +
938
                                    I18N.i18nText('txtPage') + (CONTENTVIEW.changePageNo(sPageNo[i].pageNo) + 1) + '<br /> ' +
Masaru Abe committed
939
                                    COMMON.htmlEncode(COMMON.truncate(sPageNo[i].pageText, 20)) +
Vo Duc Thang committed
940 941 942
                        '       </span>' +
                        '   </li>'
                    );
943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959

                    //Resize Image
                    var imgTemp = new Image();

                    imgTemp.onload = function () {
                        if (imgTemp.width > imgTemp.height) {
                            $("img.imgbox").attr('height', '');
                            $("img.imgbox").removeAttr('height');
                            $("img.imgbox").attr('width', '43');
                        }
                        else {
                            $("img.imgbox").attr('width', '');
                            $("img.imgbox").removeAttr('width');
                            $("img.imgbox").attr('height', '43');
                        }
                    };

960
                    imgTemp.src = COMMON.formatStringBase64(dataStored[nStored].pageThumbnail);
961 962
                } else {
                    $('#divSearchResult').append(
963
                        '   <li id="' + CONTENTVIEW.changePageNo(sPageNo[i].pageNo) + '">' +
Vo Duc Thang committed
964 965
                        '       <img id="img_search_' + sPageNo[i].pageNo + '" class="imgbox" src="img/view_loading.gif"/>' +
                        '       <span class="mdltext">' +
966
                                    I18N.i18nText('txtPage') + (CONTENTVIEW.changePageNo(sPageNo[i].pageNo) + 1) + '<br /> ' +
Masaru Abe committed
967
                                    COMMON.htmlEncode(COMMON.truncate(sPageNo[i].pageText, 20)) +
Vo Duc Thang committed
968 969 970
                        '       </span>' +
                        '   </li>'
                    );
971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989

                    //Resize Image
                    var imgTemp = new Image();

                    imgTemp.onload = function () {
                        if (imgTemp.width > imgTemp.height) {
                            $("img.imgbox").attr('height', '');
                            $("img.imgbox").removeAttr('height');
                            $("img.imgbox").attr('width', '43');
                        }
                        else {
                            $("img.imgbox").attr('width', '');
                            $("img.imgbox").removeAttr('width');
                            $("img.imgbox").attr('height', '43');
                        }
                    };

                    imgTemp.src = "img/view_loading.gif";

990
                    lstPageNo.push(sPageNo[i].pageNo);
991 992 993 994
                }
            }

            if (lstPageNo.length > 0) {
995 996
                CONTENTVIEW_GENERAL.isSendingData = true;
                CONTENTVIEW_CALLAPI.loadDataSearch(lstPageNo);
997 998 999
            }
        } else {
            $('#divSearchResult').children().remove();
1000 1001 1002 1003 1004
            if(searchText == "invaildsearchtextzeroresultfound"){
                $('#divSearchResult').append('<span class="last">' + I18N.i18nText('txtErrorSearchResult') + '</span>');
            }else{
                $('#divSearchResult').append('<span class="last">' + I18N.i18nText('txtNoSearchResult') + '</span>');
            }
1005 1006 1007 1008

            //title start
            $('#bookmarkBoxHdSearching').children().remove();
            $('#bookmarkBoxHdSearching').html('<a id="searchingResultClosing" class="delete" > </a>');
1009
            $("#searchingResultClosing").click(CONTENTVIEW_EVENTS.closeSearchingBox);
1010
            $('#bookmarkBoxHdSearching').append(I18N.i18nText('txtSearchResult'));
1011 1012
            //title end

Masaru Abe committed
1013
            //COMMON.lockLayout();
1014 1015 1016 1017 1018 1019 1020 1021 1022 1023
            $('#boxSearching').css('z-index', '101');
            $('#boxSearching').css('display', 'block');
            $('#boxSearching').draggable({ handle: "h1" });
            $("#boxSearching").offset({ left: pos[0], top: pos[1] });
            $("#divSearchResult").show();
            $("#divSearchResult").offset({ left: pos[0], top: (pos[1] + $('#bookmarkBoxHdSearching').height() - 2) });
        }
    }
};

1024
CONTENTVIEW.playBGMOfPage = function(page_index_bg) {
1025
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() && $('#rotatebtnR').attr('angle') == '0') {
1026 1027 1028
        if ($('#playaudiopage').children().length > 0) {
            $('#playaudiopage').children().remove();
        }
1029 1030 1031
        CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, page_index_bg);
        for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.pageObjects.length; nIndex++) {
            if (CONTENTVIEW_GENERAL.pageObjects[nIndex].mediaType == '3' && CONTENTVIEW_GENERAL.pageObjects[nIndex].playType == '2') {
1032 1033
                CONTENTVIEW.stopAllAudio();
                CONTENTVIEW.TypeAudio2 = CONTENTVIEW_GENERAL.pageObjects[nIndex].playType;
1034
                CONTENTVIEW.srcAudioType2 = CONTENTVIEW_GENERAL.pageObjects[nIndex].audioFile;
1035 1036 1037

                if (ClientData.userOpt_musicMode() == "1") {
                    $('#playaudiopage').html(
Vo Duc Thang committed
1038
                             '  <audio  id="play_audio_2" loop="loop" >' +
1039
                             '       <source src="' + CONTENTVIEW.srcAudioType2 + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
Vo Duc Thang committed
1040 1041
                             '  </audio>'
                         );
1042 1043 1044
                } else {

                    $('#playaudiopage').html(
Vo Duc Thang committed
1045
                         '  <audio  id="play_audio_2"  >' +
1046
                         '       <source src="' + CONTENTVIEW.srcAudioType2 + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
Vo Duc Thang committed
1047 1048
                         '  </audio>'
                     );
1049 1050 1051 1052 1053 1054 1055 1056 1057
                }
                document.getElementById('play_audio_2').load();
                document.getElementById('play_audio_2').play();
                document.getElementById("play_audio_2").pause();
            }
        }
    }
};

1058
CONTENTVIEW.playBGMOfContent = function() {
1059
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() && CONTENTVIEW_GENERAL.isJumpNotFromFirstPage == true && $('#rotatebtnR').attr('angle') == '0') {
1060 1061
        CONTENTVIEW_GENERAL.isJumpNotFromFirstPage = false;
        CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, 0);
1062 1063
        for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.pageObjects.length; nIndex++) {
            if (CONTENTVIEW_GENERAL.pageObjects[nIndex].mediaType == '3' && CONTENTVIEW_GENERAL.pageObjects[nIndex].playType == '1') {
1064 1065
                CONTENTVIEW.stopAllAudio();
                CONTENTVIEW.TypeAudio1 = CONTENTVIEW_GENERAL.pageObjects[nIndex].playType;
1066
                CONTENTVIEW.srcAudioType1 = CONTENTVIEW_GENERAL.pageObjects[nIndex].audioFile;
1067 1068 1069

                if (ClientData.userOpt_musicMode() == "1") {
                    $('#playaudioallpage').html(
Vo Duc Thang committed
1070
                         '  <audio  id="play_audio_1" loop="loop"   >' +
1071
                         '       <source src="' + CONTENTVIEW.srcAudioType1 + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
Vo Duc Thang committed
1072 1073
                         '  </audio>'
                     );
1074 1075 1076
                } else {

                    $('#playaudioallpage').html(
Vo Duc Thang committed
1077
                     '  <audio  id="play_audio_1" >' +
1078
                     '       <source src="' + CONTENTVIEW.srcAudioType1 + '&key=' + (new Date()).toIdString() + '" type="audio/mpeg" />' +
Vo Duc Thang committed
1079 1080
                     '  </audio>'
                 );
1081 1082 1083 1084 1085 1086 1087 1088 1089 1090
                }
                document.getElementById('play_audio_1').load();
                document.getElementById('play_audio_1').play();
                document.getElementById("play_audio_1").pause();
            }
        }
    }
};

/* display error screen*/
1091
CONTENTVIEW.showErrorScreen = function() {
1092

1093
    // エラーメッセージの表示
1094
    var errMes = I18N.i18nText('msgPageImgErr');
1095
    $('#divImageLoading').css('display', 'none');
Masaru Abe committed
1096
    COMMON.lockLayout();
1097 1098 1099 1100 1101 1102 1103 1104 1105 1106
    /* show error messages */
    $().toastmessage({ position: 'middle-center' });
    $().toastmessage('showToast', {
        type: 'error',
        sticky: true,
        text: errMes,
        close: function () { isShowErrorMessage = false; }
    });
    $('.toast-type-error').css('height', '100px');
    $('.toast-type-error > p').css('padding-top', '35px');
1107

1108 1109 1110 1111 1112 1113 1114 1115 1116
    //オーサリングプレビュー対応
    if(COMMON.isAuthoringPreview() && CONTENTVIEW_GENERAL.pid != ''){
        $('.toast-item-close').live('click', function(){
            window.open('', '_self', '');
            window.close();
        });
    } else {
        $('.toast-item-close').live('click', CONTENTVIEW_EVENTS.imgBack_click);
    }
1117

1118 1119
};

1120
/* display alert screen*/
Masaru Abe committed
1121
CONTENTVIEW.showAlertScreen = function(errMes, scrMove) {
1122 1123 1124

    // アラートメッセージの表示
    if( errMes == undefined || errMes == "" ){
1125
        errMes = "message."; //I18N.i18nText('msgPageImgErr');
1126 1127
    }
    $('#divImageLoading').css('display', 'none');
Masaru Abe committed
1128
    COMMON.lockLayout();
1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140
    /* show error messages */
    $().toastmessage({ position: 'middle-center' });
    $().toastmessage('showToast', {
        type: 'error',
        sticky: true,
        text: errMes,
        close: function () {}
    });
    $('.toast-type-error').css('height', '100px');
    $('.toast-type-error > p').css('padding-top', '35px');
    $('.toast-item-close').live('click',
        function () {
Masaru Abe committed
1141
            COMMON.unlockLayout();
Masaru Abe committed
1142
            if( scrMove ){
1143
                AVWEB.avwScreenMove(scrMove);
Masaru Abe committed
1144
            }
1145 1146 1147 1148
        }
    );
};

1149
/* move to page ?? */
1150
CONTENTVIEW.changePage = function(page_index) {
1151

Masaru Abe committed
1152
    //abe スライダーのページ移動
1153
    //console.log("changePage:" + page_index);
1154

1155 1156
    // Make sure page_index is number
    page_index = Number(page_index);
1157 1158 1159
    if( page_index < 0 ){
        page_index = 0;
    }
1160

1161
    if (page_index != CONTENTVIEW_GETDATA.getContent().pageIndex) {
1162

1163
        CONTENTVIEW.playBGMOfContent();
1164
        CONTENTVIEW.playBGMOfPage(page_index);
1165

1166
        CONTENTVIEW_GENERAL.disableAllControl();
1167 1168 1169

        $('#divImageLoading').css('display', 'block');
        //Start Function : No.4 - Editor : Long - Date : 08/19/2013
1170
        if(page_index == CONTENTVIEW_GETDATA.getContent().pageIndex + 1){
1171
            CONTENTVIEW_EVENTS.nextPage_click();
1172
        }
1173
        else if(page_index == CONTENTVIEW_GETDATA.getContent().pageIndex - 1){
1174
            CONTENTVIEW_EVENTS.prevPage_click();
1175 1176 1177
        }
        //End Function : No.4 - Editor : Long - Date : 08/19/2013
        else{
1178

Masaru Abe committed
1179
            //ページ閲覧ログセット
1180
            COMMON.SetPageLog( CONTENTVIEW_GENERAL.contentID, page_index);
1181

1182
            // Clear canvas offscreen
1183 1184
            CONTENTVIEW_GENERAL.clearCanvas(document.getElementById("offscreen"));
            if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
1185 1186
                //console.log("CONTENTVIEW.changePage");
                AVWEB.avwGrabContentPageImage(ClientData.userInfo_accountPath(),
1187
                     { contentId: CONTENTVIEW_GENERAL.contentID, sid: CONTENTVIEW.getSessionId(), pageNo: page_index + 1 },
1188
                     function (data) {
1189
                         CONTENTVIEW_GENERAL.pageImages = data;
1190

1191
                         /* get page Objects */
1192
                         CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, page_index);
1193 1194
                         CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages)
                                     .setPageObjects(CONTENTVIEW_GENERAL.pageObjects);
1195 1196


1197
                         //$('#divImageLoading').css('display', 'none');
1198

1199
                         var tran = new CONTENTVIEW_CREATEOBJECT.Transition();
1200
                         tran.flipToPage(page_index);
1201

1202 1203
                     },
                     function (xmlHttpRequest, txtStatus, errorThrown) {
1204
                         CONTENTVIEW.showErrorScreen();
1205
                     });
1206 1207
           }
           //START : TRB00032 - Editor : Long - Date: 09/10/2013 - Summary : type none process
1208
           else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
1209
                 /* get page Objects */
1210
               CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, page_index);
1211 1212
                 CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages)
                             .setPageObjects(CONTENTVIEW_GENERAL.pageObjects);
1213

1214 1215

                 $('#divImageLoading').css('display', 'none');
1216

1217
                var tran = new CONTENTVIEW_CREATEOBJECT.Transition();
1218 1219 1220
                tran.flipToPage(page_index);
            }
            //END : TRB00032 - Editor : Long - Date: 09/10/2013 - Summary : type none process
1221
        }
1222
    } else if (ClientData.IsJumpBack() == true
Vo Duc Thang committed
1223
       || ClientData.common_prePageNo()) {
1224 1225
        CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages)
                                    .setPageObjects(CONTENTVIEW_GENERAL.pageObjects)
Vo Duc Thang committed
1226 1227
                                    .setUpPage(0);
       //START : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM
1228 1229
        CONTENTVIEW_CREATEOBJECT.createPageBGM();
       //END : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM
1230 1231 1232 1233
    }
};

/* add event draw on canvas */
1234
CONTENTVIEW.drawOnCanvas = function() {
1235
    CONTENTVIEW_GENERAL.tool = new CONTENTVIEW.tool_drawing();
Masaru Abe committed
1236
    if (COMMON.isTouchDevice() == true) {
1237 1238
        CONTENTVIEW_PAINT.initializeCanvas(document.getElementById('draw_canvas'));
        CONTENTVIEW_PAINT.initializeCanvas(document.getElementById('marker_canvas'));
1239

1240
        //iOSかAndroid以外ならmarkerではmouseも発火させる
Masaru Abe committed
1241
        if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false && CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false){
1242
            //draw_canvas
1243 1244 1245 1246
            CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mousedown', CONTENTVIEW.ev_canvas, false);
            CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mousemove', CONTENTVIEW.ev_canvas, false);
            CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mouseup', CONTENTVIEW.ev_canvas, false);
            CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mouseout', CONTENTVIEW.ev_canvas, false);
1247
            //marker_canvas
1248 1249 1250 1251
            CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mousedown', CONTENTVIEW.ev_canvas, false);
            CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mousemove', CONTENTVIEW.ev_canvas, false);
            CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mouseup', CONTENTVIEW.ev_canvas, false);
            CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mouseout', CONTENTVIEW.ev_canvas, false);
1252
        }
1253

1254 1255 1256
    }
    else {
        // Attach the mousedown, mousemove and mouseup event listeners.
1257 1258 1259 1260 1261 1262 1263
        CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mousedown', CONTENTVIEW.ev_canvas, false);
        CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mousemove', CONTENTVIEW.ev_canvas, false);
        CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mouseup', CONTENTVIEW.ev_canvas, false);
        CONTENTVIEW_GENERAL.canvas_draw.addEventListener('mouseout', CONTENTVIEW.ev_canvas, false);
        CONTENTVIEW_GENERAL.canvas_draw.addEventListener('touchstart', CONTENTVIEW.ev_canvas, false);
        CONTENTVIEW_GENERAL.canvas_draw.addEventListener('touchmove', CONTENTVIEW.ev_canvas, false);
        CONTENTVIEW_GENERAL.canvas_draw.addEventListener('touchend', CONTENTVIEW.ev_canvas, false);
1264

1265 1266 1267 1268
        CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mousedown', CONTENTVIEW.ev_canvas, false);
        CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mousemove', CONTENTVIEW.ev_canvas, false);
        CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mouseup', CONTENTVIEW.ev_canvas, false);
        CONTENTVIEW_GENERAL.canvas_marker.addEventListener('mouseout', CONTENTVIEW.ev_canvas, false);
1269 1270 1271 1272

    }
};

1273 1274
CONTENTVIEW.drawMouseMove = function(contextDraw, ev) {
    if (CONTENTVIEW_GENERAL.tool.started && CONTENTVIEW_GENERAL.isPressLeftMouse == true) {
1275

1276
        if (CONTENTVIEW_GENERAL.isMoveOutDrawCanvas == true) {
1277
            contextDraw.moveTo(ev._x, ev._y);
1278 1279 1280
            CONTENTVIEW_GENERAL.sx = ev._x;
            CONTENTVIEW_GENERAL.sy = ev._y;
            CONTENTVIEW_GENERAL.isMoveOutDrawCanvas = false;
1281 1282
        }

1283
        if (CONTENTVIEW_GENERAL.markingType == 'eraser') {
1284 1285
            //context.clearRect(ev._x, ev._y, ClientData.erase_size(), ClientData.erase_size());
            contextDraw.globalCompositeOperation = 'destination-out';
1286
            contextDraw.lineWidth = CONTENTVIEW_GENERAL.eraseSize;
1287 1288
            contextDraw.lineJoin = 'round';
            contextDraw.lineCap = 'round';
1289
            contextDraw.lineTo(CONTENTVIEW_GENERAL.sx, CONTENTVIEW_GENERAL.sy);
1290 1291 1292
            contextDraw.stroke();
            contextDraw.globalCompositeOperation = 'source-over';
        }
1293
        else if (CONTENTVIEW_GENERAL.markingType == 'pen') {
1294 1295
            contextDraw.lineCap = "round";
            contextDraw.lineJoin = "bevel";
1296 1297
            contextDraw.lineWidth = CONTENTVIEW_GENERAL.penSize;
            contextDraw.strokeStyle = "#" + CONTENTVIEW_GENERAL.penColor;
1298 1299 1300
            contextDraw.lineTo(ev._x, ev._y);
            contextDraw.stroke();
        }
1301
        else if (CONTENTVIEW_GENERAL.markingType == 'maker') {
1302 1303 1304

            contextDraw.beginPath();

1305 1306
            var halfSize = CONTENTVIEW_GENERAL.makerSize / 2;
            var quotSize = CONTENTVIEW_GENERAL.makerSize / 4;
1307 1308

            var ptStart = [
1309 1310 1311 1312
                        { x: CONTENTVIEW_GENERAL.sx - quotSize, y: CONTENTVIEW_GENERAL.sy - halfSize },
                        { x: CONTENTVIEW_GENERAL.sx + quotSize, y: CONTENTVIEW_GENERAL.sy - halfSize },
                        { x: CONTENTVIEW_GENERAL.sx + quotSize, y: CONTENTVIEW_GENERAL.sy + halfSize },
                        { x: CONTENTVIEW_GENERAL.sx - quotSize, y: CONTENTVIEW_GENERAL.sy + halfSize }
Vo Duc Thang committed
1313
                  ];
1314
            var ptEnd = [
Masaru Abe committed
1315 1316 1317 1318
                        { x: ev._x - quotSize, y: ev._y - halfSize },
                        { x: ev._x + quotSize, y: ev._y - halfSize },
                        { x: ev._x + quotSize, y: ev._y + halfSize },
                        { x: ev._x - quotSize, y: ev._y + halfSize }
Vo Duc Thang committed
1319
                ];
1320 1321
            if (CONTENTVIEW_GENERAL.sx > ev._x) {
                if (CONTENTVIEW_GENERAL.sy > ev._y) {
1322 1323 1324 1325 1326 1327 1328 1329 1330 1331
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
1332
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
1333 1334 1335 1336
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
Masaru Abe committed
1337
                    //
1338 1339 1340 1341 1342 1343 1344
                    contextDraw.moveTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.closePath();
1345
                } else if (CONTENTVIEW_GENERAL.sy < ev._y) {
1346 1347 1348 1349 1350 1351 1352 1353 1354 1355
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
1356
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
1357 1358 1359 1360
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
Masaru Abe committed
1361
                    //
1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377
                    contextDraw.moveTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.closePath();
                } else {
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
1378
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
1379 1380 1381 1382
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
Masaru Abe committed
1383
                    //
1384 1385 1386 1387 1388 1389
                    contextDraw.moveTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.closePath();
                }
1390 1391
            } else if (CONTENTVIEW_GENERAL.sx < ev._x) {
                if (CONTENTVIEW_GENERAL.sy > ev._y) {
1392 1393 1394 1395 1396 1397 1398 1399 1400 1401
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
1402
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
1403 1404 1405 1406
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
Masaru Abe committed
1407
                    //
1408 1409 1410 1411 1412 1413 1414
                    contextDraw.moveTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.closePath();
1415
                } else if (CONTENTVIEW_GENERAL.sy < ev._y) {
1416 1417 1418 1419 1420 1421 1422 1423 1424 1425
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
1426
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
1427 1428 1429 1430 1431
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();

Masaru Abe committed
1432
                    //
1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448
                    contextDraw.moveTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.closePath();
                } else {
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
1449
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
1450 1451 1452 1453
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
Masaru Abe committed
1454
                    //
1455 1456 1457 1458 1459 1460 1461
                    contextDraw.moveTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.closePath();
                }
            } else {
1462
                if (CONTENTVIEW_GENERAL.sy > ev._y) {
1463 1464 1465 1466 1467 1468 1469 1470
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
1471
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
1472 1473 1474 1475
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
Masaru Abe committed
1476
                    //
1477 1478 1479 1480 1481
                    contextDraw.moveTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineTo(ptEnd[0].x, ptEnd[0].y);
                    contextDraw.lineTo(ptEnd[1].x, ptEnd[1].y);
                    contextDraw.closePath();
1482
                } else if (CONTENTVIEW_GENERAL.sy < ev._y) {
1483 1484 1485 1486 1487 1488 1489 1490
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
1491
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
1492 1493 1494 1495
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
Masaru Abe committed
1496
                    //
1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510
                    contextDraw.moveTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptEnd[2].x, ptEnd[2].y);
                    contextDraw.lineTo(ptEnd[3].x, ptEnd[3].y);
                    contextDraw.closePath();
                } else {
                    contextDraw.beginPath();
                    contextDraw.globalCompositeOperation = 'destination-out';
                    contextDraw.moveTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.lineJoin = 'bevel';
                    contextDraw.lineCap = 'butt';
1511
                    contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
1512 1513 1514 1515
                    contextDraw.fill();
                    contextDraw.globalCompositeOperation = 'lighter';
                    contextDraw.closePath();
                    contextDraw.beginPath();
Masaru Abe committed
1516
                    //
1517 1518 1519 1520 1521 1522 1523 1524 1525 1526
                    contextDraw.moveTo(ptStart[0].x, ptStart[0].y);
                    contextDraw.lineTo(ptStart[1].x, ptStart[1].y);
                    contextDraw.lineTo(ptStart[2].x, ptStart[2].y);
                    contextDraw.lineTo(ptStart[3].x, ptStart[3].y);
                    contextDraw.closePath();
                }
            }
            contextDraw.lineJoin = 'bevel';
            contextDraw.lineCap = 'butt';
            contextDraw.globalAlpha = 0.4;   // Opacity 20%
1527
            contextDraw.fillStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
1528 1529 1530 1531 1532 1533 1534
            contextDraw.fill();

            contextDraw.globalAlpha = 1;   // Opacity 100%
        }

        contextDraw.globalCompositeOperation = 'source-over';

1535 1536
        CONTENTVIEW_GENERAL.sx = ev._x;
        CONTENTVIEW_GENERAL.sy = ev._y;
1537 1538 1539 1540 1541 1542

    }
};


/* event mouse using for canvas */
1543
CONTENTVIEW.tool_drawing = function() {
1544 1545 1546 1547 1548 1549 1550
    var tool = this;
    this.started = false;

    this.mousedown = function (ev) {
        ev.preventDefault();

        /* set value sx,sy */
1551 1552
        CONTENTVIEW_GENERAL.sx = ev._x;
        CONTENTVIEW_GENERAL.sy = ev._y;
1553 1554

        if ($("#marker_canvas").is(":hidden")) {
1555 1556
            CONTENTVIEW_GENERAL.context_draw.beginPath();
            CONTENTVIEW_GENERAL.context_draw.moveTo(ev._x, ev._y);
1557
        } else {
1558 1559
            CONTENTVIEW_GENERAL.context_marker.beginPath();
            CONTENTVIEW_GENERAL.context_marker.moveTo(ev._x, ev._y);
1560 1561
        }

1562
        if (CONTENTVIEW_GENERAL.isAddingMarking == true) {
1563
            /* begin draw*/
1564
            CONTENTVIEW_GENERAL.isClearDrawing = false;
1565 1566

            if ($("#marker_canvas").is(":hidden")) {
1567
                if (CONTENTVIEW_GENERAL.markingType == 'eraser') {
1568 1569 1570 1571 1572 1573 1574
                    CONTENTVIEW_GENERAL.context_draw.globalCompositeOperation = 'destination-out';
                    CONTENTVIEW_GENERAL.context_draw.lineWidth = CONTENTVIEW_GENERAL.eraseSize;
                    CONTENTVIEW_GENERAL.context_draw.lineJoin = 'round';
                    CONTENTVIEW_GENERAL.context_draw.lineCap = 'round';
                    CONTENTVIEW_GENERAL.context_draw.lineTo(ev._x + 0.001, ev._y + 0.001);
                    CONTENTVIEW_GENERAL.context_draw.stroke();
                    CONTENTVIEW_GENERAL.context_draw.globalCompositeOperation = 'source-over';
1575
                }
1576
                else if (CONTENTVIEW_GENERAL.markingType == 'pen') {
1577
                    /* set flag */
1578
                    CONTENTVIEW_GENERAL.isDrawing = true;
1579

1580 1581 1582 1583 1584
                    CONTENTVIEW_GENERAL.context_draw.lineCap = "round";
                    CONTENTVIEW_GENERAL.context_draw.lineWidth = CONTENTVIEW_GENERAL.penSize;
                    CONTENTVIEW_GENERAL.context_draw.strokeStyle = "#" + CONTENTVIEW_GENERAL.penColor;
                    CONTENTVIEW_GENERAL.context_draw.lineTo(ev._x + 0.001, ev._y + 0.001);
                    CONTENTVIEW_GENERAL.context_draw.stroke();
1585
                }
1586
                else if (CONTENTVIEW_GENERAL.markingType == 'maker') {
1587
                    /* set flag */
1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606
                    CONTENTVIEW_GENERAL.isDrawing = true;

                    CONTENTVIEW_GENERAL.context_draw.globalCompositeOperation = 'destination-out';
                    CONTENTVIEW_GENERAL.context_draw.lineWidth = CONTENTVIEW_GENERAL.makerSize;
                    CONTENTVIEW_GENERAL.context_draw.lineHeight = CONTENTVIEW_GENERAL.makerSize;
                    CONTENTVIEW_GENERAL.context_draw.lineTo(ev._x, ev._y + 0.001);
                    CONTENTVIEW_GENERAL.context_draw.lineCap = 'square';
                    CONTENTVIEW_GENERAL.context_draw.strokeStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    CONTENTVIEW_GENERAL.context_draw.stroke();
                    CONTENTVIEW_GENERAL.context_draw.globalCompositeOperation = 'lighter';

                    CONTENTVIEW_GENERAL.context_draw.lineCap = "square";
                    CONTENTVIEW_GENERAL.context_draw.lineWidth = CONTENTVIEW_GENERAL.makerSize;
                    CONTENTVIEW_GENERAL.context_draw.lineHeight = CONTENTVIEW_GENERAL.makerSize;
                    CONTENTVIEW_GENERAL.context_draw.globalAlpha = 0.4;
                    CONTENTVIEW_GENERAL.context_draw.strokeStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    CONTENTVIEW_GENERAL.context_draw.lineTo(ev._x, ev._y + 0.001);
                    CONTENTVIEW_GENERAL.context_draw.stroke();
                    CONTENTVIEW_GENERAL.context_draw.globalAlpha = 1;
1607 1608
                }
            } else {
1609
                if (CONTENTVIEW_GENERAL.markingType == 'eraser') {
1610 1611 1612 1613 1614 1615 1616
                    CONTENTVIEW_GENERAL.context_marker.globalCompositeOperation = 'destination-out';
                    CONTENTVIEW_GENERAL.context_marker.lineWidth = CONTENTVIEW_GENERAL.eraseSize;
                    CONTENTVIEW_GENERAL.context_marker.lineJoin = 'round';
                    CONTENTVIEW_GENERAL.context_marker.lineCap = 'round';
                    CONTENTVIEW_GENERAL.context_marker.lineTo(ev._x + 0.001, ev._y + 0.001);
                    CONTENTVIEW_GENERAL.context_marker.stroke();
                    CONTENTVIEW_GENERAL.context_marker.globalCompositeOperation = 'source-over';
1617
                }
1618
                else if (CONTENTVIEW_GENERAL.markingType == 'pen') {
1619
                    /* set flag */
1620
                    CONTENTVIEW_GENERAL.isDrawing = true;
1621

1622 1623 1624 1625 1626
                    CONTENTVIEW_GENERAL.context_marker.lineCap = "round";
                    CONTENTVIEW_GENERAL.context_marker.lineWidth = CONTENTVIEW_GENERAL.penSize;
                    CONTENTVIEW_GENERAL.context_marker.strokeStyle = "#" + CONTENTVIEW_GENERAL.penColor;
                    CONTENTVIEW_GENERAL.context_marker.lineTo(ev._x + 0.001, ev._y + 0.001);
                    CONTENTVIEW_GENERAL.context_marker.stroke();
1627
                }
1628
                else if (CONTENTVIEW_GENERAL.markingType == 'maker') {
1629
                    /* set flag */
1630
                    CONTENTVIEW_GENERAL.isDrawing = true;
1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648

                    CONTENTVIEW_GENERAL.context_marker.globalCompositeOperation = 'destination-out';
                    CONTENTVIEW_GENERAL.context_marker.lineWidth = CONTENTVIEW_GENERAL.makerSize;
                    CONTENTVIEW_GENERAL.context_marker.lineHeight = CONTENTVIEW_GENERAL.makerSize;
                    CONTENTVIEW_GENERAL.context_marker.lineTo(ev._x, ev._y + 0.001);
                    CONTENTVIEW_GENERAL.context_marker.lineCap = 'square';
                    CONTENTVIEW_GENERAL.context_marker.strokeStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    CONTENTVIEW_GENERAL.context_marker.stroke();
                    CONTENTVIEW_GENERAL.context_marker.globalCompositeOperation = 'lighter';

                    CONTENTVIEW_GENERAL.context_marker.lineCap = "square";
                    CONTENTVIEW_GENERAL.context_marker.lineWidth = CONTENTVIEW_GENERAL.makerSize;
                    CONTENTVIEW_GENERAL.context_marker.lineHeight = CONTENTVIEW_GENERAL.makerSize;
                    CONTENTVIEW_GENERAL.context_marker.globalAlpha = 0.4;
                    CONTENTVIEW_GENERAL.context_marker.strokeStyle = "#" + CONTENTVIEW_GENERAL.makerColor;
                    CONTENTVIEW_GENERAL.context_marker.lineTo(ev._x, ev._y + 0.001);
                    CONTENTVIEW_GENERAL.context_marker.stroke();
                    CONTENTVIEW_GENERAL.context_marker.globalAlpha = 1;
1649 1650 1651 1652
                }
            }
            tool.started = true;

1653
            if (ev.which == 1) { CONTENTVIEW_GENERAL.isPressLeftMouse = true; }
1654 1655
        }

1656
        //CONTENTVIEW_GENERAL.context_draw.closePath();
1657 1658 1659
    };

    this.mousemove = function (ev) {
1660
        ev.preventDefault();
1661
        if (CONTENTVIEW_GENERAL.isAddingMarking == true) {
1662
            if ($("#marker_canvas").is(":hidden")) {
1663
                CONTENTVIEW.drawMouseMove(CONTENTVIEW_GENERAL.context_draw, ev);
1664
            } else {
1665
                CONTENTVIEW.drawMouseMove(CONTENTVIEW_GENERAL.context_marker, ev);
1666 1667 1668 1669 1670 1671 1672 1673 1674
            }

        }
    };

    this.mouseup = function (ev) {
        if (tool.started) {
            //tool.mousemove(ev);
            tool.started = false;
1675
            //CONTENTVIEW_GENERAL.context_draw.closePath();
1676
            //CONTENTVIEW_GENERAL.isPressLeftMouse = false;
1677 1678 1679 1680 1681 1682 1683 1684
        }
    };

    this.mouseout = function (ev) {

        if (tool.started) {
            //tool.mousemove(ev);
            //tool.started = false;
1685
            //CONTENTVIEW_GENERAL.context_draw.closePath();
1686
            CONTENTVIEW_GENERAL.isMoveOutDrawCanvas = true;
1687 1688
        }

1689
        /*if(CONTENTVIEW_GENERAL.isPressLeftMouse == true){
1690
        CONTENTVIEW_GENERAL.isMoveOutDrawCanvas = true;
1691
        }else{
1692
        tool.started = false;
1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760
        }*/
    };

    /*tablet [start]*/
    this.touchstart = function (ev) {
        /*ev.preventDefault();
        tool.mousedown(ev);*/
        var touches = ev.changedTouches, first = touches[0], type = "";

        switch (ev.type) {
            case "touchstart": type = "mousedown"; break;
            case "touchmove": type = "mousemove"; break;
            case "touchend": type = "mouseup"; break;
            default: return;
        }

        var simulatedEvent = document.createEvent("MouseEvent");

        simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0/*left*/, null);
        first.target.dispatchEvent(simulatedEvent);

        ev.preventDefault();

    };

    this.touchmove = function (ev) {
        /*ev.preventDefault();
        tool.mousemove(ev);*/
        var touches = ev.changedTouches, first = touches[0], type = "";

        switch (ev.type) {
            case "touchstart": type = "mousedown"; break;
            case "touchmove": type = "mousemove"; break;
            case "touchend": type = "mouseup"; break;
            default: return;
        }

        var simulatedEvent = document.createEvent("MouseEvent");

        simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0/*left*/, null);
        first.target.dispatchEvent(simulatedEvent);

        ev.preventDefault();

    };

    this.touchend = function (ev) {
        /*ev.preventDefault();
        tool.mouseup(ev);*/
        var touches = ev.changedTouches, first = touches[0], type = "";

        switch (ev.type) {
            case "touchstart": type = "mousedown"; break;
            case "touchmove": type = "mousemove"; break;
            case "touchend": type = "mouseup"; break;
            default: return;
        }

        var simulatedEvent = document.createEvent("MouseEvent");

        simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY, false, false, false, false, 0/*left*/, null);
        first.target.dispatchEvent(simulatedEvent);
        ev.preventDefault();


    };
    /* tablet [end]*/

1761
};
1762

1763
CONTENTVIEW.ev_canvas = function(ev) {
1764 1765 1766 1767 1768 1769 1770 1771 1772
    if (ev.offsetX || ev.offsetX == 0) { // Opera
        ev._x = ev.offsetX;
        ev._y = ev.offsetY;
    } else if (ev.layerX || ev.layerX == 0) { // Firefox
        ev._x = ev.layerX;
        ev._y = ev.layerY;
    }

    // Call the event handler of the tool.
1773 1774
    //var func = tool[ev.type];
    var func = CONTENTVIEW_GENERAL.tool[ev.type]; // CONTENTVIEW_GENERAL.toolで良いか?
1775 1776 1777 1778 1779 1780
    if (func) {
        func(ev);
    }
};

/* handle display page from book mark page */
1781
CONTENTVIEW.handleFromBookMarkPage = function() {
1782

1783
    //CONTENTVIEW_GENERAL.isJumpNotFromFirstPage = true;
1784 1785
    /* check exist pageno */
    if (ClientData.bookmark_pageNo()) {
Masaru Abe committed
1786
    	CONTENTVIEW_GENERAL.isJumpNotFromFirstPage = true;
1787
    	CONTENTVIEW.changePageWithoutSlide(CONTENTVIEW.changePageNo(ClientData.bookmark_pageNo()));
1788
        ClientData.bookmark_pageNo(null);
1789 1790 1791 1792
    }
};

/* handle display page from actiontype=10 mediaType =1 :jump to content */
1793
CONTENTVIEW.handleFromJumpContent = function() {
Masaru Abe committed
1794
	//CONTENTVIEW_GENERAL.isJumpNotFromFirstPage = true;
1795 1796
    /* check exist pageno */
    if (ClientData.common_prePageNo()) {
Masaru Abe committed
1797
    	CONTENTVIEW_GENERAL.isJumpNotFromFirstPage = true;
1798
    	CONTENTVIEW.changePageWithoutSlide(CONTENTVIEW.changePageNo(ClientData.common_prePageNo()));
vietdo committed
1799
        ClientData.common_prePageNo(null);
1800 1801 1802 1803
    }
};

/* handle button back */
1804
CONTENTVIEW.oldContent_Back = function() {
1805

1806
	CONTENTVIEW_GENERAL.isJumpNotFromFirstPage = true;
1807 1808 1809 1810
    var oldDataBack = ClientData.JumpQueue();
    var oldContent = oldDataBack[oldDataBack.length - 1];

    /*move to page */
1811
    //CONTENTVIEW.changePage(oldContent.oldPageIndex);
vietdo committed
1812
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
vietdo committed
1813 1814
    	CONTENTVIEW.changePageWithoutSlide(oldContent.oldPageIndex);
    }
1815
    
1816 1817
    /*remove*/
    oldDataBack.splice(oldDataBack.length - 1, 1);
1818 1819


vietdo committed
1820 1821 1822
    if(oldDataBack.length == 0){
    	ClientData.common_prePageNo(null);
    }
1823 1824 1825 1826 1827 1828 1829
    ClientData.JumpQueue(oldDataBack);
    ClientData.IsJumpBack(false);


};

/* handle display or hide toolbar */
1830
CONTENTVIEW.handleDisplayToolbar = function() {
1831

1832
    //console.log("CONTENTVIEW_GENERAL.isLoadingObject:" + CONTENTVIEW_GENERAL.isLoadingObject);
1833

1834
    if (CONTENTVIEW_GENERAL.isLoadingObject == false) {
1835 1836 1837 1838 1839
        /* save marking */
        var canvas = document.getElementById('draw_canvas');
        var context = canvas.getContext('2d');

        if (ClientData.IsAddingMarking() == true) {
1840
        	CONTENTVIEW_GENERAL.imgDrawingTemp = canvas.toDataURL("image/png");
1841
        	CONTENTVIEW_GENERAL.imgMarkerTemp = CONTENTVIEW_GENERAL.canvas_marker.toDataURL("image/png");
1842 1843 1844 1845 1846 1847
        }

        var w = $("#wrapper").width();
        var h = $("#wrapper").height();

        if ($("#header_toolbar").is(":hidden")) {
1848

1849
            CONTENTVIEW_GENERAL.isFullScreen = false;
1850 1851 1852 1853 1854

            $('#footer_toolbar_1').show();
            $('#footer_toolbar_2').hide();
            $('#control_screen_2').hide();
            $('#header_toolbar').show();
1855 1856
            CONTENTVIEW.sizingNotFull(w, h);
            CONTENTVIEW.drawCanvas();
1857

1858
            //edit
1859
            if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
1860
                CONTENTVIEW.drawCanvas(2);
1861
            }
1862

1863
            if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
1864
                CONTENTVIEW.drawCanvas(1);
1865 1866
            }

1867
        }
1868
        else {
1869

1870
            CONTENTVIEW_GENERAL.isFullScreen = true;
1871 1872 1873 1874 1875 1876 1877

            $('#header_toolbar').hide();
            //START TRB00097
            //$('#footer_toolbar_2').show();
            //END TRB00097
            $('#control_screen_2').show();
            $('#footer_toolbar_1').hide();
1878
            CONTENTVIEW.sizingFullSize(w, h);
1879

1880
            CONTENTVIEW.drawCanvas();
1881

1882
            if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
1883
                CONTENTVIEW.drawCanvas(2);
1884
            }
1885

1886
            if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
1887
                CONTENTVIEW.drawCanvas(1);
1888 1889 1890 1891
            }

        }
        /* init image had draw */
1892 1893
        //CONTENTVIEW_INITOBJECT.initDisplayMarking();
        CONTENTVIEW.resizeCanvasDraw();
1894 1895 1896 1897 1898 1899

        if (ClientData.IsAddingMarking() == true) {
            var img = new Image();
            img.onload = function () {
                context.drawImage(img, 0, 0, canvas.width, canvas.height);
            };
1900
            img.src = CONTENTVIEW_GENERAL.imgDrawingTemp;
1901 1902 1903

            var imgMarker = new Image();
            imgMarker.onload = function () {
1904
                CONTENTVIEW_GENERAL.context_marker.drawImage(imgMarker, 0, 0, CONTENTVIEW_GENERAL.canvas_marker.width, CONTENTVIEW_GENERAL.canvas_marker.height);
1905
            };
1906
            img.src = CONTENTVIEW_GENERAL.imgMarkerTemp;
1907 1908 1909 1910

        }
    }

1911
    CONTENTVIEW.closeDialogPopUpText();
1912 1913 1914
};

/* resizing canvas draw */
1915
CONTENTVIEW.resizeCanvasDraw = function() {
1916
    CONTENTVIEW.flip();
1917 1918 1919 1920 1921 1922 1923 1924 1925 1926
    if (CONTENTVIEW_GENERAL.isFullScreen == true) {
        $("#draw_canvas").attr('height', CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top)
              .attr('width', CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left)
               .css('top', CONTENTVIEW.destRect.top)
               .css('left', CONTENTVIEW.destRect.left + CONTENTVIEW.marginX);

        $("#marker_canvas").attr('height', CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top)
              .attr('width', CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left)
               .css('top', CONTENTVIEW.destRect.top)
               .css('left', CONTENTVIEW.destRect.left + CONTENTVIEW.marginX);
1927 1928

    } else {
1929 1930 1931 1932 1933 1934 1935 1936
        $("#draw_canvas").attr('height', CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top)
              .attr('width', CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left)
               .css('top', CONTENTVIEW.destRect.top + CONTENTVIEW.marginY)
               .css('left', CONTENTVIEW.destRect.left + CONTENTVIEW.marginX);
        $("#marker_canvas").attr('height', CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top)
              .attr('width', CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left)
               .css('top', CONTENTVIEW.destRect.top + CONTENTVIEW.marginY)
               .css('left', CONTENTVIEW.destRect.left + CONTENTVIEW.marginX);
1937 1938 1939 1940 1941

    }
};

/* handle slider bar */
1942
CONTENTVIEW.handleSliderBar = function() {
1943

1944 1945 1946
    $("#slider_page").slider({
        range: "max",
        min: 1,
1947 1948
        max: CONTENTVIEW_GENERAL.totalPage,
        value: CONTENTVIEW_GETDATA.getPageIndex() + 1,
1949 1950
        slide: function (event, ui) {
            $("#txtSlider").val(ui.value);
1951
            //CONTENTVIEW.changePage(ui.value - 1);
1952 1953
        },
        stop: function (event, ui) {
1954
            CONTENTVIEW.changePage(ui.value - 1);
1955
        }
1956

1957 1958 1959 1960 1961 1962 1963 1964
    });


    $("#txtSlider").val($("#slider_page").slider("value"));

    /* event change txtProcess */
    $('#txtSlider').keydown(function (event) {
        if (event.keyCode == 13) {
1965

1966 1967 1968 1969 1970 1971 1972
            var pageNo = parseInt($('#txtSlider').val());
            if(isNaN(pageNo)){
                pageNo = 1;
            }
            if(pageNo == 0){
                pageNo = 1;
            }
1973

1974
            if (pageNo <= 0) {
1975
                $('#txtSlider').val('1');
1976
            } else if (pageNo > CONTENTVIEW_GENERAL.totalPage) {
1977
                $('#txtSlider').val(CONTENTVIEW_GENERAL.totalPage);
1978 1979
            } else if (/\D/g.test($('#txtSlider').val())) {
                $('#txtSlider').val('1');
1980 1981
            } else {
                $('#txtSlider').val(pageNo);
1982 1983
            }

1984
            if (parseInt($('#txtSlider').val()) - 1 != CONTENTVIEW_GETDATA.getPageIndex()) {
1985
                $("#slider_page").slider("value", $('#txtSlider').val());
1986
                CONTENTVIEW.changePage($('#txtSlider').val() - 1);
1987 1988 1989 1990 1991 1992 1993 1994 1995
            }
        }
        else {

        }
    });
};

/* event when change page */
1996
CONTENTVIEW.changeSlider = function(page_index) {
1997 1998 1999 2000 2001
    $("#slider_page").slider("value", page_index + 1);
    $("#txtSlider").val(page_index + 1);
};

/* handle display value tooltip */
2002
CONTENTVIEW.handleTooltip = function() {
2003 2004 2005 2006 2007 2008 2009 2010 2011 2012
    /*$('#imgHome').attr('title', I18N.i18nText('dspHome'));
    $('#imgBack').attr('title', I18N.i18nText('txtTooltipBack'));
    $('#listbookmark').attr('title', I18N.i18nText('txtShioriCtnLs'));
    $('#imgbookmark').attr('title', I18N.i18nText('txtTooltipBookmark'));
    $('#listindex').attr('title', I18N.i18nText('txtIndex'));
    $('#copytext').attr('title', I18N.i18nText('txtTextCopy'));
    $('#imgmemo').attr('title', I18N.i18nText('txtTooltipShowMemo'));
    $('#imgaddmemo').attr('title', I18N.i18nText('txtTooltipAddMemo'));
    $('#imgmarking').attr('title', I18N.i18nText('txtTooltipShowMarking'));
    $('#imgmarkingtoolbar').attr('title', I18N.i18nText('txtTooltipShowMarkingTool'));       */
2013 2014
};

2015
CONTENTVIEW.StartTimerUpdateLog = function() {
2016
    /* set end log */
2017 2018
    COMMON.SetEndLog(CONTENTVIEW_GENERAL.contentID);
    setTimeout("CONTENTVIEW.StartTimerUpdateLog();", 1000);
2019 2020 2021
};

/* check status image show toolbar marking */
2022
CONTENTVIEW.checkStatusImageMarking = function() {
2023
    if (ClientData.serviceOpt_marking() == 'Y') {
2024
        $('#imgmarkingtoolbar').bind('click', CONTENTVIEW.handleDrawCanvas);
2025 2026 2027 2028 2029
    } else {
        $('#imgmarkingtoolbar').unbind('click');
    }
};

2030
CONTENTVIEW.resizeScreen = function() {
2031 2032 2033 2034 2035
    /* save marking */
    var canvas = document.getElementById('draw_canvas');
    var context = canvas.getContext('2d');

    if (ClientData.IsAddingMarking() == true) {
2036
    	CONTENTVIEW_GENERAL.imgDrawingTemp = canvas.toDataURL("image/png");
2037
    	CONTENTVIEW_GENERAL.imgMarkerTemp = CONTENTVIEW_GENERAL.canvas_marker.toDataURL("image/png");
2038 2039
    }

2040 2041 2042
    CONTENTVIEW.sizingScreen();
    CONTENTVIEW.resizeCanvasDraw();
    CONTENTVIEW.drawCanvas();
2043

2044
    if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
2045
        CONTENTVIEW.drawCanvas(2);
2046
    }
2047

2048
    if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
2049
        CONTENTVIEW.drawCanvas(1);
2050
    }
2051

2052 2053 2054 2055 2056
    if (ClientData.IsAddingMarking() == true) {
        var img = new Image();
        img.onload = function () {
            context.drawImage(img, 0, 0, canvas.width, canvas.height);
        };
2057
        img.src = CONTENTVIEW_GENERAL.imgDrawingTemp;
2058 2059 2060

        var imgMarker = new Image();
        imgMarker.onload = function () {
2061
            CONTENTVIEW_GENERAL.context_marker.drawImage(imgMarker, 0, 0, CONTENTVIEW_GENERAL.canvas_marker.width, CONTENTVIEW_GENERAL.canvas_marker.height);
2062
        };
2063
        imgMarker.src = CONTENTVIEW_GENERAL.imgMarkerTemp;
2064 2065

    }
2066

2067
    // resize anket
2068
    CONTENTVIEW_ANKET.resizeAnket();
2069 2070 2071
};


2072
CONTENTVIEW.changePageWithoutSlide = function(pageMove) {
2073

Masaru Abe committed
2074
    //abe コンテンツリンクで移動時
2075
    //console.log("changePageWithoutSlide:" + pageMove);
Masaru Abe committed
2076
    //ページ閲覧ログセット
2077
    COMMON.SetPageLog( CONTENTVIEW_GENERAL.contentID, pageMove);
2078

2079
    CONTENTVIEW_GENERAL.disableAllControl();
2080
    var isExistBGMPageContent = false;
2081 2082 2083
    CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove);
    for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.pageObjects.length; nIndex++) {
        if (CONTENTVIEW_GENERAL.pageObjects[nIndex].mediaType == '3' && CONTENTVIEW_GENERAL.pageObjects[nIndex].playType == '2') {
2084 2085 2086 2087 2088
            isExistBGMPageContent = true;
        }
    }

    if (isExistBGMPageContent == false) {
2089
        CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, 0);
2090 2091
        for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.pageObjects.length; nIndex++) {
            if (CONTENTVIEW_GENERAL.pageObjects[nIndex].mediaType == '3' && CONTENTVIEW_GENERAL.pageObjects[nIndex].playType == '1') {
2092
                CONTENTVIEW_CREATEOBJECT.createAudio(CONTENTVIEW_GENERAL.pageObjects[nIndex].audioFile, CONTENTVIEW_GENERAL.pageObjects[nIndex].playType);
2093 2094 2095 2096 2097
            }
        }
    }
    //START TRB00069
    else{
2098
        CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, 0);
2099
        for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.pageObjects.length; nIndex++) {
2100
            if (CONTENTVIEW_GENERAL.pageObjects[nIndex].mediaType == '3' && CONTENTVIEW_GENERAL.pageObjects[nIndex].playType == '1') {
2101
                CONTENTVIEW.isPendingContentBGM = true;
2102
                if(pageMove > 0){
2103
                    CONTENTVIEW_CREATEOBJECT.createAudio(CONTENTVIEW_GENERAL.pageObjects[nIndex].audioFile, CONTENTVIEW_GENERAL.pageObjects[nIndex].playType);
2104
                }
2105 2106 2107 2108 2109 2110 2111 2112
            }
        }
    }
    //END TRB00069

    $('#divImageLoading').css('display', 'block');

    // Clear canvas offscreen
2113
    CONTENTVIEW_GENERAL.clearCanvas(document.getElementById("offscreen"));
2114

2115
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
2116

2117 2118
        //console.log("CONTENTVIEW.changePageWithoutSlide");
        AVWEB.avwGrabContentPageImage(ClientData.userInfo_accountPath(),
2119
             { contentId: CONTENTVIEW_GENERAL.contentID, sid: CONTENTVIEW.getSessionId(), pageNo: pageMove + 1 },
Vo Duc Thang committed
2120
             function (data) {
2121
                 CONTENTVIEW_GENERAL.pageImages = data;
2122

Vo Duc Thang committed
2123
                 /* get page Objects */
2124
                 CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove);
2125
                 CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages).setPageObjects(CONTENTVIEW_GENERAL.pageObjects);
2126

Vo Duc Thang committed
2127
                 $('#divImageLoading').css('display', 'none');
2128

2129
                 CONTENTVIEW_GENERAL.isFirstLoad = true;
2130 2131
                 // CONTENTVIEW.screenFit();

2132
                 CONTENTVIEW_GETDATA.getContent().toPage(pageMove);
2133

Vo Duc Thang committed
2134
                 //START : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM
2135
                 CONTENTVIEW_CREATEOBJECT.createPageBGM();
2136
                 //END : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM
2137

2138
                 //Start FUnciton: No.4 - Editor : Long - Date : 08/12/2013 - Summary : Handle jump from bookmark page
2139 2140
                 if(pageMove > 0){
                     //START TRB00056 - Editor: Long - Date: 09/19/2013 - Summary :
2141
                     CONTENTVIEW_GENERAL.prevContent.pageIndex = CONTENTVIEW_GETDATA.getPageIndex();
2142
                     //END TRB00056 - Editor: Long - Date: 09/19/2013 - Summary :
2143
                     CONTENTVIEW_GETDATA.getPrevPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove - 1);
2144
                     CONTENTVIEW_GETDATA.renderPrevPage();
2145
                 }
2146

2147
                 if(pageMove < CONTENTVIEW_GENERAL.totalPage - 1){
2148
                     //START TRB00056
2149
                     CONTENTVIEW_GENERAL.nextContent.pageIndex = CONTENTVIEW_GETDATA.getPageIndex();
2150
                     //END TRB00056
2151
                     CONTENTVIEW_GETDATA.getNextPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove + 1);
2152
                     CONTENTVIEW_GETDATA.renderNextPage();
2153
                 }
2154 2155 2156

                 //End Function : No.4 - Editor : Long - Date: 08/12/2013 - Summary : Handle jump form bookmark page

Vo Duc Thang committed
2157
                 /* handle slider bar */
2158
                 CONTENTVIEW.handleSliderBar();
2159

2160 2161 2162
                 if (CONTENTVIEW_GENERAL.dataPageTitle[pageMove]) {
                     if (CONTENTVIEW_GENERAL.dataPageTitle[pageMove] != '') {
                         document.title = CONTENTVIEW_GENERAL.contentName + '_' + CONTENTVIEW_GENERAL.dataPageTitle[pageMove] + ' | ' + I18N.i18nText('sysAppTitle');
Vo Duc Thang committed
2163
                     } else {
2164
                         document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
Vo Duc Thang committed
2165 2166
                     }
                 } else {
2167
                     document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
Vo Duc Thang committed
2168
                 }
2169

Vo Duc Thang committed
2170 2171
             },
             function (xmlHttpRequest, txtStatus, errorThrown) {
2172
                 CONTENTVIEW.showErrorScreen();
Vo Duc Thang committed
2173
             });
2174 2175
     }
    //START : TRB00032 - Editor : Long - Date: 09/10/2013 - Summary : type none process
2176
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
2177
        /* get page Objects */
2178
        CONTENTVIEW_GETDATA.getPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove);
2179
         CONTENTVIEW_GETDATA.getContent().setPageImages(CONTENTVIEW_GENERAL.totalPage, CONTENTVIEW_GENERAL.pageImages).setPageObjects(CONTENTVIEW_GENERAL.pageObjects);
2180

2181
         $('#divImageLoading').css('display', 'none');
2182

2183
         CONTENTVIEW_GENERAL.isFirstLoad = true;
2184 2185
         // CONTENTVIEW.screenFit();

2186
         CONTENTVIEW_GETDATA.getContent().toPage(pageMove);
2187
         //START : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM
2188
         CONTENTVIEW_CREATEOBJECT.createPageBGM();
2189
         //END : TRB00028 - Editor: Long - Date: 09/10/2013 - Summary : Fix For Page BGM
2190

2191
         //Start FUnciton: No.4 - Editor : Long - Date : 08/12/2013 - Summary : Handle jump from bookmark page
2192 2193 2194
         if(pageMove > 0){

             //START TRB00056 - Editor: Long - Date: 09/19/2013 - Summary :
2195
             CONTENTVIEW_GENERAL.prevContent.pageIndex = CONTENTVIEW_GETDATA.getPageIndex();
2196
             //END TRB00056 - Editor: Long - Date: 09/19/2013 - Summary :
2197
             CONTENTVIEW_GETDATA.getPrevPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove - 1);
2198
             CONTENTVIEW_GETDATA.renderPrevPage();
2199
         }
2200

2201
         if(pageMove < CONTENTVIEW_GENERAL.totalPage - 1){
2202

2203
             //START TRB00056
2204
             CONTENTVIEW_GENERAL.nextContent.pageIndex = CONTENTVIEW_GETDATA.getPageIndex();
2205
             //END TRB00056
2206

2207
             CONTENTVIEW_GETDATA.getNextPageObjectsByPageIndex(CONTENTVIEW_GENERAL.pageObjectsData, pageMove + 1);
2208
             CONTENTVIEW_GETDATA.renderNextPage();
2209
         }
2210 2211 2212

         //End Function : No.4 - Editor : Long - Date: 08/12/2013 - Summary : Handle jump form bookmark page

2213
         /* handle slider bar */
2214
         CONTENTVIEW.handleSliderBar();
2215

2216 2217 2218
         if (CONTENTVIEW_GENERAL.dataPageTitle[pageMove]) {
             if (CONTENTVIEW_GENERAL.dataPageTitle[pageMove] != '') {
                 document.title = CONTENTVIEW_GENERAL.contentName + '_' + CONTENTVIEW_GENERAL.dataPageTitle[pageMove] + ' | ' + I18N.i18nText('sysAppTitle');
2219
             } else {
2220
                 document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
2221 2222
             }
         } else {
2223
             document.title = CONTENTVIEW_GENERAL.contentName + ' | ' + I18N.i18nText('sysAppTitle');
2224 2225 2226 2227 2228 2229
         }
    }
    //END : TRB00032 - Editor : Long - Date: 09/10/2013 - Summary : type none process
};

/* set position model when resize*/
2230
CONTENTVIEW.changePosDialog = function() {
2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245
    $("#divDialogMemo").center();
    /*$("#divDialogMemo").css('position', 'absolute');*/
    $("#boxBookMark").center();
    $("#boxIndex").center();
    $("#boxCopyText").center();
    $("#boxSearching").center();
    $("#boxAddMemo").center();
    $('#dlgPen').center();
    $('#dlgMaker').center();
    $('#dlgGomu').center();
    $('#dlgMarking').center();
    $('#bgmConfirm').center();
    $("#bgmConfirm_page").center();
};

2246
CONTENTVIEW.closeDialogResize = function() {
2247
    CONTENTVIEW.closeDialogPopUpText();
2248 2249 2250 2251 2252 2253 2254

    $('#pop_up_memo').hide();
};

//Start Function : No.12

//START TRB00075 - Editor: Long - Date - 24/09/2013 - Summary : Fix for prevent moving page when display dialog
2255
CONTENTVIEW.displayOverlayForHtmlAndMediaType = function(){
2256 2257 2258
    var $overlay = $('#overlay');
    var $header = $('header');
    var $footer = $('footer');
2259

2260 2261 2262 2263 2264
    $header.css('position', 'absolute');
    $header.css('width', '100%');
    $header.css('z-index', '102');
    $footer.css('z-index', '102');
    $overlay.show();
2265

2266 2267 2268
    //START TRB00075 - Editor: Long - Date - 24/09/2013 - Summary : Fix for prevent moving page when display dialog
    document.getElementById('overlay').addEventListener('touchstart', function(event){event.preventDefault(); return false;}, false);
    document.getElementById('overlay').addEventListener('touchmove', function(event){event.preventDefault(); return false;}, false);
2269
    document.getElementById('overlay').addEventListener('touchend', function(event){event.preventDefault(); return false;}, false);
2270
    //END TRB00075 - Editor: Long - Date - 24/09/2013 - Summary : Fix for prevent moving page when display dialog
2271

2272 2273 2274
};
//END TRB00075 - Editor: Long - Date - 24/09/2013 - Summary : Fix for prevent moving page when display dialog

2275
//360vtourの場合戻るボタンを処理する
vietdo committed
2276 2277
CONTENTVIEW.panoOldContent = function(){
	
vietdo committed
2278 2279
	var oldPageNo = null;
	
vietdo committed
2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291
	if(ClientData.IsJumpBack() == true){
		
		var oldDataBack = ClientData.JumpQueue();
		
		oldPageNo = oldDataBack[oldDataBack.length - 1].oldPageIndex;
		oldDataBack.splice(oldDataBack.length - 1, 1);
		ClientData.JumpQueue(oldDataBack);
		
		if(oldDataBack.length == 0){
			ClientData.IsJumpBack(false);
		}    		    
	}
vietdo committed
2292 2293
	
	return oldPageNo;
2294
};
vietdo committed
2295

2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324
CONTENTVIEW.createSessionForPanoramaContent = function(apiUrl, func, linkUrlTmp){
	
	var params = {
	        sid: ClientData.userInfo_sid()
	    };
	var sysSettings = AVWEB.avwSysSetting();
	// ajax によるAPIの実行(json)
	$.ajax( {
		async:		false,
		type:		'GET',
		url:		apiUrl,
		dataType:	'text',
		data:		params,
		crossDomain: true,
  		beforeSend:	function(xhr) {
  			xhr.setRequestHeader('X-AGT-AppId', sysSettings.appName);
			xhr.setRequestHeader('X-AGT-AppVersion', sysSettings.appVersion);
   		},
		success:	function(data) {
			var linkUrlTmp2 = linkUrlTmp + ";jsessionid=" + data;
	    	func(linkUrlTmp2);
		},
		error:		function(xmlHttpRequest, txtStatus, errorThrown) {
			/* call custom error process */
			AVWEB.avwLog("error" + errorThrown);
		}
	});
};

2325
//Display overlay dialog for specify content type
2326
CONTENTVIEW.displayOverlayForSpecifyContentType = function( resourceUrl ){
2327

2328
    var contentId = ClientData.contentInfo_contentId();
2329
    if( resourceUrl == null ){
vietdo committed
2330
    	resourceUrl = CONTENTVIEW.downloadResourceById(CONTENTVIEW_GENERAL.contentID);
2331
    }
2332
    //CONTENTVIEW_GENERAL.contentType = COMMON.ContentTypeKeys.Type_Html;
2333
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Music){
2334
        CONTENTVIEW.handleForContentTypeMusic(resourceUrl);
2335
    }
2336 2337
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Video){
    	CONTENTVIEW.handleForContentTypeVideo(resourceUrl);
2338
    }
2339
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Html){
2340

2341
        var linkUrlTmp = resourceUrl;
2342 2343
        //HTMLカスタムログオプション有り
        if(ClientData.serviceOpt_html_custom_log() == 'Y'){
Masaru Abe committed
2344
            var apiUrl = AVWEB.getApiUrl(ClientData.userInfo_accountPath());
2345
            linkUrlTmp = linkUrlTmp + "?sid=" + CONTENTVIEW.getSessionId() + "&apiurl=" + apiUrl + "&cid=" + CONTENTVIEW_GENERAL.contentID;
2346
        }
2347
        CONTENTVIEW.handleForContentTypeHTML(linkUrlTmp);
2348
    }
2349
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Exam){
2350
        CONTENTVIEW.handleForContentTypeExam(resourceUrl);
2351 2352
    }
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Enquete){
2353
        CONTENTVIEW.handleForContentTypeEnquete(resourceUrl);
2354
    }
2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375
	else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PanoMovie){
		var url = ClientData.conf_apiUrl();    	
		var linkUrlTmp = AVWEB.format(url, ClientData.userInfo_accountPath());
		var apiUrl = linkUrlTmp + "/createSession/";
		CONTENTVIEW.panoOldContent();
		
		linkUrlTmp = linkUrlTmp.substring(0, linkUrlTmp.length - 6) + "shop/panorama/play/" + CONTENTVIEW_GENERAL.contentID + "/";
		
		CONTENTVIEW.createSessionForPanoramaContent(apiUrl,function(){
			CONTENTVIEW.handleForContentTypePanoMovie(linkUrlTmp);
		}, linkUrlTmp);
	
	}
	else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PanoImage){
		var url = ClientData.conf_apiUrl();
		var linkUrlTmp = AVWEB.format(url, ClientData.userInfo_accountPath());
		var apiUrl = linkUrlTmp + "/createSession/";
		
		var oldPageNo = CONTENTVIEW.panoOldContent();
		if(oldPageNo != null){
			linkUrlTmp = linkUrlTmp.substring(0, linkUrlTmp.length - 6) + "shop/vtour/play/" + CONTENTVIEW_GENERAL.contentID + "/" + "?startscene=scene" + oldPageNo+"&a=1";
2376 2377
		}else if (CONTENTVIEW_GENERAL.prePageNo) {
            linkUrlTmp = linkUrlTmp.substring(0, linkUrlTmp.length - 6) + "shop/vtour/play/" + CONTENTVIEW_GENERAL.contentID + "/" + "?startscene=scene" + CONTENTVIEW_GENERAL.prePageNo+"&a=1";
2378 2379
		}else{
			linkUrlTmp = linkUrlTmp.substring(0, linkUrlTmp.length - 6) + "shop/vtour/play/" + CONTENTVIEW_GENERAL.contentID + "/";
2380
        }
2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399
			
		CONTENTVIEW.createSessionForPanoramaContent(apiUrl,function(){
			CONTENTVIEW.handleForContentTypePanoImage(linkUrlTmp);
		},linkUrlTmp);
	}
	else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_ObjectVR){
		var url = ClientData.conf_apiUrl();    	
		var linkUrlTmp = AVWEB.format(url, ClientData.userInfo_accountPath());
		var apiUrl = linkUrlTmp + "/createSession/";
		CONTENTVIEW.panoOldContent();
		
		linkUrlTmp = linkUrlTmp.substring(0, linkUrlTmp.length - 6) + "shop/objectvr/play/" + CONTENTVIEW_GENERAL.contentID + "/";
		
		CONTENTVIEW.createSessionForPanoramaContent(apiUrl,function(){
			CONTENTVIEW.handleForContentTypeObjectVR(linkUrlTmp);
		}, linkUrlTmp);
	
	}
    
Masaru Abe committed
2400
    if (COMMON.isTouchDevice() == true) {
Masaru Abe committed
2401
        if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
2402
            CONTENTVIEW_GENERAL.standardRatio = document.documentElement.clientWidth / window.innerWidth;
2403
            ZOOM_DETECTOR.startDetectZoom({ time: 500,
2404
                callbackFunction: function (oldRatio, newRatio, oldW, oldH, newW, newH) {
2405
                    CONTENTVIEW_GENERAL.currentRatio = newRatio;
2406 2407 2408 2409 2410 2411 2412 2413

                }
            });
            var top = window.innerHeight - $("#footer_toolbar_1").height();
            $("#wrapper").css("width", window.innerWidth);
            $("#wrapper").css("height", window.innerHeight);
            $("#footer_toolbar_1").css("top", top + "px");
            $("#footer_toolbar_2").css("top", top + "px");
2414
            CONTENTVIEW.sizingScreen();
2415
        }
2416

2417 2418 2419
    }

    //Start : TRB00082 - Editor : Long - Date : 09/25/2013 - Summary : For win 8 rotate handling.
2420
    CONTENTVIEW.setViewportForWin8();
2421
    //End : TRB00082 - Editor : Long - Date : 09/25/2013 - Summary : For win 8 rotate handling.
2422

2423
    //Start : TRB00075 - Editor : Long - Date : 09/25/2013 - Summary : prevent moving page
Masaru Abe committed
2424
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
2425
        CONTENTVIEW.displayOverlayForHtmlAndMediaType();
2426 2427 2428 2429
    }
    //End : TRB00075 - Editor : Long - Date : 09/25/2013 - Summary : prevent moving page
    /* window resize event */
    $(window).resize(function () {
2430 2431 2432

        //CONTENTVIEW.sizingScreen();
        //START : TRB00034 - DATE : 09/11/2013 - Editor : Long  - Summary : Fix for center loading image
2433
        CONTENTVIEW_INITOBJECT.setLoadingSize();
2434
        //END : TRB00034 - DATE : 09/11/2013 - Editor : Long  - Summary : Fix for center loading image
Masaru Abe committed
2435
        if (COMMON.isTouchDevice() == true) {
Masaru Abe committed
2436
            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454
                var tempRatio = document.documentElement.clientWidth / window.innerWidth;
                if (tempRatio <= 1) {
                    // Adjust position for toolbar and footer bar
                    var top = window.innerHeight - $("#footer_toolbar_1").height();
                    $("#wrapper").css("width", window.innerWidth);
                    $("#wrapper").css("height", window.innerHeight);
                    $("#footer_toolbar_1").css("top", top + "px");
                    $("#footer_toolbar_2").css("top", top + "px");
                }
                else {
                    var top = $(window).height() - $("#footer_toolbar_1").height();
                    $("#wrapper").css("width", $(window).width());
                    $("#wrapper").css("height", $(window).height());
                    $("#footer_toolbar_1").css("top", top + "px");
                    $("#footer_toolbar_2").css("top", top + "px");
                }
            }
        }
2455
        CONTENTVIEW.sizingScreen();
2456

2457
        //Start : TRB00082 - Editor : Long - Date : 09/25/2013 - Summary : For win 8 rotate handling.
2458
        CONTENTVIEW.setViewportForWin8();
2459 2460
        //End : TRB00082 - Editor : Long - Date : 09/25/2013 - Summary : For win 8 rotate handling.

2461
        CONTENTVIEW_GENERAL.isChangeSizeScreen = false;
2462 2463

        /* change position dialog */
2464
        CONTENTVIEW.changePosDialog();
2465 2466

        /* close dialog popuptext */
2467
        CONTENTVIEW.closeDialogResize();
2468

2469 2470 2471
        //START TRB00091 - Editor : LOng - Date : 09/26/2013 - Summary : Dialog at center when rotate
        $("#contentVideoConfirm").center();
        $("#contentAudioConfirm").center();
2472 2473 2474
        //END TRB00091 - Editor : LOng - Date : 09/26/2013 - Summary : Dialog at center when rotate

    });
2475 2476 2477
};

//handle for content type = video
2478
CONTENTVIEW.handleForContentTypeVideo = function(resourceUrl){
2479

2480 2481
    //Create Dialog overlay
    var $container = $('#dialog');
2482 2483 2484

    $container.html('');

2485
    if (ClientData.userOpt_musicMode() == "1") {
2486
            $container.html('<video id="content_video" autoplay="true" loop="true" controls="controls" controlsList="nodownload" style="position: absolute; width: 100%; height: 100%;">'
2487 2488
            + '     <source src="' + resourceUrl + '" type="video/mp4"> '
            + '</video>'
2489 2490 2491
            );
    }
    else {
2492
        $container.html('<video id="content_video" autoplay="true" controls="controls" controlsList="nodownload" style="position: absolute; width: 100%; height: 100%;">'
2493 2494 2495
        + '     <source src="' + resourceUrl + '" type="video/mp4"> '
        + '</video>'
        );
2496 2497
    }

2498 2499
    //START TRB00068
    // Check to play Video on ipad
2500
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
2501 2502 2503 2504
        // Show confim message to play background music
        $("#contentVideoConfirm").css('z-index', 999);
        $("#contentVideoConfirm_OK").unbind('click');
        $("#contentVideoConfirm_OK").click(function () {
2505 2506

            var myVideo=document.getElementById("content_video");
2507 2508
            if (myVideo.paused)
            {
2509 2510 2511
                myVideo.play();
            }

2512 2513
            $container.show();
            $("#contentVideoConfirm").hide();
2514
            CONTENTVIEW.isShowVideoContent = true;
2515 2516 2517 2518
        });
        $("#contentVideoConfirm").show();
        $("#contentVideoConfirm").center();
    }
2519
    else if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()) {
2520 2521 2522 2523 2524
        // Show confim message to play background music
        $("#contentVideoConfirm").css('z-index', 999);
        $("#contentVideoConfirm_OK").unbind('click');
        $container.show();
        $("#contentVideoConfirm_OK").click(function () {
2525 2526

            var myVideo=document.getElementById("content_video");
2527 2528
            if (myVideo.paused)
            {
2529
                myVideo.play();
2530 2531
            }

2532
            $("#contentVideoConfirm").hide();
2533
            CONTENTVIEW.isShowVideoContent = true;
2534 2535 2536 2537 2538 2539
        });
        $("#contentVideoConfirm").show();
        $("#contentVideoConfirm").center();
    }
    else{
        $container.show();
2540 2541
    }
    //END TRB00068
2542 2543
};

2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560
//handle for content type = panoMovie
CONTENTVIEW.handleForContentTypePanoMovie = function(resourceUrl){
	//Create Dialog overlay
    var $container = $('#dialog');

    $container.html('');
    $container.css('left','0%');
    $container.css('width','100%');
    $container.css('background-color','white');

    if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
       $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%;"></iframe>');

       $container.css('overflow', 'scroll');
       $container.css('-webkit-overflow-scrolling', 'touch');
    }
    else{
2561
       $container.html('<iframe src="'+ resourceUrl +'" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" style="position: absolute; width: 100%; height: 100%; "> </iframe>');
2562 2563 2564 2565 2566 2567
       $container.css('overflow', 'hidden');
    }
    $container.show();
    return;
};

2568
//handle for content type = panoImage
vietdo committed
2569 2570 2571 2572 2573 2574 2575 2576 2577 2578 2579 2580 2581 2582 2583 2584 2585 2586 2587
CONTENTVIEW.handleForContentTypePanoImage = function(resourceUrl){
	//Create Dialog overlay
    var $container = $('#dialog');

    $container.html('');
    $container.css('left','0%');
    $container.css('width','100%');
    $container.css('background-color','white');

    if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
       $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%;"></iframe>');

       $container.css('overflow', 'scroll');
       $container.css('-webkit-overflow-scrolling', 'touch');
    }
    else{
       $container.html('<iframe src="'+ resourceUrl +'" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" style="position: absolute; width: 100%; height: 100%; "> </iframe>');
       $container.css('overflow', 'hidden');
    }
2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611
    $container.show();
    return;
};

//handle for content type = objectvr
CONTENTVIEW.handleForContentTypeObjectVR = function(resourceUrl){
	//Create Dialog overlay
    var $container = $('#dialog');

    $container.html('');
    $container.css('left','0%');
    $container.css('width','100%');
    $container.css('background-color','white');

    if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
       $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%;"></iframe>');

       $container.css('overflow', 'scroll');
       $container.css('-webkit-overflow-scrolling', 'touch');
    }
    else{
       $container.html('<iframe src="'+ resourceUrl +'" allowfullscreen="true" webkitallowfullscreen="true" mozallowfullscreen="true" style="position: absolute; width: 100%; height: 100%; "> </iframe>');
       $container.css('overflow', 'hidden');
    }
vietdo committed
2612 2613 2614 2615
    $container.show();
    return;
};

2616
//handle for content type = music
2617
CONTENTVIEW.handleForContentTypeMusic = function(resourceUrl){
2618

2619 2620 2621
    //Create Dialog overlay
    var $container = $('#dialog');
    $container.html('');
2622

Vo Duc Thang committed
2623 2624 2625 2626
    //START FIX CSS
    //$container.css('background', 'url(./img/iPad_music.png) center center no-repeat');
    //$container.css('background-color', 'white');
    $container.addClass('dialog-content-music');
2627 2628 2629
    //END FIX CSS

    if (ClientData.userOpt_musicMode() == "1") {
2630 2631 2632 2633
        $container.html('<audio autoplay="true" loop="true" controls="controls" style="position: absolute; width: 100%; bottom: 1%;">'
        + '     <source src="' + resourceUrl + '" type="audio/mpeg"> '
        + '</audio>'
        );
2634
    }
2635 2636 2637 2638 2639
    else {
        $container.html('<audio autoplay="true" controls="controls" style="position: absolute; width: 100%; bottom: 1%;">'
        + '     <source src="' + resourceUrl + '" type="audio/mpeg"> '
        + '</audio>'
        );
2640 2641
    }

2642
    if(CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox'){
2643 2644
        $container.find('audio').css('height', '30px');
    }
2645

2646
    $container.show();
2647

2648 2649
    //START TRB00068
    // Check to play BGM on ipad
Masaru Abe committed
2650
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
2651 2652 2653 2654 2655 2656 2657
        // Show confim message to play background music
        $("#contentAudioConfirm").css('z-index', 999);
        $("#contentAudioConfirm_OK").unbind('click');
        $("#contentAudioConfirm_OK").click(function () {

            $("#contentAudioConfirm").hide();
            $("#dialog").find('audio').load();
2658
            $("#dialog").find('audio').play();
2659 2660 2661 2662 2663 2664 2665 2666
        });
        $("#contentAudioConfirm").show();
        $("#contentAudioConfirm").center();
    }
    //END TRB00068
};

//handle for content type = html
2667
CONTENTVIEW.handleForContentTypeHTML = function(resourceUrl){
2668 2669
     //Create Dialog overlay
    var $container = $('#dialog');
2670

2671 2672 2673 2674
    $container.html('');
    $container.css('left','0%');
    $container.css('width','100%');
    $container.css('background-color','white');
2675

2676
    //START TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad
Masaru Abe committed
2677
    if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
2678 2679
       $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%;"></iframe>');

2680 2681 2682 2683 2684 2685 2686 2687
       $container.css('overflow', 'scroll');
       $container.css('-webkit-overflow-scrolling', 'touch');
    }
    else{
        $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%; height: 100%; "> </iframe>');
         $container.css('overflow', 'hidden');
    }
    //END TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad
2688
    $container.show();
2689 2690
};

2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708
CONTENTVIEW.handleForContentTypeExam = function(resourceUrl){
    //Create Dialog overlay
   var $container = $('#dialog');

   $container.html('');
   $container.css('left','0%');
   $container.css('width','100%');
   $container.css('background-color','white');

   //START TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad
   if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
      $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%;"></iframe>');

      $container.css('overflow', 'scroll');
      $container.css('-webkit-overflow-scrolling', 'touch');
   }
   else{
       $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%; height: 100%; "> </iframe>');
2709 2710 2711 2712 2713 2714 2715 2716 2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 2729 2730 2731 2732 2733
       $container.css('overflow', 'hidden');
   }
   //END TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad
   $container.show();
};

CONTENTVIEW.handleForContentTypeEnquete = function(resourceUrl){
    //Create Dialog overlay
   var $container = $('#dialog');

   $container.html('');
   $container.css('left','0%');
   $container.css('width','100%');
   $container.css('background-color','white');

   //START TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad
   if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
      $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%;"></iframe>');

      $container.css('overflow', 'scroll');
      $container.css('-webkit-overflow-scrolling', 'touch');
   }
   else{
       $container.html('<iframe src="'+ resourceUrl +'" style="position: absolute; width: 100%; height: 100%; "> </iframe>');
       $container.css('overflow', 'hidden');
2734 2735 2736 2737 2738
   }
   //END TRB00076 - EDITOR : Long - Date : 09/24/2013 - Summary : Fix for scrolling on ipad
   $container.show();
};

2739
//Check type of content
2740
CONTENTVIEW.isMediaAndHTMLContent = function(){
2741
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Music || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Video || 
2742
    		CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Html || 
2743
    		CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PanoMovie || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PanoImage || 
2744
    		CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_ObjectVR){
2745
        return true;
2746 2747 2748 2749 2750 2751 2752
    }
    else{
        return false;
    }
};

//Enable Specify Control
2753
CONTENTVIEW.enableSpecifyControl = function(){
2754

2755
    //Disable All control
2756
    CONTENTVIEW_GENERAL.disableAllControl();
2757

2758
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Html || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Music || 
2759 2760
    	CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Video || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PanoMovie || 
    	CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PanoImage || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_ObjectVR){
2761

2762
        CONTENTVIEW.enableControlForMediaAndHtmlType();
2763
    }
2764 2765 2766
};

//Enable Control for video, audio, html type.
2767
CONTENTVIEW.enableControlForMediaAndHtmlType = function(){
2768 2769 2770
    /* set cursor pointer*/
    $("#imgHome").css('cursor', 'pointer');
    $("#imgBack").css('cursor', 'pointer');
2771

2772 2773
    $("#control_screen").removeClass();
    $("#control_screen_2").removeClass();
2774

2775
    $('#imgHome').bind('click', CONTENTVIEW_EVENTS.imgHome_click);
2776
    $('#imgHome').removeClass();
2777

2778
    $('#imgBack').bind('click', CONTENTVIEW_EVENTS.imgBack_click);
2779
    $('#imgBack').removeClass();
2780

2781 2782
    $("#control_screen").bind('click', CONTENTVIEW.fullScreenForNotPdfType);
    $("#control_screen_2").bind('click', CONTENTVIEW.originalScreenForNotPdfType);
vietdo committed
2783
    
Masaru Abe committed
2784
    if (COMMON.isTouchDevice() == true) {/* set css for device */
2785 2786
        $('#imgHome').addClass('home_device');
        $('#imgBack').addClass('back_device');
2787

2788
        $("#control_screen").addClass('toolbar_device');
2789
        //$("#control_screen_2").addClass('toolbar_device');
2790
        $("#control_screen_2").addClass('toolbar_close_device');
2791

2792 2793 2794
    } else { /* set css for PC */
        $('#imgHome').addClass('home');
        $('#imgBack').addClass('back');
2795

2796
        $("#control_screen").addClass('toolbar');
2797
        $("#control_screen_2").addClass('toolbar_close');
2798
    }
2799

2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810
    //getits対応
    if( ClientData.isGetitsMode() == true ){
        $('#imgHome').unbind('click');
        $('#imgHome').removeClass();
        $('#imgHome').addClass('home_off');

        /* back button */
        $('#imgBack').unbind('click');
        $('#imgBack').removeClass();
        $('#imgBack').addClass('back_off');
    }
2811

2812 2813 2814
};

//Full screen function for not pdf type
2815
CONTENTVIEW.fullScreenForNotPdfType = function(){
2816

2817
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Video){
Masaru Abe committed
2818
        if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
2819
            $('#content_video').removeAttr('controls');
2820
        }
2821
    }
2822

2823
    var $container = $('#dialog');
2824

2825 2826 2827 2828 2829 2830 2831 2832
    $('#header_toolbar').hide();
    //START TRB00097
    //$('#footer_toolbar_2').show();
    //END TRB00097
    $('#control_screen_2').show();
    $('#footer_toolbar_2').css('z-index', '999');
    $('#control_screen_2').css('z-index', '999');
    $('#footer_toolbar_1').hide();
2833

2834 2835 2836 2837 2838
    $container.css('top', '0%')
              .css('left', '0%')
              .css('height', '100%')
              .css('width', '100%');
    //$container.attr('style', 'top: 0; left: 0; height: 100%; width: 100%;');
2839

2840 2841
    CONTENTVIEW.isZoomingContent = true;
    CONTENTVIEW_GENERAL.isFullScreen = true;
2842 2843 2844
};

//Original screen for not pdf type
2845
CONTENTVIEW.originalScreenForNotPdfType = function(){
2846 2847 2848 2849 2850 2851
    $('#footer_toolbar_2').css('z-index', '');
    $('#control_screen_2').css('z-index', '');
    $('#footer_toolbar_1').show();
    $('#footer_toolbar_2').hide();
    $('#control_screen_2').hide();
    $('#header_toolbar').show();
2852

2853
    var $container = $('#dialog');
2854 2855
    $container.removeAttr('style');

2856
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Music){
2857 2858 2859
        $container.css('background', 'url(./img/iPad_music.png) center no-repeat');
        $container.css('background-color', 'white');
    }
2860
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Html){
2861 2862 2863 2864 2865 2866 2867 2868
        $container.css('left','0%');
        $container.css('position','absolute');
        //$container.css('height','100%');
        $container.css('width','100%');
        $container.css('background-color', 'white');
        $container.css('overflow', 'scroll');
        $container.css('-webkit-overflow-scrolling', 'touch');
    }
2869
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Enquete){
2870
        $container.css('left','0%');
2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883
        $container.css('position','absolute');
        //$container.css('height','100%');
        $container.css('width','100%');
        $container.css('background-color', 'white');
        $container.css('overflow', 'scroll');
        $container.css('-webkit-overflow-scrolling', 'touch');
    }
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Exam){
    	$container.css('left','0%');
        $container.css('position','absolute');
        //$container.css('height','100%');
        $container.css('width','100%');
        $container.css('background-color', 'white');
2884 2885
        $container.css('overflow', 'scroll');
        $container.css('-webkit-overflow-scrolling', 'touch');
2886 2887
    }else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PanoMovie || 
    		CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PanoImage || 
2888
    		CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_ObjectVR){
vietdo committed
2889 2890 2891 2892 2893 2894 2895 2896
    	$container.css('left','0%');
        $container.css('position','absolute');
        //$container.css('height','100%');
        $container.css('width','100%');
        $container.css('background-color', 'white');
        $container.css('overflow', 'scroll');
        $container.css('-webkit-overflow-scrolling', 'touch');
    }
2897

2898
    //START TRB00068
Masaru Abe committed
2899
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
2900
        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Video){
2901
            $('#content_video').attr('controls', 'controls');
2902

2903
            if(CONTENTVIEW.isShowVideoContent){
2904 2905 2906
                $container.show();
            }
            else{
2907

2908 2909 2910
            }
        }
        else{
2911 2912
            $container.show();
        }
2913 2914
    }
    else{
2915
        $container.show();
2916 2917
    }
    //END TRB00068
2918

2919 2920
    CONTENTVIEW.isZoomingContent = false;
    CONTENTVIEW_GENERAL.isFullScreen = false;
2921 2922 2923
};

//Get resource Id of content
2924
CONTENTVIEW.downloadResourceById = function(contentId){
2925
    var params = {
2926
        sid: CONTENTVIEW.getSessionId(),
2927 2928
        contentId: contentId,
        getType: '2',
Masaru Abe committed
2929
        isStreaming: ClientData.isStreamingMode()
2930
    };
2931

2932
    var resourceUrl;
2933
    CONTENTVIEW_CALLAPI.abapi('webGetContent', params, 'GET', function (data) {
2934
        var resourceId;
2935
        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Html){
2936 2937 2938 2939 2940
            resourceUrl = data.contentDataSub[0].resourceUrl;
        }
        else{
            $.each(data.contentData , function(i, n){
                if(typeof n == "object"){
2941 2942 2943
                    resourceId = n.resourceId;
                }
            });
2944
           //Get resource
2945
           resourceUrl = CONTENTVIEW_GETDATA.getResourceByIdFromAPI(resourceId);
2946
        }
2947 2948 2949 2950

    });

    return resourceUrl;
2951 2952
};

2953
CONTENTVIEW.getVideoContentResourceId = function(contentId){
2954

2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972
    if(CONTENTVIEW_GENERAL.contentType != COMMON.ContentTypeKeys.Type_Video){
        return null;
    }

    var params = {
        sid: ClientData.userInfo_sid(),
        contentId: contentId,
        getType: '2'
    };
    var resourceId;
    CONTENTVIEW_CALLAPI.abapi('webGetContent', params, 'GET', function (data) {
        $.each(data.contentData , function(i, n){
            if(typeof n == "object"){
                resourceId = n.resourceId;
            }
        });
        //Get resource
    });
2973

2974
    return resourceId;
2975

2976 2977
};

2978
//Start : TRB00015 - Editor : Long - Date : 08/28/2013 - Summary : For win 8 rotate handling.
2979
CONTENTVIEW.setViewportForWin8 = function(){
2980
    if (window.navigator.msPointerEnabled) {
2981 2982
        //Landscape
        if($(window).width() > $(window).height()){
2983

2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996
            var msViewportStyle = document.createElement("style");
            msViewportStyle.appendChild(
              document.createTextNode("@-ms-viewport{width: device-width;!important}")
            );
            document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
        }
        //Portrait
        else{
            var msViewportStyle = document.createElement("style");
            msViewportStyle.appendChild(
              document.createTextNode("@-ms-viewport{width: device-height;!important}")
            );
            document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
2997 2998
        }
    }
2999 3000 3001
};
//End : TRB00015 - Editor : Long - Date : 08/28/2013 - Summary : For win 8 rotate handling.

3002
//Start : TRB00022 - Editor : Long - Date : 08/28/2013 - Summary : For ipad rotate handling.
3003
CONTENTVIEW.setViewportForTouchDevice = function(maximumScale){
Masaru Abe committed
3004
    if (COMMON.isTouchDevice()) {
Masaru Abe committed
3005
        if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()){
3006
            var viewportmeta = document.querySelector('meta[name="viewport"]');
3007
            if (viewportmeta) {
3008 3009
                viewportmeta.content = 'minimum-scale=0.75, maximum-scale=' + maximumScale;
            }
3010
        }
3011 3012
    }
};
3013
//End : TRB00022 - Editor : Long - Date : 08/28/2013 - Summary : For ipad rotate handling.
3014 3015 3016 3017 3018


/* ========================================================================================================== */

/**
3019
* CurrentPage Class Definition
3020 3021
*/
/* constructor */
3022
CONTENTVIEW.ContentPage = function (pageNum, pageImageUrl) {
3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035

    this.pageNumber = 0;
    this.pageImageUrl = pageImageUrl;
    this.bInitialized = false;

    /* init screen image */
    this.image = null;

    /* array page objects */
    this.pageObjects = new Array();
};

/* Load page */
3036
CONTENTVIEW.ContentPage.prototype.load = function (onCompletedFunc) {
3037

3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050 3051 3052 3053
    /* load image  */
    this.image = new Image();
    this.image.onerror = function () {

    };
    this.image.onload = function (context) {
        /* load complete */
        if (onCompletedFunc) {
            onCompletedFunc();
        }
    };

    this.image.src = this.pageImageUrl;
};

/* add 1 page to pageObject */
3054
CONTENTVIEW.ContentPage.prototype.addPageObject = function (pageObject) {
3055 3056 3057 3058
    this.pageObjects.push(pageObject);
};

/* init Json object using for init pages */
3059
CONTENTVIEW.ContentPage.prototype.addPageObjects = function (pageObjects) {
3060 3061 3062 3063 3064 3065 3066 3067
    for (var i = 0; i < pageObjects.length; i++) {
        var obj = pageObjects[i];

        var pageObj = null;
        switch (obj.mediaType) {
            case 1:
                //mediaType = 1
                if (obj.actionType == 0) {
3068
                    pageObj = new CONTENTVIEW_CREATEOBJECT.imageNoAction(     /* no action */
Vo Duc Thang committed
3069 3070 3071 3072 3073 3074 3075 3076
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
3077 3078
                                    obj.visible,
                                    obj.objectId
Vo Duc Thang committed
3079 3080
                                );
                } else if (obj.actionType == 1) {   /* play video */
3081
                    pageObj = new CONTENTVIEW_CREATEOBJECT.videoType1(
Vo Duc Thang committed
3082 3083 3084 3085 3086 3087 3088 3089 3090 3091
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.mediaFile,
3092
                                    obj.media,
Masaru Abe committed
3093
                                    obj.mediaResourceId,
3094
                                    obj.objectId
Vo Duc Thang committed
3095
                                );
3096
                } else if (obj.actionType == 2) {
3097
                    pageObj = new CONTENTVIEW_CREATEOBJECT.audioType1(    /* play audio */
Vo Duc Thang committed
3098 3099 3100 3101 3102 3103 3104 3105 3106
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
3107
                                    obj.audioFile,
Masaru Abe committed
3108 3109
                                    obj.audio,
                                    obj.audioResourceId,
3110
                                    obj.objectId
Vo Duc Thang committed
3111
                                );
3112
                } else if (obj.actionType == 3) { /*open new url */
3113
                    pageObj = new CONTENTVIEW_CREATEOBJECT.linkURL(
Vo Duc Thang committed
3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.action,
                                    obj.linkUrl,
3125 3126
                                    obj.browserType,
                                    obj.objectId
Vo Duc Thang committed
3127
                                );
3128
                } else if (obj.actionType == 4) { /*image preview */
3129
                    pageObj = new CONTENTVIEW_CREATEOBJECT.imagePreview(
Vo Duc Thang committed
3130 3131 3132 3133 3134 3135 3136 3137 3138
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
3139
                                    obj.imagePreview,
Masaru Abe committed
3140
                                    obj.imagePreviewResourceIds,
3141
                                    obj.objectId
Vo Duc Thang committed
3142
                                );
3143
                } else if (obj.actionType == 5) {  /*jump page */
3144
                    pageObj = new CONTENTVIEW_CREATEOBJECT.jumpPage(
Vo Duc Thang committed
3145 3146 3147 3148 3149 3150 3151 3152 3153
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
3154 3155
                                    obj.jumpPage,
                                    obj.objectId
Vo Duc Thang committed
3156
                                );
3157
                } else if (obj.actionType == 6) { /*send mail */
3158

3159
                    pageObj = new CONTENTVIEW_CREATEOBJECT.sendMail(
Vo Duc Thang committed
3160 3161 3162 3163 3164 3165 3166 3167 3168 3169
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.emailSubject,
3170 3171
                                    obj.emailAddress,
                                    obj.objectId
Vo Duc Thang committed
3172
                                );
3173
                } else if (obj.actionType == 8) { /* show popup */
3174
                    pageObj = new CONTENTVIEW_CREATEOBJECT.openPopUp(
Vo Duc Thang committed
3175 3176 3177 3178 3179 3180 3181 3182 3183
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
3184 3185
                                    obj.content,
                                    obj.objectId
Vo Duc Thang committed
3186
                                );
3187
                } else if (obj.actionType == 10) { /* move to another content */
3188
                    pageObj = new CONTENTVIEW_CREATEOBJECT.moveToContent(
Vo Duc Thang committed
3189 3190 3191 3192 3193 3194 3195 3196 3197 3198
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.contentId,
3199 3200
                                    obj.pageNo,
                                    obj.objectId
Vo Duc Thang committed
3201
                                );
3202
                //Start Function : No.9 - Editor : Long - Summary :
3203
                }else if(obj.actionType == 11){
3204
                    pageObj = new CONTENTVIEW_CREATEOBJECT.htmlLinkButton(
3205 3206 3207 3208 3209 3210 3211 3212 3213
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
3214 3215
                                    obj.resourceUrl,
                                    obj.objectId
3216 3217
                                );
                }else if(obj.actionType == 12){
3218

3219
                    pageObj = new CONTENTVIEW_CREATEOBJECT.anket(
3220 3221 3222 3223 3224 3225 3226 3227 3228
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
3229 3230 3231 3232 3233 3234 3235 3236 3237 3238 3239 3240 3241 3242 3243 3244 3245 3246 3247 3248 3249
                                    obj.questionNo,
                                    obj.replyLimit,
                                    obj.fullScreen,
                                    obj.saveAs,
                                    obj.resourceId,
                                    obj.enquete,
                                    obj.objectId
                                );
                }else if(obj.actionType == 14){

                    pageObj = new CONTENTVIEW_CREATEOBJECT.exam(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.showResult,
3250
                                    obj.sendResult,
3251 3252 3253 3254 3255 3256 3257 3258 3259 3260 3261
                                    obj.replyLimit,
                                    obj.fullScreen,
                                    obj.saveAs,
                                    obj.resourceId,
                                    obj.enquete,
                                    obj.objectId
                                );
                }
                //End Function : No.9 - Editor : Long - Summary :
                else if(obj.actionType == 15){

3262
                    pageObj = new CONTENTVIEW_CREATEOBJECT.quiz(
3263 3264 3265 3266 3267 3268 3269 3270 3271 3272 3273
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.replyLimit,
                                    obj.fullScreen,
3274
                                    obj.saveAs,
Masaru Abe committed
3275 3276
                                    obj.resourceId,
                                    obj.enquete,
3277 3278 3279 3280 3281
                                    obj.objectId
                                );
                }
                break;
            case 2:
3282
                pageObj = new CONTENTVIEW_CREATEOBJECT.videoType2(
Vo Duc Thang committed
3283 3284 3285 3286 3287 3288 3289 3290 3291 3292 3293
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.mediaFile,
                                    obj.media,
3294 3295
                                    obj.embed,
                                    obj.objectId
Vo Duc Thang committed
3296
                                );
3297 3298
                break;
            case 3:
3299
                pageObj = new CONTENTVIEW_CREATEOBJECT.audioType3(
Vo Duc Thang committed
3300 3301 3302 3303 3304 3305 3306 3307 3308 3309
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.audioFile,
Masaru Abe committed
3310
                                    obj.audioResourceId,
3311 3312
                                    obj.playType,
                                    obj.objectId
Vo Duc Thang committed
3313
                                );
3314 3315 3316
                break;
            case 4:
                // mediaType = 4
3317
                CONTENTVIEW.objType4_5.push(obj);
3318
                pageObj = new CONTENTVIEW_CREATEOBJECT.listImage(
Vo Duc Thang committed
3319 3320 3321 3322 3323 3324 3325 3326 3327
                                    obj.mediaType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.dataObjects,
3328
                                    obj.triggerType,
3329 3330
                                    obj.objectId,
                                    obj.aspectType
Vo Duc Thang committed
3331
                                );
3332 3333
                break;
            case 5:
3334
                // mediaType = 5
3335
                CONTENTVIEW.objType4_5.push(obj);
3336
                pageObj = new CONTENTVIEW_CREATEOBJECT.listVideo(
Vo Duc Thang committed
3337 3338 3339 3340 3341 3342 3343 3344
                                    obj.mediaType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
3345 3346
                                    obj.dataObjects,
                                    obj.objectId
Vo Duc Thang committed
3347
                                );
3348 3349 3350
                break;
            case 6:
                // mediaType = 6
3351
                pageObj = new CONTENTVIEW_CREATEOBJECT.trigger(
Vo Duc Thang committed
3352 3353 3354 3355 3356 3357 3358 3359 3360 3361 3362
                                        obj.mediaType,
                                        obj.actionType,
                                        obj.id,
                                        obj.imageUrl,
                                        obj.x,
                                        obj.y,
                                        obj.width,
                                        obj.height,
                                        obj.index,
                                        obj.target,
                                        obj.visible,
3363 3364
                                        obj.action,
                                        obj.objectId
Vo Duc Thang committed
3365
                                    );
3366 3367 3368
                break;
            case 7:
                // mediaType = 7
3369
                pageObj = new CONTENTVIEW_CREATEOBJECT.text(
Vo Duc Thang committed
3370 3371 3372 3373 3374 3375 3376 3377 3378
                                        obj.mediaType,
                                        obj.actionType,
                                        obj.id,
                                        obj.x,
                                        obj.y,
                                        obj.width,
                                        obj.height,
                                        obj.visible,
                                        obj.action,
3379 3380
                                        obj.content,
                                        obj.objectId
Vo Duc Thang committed
3381
                                    );
3382 3383 3384
                break;
            //Start Function : No.9 - Editor : Long - Date : 08/15/2013 - Summary : 3d object
            case 8:
3385
                //mediaType = 9
3386
                //obj["_3dLastId"] = CONTENTVIEW_GETDATA.convNumTo2Char(Math.round(obj.verticalCount/2)) +"-"+ CONTENTVIEW_GETDATA.convNumTo2Char(Math.round(obj.horizonCount/2));
3387 3388 3389
                obj["_currFrameX"] = Math.round(obj.horizonCount/2);
                obj["_currFrameY"] = Math.round(obj.verticalCount/2);
                obj["_lastSelectedFrame"] = Object();
3390
                obj["arrFrame"] = CONTENTVIEW_3D.createMatrixPoints(obj.width, obj.height, obj.verticalCount,
3391
                     obj.horizonCount, Math.round(obj.horizonCount/2), Math.round(obj.verticalCount/2));
3392

3393 3394
                CONTENTVIEW_GENERAL._object3DImageArr.push(obj);
                pageObj = new CONTENTVIEW_CREATEOBJECT.object3d(
3395 3396 3397 3398 3399 3400 3401 3402 3403 3404 3405
                                        obj.mediaType,
                                        obj.actionType,
                                        obj.id,
                                        obj.initImage,
                                        obj.x,
                                        obj.y,
                                        obj.width,
                                        obj.height,
                                        obj.horizonCount,
                                        obj.verticalCount,
                                        obj.visible,
3406 3407
                                        obj['3dview'],
                                        obj.objectId
3408 3409 3410 3411 3412
                                    );
                break;
            case 9:
                //mediaType = 9
                if(obj.actionType == 11){
3413
                    pageObj = new CONTENTVIEW_CREATEOBJECT.htmlLinkButton(
3414 3415 3416 3417 3418 3419 3420 3421 3422
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
3423 3424
                                    obj.resourceUrl,
                                    obj.objectId
3425
                                );
3426 3427 3428 3429 3430
                }
                break;
            case 11:
                //mediaType = 11
                if(obj.actionType == 12){
3431

3432
                    pageObj = new CONTENTVIEW_CREATEOBJECT.anket(
3433 3434 3435 3436 3437 3438 3439 3440 3441
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
3442 3443 3444
                                    obj.questionNo,
                                    obj.replyLimit,
                                    obj.fullScreen,
3445
                                    obj.saveAs,
Masaru Abe committed
3446 3447
                                    obj.resourceId,
                                    obj.enquete,
3448
                                    obj.objectId
3449
                                );
3450 3451
                }
                break;
3452 3453 3454 3455 3456 3457 3458 3459 3460 3461 3462 3463 3464 3465 3466 3467 3468 3469 3470 3471 3472 3473 3474 3475 3476 3477 3478 3479 3480 3481 3482 3483 3484 3485 3486 3487 3488 3489 3490 3491 3492 3493 3494 3495 3496 3497 3498 3499 3500
            case 12:
                //mediaType = 12
                if(obj.actionType == 14){

                    pageObj = new CONTENTVIEW_CREATEOBJECT.exam(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.showResult,
                                    obj.sendResult,
                                    obj.replyLimit,
                                    obj.fullScreen,
                                    obj.saveAs,
                                    obj.resourceId,
                                    obj.enquete,
                                    obj.objectId
                                );
                }
            case 13:
                //mediaType = 13
                if(obj.actionType == 15){

                    pageObj = new CONTENTVIEW_CREATEOBJECT.quiz(
                                    obj.mediaType,
                                    obj.actionType,
                                    obj.id,
                                    obj.imageUrl,
                                    obj.x,
                                    obj.y,
                                    obj.width,
                                    obj.height,
                                    obj.visible,
                                    obj.replyLimit,
                                    obj.fullScreen,
                                    obj.saveAs,
                                    obj.resourceId,
                                    obj.enquete,
                                    obj.objectId
                                );
                }
                break;
            //Start Function : No.9 - Editor : Long - Date : 08/15/2013 - Summary : 3d object
            default:
3501
                // default Object
3502
                pageObj = new CONTENTVIEW_CREATEOBJECT.PageObject();
3503
                pageObj.setup(
Vo Duc Thang committed
3504 3505 3506 3507 3508 3509 3510 3511 3512
                            obj.mediaType,
                            obj.actionType,
                            obj.id,
                            obj.imageUrl,
                            obj.x,
                            obj.y,
                            obj.width,
                            obj.height,
                            obj.visible,
3513 3514 3515
                            obj.action,
                            null,
                            obj.objectId
Vo Duc Thang committed
3516
                        );
3517
        }
Masaru Abe committed
3518
        if( pageObj != null ){
3519 3520
            // add pageObject
            this.addPageObject(pageObj);
Masaru Abe committed
3521
        }
3522 3523 3524 3525
    }
};
//Start Function: No.4 - Editor : Long - Date : 08/09/2013 - Summary: Edit function to draw on multi canvas
/* drawing for current page */
3526
CONTENTVIEW.ContentPage.prototype.drawPage = function (context, opt) {
3527

3528 3529 3530 3531
    if( opt == undefined || opt == null){
        opt = 0;
    }
    //console.log("CONTENTVIEW.ContentPage.prototype.drawPage:" + opt);
3532

3533
    /*set status is loading page */
3534
    CONTENTVIEW_GENERAL.isLoadingObject = true;
3535
    /* lock all controls in page */
3536
    CONTENTVIEW_GENERAL.disableAllControl();
3537
    /* init array image */
3538
    CONTENTVIEW_GENERAL.arrImage = [];
3539
    CONTENTVIEW_GENERAL.nCountObjectLoad[opt] = 0;
3540 3541 3542 3543 3544 3545
    $('#divImageLoading').css('display', 'block');

    //var width = this.image.width;
    //var height = this.image.height;

    //START TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
3546
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
3547
        if(opt == null || opt == 0){
3548
            CONTENTVIEW_CALLAPI.getPageSizeByPageNo(CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex()));
3549
            //#11478
3550 3551 3552 3553
            //CONTENTVIEW_GENERAL.widthEachPage = CONTENTVIEW_GENERAL.widthContentImage;
            //CONTENTVIEW_GENERAL.heightEachPage = CONTENTVIEW_GENERAL.heightContentImage;
            CONTENTVIEW_GENERAL.widthEachPageApi = CONTENTVIEW_GENERAL.widthContentImage;
            CONTENTVIEW_GENERAL.heightEachPageApi = CONTENTVIEW_GENERAL.heightContentImage;
3554 3555
        }
        else if(opt == 1){
3556
            CONTENTVIEW_CALLAPI.getPageSizeByPageNo(CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex() + 1));
3557 3558
            CONTENTVIEW_GENERAL.widthEachNextPage = CONTENTVIEW_GENERAL.widthContentImage;
            CONTENTVIEW_GENERAL.heightEachNextPage = CONTENTVIEW_GENERAL.heightContentImage;
3559
            //#11478
3560
            CONTENTVIEW_GENERAL.widthEachNextPageApi = CONTENTVIEW_GENERAL.widthContentImage;
3561
            CONTENTVIEW_GENERAL.heightEachNextPageApi = CONTENTVIEW_GENERAL.heightContentImage;
3562 3563
        }
        else if(opt == 2){
3564
            CONTENTVIEW_CALLAPI.getPageSizeByPageNo(CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex() - 1));
3565 3566
            CONTENTVIEW_GENERAL.widthEachPrevPage = CONTENTVIEW_GENERAL.widthContentImage;
            CONTENTVIEW_GENERAL.heightEachPrevPage = CONTENTVIEW_GENERAL.heightContentImage;
3567
            //#11478
3568 3569
            CONTENTVIEW_GENERAL.widthEachPrevPageApi = CONTENTVIEW_GENERAL.widthContentImage;
            CONTENTVIEW_GENERAL.heightEachPrevPageApi = CONTENTVIEW_GENERAL.heightContentImage;
3570 3571 3572
        }
    }
    else{
3573
        CONTENTVIEW_GENERAL.widthEachPage = CONTENTVIEW_GENERAL.widthContentImage;
3574
        CONTENTVIEW_GENERAL.heightEachPage = CONTENTVIEW_GENERAL.heightContentImage;
3575
        //#11478
3576 3577 3578
        CONTENTVIEW_GENERAL.widthEachPageApi = CONTENTVIEW_GENERAL.widthContentImage;
        CONTENTVIEW_GENERAL.heightEachPageApi = CONTENTVIEW_GENERAL.heightContentImage;
        CONTENTVIEW_GENERAL.widthEachNextPageApi = CONTENTVIEW_GENERAL.widthContentImage;
3579
        CONTENTVIEW_GENERAL.heightEachNextPageApi = CONTENTVIEW_GENERAL.heightContentImage;
3580 3581
        CONTENTVIEW_GENERAL.widthEachPrevPageApi = CONTENTVIEW_GENERAL.widthContentImage;
        CONTENTVIEW_GENERAL.heightEachPrevPageApi = CONTENTVIEW_GENERAL.heightContentImage;
3582
    }
3583

3584
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
Masaru Abe committed
3585
        //
3586 3587 3588
    }
    else{
        if(opt == null || opt == 0){
3589 3590
            $("#offscreen").attr('height', CONTENTVIEW_GENERAL.heightEachPage);
            $("#offscreen").attr('width', CONTENTVIEW_GENERAL.widthEachPage);
3591 3592
        }
        else if(opt == 1){
3593 3594
            $("#offscreenNext").attr('height', CONTENTVIEW_GENERAL.heightEachPage);
            $("#offscreenNext").attr('width', CONTENTVIEW_GENERAL.widthEachPage);
3595 3596
        }
        else if(opt == 2){
3597 3598
            $("#offscreenPre").attr('height', CONTENTVIEW_GENERAL.heightEachPage);
            $("#offscreenPre").attr('width', CONTENTVIEW_GENERAL.widthEachPage);
3599 3600
        }
    }
3601

3602
    //END TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
3603

3604 3605 3606 3607
    var objPageTemp = this.pageObjects;
    var img = new Image();
    img.onload = function () {
        //START TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
3608
        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
3609
            if(opt == null || opt == 0){
3610
                //#11478
3611
                CONTENTVIEW_GENERAL.heightEachPage = img.naturalHeight;
3612 3613 3614
                CONTENTVIEW_GENERAL.widthEachPage = img.naturalWidth;
                $("#offscreen").attr('height', CONTENTVIEW_GENERAL.heightEachPage);
                $("#offscreen").attr('width', CONTENTVIEW_GENERAL.widthEachPage);
3615

3616
                context.drawImage(img, 0, 0, CONTENTVIEW_GENERAL.widthEachPage, CONTENTVIEW_GENERAL.heightEachPage);
3617 3618
            }
            else if(opt == 1){
3619
                //#11478
3620
                CONTENTVIEW_GENERAL.heightEachNextPage = img.naturalHeight;
3621 3622 3623
                CONTENTVIEW_GENERAL.widthEachNextPage = img.naturalWidth;
                $("#offscreenNext").attr('height', CONTENTVIEW_GENERAL.heightEachNextPage);
                $("#offscreenNext").attr('width', CONTENTVIEW_GENERAL.widthEachNextPage);
3624

3625
                context.drawImage(img, 0, 0, CONTENTVIEW_GENERAL.widthEachNextPage, CONTENTVIEW_GENERAL.heightEachNextPage);
3626 3627
            }
            else if(opt == 2){
3628
                //#11478
3629
                CONTENTVIEW_GENERAL.heightEachPrevPage = img.naturalHeight;
3630 3631 3632
                CONTENTVIEW_GENERAL.widthEachPrevPage = img.naturalWidth;
                $("#offscreenPre").attr('height', CONTENTVIEW_GENERAL.heightEachPrevPage);
                $("#offscreenPre").attr('width', CONTENTVIEW_GENERAL.widthEachPrevPage);
3633

3634
                context.drawImage(img, 0, 0, CONTENTVIEW_GENERAL.widthEachPrevPage, CONTENTVIEW_GENERAL.heightEachPrevPage);
3635
            }
3636 3637
        }
        else{
3638
            context.drawImage(img, 0, 0, CONTENTVIEW_GENERAL.widthEachPage, CONTENTVIEW_GENERAL.heightEachPage);
3639
        }
3640

3641
        //END TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
3642

3643
        CONTENTVIEW.flip(opt);
3644
        //Start Function: No.12
3645
        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
3646
            /* draw linkList */
3647
            CONTENTVIEW.drawGetWebContent4(context, opt);
3648
        }
3649
        //Start Function: No.12
3650

3651 3652 3653 3654 3655
        if (objPageTemp.length > 0) {
            // draw object
            for (var i = 0; i < objPageTemp.length; i++) {
                if (objPageTemp[i].imageUrl != null) {
                    objPageTemp[i].drawPageObject(context, opt);
3656
                }
3657
                else {
3658
                    CONTENTVIEW_GENERAL.nCountObjectLoad[opt]++;
3659

3660
                    if (CONTENTVIEW_GENERAL.nCountObjectLoad[opt] == objPageTemp.length) {
3661
                        /* draw marking */
3662
                        CONTENTVIEW.drawMarkingOnScreen(opt);
3663 3664

                        /*set status is loading page */
3665 3666
                       if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                            if(CONTENTVIEW_GENERAL.totalPage > 1){
3667
                                if(opt != 0 && opt != null){
3668
                                    CONTENTVIEW_GENERAL.isLoadingObject = false;
3669 3670 3671
                                }
                            }
                            else{
3672
                                CONTENTVIEW_GENERAL.isLoadingObject = false;
3673
                            }
3674 3675
                       }
                       else{
3676
                           CONTENTVIEW_GENERAL.isLoadingObject = false;
3677
                       }
3678

3679 3680
                        /* enable controls in page */
                        if (ClientData.IsAddingMarking() == true) {
3681 3682
                            CONTENTVIEW_GENERAL.disableAllControl();
                            CONTENTVIEW_MARKING.enableButtonMarking();
3683 3684
                        } else {
                            //Start Function : No.4 - Summary : make sure next or prev page is loaded
3685 3686
                            if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                                if(CONTENTVIEW_GENERAL.totalPage > 1){
3687
                                    if(opt != 0 && opt != null){
3688
                                        CONTENTVIEW_GENERAL.enableAllControl();
3689 3690 3691
                                    }
                                }
                                else{
3692
                                    CONTENTVIEW_GENERAL.enableAllControl();
3693
                                }
3694 3695
                            }
                            else{
3696
                                CONTENTVIEW_GENERAL.enableAllControl();
3697 3698
                            }
                            //End Function : No.4 - Summary : make sure next or prev page is loaded
3699 3700 3701
                        }
                        /*finish loading */
                       //Start Function : No.4 - Summary : make sure next or prev page is loaded
3702 3703
                        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                            if(CONTENTVIEW_GENERAL.totalPage > 1){
3704 3705
                                if(opt != 0 && opt != null){
                                   $('#divImageLoading').css('display', 'none');
3706
                                }
3707 3708 3709
                            }
                            else{
                                $('#divImageLoading').css('display', 'none');
3710
                            }
3711 3712 3713 3714
                        }
                        else{
                            $('#divImageLoading').css('display', 'none');
                        }
3715
                        //End Function : No.4 - Summary : make sure next or prev page is loaded
3716
                        /* set pos video */
3717
                        CONTENTVIEW.zoomVideo();
3718 3719 3720 3721
                    }

                }
            }
3722
        }
3723 3724
        else {
            /* draw marking */
3725
            CONTENTVIEW.drawMarkingOnScreen(opt);
3726 3727

            /*set status is loading page */
3728 3729
            if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                if(CONTENTVIEW_GENERAL.totalPage > 1){
3730
                   if(opt != 0 && opt != null){
3731
                       CONTENTVIEW_GENERAL.isLoadingObject = false;
3732
                   }
3733 3734
                }
                else{
3735
                    CONTENTVIEW_GENERAL.isLoadingObject = false;
3736
                }
3737 3738
            }
            else{
3739
                CONTENTVIEW_GENERAL.isLoadingObject = false;
3740 3741 3742
            }
            /* enable controls in page */
            if (ClientData.IsAddingMarking() == true) {
3743
            	CONTENTVIEW_GENERAL.disableAllControl();
3744
            	CONTENTVIEW_MARKING.enableButtonMarking();
3745
            }
3746
            else {
3747
                //Start Function : No.4 - Summary : make sure next or prev page is loaded
3748 3749
                if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                    if(CONTENTVIEW_GENERAL.totalPage > 1){
3750
                        if(opt != 0 && opt != null){
3751
                            CONTENTVIEW_GENERAL.enableAllControl();
3752 3753 3754
                        }
                    }
                    else{
3755
                        CONTENTVIEW_GENERAL.enableAllControl();
3756
                    }
3757 3758
                }
                else{
3759
                    CONTENTVIEW_GENERAL.enableAllControl();
3760 3761 3762 3763 3764 3765 3766
                }
                //End Function : No.4 - Summary : make sure next or prev page is loaded
            }

            /*finish loading */
            //Start Function : No.4 - Summary : make sure next or prev page is loaded

3767 3768
            if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
                if(CONTENTVIEW_GENERAL.totalPage > 1){
3769 3770
                    if(opt != 0 && opt != null){
                        $('#divImageLoading').css('display', 'none');
3771
                    }
3772 3773 3774
                }
                else{
                    $('#divImageLoading').css('display', 'none');
3775
                }
3776 3777 3778 3779
            }
            else{
                 $('#divImageLoading').css('display', 'none');
            }
3780
            //End Function : No.4 - Summary : make sure next or prev page is loaded
3781 3782

            /* set pos video */
3783
            CONTENTVIEW.zoomVideo();
3784
        }
3785

3786 3787 3788 3789 3790 3791 3792
    };
    img.src = this.image.src;
};
//End Function: No.4 - Editor : Long - Date : 08/09/2013 - Summary: Edit function to draw on multi canvas


/* If have hitTest on the objects within the page and return PageObject */
3793
CONTENTVIEW.ContentPage.prototype.hitTest = function (px, py) {
3794 3795 3796
    //#16549 WebViewerで、差し替え画像の上に置いたボタンの動きが正しくない
    //for (var i = 0; i < this.pageObjects.length; i++) {
    for (var i = this.pageObjects.length - 1; i > -1; i--) {
3797 3798 3799 3800 3801 3802 3803 3804
        if (this.pageObjects[i].hitTest(px, py)) {
            return this.pageObjects[i];
        }
    }
    return null;
};

/* search by Object ID */
3805
CONTENTVIEW.ContentPage.prototype.findById = function (id) {
3806 3807 3808 3809 3810 3811 3812 3813 3814 3815
    for (var i = 0; i < this.pageObjects.length; i++) {
        if (this.pageObjects[i].id == id) {
            return this.pageObjects[i];
        }
    }
    return null;
};


/* check status button move page when change page */
3816
CONTENTVIEW.checkExistNextPrePage = function() {
3817
    //check next page
3818
    if (CONTENTVIEW_GETDATA.getContent().hasNextPage()) {
3819
        //$('#nextpage').show();
Masaru Abe committed
3820
        //COMMON.enable('#nextpage');
3821
        $('#nextpage').unbind('click');
3822
        $('#nextpage').bind('click', CONTENTVIEW_EVENTS.nextPage_click);
3823 3824

        $('#lastpage').unbind('click');
3825
        $('#lastpage').bind('click', CONTENTVIEW_EVENTS.lastPage_click);
3826

Masaru Abe committed
3827
        if (COMMON.isTouchDevice() == true) {
3828 3829 3830 3831 3832 3833 3834 3835 3836 3837 3838 3839 3840 3841
            $('#nextpage').removeClass();
            $('#nextpage').addClass('next_device');

            $('#lastpage').removeClass();
            $('#lastpage').addClass('last_device');
        } else {
            $('#nextpage').removeClass();
            $('#nextpage').addClass('next');

            $('#lastpage').removeClass();
            $('#lastpage').addClass('last');
        }
    } else {
        //$('#nextpage').hide();
Masaru Abe committed
3842
        //COMMON.disable('#nextpage');
3843 3844 3845
        $('#nextpage').unbind('click');
        $('#lastpage').unbind('click');

Masaru Abe committed
3846
        if (COMMON.isTouchDevice() == true) {
3847 3848 3849 3850 3851 3852 3853 3854 3855 3856 3857 3858 3859 3860 3861 3862
            $('#nextpage').removeClass();
            $('#nextpage').addClass('next_off');

            $('#lastpage').removeClass();
            $('#lastpage').addClass('last_off');
        } else {
            $('#nextpage').removeClass();
            $('#nextpage').addClass('next_off');

            $('#lastpage').removeClass();
            $('#lastpage').addClass('last_off');
        }
        $('#button_next_canvas').css('opacity', '0');
    }

    //check prev page
3863
    if (CONTENTVIEW_GETDATA.getContent().hasPreviousPage()) {
3864
        //$('#prevpage').show();
Masaru Abe committed
3865
        //COMMON.enable('#prevpage');
3866
        $('#prevpage').unbind('click');
3867
        $('#prevpage').bind('click', CONTENTVIEW_EVENTS.prevPage_click);
3868 3869

        $('#firstpage').unbind('click');
3870
        $('#firstpage').bind('click', CONTENTVIEW_EVENTS.firstPage_click);
3871

Masaru Abe committed
3872
        if (COMMON.isTouchDevice() == true) {
3873 3874 3875 3876 3877 3878 3879 3880 3881 3882 3883 3884 3885 3886
            $('#prevpage').removeClass();
            $('#prevpage').addClass('prev_device');

            $('#firstpage').removeClass();
            $('#firstpage').addClass('begin_device');
        } else {
            $('#prevpage').removeClass();
            $('#prevpage').addClass('prev');

            $('#firstpage').removeClass();
            $('#firstpage').addClass('begin');
        }
    } else {
        //$('#prevpage').hide();
Masaru Abe committed
3887
        //COMMON.disable('#prevpage');
3888 3889 3890
        $('#prevpage').unbind('click');
        $('#firstpage').unbind('click');

Masaru Abe committed
3891
        if (COMMON.isTouchDevice() == true) {
3892 3893 3894 3895 3896 3897 3898 3899 3900 3901 3902 3903 3904 3905 3906
            $('#prevpage').removeClass();
            $('#prevpage').addClass('prev_off');

            $('#firstpage').removeClass();
            $('#firstpage').addClass('begin_off');
        } else {
            $('#prevpage').removeClass();
            $('#prevpage').addClass('prev_off');

            $('#firstpage').removeClass();
            $('#firstpage').addClass('begin_off');
        }
        $('#button_pre_canvas').css('opacity', '0');

    }
3907

3908 3909 3910 3911
};


/* Point objects */
3912
CONTENTVIEW.Point = function (x, y) {
3913 3914 3915 3916 3917 3918
    this.x = x;
    this.y = y;
};


/* remove all object when change page */
3919
CONTENTVIEW.removeObject = function() {
3920 3921 3922
    $('#text').children().remove();

    /* close dialog */
3923
    if (CONTENTVIEW_GENERAL.isOpenPopUpText == true) {
3924 3925
        CONTENTVIEW_GENERAL.isOpenPopUpText = false;
        CONTENTVIEW_POPUPTEXT.ClosePopupText();
3926 3927 3928
    }

    $("#bgmConfirm").hide();
Masaru Abe committed
3929
    $("#bgmConfirm_page").hide();
3930 3931 3932 3933 3934
    $("#boxCopyText").hide();
    $("#boxSearching").hide();
    $("#boxIndex").hide();
    $("#boxBookMark").hide();
    $('#pop_up_memo').hide();
3935
    CONTENTVIEW_GENERAL.isSendingData = false;
3936

3937 3938 3939
    CONTENTVIEW_GENERAL.isDisplayBookMarkList = false;
    CONTENTVIEW_GENERAL.isDisplayCopyText = false;
    CONTENTVIEW_GENERAL.isDisplayListIndex = false;
3940 3941 3942 3943 3944 3945 3946 3947 3948

    if ($('#playvideo').children().length > 0) {
        $('#playvideo').children().remove();
    }

    if ($('#playaudio').children().length > 0) {
        $('#playaudio').children().remove();
    }
    if ($('#playaudiopage').children().length > 0) {
Masaru Abe committed
3949
        if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false) {
3950 3951 3952 3953
            $('#playaudiopage').children().remove();
        }
    }

3954
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
3955 3956 3957 3958
        CONTENTVIEW.srcAudioType0 = '';
        CONTENTVIEW.TypeAudio0 = '';
        CONTENTVIEW.srcAudioType2 = '';
        CONTENTVIEW.TypeAudio2 = '';
3959 3960 3961 3962 3963 3964
    } else {
        /* do nothing */
    }


    //Start Function : No.12 - Editor :Long - Date: 08/12/2013 - Summary : prevent close dialog if content is not pdf
3965
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
3966
        CONTENTVIEW_GENERAL.hideDialog();
3967 3968 3969 3970
    }
    //End Function : No.12 - Editor :Long - Date: 08/12/2013 - Summary : prevent close dialog if content is not pdf

    /* play background audio */
3971
    CONTENTVIEW.playAllAudio();
3972 3973

    /* mediaType = 4 */
3974
    CONTENTVIEW_GENERAL.mediaType4_changeImage = [];
3975 3976 3977
};

/* View Component setDefaultEvent */
3978
CONTENTVIEW.setDefaultEvent = function() {
3979

3980
    CONTENTVIEW_GENERAL._bTouchDeviceEnabled = COMMON.isTouchDevice();
3981

3982 3983 3984
    var canvasPre = document.getElementById('mainPre');
    var canvasNext = document.getElementById('mainNext');
    //mouse event
3985
    // add event for wrap
3986 3987 3988 3989 3990 3991 3992 3993 3994 3995 3996

    //remove wrapper event
    canvasPre.removeEventListener('mousedown',function(){},false);
    canvasPre.removeEventListener('mousemove',function(){},false);
    canvasPre.removeEventListener('mouseup',function(){},false);
    canvasPre.removeEventListener('mouseout',function(){},false);

    canvasNext.removeEventListener('mousedown',function(){},false);
    canvasNext.removeEventListener('mousemove',function(){},false);
    canvasNext.removeEventListener('mouseup',function(){},false);
    canvasNext.removeEventListener('mouseout',function(){},false);
3997

3998
    document.getElementById('main').addEventListener('click', CONTENTVIEW_EVENTS.onClick_CanvasMain, false);
Masaru Abe committed
3999
    if ($('#divCheckExistMarking').length) {
4000
        document.getElementById('divCheckExistMarking').addEventListener('click', CONTENTVIEW_EVENTS.onClick_CanvasMain, false);
Masaru Abe committed
4001
    }
4002
    if ($('#divCheckExistMemo').length) {
4003
        document.getElementById('divCheckExistMemo').addEventListener('click', CONTENTVIEW_EVENTS.onClick_CanvasMain, false);
4004
    }
Masaru Abe committed
4005
    if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false && CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false){
4006

4007 4008
        document.getElementById('main').addEventListener('mousedown', CONTENTVIEW_EVENTS.mouseDown_CanvasMain, false);
        document.getElementById('main').addEventListener('mousemove', CONTENTVIEW_EVENTS.mouseMove_CanvasMain, false);
4009 4010
        document.getElementById('main').addEventListener('mouseup', CONTENTVIEW_EVENTS.mouseUp_CanvasMain, false);

4011 4012 4013
        //#12408 ホイール対応
        // MouseScrollEvent に対応している(FireFox 専用)
        if(window.MouseScrollEvent){
4014
            //console.log("addEventListener DOMMouseScroll");
4015
            document.getElementById('main').addEventListener('DOMMouseScroll', function(event){
4016
                CONTENTVIEW_EVENTS.mouseWheel_CanvasMain(event, event.detail);
4017 4018 4019
            }, false);
        // FireFox 以外の主要ブラウザの場合
        }else{
4020
            //console.log("addEventListener mousewheel");
4021
            var mousewheelevent = 'onwheel' in document ? 'wheel' : 'onmousewheel' in document ? 'mousewheel' : 'DOMMouseScroll';
Masaru Abe committed
4022
            document.getElementById('main').addEventListener(mousewheelevent, function(e){
4023
                CONTENTVIEW_EVENTS.mouseWheel_CanvasMain(event, -(e.wheelDelta / 40));
Masaru Abe committed
4024
            }, false);
4025
        }
4026

4027
        if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'msie') {
4028 4029 4030 4031 4032
            //IEかつタッチ対応のデバイスか判定追加
            if(navigator.msMaxTouchPoints && navigator.msMaxTouchPoints > 1) {
                //console.log("navigator.msMaxTouchPoints:" + navigator.msMaxTouchPoints)
                CONTENTVIEW_GENERAL._bWin8TouchEnabled = window.navigator.msPointerEnabled;
            }
4033
        } else {
4034 4035 4036 4037
            if( CONTENTVIEW_GENERAL._bTouchDeviceEnabled ){
                document.getElementById('main').addEventListener('touchstart', CONTENTVIEW_EVENTS.onTouchstart, false);
                document.getElementById('main').addEventListener('touchmove', CONTENTVIEW_EVENTS.onTouchmove, false);
                document.getElementById('main').addEventListener('touchend', CONTENTVIEW_EVENTS.onTouchend, false);
4038
                //iPad&Andの実装から
Masaru Abe committed
4039
                document.getElementById('canvasWrapper').addEventListener('touchstart', function(event){event.preventDefault();}, false);
4040
                document.getElementById('canvasWrapper').addEventListener('touchmove', function(event){event.preventDefault();}, false);
4041
                document.getElementById('canvasWrapper').addEventListener('touchend', function(event){event.preventDefault();}, false);
Masaru Abe committed
4042
                document.getElementById('overlay').addEventListener('touchstart', function(event){event.preventDefault(); return false;}, false);
4043
                document.getElementById('overlay').addEventListener('touchmove', function(event){event.preventDefault(); return false;}, false);
4044
                document.getElementById('overlay').addEventListener('touchend', function(event){event.preventDefault(); return false;}, false);
4045 4046 4047
                //デフォルトのD&Dが効いてしまう問題回避
                document.getElementById('button_next_canvas').addEventListener('touchstart', function(event){event.preventDefault();}, false);
                document.getElementById('button_next_canvas').addEventListener('touchmove', function(event){event.preventDefault();}, false);
4048
                document.getElementById('button_next_canvas').addEventListener('touchend', function(event){event.preventDefault();}, false);
4049 4050
                document.getElementById('button_pre_canvas').addEventListener('touchstart', function(event){event.preventDefault();}, false);
                document.getElementById('button_pre_canvas').addEventListener('touchmove', function(event){event.preventDefault();}, false);
4051 4052
                document.getElementById('button_pre_canvas').addEventListener('touchend', function(event){event.preventDefault();}, false);

4053
            }
4054
        }
4055

4056 4057 4058 4059
        if(CONTENTVIEW_GENERAL._bWin8TouchEnabled){
            document.getElementById('main').addEventListener('MSPointerDown', CONTENTVIEW_EVENTS.onTouchstart, false);
            document.getElementById('main').addEventListener('MSPointerMove', CONTENTVIEW_EVENTS.onTouchmove, false);
            document.getElementById('main').addEventListener('MSPointerUp', CONTENTVIEW_EVENTS.onTouchend, false);
4060 4061
        }
    }
Masaru Abe committed
4062
    else if(CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() || CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid()){
4063
        document.getElementById('main').removeEventListener('click', function(){}, false);
4064 4065 4066
        document.getElementById('main').addEventListener('touchstart', CONTENTVIEW_EVENTS.onTouchstart, false);
        document.getElementById('main').addEventListener('touchmove', CONTENTVIEW_EVENTS.onTouchmove, false);
        document.getElementById('main').addEventListener('touchend', CONTENTVIEW_EVENTS.onTouchend, false);
4067 4068
        document.getElementById('canvasWrapper').addEventListener('touchstart', function(event){event.preventDefault();}, false);
        document.getElementById('canvasWrapper').addEventListener('touchmove', function(event){event.preventDefault();}, false);
4069
        document.getElementById('canvasWrapper').addEventListener('touchend', function(event){event.preventDefault();}, false);
4070 4071
        document.getElementById('overlay').addEventListener('touchstart', function(event){event.preventDefault(); return false;}, false);
        document.getElementById('overlay').addEventListener('touchmove', function(event){event.preventDefault(); return false;}, false);
4072 4073
        document.getElementById('overlay').addEventListener('touchend', function(event){event.preventDefault(); return false;}, false);

Masaru Abe committed
4074 4075 4076
        //document.getElementById('contentVideoConfirm').addEventListener('click', function(event){event.preventDefault(); return false;}, false);
        //document.getElementById('contentVideoConfirm').addEventListener('touchstart', function(event){event.preventDefault(); return false;}, false);
        //document.getElementById('contentVideoConfirm').addEventListener('touchmove', function(event){event.preventDefault(); return false;}, false);
4077 4078
        //document.getElementById('contentVideoConfirm').addEventListener('touchend', function(event){event.preventDefault(); return false;}, false);

4079
    }
4080

4081
    $('#main').mouseout(function (event) {
4082
        if (CONTENTVIEW.moveFlag) {
4083
            CONTENTVIEW.moveFlag = false;
4084 4085 4086 4087 4088
        }

        $('#button_pre_canvas').css('opacity', '0');
        $('#button_next_canvas').css('opacity', '0');
    });
4089

4090 4091 4092 4093 4094 4095 4096
    //オーサリングプレビュー対応
    if(COMMON.isAuthoringPreview() && CONTENTVIEW_GENERAL.pid != ''){
        $('#close_screen').click(function(){
            window.open('', '_self', '');
            window.close();
        });
    }
4097

4098 4099 4100
};

/*disable all control when click copy memo */
4101
CONTENTVIEW.disableControlsCopyMemo = function() {
4102 4103 4104 4105 4106 4107 4108 4109 4110 4111 4112
    /* set cursor pointer*/
    $("#imgHome").css('cursor', 'default');
    $("#imgBack").css('cursor', 'default');
    $("#listbookmark").css('cursor', 'default');
    $("#imgbookmark").css('cursor', 'default');
    $("#listindex").css('cursor', 'default');
    $("#copytext").css('cursor', 'default');
    $("#imgmemo").css('cursor', 'default');
    $("#imgaddmemo").css('cursor', 'default');
    $("#imgmarking").css('cursor', 'default');
    $("#imgmarkingtoolbar").css('cursor', 'default');
4113 4114
    $("#rotateR").css('cursor', 'default');
    $("#rotateL").css('cursor', 'default');
4115 4116 4117 4118 4119 4120 4121 4122 4123 4124 4125 4126 4127 4128 4129 4130 4131 4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 4143 4144 4145 4146 4147 4148 4149 4150 4151 4152 4153 4154 4155 4156 4157 4158 4159 4160 4161 4162 4163 4164 4165 4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177
    $("#firstpage").css('cursor', 'default');
    $("#prevpage").css('cursor', 'default');
    $("#nextpage").css('cursor', 'default');
    $("#lastpage").css('cursor', 'default');

    $('#imgHome').unbind('click');
    $('#imgHome').removeClass();
    $('#imgHome').addClass('home_off');

    /* back button */
    $('#imgBack').unbind('click');
    $('#imgBack').removeClass();
    $('#imgBack').addClass('back_off');

    /*list bookmark */
    $('#listbookmark').unbind('click');
    $('#listbookmark').removeClass();
    $('#listbookmark').addClass('bmList_off');

    $('#imgbookmark').unbind('click');
    $('#imgbookmark').removeClass();
    $('#imgbookmark').addClass('bmAdd_off');

    $('#listindex').unbind('click');
    $('#listindex').removeClass();
    $('#listindex').addClass('index_off');

    $('#copytext').unbind('click');
    $('#copytext').removeClass();
    $('#copytext').addClass('copy_off');

    /* imgage display memo */
    $('#imgmemo').unbind('click');
    $('#imgmemo').removeClass();
    $('#imgmemo').addClass('memoDisplay_off');

    /* image add memo */
    $('#imgaddmemo').unbind('click');
    $('#imgaddmemo').removeClass();
    $('#imgaddmemo').addClass('memoAdd_off');

    $('#imgmarking').unbind('click');
    $('#imgmarking').removeClass();
    $('#imgmarking').addClass('marking_off');

    /* check is loading page */
    $('#imgmarkingtoolbar').unbind('click');
    $('#imgmarkingtoolbar').removeClass();
    $('#imgmarkingtoolbar').addClass('markingToolbar_off');

    $('#firstpage').unbind('click');
    $('#firstpage').removeClass();
    $('#firstpage').addClass('begin_off');
    $('#prevpage').unbind('click');
    $('#prevpage').removeClass();
    $('#prevpage').addClass('prev_off');
    $('#nextpage').unbind('click');
    $('#nextpage').removeClass();
    $('#nextpage').addClass('next_off');
    $('#lastpage').unbind('click');
    $('#lastpage').removeClass();
    $('#lastpage').addClass('last_off');

Masaru Abe committed
4178
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false) {
4179 4180
        $("#slider_page").slider("option", "disabled", true);
    }
Masaru Abe committed
4181
    COMMON.disable('#txtSearch', '#txtSlider');
4182 4183 4184 4185 4186 4187

    $('#button_next_canvas').css('display', 'none');
    $('#button_pre_canvas').css('display', 'none');
};

/*enable all control when finish copy memo */
4188
CONTENTVIEW.enableControlsCopyMemo = function() {
4189
    CONTENTVIEW.disableControlsCopyMemo();
4190 4191 4192 4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204 4205 4206 4207 4208 4209

    /* set cursor pointer*/
    $("#imgHome").css('cursor', 'pointer');
    $("#imgBack").css('cursor', 'pointer');
    $("#listbookmark").css('cursor', 'pointer');
    $("#imgbookmark").css('cursor', 'pointer');
    $("#listindex").css('cursor', 'pointer');
    $("#copytext").css('cursor', 'pointer');
    $("#imgmemo").css('cursor', 'pointer');
    $("#imgaddmemo").css('cursor', 'pointer');
    $("#imgmarking").css('cursor', 'pointer');
    $("#imgmarkingtoolbar").css('cursor', 'pointer');
    $("#firstpage").css('cursor', 'pointer');
    $("#prevpage").css('cursor', 'pointer');
    $("#nextpage").css('cursor', 'pointer');
    $("#lastpage").css('cursor', 'pointer');

    $("#control_screen").removeClass();
    $("#control_screen_2").removeClass();

4210
    $('#imgHome').bind('click', CONTENTVIEW_EVENTS.imgHome_click);
4211 4212
    $('#imgHome').removeClass();

4213
    $('#imgBack').bind('click', CONTENTVIEW_EVENTS.imgBack_click);
4214 4215 4216
    $('#imgBack').removeClass();

    /*list bookmark */
4217
    $('#listbookmark').bind('click', CONTENTVIEW_EVENTS.showListBookMark);
4218 4219
    $('#listbookmark').removeClass();

4220
    $('#imgbookmark').bind('click', CONTENTVIEW.bookmarkPage);
4221 4222
    $('#imgbookmark').removeClass();

4223
    //Start Function : No.12 - Editor : Long - Date : 08/28/2013 - Summary :
4224 4225
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
        $('#listindex').bind('click', CONTENTVIEW_EVENTS.showListPageIndex);
4226
        $('#listindex').removeClass();
4227
        if(ClientData.serviceOpt_copy_text() == 'Y') {
4228
            $('#copytext').bind('click', CONTENTVIEW_EVENTS.showCopyText);
4229 4230
            $('#copytext').removeClass();
        } else {
4231 4232
            $('#copytext').unbind('click');
            $('#copytext').removeClass();
4233 4234 4235
            $('#copytext').addClass('copy_off');
        }
        //sessionStorage.removeItem('copy_text');
4236
    }
4237 4238
    //Start Function : No.12 - Editor : Long - Date : 08/28/2013 - Summary :

4239
    /* image memo */
4240
    $('#imgmemo').bind('click', CONTENTVIEW.handleMemo);
4241 4242 4243
    $('#imgmemo').removeClass();

    /* image add memo */
4244
    $('#imgaddmemo').bind('click', CONTENTVIEW_EVENTS.handleAddMemo);
4245 4246
    $('#imgaddmemo').removeClass();

4247
    $('#imgmarking').bind('click', CONTENTVIEW_EVENTS.imgmarking_click);
4248 4249 4250
    $('#imgmarking').removeClass();

    if (ClientData.serviceOpt_marking() == 'Y') {
4251
        $('#imgmarkingtoolbar').bind('click', CONTENTVIEW.handleDrawCanvas);
4252 4253
        $('#imgmarkingtoolbar').removeClass();
    }
4254

4255
    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PDF){
4256
        $("#slider_page").slider("option", "disabled", false);
Masaru Abe committed
4257
        COMMON.enable('#txtSearch', '#txtSlider');
4258
    }
4259
    else if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_NoFile){
4260
        $("#slider_page").slider("option", "disabled", false);
Masaru Abe committed
4261
        COMMON.enable('#txtSlider');
4262 4263 4264
    }


Masaru Abe committed
4265
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos() == false && CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false) {
4266 4267 4268 4269
        $('#button_next_canvas').css('display', 'block');
        $('#button_pre_canvas').css('display', 'block');
    }

Masaru Abe committed
4270
    if (COMMON.isTouchDevice() == true) {/* set css for device */
4271 4272 4273 4274 4275 4276 4277 4278 4279
        $('#imgHome').addClass('home_device');
        $('#imgBack').addClass('back_device');
        /*$('#firstpage').addClass('begin_device');
        $('#prevpage').addClass('prev_device');
        $('#nextpage').addClass('next_device');
        $('#lastpage').addClass('last_device');*/
        $("#control_screen").addClass('toolbar_device');
        //$("#control_screen_2").addClass('toolbar_device');
        $("#control_screen_2").addClass('toolbar_close_device');
4280

4281
        var nBookmarkId = CONTENTVIEW.isExistBookmark();
4282 4283 4284 4285 4286 4287
        if (nBookmarkId == -1) {
            $('#imgbookmark').addClass('bmAdd_device');
        } else {
            $('#imgbookmark').addClass('bmAdd_hover');
        }

4288
        if (CONTENTVIEW_GENERAL.isDisplayBookMarkList == true) {
4289 4290 4291 4292 4293
            $('#listbookmark').addClass('bmList_hover');
        } else {
            $('#listbookmark').addClass('bmList_device');
        }

4294
        if (CONTENTVIEW_GENERAL.isDisplayCopyText == true) {
4295 4296 4297 4298 4299
            $('#copytext').addClass('copy_hover');
        } else {
            $('#copytext').addClass('copy_device');
        }

4300
        if (CONTENTVIEW_GENERAL.isDisplayListIndex == true) {
4301 4302 4303 4304 4305 4306 4307 4308 4309 4310 4311 4312 4313 4314 4315 4316 4317 4318 4319 4320 4321 4322 4323 4324 4325 4326 4327 4328 4329 4330 4331 4332 4333 4334 4335 4336 4337 4338 4339
            $('#listindex').addClass('index_hover');
        } else {
            $('#listindex').addClass('index_device');
        }

        if (ClientData.IsDisplayMemo() == true) {
            $('#imgmemo').addClass('memoDisplay_hover');
        } else {
            $('#imgmemo').addClass('memoDisplay_device');
        }

        if (ClientData.IsAddingMemo() == true) {
            $('#imgaddmemo').addClass('memoAdd_hover');
        } else {
            $('#imgaddmemo').addClass('memoAdd_device');
        }

        if (ClientData.IsDisplayMarking() == true) {
            $('#imgmarking').addClass('marking_hover');
        } else {
            $('#imgmarking').addClass('marking_device');
        }
        if (ClientData.serviceOpt_marking() == 'Y') {
            if (ClientData.IsAddingMarking() == true) {
                $('#imgmarkingtoolbar').addClass('markingToolbar_hover');
            } else {
                $('#imgmarkingtoolbar').addClass('markingToolbar_device');
            }
        }
    } else { /* set css for PC */
        $('#imgHome').addClass('home');
        $('#imgBack').addClass('back');
        /*$('#firstpage').addClass('begin');
        $('#prevpage').addClass('prev');
        $('#nextpage').addClass('next');
        $('#lastpage').addClass('last');*/
        $("#control_screen").addClass('toolbar');
        $("#control_screen_2").addClass('toolbar_close');

4340
        var nBookmarkId = CONTENTVIEW.isExistBookmark();
4341 4342 4343 4344 4345 4346
        if (nBookmarkId == -1) {
            $('#imgbookmark').addClass('bmAdd');
        } else {
            $('#imgbookmark').addClass('bmAdd_hover');
        }

4347
        if (CONTENTVIEW_GENERAL.isDisplayBookMarkList == true) {
4348 4349 4350 4351 4352
            $('#listbookmark').addClass('bmList_hover');
        } else {
            $('#listbookmark').addClass('bmList');
        }

4353
        if (CONTENTVIEW_GENERAL.isDisplayCopyText == true) {
4354 4355 4356 4357 4358
            $('#copytext').addClass('copy_hover');
        } else {
            $('#copytext').addClass('copy');
        }

4359
        if (CONTENTVIEW_GENERAL.isDisplayListIndex == true) {
4360 4361 4362 4363 4364 4365 4366 4367 4368 4369 4370 4371 4372 4373 4374 4375 4376 4377 4378 4379 4380 4381 4382 4383 4384 4385 4386 4387 4388 4389
            $('#listindex').addClass('index_hover');
        } else {
            $('#listindex').addClass('index');
        }

        if (ClientData.IsDisplayMemo() == true) {
            $('#imgmemo').addClass('memoDisplay_hover');
        } else {
            $('#imgmemo').addClass('memoDisplay');
        }

        if (ClientData.IsAddingMemo() == true) {
            $('#imgaddmemo').addClass('memoAdd_hover');
        } else {
            $('#imgaddmemo').addClass('memoAdd');
        }

        if (ClientData.IsDisplayMarking() == true) {
            $('#imgmarking').addClass('marking_hover');
        } else {
            $('#imgmarking').addClass('marking');
        }
        if (ClientData.serviceOpt_marking() == 'Y') {
            if (ClientData.IsAddingMarking() == true) {
                $('#imgmarkingtoolbar').addClass('markingToolbar_hover');
            } else {
                $('#imgmarkingtoolbar').addClass('markingToolbar');
            }
        }
    }
4390
    CONTENTVIEW.checkExistNextPrePage();
4391 4392 4393
};

/* Change Coordinate Screen to Image */
4394
CONTENTVIEW.screenToImage = function(x, y) {
4395

4396
    var pt = new CONTENTVIEW.Point(0, 0);
4397

4398
    // get current position of mouse on screen
4399 4400
    if (CONTENTVIEW_GENERAL.isFullScreen == true) {
        pt.x = x - CONTENTVIEW.marginX;
4401 4402
        pt.y = y;
    } else {
4403 4404
        pt.x = x - CONTENTVIEW.marginX;
        pt.y = y - CONTENTVIEW.marginY;
4405 4406
    }

4407 4408
    var sx = (CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left) / (CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left);
    var sy = (CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top) / (CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top);
4409 4410

    // change size image correct
4411 4412 4413 4414
    var nx = (pt.x - CONTENTVIEW.destRect.left) / sx;
    var ny = (pt.y - CONTENTVIEW.destRect.top) / sy;
    pt.x = Math.floor(nx + CONTENTVIEW.srcRect.left);
    pt.y = Math.floor(ny + CONTENTVIEW.srcRect.top);
4415

4416
    //console.log('CONTENTVIEW.screenToImage ' + CONTENTVIEW.srcRect.right + ' ' + CONTENTVIEW.srcRect.left + ' ' + CONTENTVIEW.destRect.right + ' ' + CONTENTVIEW.destRect.left + ' ' + x + ' ' + sx + ' ' + nx + ' ' + pt.x + ' ' + srcRect.bottom + ' ' + srcRect.top + ' ' + CONTENTVIEW.destRect.bottom + ' ' + CONTENTVIEW.destRect.top + ' ' + y + ' ' + sy + ' ' + ny + ' ' + pt.y);
4417 4418 4419 4420 4421

    return pt;
};

/* draw Canvas  */
4422
CONTENTVIEW.drawCanvas = function(opt) {
4423

4424 4425 4426 4427 4428
    //Draw on offscreen
    if(opt==null || opt == 0){
        // draw main canvas
        var canvas = document.getElementById('offscreen');
        var context = canvas.getContext('2d');
4429

4430
        context.clearRect(0, 0, canvas.width, canvas.height);
4431

4432
        CONTENTVIEW.draw(context, 0);
4433
    }
4434 4435 4436 4437 4438
    //Draw on next offscreen
    else if (opt==1){
        // draw mainNext canvas
        var canvas = document.getElementById('offscreenNext');
        var context = canvas.getContext('2d');
4439

4440
        context.clearRect(0, 0, canvas.width, canvas.height);
4441

4442
        CONTENTVIEW.draw(context, 1);
4443 4444 4445 4446 4447 4448
    }
    //Draw on previous offscreen
    else if (opt==2){
        // draw mainPre canvas
        var canvas = document.getElementById('offscreenPre');
        var context = canvas.getContext('2d');
4449

4450
        context.clearRect(0, 0, canvas.width, canvas.height);
4451 4452

        CONTENTVIEW.draw(context, 2);
4453 4454 4455 4456
    }
};

/* draw memo */
4457
CONTENTVIEW.drawMemoOnScreen = function(opt) {
4458

4459 4460 4461 4462 4463 4464 4465 4466
    //Start Function : No.4
    var canvas;
    var context;
    //START TRB00097
    var tempPageHeight;
    var tempPageWidth;
    //END TRB00097
    var tempPageNo = 0;
4467

4468 4469 4470
    if(opt == null || opt == 0){
        canvas = document.getElementById('offscreen');
        canvasWidth = $('#offscreen').width();
4471 4472 4473
        canvasHeight = $('#offscreen').height();

        //START TRB00097
4474 4475
        tempPageHeight = CONTENTVIEW_GENERAL.heightEachPage;
        tempPageWidth = CONTENTVIEW_GENERAL.widthEachPage;
4476
        //END TRB00097
4477
        tempPageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex());
4478 4479 4480 4481 4482
    }
    else if(opt == 1){
        canvas = document.getElementById('offscreenNext');
        canvasWidth = $('#offscreenNext').width();
        canvasHeight = $('#offscreenNext').height();
4483 4484

        //START TRB00097
4485 4486
        tempPageHeight = CONTENTVIEW_GENERAL.heightEachNextPage;
        tempPageWidth = CONTENTVIEW_GENERAL.widthEachNextPage;
4487
        //END TRB00097
4488
        tempPageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex() + 1);
4489 4490 4491 4492 4493
    }
    else if(opt == 2){
        canvas = document.getElementById('offscreenPre');
        canvasWidth = $('#offscreenPre').width();
        canvasHeight = $('#offscreenPre').height();
4494
        //START TRB00097
4495 4496
        tempPageHeight = CONTENTVIEW_GENERAL.heightEachPrevPage;
        tempPageWidth = CONTENTVIEW_GENERAL.widthEachPrevPage;
4497
        //END TRB00097
4498
        tempPageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex() - 1);
4499
    }
4500

4501 4502 4503 4504
    context = canvas.getContext('2d');
    //End Function : No.4

    if (ClientData.IsDisplayMemo() == true) {
4505
        CONTENTVIEW_CREATEOBJECT.memoObjects = [];
4506 4507 4508

        /*get data memo */
        var memoData = ClientData.MemoData();
4509

4510 4511 4512 4513
        //Start Function : No.17 - Editor : Long - Date: 08/13/2013 - Summary : Draw newest memo
        var tempPosX = 0;
        var tempPosY = 0;
        //End Function : No.17 - Editor : Long - Date: 08/13/2013 - Summary : Draw newest memo
4514

4515
        for (var nIndex = 0; nIndex < memoData.length; nIndex++) {
4516
            if (memoData[nIndex].contentid == CONTENTVIEW_GENERAL.contentID
Vo Duc Thang committed
4517
            && memoData[nIndex].pageNo == tempPageNo) {
4518 4519
                /* create object of memo */
                var memoObject = null;
4520
                 //START TRB00097
4521 4522 4523 4524 4525 4526 4527
                if (memoData[nIndex].posY > tempPageHeight - 50) {
                    memoData[nIndex].posY = tempPageHeight - 50;
                }

                if (memoData[nIndex].posX > tempPageWidth - 50) {
                    memoData[nIndex].posX = tempPageWidth - 50;
                }
4528 4529
                 //END TRB00097

4530 4531 4532 4533
                //Start Function : No.17 - Editor : Long - Date: 08/13/2013 - Summary : Draw newest memo
                if(memoData[nIndex].posY != tempPosY && memoData[nIndex].posX != tempPosX){
                    tempPosX = memoData[nIndex].posX;
                    tempPosY = memoData[nIndex].posY;
4534

4535
                    memoObject = new CONTENTVIEW_CREATEOBJECT.memo(
4536 4537 4538 4539 4540 4541 4542 4543
                        nIndex,
                        memoData[nIndex].Text,
                        memoData[nIndex].posX,
                        memoData[nIndex].posY,
                        50,
                        50,
                        "img/memo.png"
                    );
4544

4545
                    CONTENTVIEW_CREATEOBJECT.memoObjects.push(memoObject);
4546

4547
                }else{
4548 4549
                    for (var i = CONTENTVIEW_CREATEOBJECT.memoObjects.length - 1; i >= 0; i--) {
                        var tempObj = CONTENTVIEW_CREATEOBJECT.memoObjects[i];
4550

4551
                        if(tempObj.x == tempPosX && tempObj.y == tempPosY){
4552
                            CONTENTVIEW_CREATEOBJECT.memoObjects.slice(i, 1);
4553 4554
                        }
                    }
4555

4556
                    memoObject = new CONTENTVIEW_CREATEOBJECT.memo(
4557 4558 4559 4560 4561 4562 4563 4564
                        nIndex,
                        memoData[nIndex].Text,
                        memoData[nIndex].posX,
                        memoData[nIndex].posY,
                        50,
                        50,
                        "img/memo.png"
                    );
4565

4566
                    CONTENTVIEW_CREATEOBJECT.memoObjects.push(memoObject);
4567
                }
4568 4569
            }
        }
4570

4571 4572
        for (var nIndex = 0; nIndex < CONTENTVIEW_CREATEOBJECT.memoObjects.length; nIndex++) {
            var tempObj = CONTENTVIEW_CREATEOBJECT.memoObjects[nIndex];
4573 4574
            tempObj.drawMemo(context, opt);
        }
4575 4576

        //End Function : No.17 - Editor : Long - Date: 08/13/2013 - Summary : Draw newest memo
4577 4578 4579 4580
    }
};

/* draw webGetContent4 */
4581
CONTENTVIEW.drawGetWebContent4 = function(context, opt) {
4582
    CONTENTVIEW_CREATEOBJECT.webGetContentType4Objects = [];
4583 4584
    //Start Function : No.4 - Editor : Long - Date: 08/14/2013 - Summary : For lazy loading
    var tempIndex = 0;
4585

4586
    if(opt == 0 || opt == null){
4587
        tempIndex = CONTENTVIEW_GETDATA.getPageIndex();
4588 4589
    }
    else if(opt == 1){
4590
        tempIndex = CONTENTVIEW_GETDATA.getPageIndex() + 1;
4591 4592
    }
    else if(opt == 2){
4593
        tempIndex = CONTENTVIEW_GETDATA.getPageIndex() - 1;
4594
    }
4595

4596
    for (var nIndex = 0; nIndex < CONTENTVIEW_GENERAL.dataJsonType4.length; nIndex++) {
4597
        /* get data belong current page*/
4598
        var dataLinkList = CONTENTVIEW_GENERAL.dataJsonType4[nIndex].linkList;
4599 4600 4601 4602
        for (var nLinkList = 0; nLinkList < dataLinkList.length; nLinkList++) {
            /* create object webContentTyp4 */
            var dataObject = null;

4603
            dataObject = new CONTENTVIEW_CREATEOBJECT.webContentType4(
Vo Duc Thang committed
4604 4605 4606 4607 4608 4609 4610 4611 4612 4613
                nLinkList,
                dataLinkList[nLinkList].linkLocationX,
                dataLinkList[nLinkList].linkLocationY,
                dataLinkList[nLinkList].linkLocationWidth,
                dataLinkList[nLinkList].linkLocationHeight,
                "img/webGetContent4.png",
                dataLinkList[nLinkList].linkKind,
                dataLinkList[nLinkList].destURI,
                dataLinkList[nLinkList].destPageNumber
            );
4614

4615 4616
            dataObject["pageNo"] = CONTENTVIEW_GENERAL.dataJsonType4[nIndex].page;
            CONTENTVIEW_CREATEOBJECT.webGetContentType4Objects.push(dataObject);
4617

4618
            //Start Fix Bug : Cannot not click on link object - Editor : Long - Date : 08/30/2013
4619
            if (CONTENTVIEW.changePageIndex(tempIndex) == dataObject["pageNo"]) {
4620
                dataObject.drawObject(context, opt);
4621 4622 4623
            }
            //End Fix Bug : Cannot not click on link object - Editor : Long - Date : 08/30/2013
        }
4624 4625 4626 4627 4628 4629
    }
    //End Function : No.4 - Editor : Long - Date: 08/14/2013 - Summary : For lazy loading
};

//Start Function : No.4 - Editor : Long - Date: 08/14/2013 - Summary : For lazy loading
/* draw marking */
4630
CONTENTVIEW.drawMarkingOnScreen = function(opt) {
4631

4632 4633 4634 4635 4636 4637 4638
    var canvas;
    var context;
    var canvasWidth = $('#offscreen').width();
    var canvasHeight = $('#offscreen').height();
    var indexMarking;

    var tempPageNo = 0;
4639

4640 4641 4642 4643
    if(opt == null || opt == 0){
        canvas = document.getElementById('offscreen');
        canvasWidth = $('#offscreen').width();
        canvasHeight = $('#offscreen').height();
4644 4645

        tempPageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex());
4646 4647 4648 4649 4650
    }
    else if(opt == 1){
        canvas = document.getElementById('offscreenNext');
        canvasWidth = $('#offscreenNext').width();
        canvasHeight = $('#offscreenNext').height();
4651

4652
        tempPageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex() + 1);
4653 4654 4655 4656 4657
    }
    else if(opt == 2){
        canvas = document.getElementById('offscreenPre');
        canvasWidth = $('#offscreenPre').width();
        canvasHeight = $('#offscreenPre').height();
4658

4659
        tempPageNo = CONTENTVIEW.changePageIndex(CONTENTVIEW_GETDATA.getPageIndex() - 1);
4660 4661 4662
    }

    context = canvas.getContext('2d');
4663

4664
    if (ClientData.IsAddingMarking() == false && ClientData.IsDisplayMarking() == true) {
4665
        CONTENTVIEW.isExistDrawing = false;
4666 4667 4668 4669

        /* get data marking on local */
        var dataMarking = ClientData.MarkingData();
        for (var nIndex = 0; nIndex < dataMarking.length; nIndex++) {
4670
            if (dataMarking[nIndex].contentid == CONTENTVIEW_GENERAL.contentID
Vo Duc Thang committed
4671
            && dataMarking[nIndex].pageNo == tempPageNo) {
4672 4673 4674 4675 4676
                /*create image */
                var img = new Image();
                img.onload = function () {
                    //context.drawImage(img,dataMarking[indexMarking].left,0,dataMarking[indexMarking].right - dataMarking[indexMarking].left,dataMarking[indexMarking].bottom - dataMarking[indexMarking].top,0,0,canvasWidth,canvasHeight);
                    context.drawImage(img, 0, 0, canvasWidth, canvasHeight);
4677
                    CONTENTVIEW.flip(opt);
4678
                    /* set flag */
4679
                    CONTENTVIEW.isExistDrawing = true;
4680
                    /* draw memo */
4681
                    CONTENTVIEW.drawMemoOnScreen(opt);
4682 4683 4684 4685 4686 4687
                };
                img.src = dataMarking[nIndex].content;
                indexMarking = nIndex;
            }
        }

4688
        if (CONTENTVIEW.isExistDrawing == false) {
4689
            /* draw memo */
4690
            CONTENTVIEW.drawMemoOnScreen(opt);
4691 4692 4693
        }
    } else {
        /* draw memo */
4694
        CONTENTVIEW.drawMemoOnScreen(opt);
4695 4696 4697 4698
    }
};

/*draw canvas*/
4699
CONTENTVIEW.draw = function(context, opt) {
4700
    context.save();
4701

4702
    //Draw on main canvas
4703
    if(opt==null || opt == 0){
4704
        /* draw page objects */
4705
        CONTENTVIEW_GETDATA.getContent().currentPage.drawPage(context);
4706 4707 4708
    }
    //Draw on next canvas
    else if(opt == 1){
4709
        CONTENTVIEW_GENERAL.getNextContent().currentPage.drawPage(context, 1);
4710 4711 4712
    }
    //Draw on previous canvas
    else if(opt == 2){
4713
        CONTENTVIEW_GENERAL.getPrevContent().currentPage.drawPage(context, 2);
4714
    }
4715

4716 4717
    context.restore();

4718
    CONTENTVIEW_INITOBJECT.initImageCheckMarking();
4719
    CONTENTVIEW_INITOBJECT.initImageCheckMemo();
4720 4721 4722 4723 4724 4725
};
//End Function : No.4 - Editor : Long - Date: 08/09/2013 - Summary : Edit function to draw multi canvas


//Start Function : No.4 - Editor : Long - Date: 08/09/2013 - Summary : Edit function to draw multi canvas
/* display to screen */
4726
CONTENTVIEW.flip = function(opt) {
4727 4728
    var canvas;
    var offscreen;
4729

4730 4731 4732 4733 4734 4735 4736 4737 4738 4739 4740 4741
    if(opt==null || opt == 0){
        canvas = document.getElementById('main');
        offscreen = document.getElementById('offscreen');
    }else if(opt==1){
        canvas = document.getElementById('mainNext');
        offscreen = document.getElementById('offscreenNext');
    }else if(opt==2){
        canvas = document.getElementById('mainPre');
        offscreen = document.getElementById('offscreenPre');
    }

    var context = canvas.getContext('2d');
4742 4743

    //START TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
4744 4745
    // init rect
    if(opt==null || opt == 0){
4746
        if (CONTENTVIEW.srcRect.width == 0) {
4747
            CONTENTVIEW.srcRect = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, offscreen.width, offscreen.height);
4748 4749 4750
        }
    }
    else if(opt==1){
4751
        CONTENTVIEW.srcRectNext = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, offscreen.width, offscreen.height);
4752 4753
    }
    else if(opt==2){
4754
        CONTENTVIEW.srcRectPrev = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, offscreen.width, offscreen.height);
4755 4756
    }
    //END TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
4757

4758
    if(opt==null || opt==0){
4759

4760
        // display rect
4761
        CONTENTVIEW.srcRect.add(CONTENTVIEW.moveX, CONTENTVIEW.moveY);
4762

4763
        // fix rect
4764
        if (CONTENTVIEW.srcRect.left < 0) {
4765 4766
            CONTENTVIEW.srcRect.left = 0;
            CONTENTVIEW.srcRect.right = CONTENTVIEW.srcRect.left + CONTENTVIEW.srcRect.width;
4767
        } else if (CONTENTVIEW.srcRect.right > offscreen.width) {
4768 4769
            CONTENTVIEW.srcRect.left = offscreen.width - CONTENTVIEW.srcRect.width;
            CONTENTVIEW.srcRect.right = offscreen.width;
4770 4771
        }
        if (CONTENTVIEW.srcRect.top < 0) {
4772 4773
            CONTENTVIEW.srcRect.top = 0;
            CONTENTVIEW.srcRect.bottom = CONTENTVIEW.srcRect.top + CONTENTVIEW.srcRect.height;
4774
        } else if (CONTENTVIEW.srcRect.bottom > offscreen.height) {
4775 4776
            CONTENTVIEW.srcRect.top = offscreen.height - CONTENTVIEW.srcRect.height;
            CONTENTVIEW.srcRect.bottom = offscreen.height;
4777
        }
4778

4779 4780 4781 4782
        // target rect
        var width = offscreen.width;
        var height = offscreen.height;
        var aspect = offscreen.width / offscreen.height;
4783

4784
        if($(rotatebtnR).attr('angle') == '90' || $(rotatebtnR).attr('angle') == '-90'){
4785

4786
            aspect = offscreen.height / offscreen.width;
4787

4788 4789 4790
            if (canvas.width > canvas.height) {
                width = canvas.height;
                height = width * aspect;
4791

4792 4793 4794 4795
            } else {
                height = canvas.width;
                width = height / aspect;
            }
4796

4797 4798 4799 4800 4801 4802 4803 4804 4805 4806 4807 4808 4809 4810 4811 4812 4813 4814 4815 4816 4817 4818 4819 4820 4821 4822 4823 4824 4825 4826 4827
            if (width > canvas.height) {
                var size = canvas.height / width;
                width = canvas.height;
                height = height * size;
            }

            if (height > canvas.width) {
                var size = canvas.height / height;
                height = canvas.width;
                width = width * size;
            }

            if (CONTENTVIEW.userScale != 1 && height < canvas.width) {

                if(offscreen.width < offscreen.height){
                    height = height * CONTENTVIEW.userScale * aspect;
                }else{
                    height = height * CONTENTVIEW.userScale;
                }

                if (height > canvas.width) {
                    height = canvas.width;
                }

            } else if (CONTENTVIEW.userScale != 1 && width < canvas.height) {
              
                width = width * CONTENTVIEW.userScale;

                if (width > canvas.height) {
                    width = canvas.height;
                }
4828
            }
4829 4830


4831 4832 4833 4834 4835 4836 4837 4838 4839
        }else{
            
            if (canvas.width > canvas.height) {
                height = canvas.height;
                width = height * aspect;
            } else {
                width = canvas.width;
                height = width / aspect;
            }
4840

4841
            if (height > canvas.height) {
4842
                var size = canvas.height / height;
4843
                height = canvas.height;
4844
                width = width * size;
4845
            }
4846

4847 4848 4849 4850 4851 4852 4853 4854 4855 4856 4857 4858 4859 4860 4861 4862 4863 4864 4865 4866
            if (width > canvas.width) {
                var size = canvas.width / width;
                width = canvas.width;
                height = height * size;
            }

            if (CONTENTVIEW.userScale != 1 && width < canvas.width) {
                width = width * CONTENTVIEW.userScale;
                if (width > canvas.width) {
                    width = canvas.width;
                }

            } else if (CONTENTVIEW.userScale != 1 && height < canvas.height) {
                height = height * CONTENTVIEW.userScale;

                if (height > canvas.height) {
                    height = canvas.height;
                }
            }
        }
4867 4868 4869
        var destX = 0, destY = 0;
        destX = (canvas.width / 2) - (width / 2);
        destY = (canvas.height / 2) - (height / 2);
4870

4871 4872 4873 4874 4875 4876
        if (destX < 0) {
            destX = 0;
        }
        if (destY < 0) {
            destY = 0;
        }
4877

4878
        if (CONTENTVIEW.srcRect.left < 0) {
4879
            CONTENTVIEW.srcRect.left = 0;
4880
        }
4881
        if (CONTENTVIEW.srcRect.top < 0) {
4882
            CONTENTVIEW.srcRect.top = 0;
4883
        }
4884

4885
        CONTENTVIEW.destRect = new CONTENTVIEW_CREATEOBJECT.Rect(destX, destY, width, height);
4886

4887
        /* get position for drawing canvas*/
4888
        if (CONTENTVIEW_GENERAL.isFirstLoad == true) {
4889 4890 4891 4892
            CONTENTVIEW_GENERAL.nPositionCanvas.left = CONTENTVIEW.destRect.left;
            CONTENTVIEW_GENERAL.nPositionCanvas.right = CONTENTVIEW.destRect.right;
            CONTENTVIEW_GENERAL.nPositionCanvas.top = CONTENTVIEW.destRect.top;
            CONTENTVIEW_GENERAL.nPositionCanvas.bottom = CONTENTVIEW.destRect.bottom;
4893

4894 4895 4896 4897
            $("#draw_canvas").attr('height', CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top)
                  .attr('width', CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left)
                   .css('top', CONTENTVIEW.destRect.top + CONTENTVIEW.marginY)
                   .css('left', CONTENTVIEW.destRect.left + CONTENTVIEW.marginX);
4898

4899 4900 4901 4902
            $("#marker_canvas").attr('height', CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top)
                  .attr('width', CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left)
                   .css('top', CONTENTVIEW.destRect.top + CONTENTVIEW.marginY)
                   .css('left', CONTENTVIEW.destRect.left + CONTENTVIEW.marginX);
4903

4904
            CONTENTVIEW_GENERAL.isFirstLoad = false;
4905
        }
4906

4907 4908
        CONTENTVIEW.leftCanvas = destX;
        CONTENTVIEW.topCanvas = destY;
4909
        // change scale
4910 4911
        CONTENTVIEW.scaleX = offscreen.width / width;
        CONTENTVIEW.scaleY = offscreen.height / height;
4912 4913

        // draw canvas
4914 4915
        context.clearRect(0, 0, canvas.width, canvas.height);
        context.save();
4916 4917 4918 4919 4920 4921 4922 4923 4924 4925 4926 4927 4928 4929 4930 4931 4932 4933
        if($(rotatebtnR).attr('angle') != '0'){
            if($(rotatebtnR).attr('angle') == '90' || $(rotatebtnR).attr('angle') == '-90'){
                context.translate(canvas.width/2,canvas.height/2);
                context.rotate($(rotatebtnR).attr('angle')*Math.PI/180);
                context.translate(-(canvas.width/2),-(canvas.height/2));
                context.drawImage(offscreen, 
                    CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.top, CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top,
                    CONTENTVIEW.destRect.left, (canvas.height - height)/2, width, height);
            }else{
                context.translate(canvas.width/2,canvas.height/2);
                context.rotate($(rotatebtnR).attr('angle')*Math.PI/180);
                context.translate(-(canvas.width/2),-(canvas.height/2));
                context.drawImage(offscreen, 
                    CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.top, CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top,
                    CONTENTVIEW.destRect.left, CONTENTVIEW.destRect.top, width, height);
            }
        }else{
            context.drawImage(offscreen,
4934 4935
                CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.top, CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top,
                CONTENTVIEW.destRect.left, CONTENTVIEW.destRect.top, width, height);
4936 4937
        }

4938 4939 4940 4941
        context.restore();
    }
    else if(opt==1){
        // display rect
4942
        //CONTENTVIEW.srcRectNext.add(CONTENTVIEW.moveX, CONTENTVIEW.moveY);
4943

4944
        // fix rect
4945
        if (CONTENTVIEW.srcRectNext.left < 0) {
4946 4947
            CONTENTVIEW.srcRectNext.left = 0;
            CONTENTVIEW.srcRectNext.right = CONTENTVIEW.srcRectNext.left + CONTENTVIEW.srcRectNext.width;
4948 4949
        } else if (CONTENTVIEW.srcRectNext.right > offscreen.width) {
        	CONTENTVIEW.srcRectNext.left = offscreen.width - CONTENTVIEW.srcRectNext.width;
4950
        	CONTENTVIEW.srcRectNext.right = offscreen.width;
4951 4952
        }
        if (CONTENTVIEW.srcRectNext.top < 0) {
4953 4954
            CONTENTVIEW.srcRectNext.top = 0;
            CONTENTVIEW.srcRectNext.bottom = CONTENTVIEW.srcRectNext.top + CONTENTVIEW.srcRectNext.height;
4955
        } else if (CONTENTVIEW.srcRectNext.bottom > offscreen.height) {
4956 4957
            CONTENTVIEW.srcRectNext.top = offscreen.height - CONTENTVIEW.srcRectNext.height;
            CONTENTVIEW.srcRectNext.bottom = offscreen.height;
4958
        }
4959

4960 4961 4962 4963
        // target rect
        var width = offscreen.width;
        var height = offscreen.height;
        var aspect = offscreen.width / offscreen.height;
4964

4965
        if($(rotatebtnR).attr('angle') == '90' || $(rotatebtnR).attr('angle') == '-90'){
4966

4967
            aspect = offscreen.height / offscreen.width;
4968

4969 4970 4971
            if (canvas.width > canvas.height) {
                width = canvas.height;
                height = width * aspect;
4972

4973 4974 4975 4976
            } else {
                height = canvas.width;
                width = height / aspect;
            }
4977

4978 4979 4980 4981
            if (width > canvas.height) {
                var size = canvas.height / width;
                width = canvas.height;
                height = height * size;
4982
            }
4983

4984 4985 4986 4987 4988
            if (height > canvas.width) {
                var size = canvas.height / height;
                height = canvas.width;
                width = width * size;
            }
4989

4990 4991 4992 4993 4994 4995 4996 4997 4998 4999 5000 5001 5002 5003 5004 5005 5006 5007 5008 5009 5010 5011 5012 5013 5014 5015 5016 5017 5018 5019 5020
            if (CONTENTVIEW.userScale != 1 && height < canvas.width) {

                if(offscreen.width < offscreen.height){
                    height = height * CONTENTVIEW.userScale * aspect;
                }else{
                    height = height * CONTENTVIEW.userScale;
                }

                if (height > canvas.width) {
                    height = canvas.width;
                }

            } else if (CONTENTVIEW.userScale != 1 && width < canvas.height) {
              
                width = width * CONTENTVIEW.userScale;

                if (width > canvas.height) {
                    width = canvas.height;
                }
            }


        }else{

            if (canvas.width > canvas.height) {
                height = canvas.height;
                width = height * aspect;
            } else {
                width = canvas.width;
                height = width / aspect;
            }
5021

5022
            if (height > canvas.height) {
5023
                var size = canvas.height / height;
5024
                height = canvas.height;
5025 5026 5027 5028 5029 5030 5031 5032 5033 5034 5035 5036 5037 5038 5039 5040 5041 5042 5043 5044 5045 5046 5047
                width = width * size;
            }

            if (width > canvas.width) {
                var size = canvas.width / width;
                width = canvas.width;
                height = height * size;
            }

            if (CONTENTVIEW.userScale != 1 && width < canvas.width) {

                width = width * CONTENTVIEW.userScale;
                if (width > canvas.width) {
                    width = canvas.width;
                }

            } else if (CONTENTVIEW.userScale != 1 && height < canvas.height) {

                height = height * CONTENTVIEW.userScale;

                if (height > canvas.height) {
                    height = canvas.height;
                }
5048 5049
            }
        }
5050

5051 5052 5053
        var destX = 0, destY = 0;
        destX = (canvas.width / 2) - (width / 2);
        destY = (canvas.height / 2) - (height / 2);
5054

5055 5056 5057 5058 5059 5060
        if (destX < 0) {
            destX = 0;
        }
        if (destY < 0) {
            destY = 0;
        }
5061

5062
        if (CONTENTVIEW.srcRectNext.left < 0) {
5063
            CONTENTVIEW.srcRectNext.left = 0;
5064
        }
5065
        if (CONTENTVIEW.srcRectNext.top < 0) {
5066
            CONTENTVIEW.srcRectNext.top = 0;
5067
        }
5068

5069
        CONTENTVIEW.destRectNext = new CONTENTVIEW_CREATEOBJECT.Rect(destX, destY, width, height);
5070

5071
        /* get position for drawing canvas*/
5072
        if (CONTENTVIEW_GENERAL.isFirstLoad == true) {
5073 5074 5075 5076
            CONTENTVIEW_GENERAL.nPositionCanvas.left = CONTENTVIEW.destRectNext.left;
            CONTENTVIEW_GENERAL.nPositionCanvas.right = CONTENTVIEW.destRectNext.right;
            CONTENTVIEW_GENERAL.nPositionCanvas.top = CONTENTVIEW.destRectNext.top;
            CONTENTVIEW_GENERAL.nPositionCanvas.bottom = CONTENTVIEW.destRectNext.bottom;
5077

5078 5079 5080 5081
            $("#draw_canvas").attr('height', CONTENTVIEW.destRectNext.bottom - CONTENTVIEW.destRectNext.top)
                  .attr('width', CONTENTVIEW.destRectNext.right - CONTENTVIEW.destRectNext.left)
                   .css('top', CONTENTVIEW.destRectNext.top + CONTENTVIEW.marginY)
                   .css('left', CONTENTVIEW.destRectNext.left + CONTENTVIEW.marginX);
5082

5083 5084 5085 5086
            $("#marker_canvas").attr('height', CONTENTVIEW.destRectNext.bottom - CONTENTVIEW.destRectNext.top)
                  .attr('width', CONTENTVIEW.destRectNext.right - CONTENTVIEW.destRectNext.left)
                   .css('top', CONTENTVIEW.destRectNext.top + CONTENTVIEW.marginY)
                   .css('left', CONTENTVIEW.destRectNext.left + CONTENTVIEW.marginX);
5087

5088
            CONTENTVIEW_GENERAL.isFirstLoad = false;
5089
        }
5090

5091 5092
        //CONTENTVIEW.leftCanvas = destX;
        //CONTENTVIEW.topCanvas = destY;
5093
        // change scale
5094 5095
        //CONTENTVIEW.scaleX = offscreen.width / width;
        //CONTENTVIEW.scaleY = offscreen.height / height;
5096 5097

        // draw canvas
5098 5099
        context.clearRect(0, 0, canvas.width, canvas.height);
        context.save();
5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 5112 5113 5114 5115 5116 5117 5118 5119 5120
        if($(rotatebtnR).attr('angle') != '0'){
            if($(rotatebtnR).attr('angle') == '90' || $(rotatebtnR).attr('angle') == '-90'){
                context.translate(canvas.width/2,canvas.height/2);
                context.rotate($(rotatebtnR).attr('angle')*Math.PI/180);
                context.translate(-(canvas.width/2),-(canvas.height/2));
                context.drawImage(offscreen, 
                    CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.top, CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top,
                    CONTENTVIEW.destRect.left, (canvas.height - height)/2, width, height);
            }else{
                context.translate(canvas.width/2,canvas.height/2);
                context.rotate($(rotatebtnR).attr('angle')*Math.PI/180);
                context.translate(-(canvas.width/2),-(canvas.height/2));
                context.drawImage(offscreen, 
                    CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.top, CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top,
                    CONTENTVIEW.destRect.left, CONTENTVIEW.destRect.top, width, height);
            }
        }else{
            context.drawImage(offscreen,
                CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.top, CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top,
                CONTENTVIEW.destRect.left, CONTENTVIEW.destRect.top, width, height);
        }
5121 5122 5123 5124
        context.restore();
    }
    else if(opt==2){
        // display rect
5125
        //CONTENTVIEW.srcRectNext.add(CONTENTVIEW.moveX, CONTENTVIEW.moveY);
5126

5127
        // fix rect
5128
        if (CONTENTVIEW.srcRectPrev.left < 0) {
5129 5130
            CONTENTVIEW.srcRectPrev.left = 0;
            CONTENTVIEW.srcRectPrev.right = CONTENTVIEW.srcRectPrev.left + CONTENTVIEW.srcRectPrev.width;
5131 5132
        } else if (CONTENTVIEW.srcRectNext.right > offscreen.width) {
        	CONTENTVIEW.srcRectPrev.left = offscreen.width - CONTENTVIEW.srcRectPrev.width;
5133
        	CONTENTVIEW.srcRectPrev.right = offscreen.width;
5134 5135
        }
        if (CONTENTVIEW.srcRectPrev.top < 0) {
5136 5137
            CONTENTVIEW.srcRectPrev.top = 0;
            CONTENTVIEW.srcRectPrev.bottom = CONTENTVIEW.srcRectPrev.top + CONTENTVIEW.srcRectPrev.height;
5138
        } else if (CONTENTVIEW.srcRectPrev.bottom > offscreen.height) {
5139 5140
            CONTENTVIEW.srcRectPrev.top = offscreen.height - CONTENTVIEW.srcRectPrev.height;
            CONTENTVIEW.srcRectPrev.bottom = offscreen.height;
5141
        }
5142

5143 5144 5145 5146
        // target rect
        var width = offscreen.width;
        var height = offscreen.height;
        var aspect = offscreen.width / offscreen.height;
5147

5148
        if($(rotatebtnR).attr('angle') == '90' || $(rotatebtnR).attr('angle') == '-90'){
5149

5150
            aspect = offscreen.height / offscreen.width;
5151

5152 5153 5154
            if (canvas.width > canvas.height) {
                width = canvas.height;
                height = width * aspect;
5155

5156 5157 5158 5159
            } else {
                height = canvas.width;
                width = height / aspect;
            }
5160

5161 5162 5163 5164
            if (width > canvas.height) {
                var size = canvas.height / width;
                width = canvas.height;
                height = height * size;
5165
            }
5166

5167 5168 5169 5170 5171 5172 5173
            if (height > canvas.width) {
                var size = canvas.height / height;
                height = canvas.width;
                width = width * size;
            }

            if (CONTENTVIEW.userScale != 1 && height < canvas.width) {
5174

5175 5176 5177 5178 5179 5180 5181 5182 5183 5184 5185 5186 5187 5188 5189 5190 5191 5192 5193 5194 5195 5196 5197 5198 5199 5200 5201 5202 5203
                if(offscreen.width < offscreen.height){
                    height = height * CONTENTVIEW.userScale * aspect;
                }else{
                    height = height * CONTENTVIEW.userScale;
                }

                if (height > canvas.width) {
                    height = canvas.width;
                }

            } else if (CONTENTVIEW.userScale != 1 && width < canvas.height) {
              
                width = width * CONTENTVIEW.userScale;

                if (width > canvas.height) {
                    width = canvas.height;
                }
            }


        }else{

            if (canvas.width > canvas.height) {
                height = canvas.height;
                width = height * aspect;
            } else {
                width = canvas.width;
                height = width / aspect;
            }
5204

5205
            if (height > canvas.height) {
5206
                var size = canvas.height / height;
5207
                height = canvas.height;
5208 5209 5210 5211 5212 5213 5214 5215 5216 5217 5218 5219 5220 5221 5222 5223 5224 5225 5226 5227 5228 5229 5230
                width = width * size;
            }

            if (width > canvas.width) {
                var size = canvas.width / width;
                width = canvas.width;
                height = height * size;
            }

            if (CONTENTVIEW.userScale != 1 && width < canvas.width) {

                width = width * CONTENTVIEW.userScale;
                if (width > canvas.width) {
                    width = canvas.width;
                }

            } else if (CONTENTVIEW.userScale != 1 && height < canvas.height) {

                height = height * CONTENTVIEW.userScale;

                if (height > canvas.height) {
                    height = canvas.height;
                }
5231 5232
            }
        }
5233

5234 5235 5236
        var destX = 0, destY = 0;
        destX = (canvas.width / 2) - (width / 2);
        destY = (canvas.height / 2) - (height / 2);
5237

5238 5239 5240 5241 5242 5243
        if (destX < 0) {
            destX = 0;
        }
        if (destY < 0) {
            destY = 0;
        }
5244

5245
        if (CONTENTVIEW.srcRectPrev.left < 0) {
5246
            CONTENTVIEW.srcRectPrev.left = 0;
5247
        }
5248
        if (CONTENTVIEW.srcRectPrev.top < 0) {
5249
            CONTENTVIEW.srcRectPrev.top = 0;
5250
        }
5251

5252
        CONTENTVIEW.destRectPrev = new CONTENTVIEW_CREATEOBJECT.Rect(destX, destY, width, height);
5253

5254
        /* get position for drawing canvas*/
5255
        if (CONTENTVIEW_GENERAL.isFirstLoad == true) {
5256 5257 5258 5259
            CONTENTVIEW_GENERAL.nPositionCanvas.left = CONTENTVIEW.destRectPrev.left;
            CONTENTVIEW_GENERAL.nPositionCanvas.right = CONTENTVIEW.destRectPrev.right;
            CONTENTVIEW_GENERAL.nPositionCanvas.top = CONTENTVIEW.destRectPrev.top;
            CONTENTVIEW_GENERAL.nPositionCanvas.bottom = CONTENTVIEW.destRectPrev.bottom;
5260

5261 5262 5263 5264
            $("#draw_canvas").attr('height', CONTENTVIEW.destRectPrev.bottom - CONTENTVIEW.destRectPrev.top)
                  .attr('width', CONTENTVIEW.destRectPrev.right - CONTENTVIEW.destRectPrev.left)
                   .css('top', CONTENTVIEW.destRectPrev.top + CONTENTVIEW.marginY)
                   .css('left', CONTENTVIEW.destRectPrev.left + CONTENTVIEW.marginX);
5265

5266 5267 5268 5269
            $("#marker_canvas").attr('height', CONTENTVIEW.destRectPrev.bottom - CONTENTVIEW.destRectPrev.top)
                  .attr('width', CONTENTVIEW.destRectPrev.right - CONTENTVIEW.destRectPrev.left)
                   .css('top', CONTENTVIEW.destRectPrev.top + CONTENTVIEW.marginY)
                   .css('left', CONTENTVIEW.destRectPrev.left + CONTENTVIEW.marginX);
5270

5271
            CONTENTVIEW_GENERAL.isFirstLoad = false;
5272
        }
5273 5274

        // draw canvas
5275 5276
        context.clearRect(0, 0, canvas.width, canvas.height);
        context.save();
5277

5278 5279 5280 5281 5282 5283 5284 5285 5286 5287 5288 5289 5290 5291 5292 5293 5294 5295 5296 5297 5298 5299
        if($(rotatebtnR).attr('angle') != '0'){
            if($(rotatebtnR).attr('angle') == '90' || $(rotatebtnR).attr('angle') == '-90'){
                context.translate(canvas.width/2,canvas.height/2);
                context.rotate($(rotatebtnR).attr('angle')*Math.PI/180);
                context.translate(-(canvas.width/2),-(canvas.height/2));
                context.drawImage(offscreen, 
                    CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.top, CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top,
                    CONTENTVIEW.destRect.left, (canvas.height - height)/2, width, height);
            }else{
                context.translate(canvas.width/2,canvas.height/2);
                context.rotate($(rotatebtnR).attr('angle')*Math.PI/180);
                context.translate(-(canvas.width/2),-(canvas.height/2));
                context.drawImage(offscreen, 
                    CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.top, CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top,
                    CONTENTVIEW.destRect.left, CONTENTVIEW.destRect.top, width, height);
            }
        }else{
            context.drawImage(offscreen,
                CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.top, CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left, CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top,
                CONTENTVIEW.destRect.left, CONTENTVIEW.destRect.top, width, height);
        }

5300
        context.restore();
5301
    }
5302 5303 5304 5305
};
//End Function : No.4 - Editor : Long - Date: 08/09/2013 - Summary : Edit function to draw multi canvas

/* show video*/
5306
CONTENTVIEW.showVideoObject = function(x, y, width, height, src, isFullscreen) {
5307

5308 5309
    var pt1 = CONTENTVIEW.imageToScreen(x, y);
    var pt2 = CONTENTVIEW.imageToScreen(x + width, y + height);
5310

5311 5312 5313
    if (CONTENTVIEW_GENERAL.isFullScreen == true) {
        pt2.y = pt2.y - CONTENTVIEW.marginY;
        pt1.y = pt1.y - CONTENTVIEW.marginY;
5314 5315
    }

5316
    CONTENTVIEW_GETDATA.getPosVideo(x, y, width, height);
5317 5318

    if (isFullscreen === false) {
5319 5320 5321 5322 5323 5324 5325 5326 5327 5328 5329 5330 5331 5332 5333 5334 5335 5336 5337 5338 5339 5340 5341 5342 5343 5344 5345 5346 5347 5348
    	
    	//#17378 Chromeで差し替え動画の再生ボタンを連続クリックすると、動画が再生されなくなる問題の対応
    	var isCreateVideo = true;
    	if($('#videoOnPage').length){
    		
    		//表示位置が同じか判定
    		var pos = $('#playvideo').position();
    		if(pos.left == pt1.x && pos.top == pt1.y){
    			isCreateVideo = false;
    		}
    		
    	}
    	
    	if($('#videoOnPage').length && !isCreateVideo){
    		//ソースのみ入替え
    		var videoObj = document.getElementById('videoOnPage');
    		videoObj.setAttribute("src", src);
    		videoObj.load();
    		
    	} else {
    	
    		$('#playvideo').attr('z-order', '10000');
    		$('#playvideo').css('left', pt1.x + 'px');
    		$('#playvideo').css('top', pt1.y + 'px');
    		$('#playvideo').children().remove();
    		
    		if (ClientData.userOpt_videoMode() == "1") {/* loop video */
    			$('#playvideo').html('<video class="mov" id="videoOnPage" ' +
    					'width="' + (pt2.x - pt1.x) + '" ' +
    					'height="' + (pt2.y - pt1.y) + '" ' +
5349
    					'autoplay controls controlsList="nodownload" loop>' +
5350 5351 5352 5353 5354 5355 5356 5357 5358 5359
    					'   <source src="' + src + '" type="video/mp4"> ' +
    					//'   <source src="' + src + '&key=' + (new Date()).toIdString() + '" type="video/mp4"> ' +
    					//'   <source src="' + src + '&key=' + (new Date()).toIdString() + '" type="video/ogg"> ' +
    					'</video>'
    			);
    			
    		} else {
    			$('#playvideo').html('<video class="mov" id="videoOnPage"' +
    					'width="' + (pt2.x - pt1.x) + '" ' +
    					'height="' + (pt2.y - pt1.y) + '" ' +
5360
    					'autoplay controls controlsList="nodownload">' +
5361 5362 5363 5364 5365 5366
    					//'   <source src="' + src + '&key=' + (new Date()).toIdString() + '" type="video/mp4"> ' +
    					'   <source src="' + src + '" type="video/mp4"> ' +
    					'</video>'
    			);
    		}
    	}
5367 5368 5369
    } else {
        $('#playvideo').attr('z-order', '1000');
        $('#playvideo').html('<video class="mov" id="videoOnPage" src="' + src + '" ' +
5370
                         'autoplay controls controlsList="nodownload"></video>');
5371 5372
    }

5373
    //CONTENTVIEW.showControlsVideo($('#videoOnPage'));
5374 5375 5376 5377

};

/* stop all audio on page */
5378 5379
CONTENTVIEW.stopAllAudio = function() {
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
5380 5381 5382 5383 5384 5385
        $('#playaudiopage').children().remove();
        $('#playaudioallpage').children().remove();
        $('#playaudio').children().remove();
    } else {
        if (document.getElementById("play_audio_0") != undefined) {
            if(document.getElementById("play_audio_0").played){
5386 5387
               document.getElementById("play_audio_0").pause();
            }
5388 5389
        }

5390
        if (document.getElementById("play_audio_1") != undefined) {
5391 5392
            if(document.getElementById("play_audio_1").played){
               document.getElementById("play_audio_1").pause();
5393
            }
5394 5395 5396 5397
        }

        if (document.getElementById("play_audio_2") != undefined) {
            document.getElementById("play_audio_2").pause();
5398

5399 5400
            if(document.getElementById("play_audio_2").played){
               document.getElementById("play_audio_2").pause();
5401
            }
5402 5403 5404 5405 5406
        }
    }
};

/* play all audio on page */
5407 5408 5409
CONTENTVIEW.playAllAudio = function() {
    if (CONTENTVIEW_GENERAL.avwUserEnvObj.browser == 'firefox') {
        if (CONTENTVIEW.srcAudioType0 != '') {
5410
            CONTENTVIEW_CREATEOBJECT.createAudio(CONTENTVIEW.srcAudioType0, CONTENTVIEW.TypeAudio0);
5411
        } else if (CONTENTVIEW.srcAudioType2 != '') {
5412
            CONTENTVIEW_CREATEOBJECT.createAudio(CONTENTVIEW.srcAudioType2, CONTENTVIEW.TypeAudio2);
5413
        } else if (CONTENTVIEW.TypeAudio1 != '') {
5414
            CONTENTVIEW_CREATEOBJECT.createAudio(CONTENTVIEW.srcAudioType1, CONTENTVIEW.TypeAudio1);
5415
        }
5416
    } else if ($('#rotatebtnR').attr('angle') == '0'){
5417
        if (document.getElementById("play_audio_0") != undefined) {
Masaru Abe committed
5418
            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
5419 5420 5421 5422
                //document.getElementById("play_audio_0").load();
            }
            document.getElementById("play_audio_0").play();
        } else if (document.getElementById("play_audio_2") != undefined) {
Masaru Abe committed
5423
            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
5424 5425 5426 5427
                //document.getElementById("play_audio_2").load();
            }
            document.getElementById("play_audio_2").play();
        } else if (document.getElementById("play_audio_1") != undefined) {
Masaru Abe committed
5428
            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
5429 5430 5431 5432 5433 5434 5435 5436 5437
                //document.getElementById("play_audio_1").load();
            }
            document.getElementById("play_audio_1").play();
        }
    }
};


/* change main image of media type 4 */
5438
CONTENTVIEW.changeImageType4 = function(objTarget, nIndex, nIndex1) {
5439 5440 5441 5442
    var imageObj = new Image();
    imageObj.onload = function () {
        var canvasObject = document.getElementById("offscreen");
        var contextObject = canvasObject.getContext("2d");
5443

5444 5445 5446
        //#11478
        var canvasWidth = $('#offscreen').width();
        var canvasHeight = $('#offscreen').height();
5447
        var tempRatioWidth = canvasWidth / CONTENTVIEW_GENERAL.widthEachPageApi;
5448 5449 5450
        if( tempRatioWidth < 1 ){
            tempRatioWidth = 1;
        }
5451
        var tempRatioHeight = canvasHeight / CONTENTVIEW_GENERAL.heightEachPageApi;
5452 5453 5454 5455 5456 5457 5458
        if( tempRatioHeight < 1 ){
            tempRatioHeight = 1;
        }
        var tmpX = objTarget[nIndex].x *  tempRatioWidth;
        var tmpY = objTarget[nIndex].y * tempRatioHeight;
        var tmpW = objTarget[nIndex].width *  tempRatioWidth;
        var tmpH = objTarget[nIndex].height * tempRatioHeight;
5459

5460 5461
        contextObject.fillStyle = "#FFFFFF";
        contextObject.fillRect(tmpX, tmpY, tmpW+1, tmpH+1);
5462 5463 5464 5465 5466 5467 5468 5469 5470 5471 5472 5473
        var aspectType = objTarget[nIndex].aspectType;
        if(aspectType == '1'){
        	
        	
        	var drawObj = CONTENTVIEW.adjustAspectRatio(tmpX, tmpY, tmpW, tmpH, imageObj.width, imageObj.height);
        	tmpX = drawObj.drawX;
        	tmpY = drawObj.drawY;
        	tmpW = drawObj.drawW;
        	tmpH = drawObj.drawH;
        	
        }

5474 5475
        contextObject.drawImage(imageObj, tmpX, tmpY, tmpW, tmpH);
        //contextObject.drawImage(imageObj, objTarget[nIndex].x, objTarget[nIndex].y, objTarget[nIndex].width, objTarget[nIndex].height);
5476

5477
        CONTENTVIEW.flip();
5478 5479 5480 5481
    };
    imageObj.src = objTarget[nIndex].dataObjects[nIndex1].fileName;
};

5482
CONTENTVIEW.imageToScreen = function(x, y) {
5483

5484 5485 5486
    //#11478
    var canvasWidth = $('#offscreen').width();
    var canvasHeight = $('#offscreen').height();
5487
    var tempRatioWidth = canvasWidth / CONTENTVIEW_GENERAL.widthEachPageApi;
5488 5489 5490
    if( tempRatioWidth < 1 ){
        tempRatioWidth = 1;
    }
5491
    var tempRatioHeight = canvasHeight / CONTENTVIEW_GENERAL.heightEachPageApi;
5492 5493 5494 5495 5496 5497
    if( tempRatioHeight < 1 ){
        tempRatioHeight = 1;
    }
    var tmpX = x *  tempRatioWidth;
    var tmpY = y * tempRatioHeight;

5498
    var pt = new CONTENTVIEW.Point(0, 0);
5499

5500
    // scale vertical and horizontal
5501 5502
    var sx = (CONTENTVIEW.destRect.right - CONTENTVIEW.destRect.left) / (CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left);
    var sy = (CONTENTVIEW.destRect.bottom - CONTENTVIEW.destRect.top) / (CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top);
5503

5504 5505
    pt.x = Math.round(sx * (tmpX - CONTENTVIEW.srcRect.left)) + CONTENTVIEW.destRect.left + CONTENTVIEW.marginX;
    pt.y = Math.round(sy * (tmpY - CONTENTVIEW.srcRect.top)) + CONTENTVIEW.destRect.top + CONTENTVIEW.marginY;
5506 5507 5508

    return pt;
};
5509
//Start Function : No.4 - Editor : Long - Date : 08/09/2013 - Summary :
5510
/* Adjust Component size */
5511
CONTENTVIEW.sizingNotFull = function(width, height) {
5512

5513
    //START TRB
5514
    if(CONTENTVIEW.isMediaAndHTMLContent()){
5515 5516 5517 5518

    }
    //END TRB
    else{
5519
        //adjust size of canvas using for draw
Masaru Abe committed
5520
        if (COMMON.isTouchDevice() == true) {
5521 5522 5523 5524
            $("#main").css('top', CONTENTVIEW.marginY);
            $("#main").attr('height', height - (CONTENTVIEW.marginY * 2))
              .attr('width', width - (CONTENTVIEW.marginX * 2));
            $("#mainNext").css('top', CONTENTVIEW.marginY);
5525 5526
            $("#mainPre").css('top', CONTENTVIEW.marginY);

5527 5528 5529
            $("#mainNext").attr('height', height - (CONTENTVIEW.marginY * 2))
              .attr('width', width - (CONTENTVIEW.marginX * 2))
              .css('left', width + CONTENTVIEW.marginX);
5530

5531 5532 5533
            $("#mainPre").attr('height', height - (CONTENTVIEW.marginY * 2))
              .attr('width', width - (CONTENTVIEW.marginX * 2))
              .css('left', - (width + CONTENTVIEW.marginX));
5534

5535
        } else {
5536 5537 5538
            $("#main").attr('height', height - (CONTENTVIEW.marginY * 2))
                  .attr('width', width - (CONTENTVIEW.marginX * 2))
                   .css('top', CONTENTVIEW.marginY);
5539

5540 5541 5542 5543
            $("#mainNext").attr('height', height - (CONTENTVIEW.marginY * 2))
              .attr('width', width - (CONTENTVIEW.marginX * 2))
               .css('top', CONTENTVIEW.marginY)
               .css('left', width + CONTENTVIEW.marginX);
5544

5545 5546 5547 5548
            $("#mainPre").attr('height', height - (CONTENTVIEW.marginY * 2))
              .attr('width', width - (CONTENTVIEW.marginX * 2))
               .css('top', CONTENTVIEW.marginY)
               .css('left', -(width + CONTENTVIEW.marginX));
5549

5550
        }
5551

5552 5553
        $("#draw_canvas").css('cursor', 'default');
        $("#marker_canvas").css('cursor', 'default');
5554

5555
        if (CONTENTVIEW.userScale != 1) {
5556
            CONTENTVIEW.changeScale(CONTENTVIEW.userScale);
5557
            CONTENTVIEW.flip();
5558
            //Start Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
5559
            if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
5560
                //START TRB00097
5561
                //CONTENTVIEW.flip(1);
5562 5563
                //END TRB00097
            }
5564

5565
            if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
5566
                //START TRB00097
5567
                //CONTENTVIEW.flip(2);
5568 5569 5570 5571
                //END TRB00097
            }
            //End Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
        }
5572

5573 5574 5575
        /* move image check marking*/
        $('#divCheckExistMarking').css('top', '70px');
        $('#divCheckExistMarking').show();
5576 5577 5578 5579

        /* move image check memo*/
        $('#divCheckExistMemo').css('top', '125px');
        $('#divCheckExistMemo').show();
5580
    }
5581 5582 5583
};

/* Adjust Component size */
5584
CONTENTVIEW.sizingFullSize = function(width, height) {
5585
    // adjust size of body
5586

5587
    //START TRB
5588
    if(CONTENTVIEW.isMediaAndHTMLContent()){
5589 5590 5591 5592

    }
    //END TRB
    else{
Masaru Abe committed
5593
        if (COMMON.isTouchDevice() == true) {
5594 5595
            $("#main").css('top', '0px');
            $("#main").attr('height', height)
5596
                       .attr('width', width - (CONTENTVIEW.marginX * 2));
5597

5598 5599
            $("#mainNext").css('top', '0px');
            $("#mainNext").attr('height', height)
5600
                       .attr('width', width - (CONTENTVIEW.marginX * 2));
5601

5602 5603
            $("#mainPre").css('top', '0px');
            $("#mainPre").attr('height', height)
5604
                       .attr('width', width - (CONTENTVIEW.marginX * 2));
5605 5606
        } else {
            $("#main").attr('height', height)
5607
                       .attr('width', width - (CONTENTVIEW.marginX * 2))
5608 5609
                       .css('top', '0px');
            $("#mainNext").attr('height', height)
5610
                        .attr('width', width - (CONTENTVIEW.marginX * 2))
5611 5612
                    .css('top', '0px');
            $("#mainPre").attr('height', height)
5613
                    .attr('width', width - (CONTENTVIEW.marginX * 2))
5614 5615
                .css('top', '0px');
        }
5616

5617
        //adjust size of canvas using for draw
5618

5619 5620
        $("#draw_canvas").css('cursor', 'default');
        $("#marker_canvas").css('cursor', 'default');
5621

5622
        if (CONTENTVIEW.userScale != 1) {
5623
            CONTENTVIEW.changeScale(CONTENTVIEW.userScale);
5624
            CONTENTVIEW.flip();
5625
            //Start Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
5626
            if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
5627
                //START TRB00097
5628
                //CONTENTVIEW.flip(1);
5629 5630
                //END TRB00097
            }
5631

5632
            if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
5633
                //START TRB00097
5634
                //CONTENTVIEW.flip(2);
5635
                //END TRB00097
5636

5637 5638 5639
            }
            //End Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
        }
5640

5641 5642 5643 5644 5645 5646 5647
        /* move image check marking*/
        $('#divCheckExistMarking').css('top', '5px');
        if (ClientData.IsAddingMarking() == true) {
            $('#divCheckExistMarking').hide();
        } else {
            $('#divCheckExistMarking').show();
        }
5648 5649 5650 5651 5652 5653 5654 5655

        /* move image check memo*/
        $('#divCheckExistMemo').css('top', '60px');
        if (ClientData.IsAddingMemo() == true) {
            $('#divCheckExistMemo').hide();
        } else {
            $('#divCheckExistMemo').show();
        }
5656
    }
5657
};
5658
//End Function : No.4 - Editor : Long - Date : 08/09/2013 - Summary :
5659
CONTENTVIEW.zoomVideo = function() {
5660 5661
    var objVideo = document.getElementsByTagName('video');
    if (objVideo.length > 0) {
5662 5663
        var pt1 = CONTENTVIEW.imageToScreen(CONTENTVIEW_GENERAL.pxVideo, CONTENTVIEW_GENERAL.pyVideo);
        var pt2 = CONTENTVIEW.imageToScreen(CONTENTVIEW_GENERAL.pxVideo + CONTENTVIEW_GENERAL.wVideo, CONTENTVIEW_GENERAL.pyVideo + CONTENTVIEW_GENERAL.hVideo);
5664

5665 5666 5667
        if (CONTENTVIEW_GENERAL.isFullScreen == true) {
            pt2.y = pt2.y - CONTENTVIEW.marginY;
            pt1.y = pt1.y - CONTENTVIEW.marginY;
5668 5669 5670 5671 5672 5673 5674 5675 5676 5677 5678 5679 5680
        }
        $('#playvideo').attr('z-order', '1000');

        $('#playvideo').css('left', pt1.x + 'px');
        $('#playvideo').css('top', pt1.y + 'px');

        $(objVideo[0]).attr('width', pt2.x - pt1.x);
        $(objVideo[0]).attr('height', pt2.y - pt1.y);
    }
};

// Adds ctx.getTransform() - returns an SVGMatrix
// Adds ctx.transformedPoint(x,y) - returns an SVGPoint
5681
CONTENTVIEW.trackTransforms = function(ctx) {
5682 5683 5684 5685 5686 5687 5688 5689 5690 5691 5692 5693 5694 5695 5696 5697 5698 5699 5700 5701 5702 5703 5704 5705 5706 5707 5708 5709 5710 5711 5712 5713 5714 5715 5716 5717 5718 5719 5720 5721 5722 5723 5724 5725 5726 5727 5728 5729 5730 5731 5732 5733
    var svg = document.createElementNS("http://www.w3.org/2000/svg", 'svg');
    var xform = svg.createSVGMatrix();
    ctx.getTransform = function () { return xform; };

    var savedTransforms = [];
    var save = ctx.save;
    ctx.save = function () {
        savedTransforms.push(xform.translate(0, 0));
        return save.call(ctx);
    };
    var restore = ctx.restore;
    ctx.restore = function () {
        xform = savedTransforms.pop();
        return restore.call(ctx);
    };

    var scale = ctx.scale;
    ctx.scale = function (sx, sy) {
        xform = xform.scaleNonUniform(sx, sy);
        return scale.call(ctx, sx, sy);
    };
    var rotate = ctx.rotate;
    ctx.rotate = function (radians) {
        xform = xform.rotate(radians * 180 / Math.PI);
        return rotate.call(ctx, radians);
    };
    var translate = ctx.translate;
    ctx.translate = function (dx, dy) {
        xform = xform.translate(dx, dy);
        return translate.call(ctx, dx, dy);
    };
    var transform = ctx.transform;
    ctx.transform = function (a, b, c, d, e, f) {
        var m2 = svg.createSVGMatrix();
        m2.a = a; m2.b = b; m2.c = c; m2.d = d; m2.e = e; m2.f = f;
        xform = xform.multiply(m2);
        return transform.call(ctx, a, b, c, d, e, f);
    };
    var setTransform = ctx.setTransform;
    ctx.setTransform = function (a, b, c, d, e, f) {
        xform.a = a;
        xform.b = b;
        xform.c = c;
        xform.d = d;
        xform.e = e;
        xform.f = f;
        return setTransform.call(ctx, a, b, c, d, e, f);
    };
    var pt = svg.createSVGPoint();
    ctx.transformedPoint = function (x, y) {
        pt.x = x; pt.y = y;
        return pt.matrixTransform(xform.inverse());
5734
    };
5735 5736 5737
};

/* zoomIn event */
5738
CONTENTVIEW.zoomIn = function() {
5739
    CONTENTVIEW.userScale += CONTENTVIEW.scaleDelta;
5740

5741
    if (CONTENTVIEW.userScale > 4) {
5742
        CONTENTVIEW.userScale = 4;
5743 5744
    }
    else {
5745
        CONTENTVIEW.changeScale(CONTENTVIEW.userScale);
5746

5747
        CONTENTVIEW.flip();
5748
        CONTENTVIEW.flip();
5749 5750

        //Start Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
5751
        if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
5752
            //START TRB00097
5753
            //CONTENTVIEW.flip(1);
5754 5755
            //END TRB00097
        }
5756

5757
        if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
5758
            //START TRB00097
5759
            //CONTENTVIEW.flip(2);
5760 5761 5762
            //END TRB00097
        }
        //End Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
5763

5764
        /* zoom video */
5765
        CONTENTVIEW.zoomVideo();
5766 5767
    }

5768
    CONTENTVIEW.checkDisableButtonZoom();
5769 5770

    /* close dialog popuptext */
5771
    CONTENTVIEW.closeDialogPopUpText();
5772 5773 5774
};

/* close dialog pop */
5775 5776
CONTENTVIEW.closeDialogPopUpText = function() {
    if (CONTENTVIEW_GENERAL.isOpenPopUpText == true) {
5777 5778
        CONTENTVIEW_GENERAL.isOpenPopUpText = false;
        CONTENTVIEW_POPUPTEXT.ClosePopupText();
5779 5780 5781
    }
};

5782 5783
CONTENTVIEW.checkDisableButtonZoom = function() {
    if (CONTENTVIEW.userScale >= 4) {
5784 5785 5786 5787 5788
        $('#zoomin').removeClass();
        $('#zoomin').addClass('expansion_off');
        $("#zoomin").css('cursor', 'default');
    } else {
        $('#zoomin').unbind('click');
5789
        $('#zoomin').bind('click', CONTENTVIEW.zoomIn);
5790 5791

        $('#zoomin').removeClass();
Masaru Abe committed
5792
        if (COMMON.isTouchDevice() == true) {
5793 5794 5795 5796 5797 5798 5799
            $('#zoomin').addClass('expansion_device');
        } else {
            $('#zoomin').addClass('expansion');
        }
        $("#zoomin").css('cursor', 'pointer');
    }

5800
    if (CONTENTVIEW.userScale <= 1) {
5801 5802 5803 5804 5805
        $('#zoomout').removeClass();
        $('#zoomout').addClass('reduction_off');
        $("#zoomout").css('cursor', 'default');
    } else {
        $('#zoomout').unbind('click');
5806
        $('#zoomout').bind('click', CONTENTVIEW.zoomOut);
5807 5808

        $('#zoomout').removeClass();
Masaru Abe committed
5809
        if (COMMON.isTouchDevice() == true) {
5810 5811 5812 5813 5814 5815 5816
            $('#zoomout').addClass('reduction_device');
        } else {
            $('#zoomout').addClass('reduction');
        }
        $("#zoomout").css('cursor', 'pointer');
    }

5817
    if (CONTENTVIEW.userScale == 1) {
5818 5819 5820 5821 5822
        $('#zoomfit').removeClass();
        $('#zoomfit').addClass('fit_off');
        $("#zoomfit").css('cursor', 'default');
    } else {
        $('#zoomfit').unbind('click');
5823
        $('#zoomfit').bind('click', CONTENTVIEW.screenFit);
5824 5825

        $('#zoomfit').removeClass();
Masaru Abe committed
5826
        if (COMMON.isTouchDevice() == true) {
5827 5828 5829 5830 5831 5832 5833 5834 5835
            $('#zoomfit').addClass('fit_device');
        } else {
            $('#zoomfit').addClass('fit');
        }
        $("#zoomfit").css('cursor', 'pointer');
    }
};

/* zoomOut event */
5836
CONTENTVIEW.zoomOut = function() {
5837
    CONTENTVIEW.userScale -= CONTENTVIEW.scaleDelta;
5838
    if (CONTENTVIEW.userScale < 1) {
5839
        CONTENTVIEW.userScale = 1;
5840
    } else {
5841
        CONTENTVIEW.changeScale(CONTENTVIEW.userScale);
5842

5843
        CONTENTVIEW.flip();
5844
        CONTENTVIEW.flip();
5845

5846
        //Start Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
5847
        if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
5848
            //START TRB00097
5849
            //CONTENTVIEW.flip(1);
5850 5851
            //END TRB00097
        }
5852

5853
        if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
5854
            //START TRB00097
5855
            //CONTENTVIEW.flip(2);
5856 5857 5858
            //END TRB00097
        }
        //End Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
5859

5860 5861

        /* zoom video */
5862
        CONTENTVIEW.zoomVideo();
5863 5864
    }

5865
    CONTENTVIEW.checkDisableButtonZoom();
5866 5867

    /* close dialog popuptext */
5868
    CONTENTVIEW.closeDialogResize();
5869 5870
};

5871 5872 5873 5874 5875 5876 5877 5878 5879 5880 5881 5882 5883 5884
CONTENTVIEW.rotateR = function() {

    if($('#rotatebtnR').attr('angle') == '0'){
        $('#rotatebtnR').attr('angle', '90');
    }else if($('#rotatebtnR').attr('angle') == '90'){
        $('#rotatebtnR').attr('angle', '180');
    }else if($('#rotatebtnR').attr('angle') == '180'){
        $('#rotatebtnR').attr('angle', '-90');
    }else{
        $('#rotatebtnR').attr('angle', '0');
    }

    //CONTENTVIEW.srcRect.width = 0;

5885 5886 5887
    if($('#rotatebtnR').attr('angle') != '0'){
        if(document.getElementById('videoOnPage')){
            var videoObj = document.getElementById('videoOnPage');
5888 5889
            if(videoObj.parentNode)
            videoObj.parentNode.removeChild(videoObj);
5890
        }
5891 5892 5893 5894 5895 5896 5897 5898 5899 5900 5901 5902 5903 5904 5905 5906
        if(document.getElementById("play_audio_0")){
            document.getElementById("play_audio_0").pause();
        }
        if(document.getElementById("play_audio_1")){
            document.getElementById("play_audio_1").pause();
        }
        if(document.getElementById("play_audio_2")){
            document.getElementById("play_audio_2").pause();
        }

    }else{
        if(document.getElementById("play_audio_2")){
            document.getElementById("play_audio_2").play();
        }else if(document.getElementById("play_audio_1")){
            document.getElementById("play_audio_1").play();
        }
5907 5908
    }

5909 5910 5911 5912 5913 5914 5915 5916 5917 5918 5919 5920 5921 5922 5923 5924 5925 5926 5927 5928 5929 5930 5931
    CONTENTVIEW.changePageWithoutSlide($("#txtSlider").val() - 1);

    CONTENTVIEW.changeScale(CONTENTVIEW.userScale);

    CONTENTVIEW.flip();

    /* close dialog popuptext */
    CONTENTVIEW.closeDialogPopUpText();
};

CONTENTVIEW.rotateL = function() {

    if($('#rotatebtnR').attr('angle') == '0'){
        $('#rotatebtnR').attr('angle', '-90');
    }else if($('#rotatebtnR').attr('angle') == '-90'){
        $('#rotatebtnR').attr('angle', '180');
    }else if($('#rotatebtnR').attr('angle') == '180'){
        $('#rotatebtnR').attr('angle', '90');
    }else{
        $('#rotatebtnR').attr('angle', '0');
    }

    //CONTENTVIEW.srcRect.width = 0;
5932

5933 5934 5935
    if($('#rotatebtnR').attr('angle') != '0'){
        if(document.getElementById('videoOnPage')){
            var videoObj = document.getElementById('videoOnPage');
5936 5937
            if(videoObj.parentNode)
            videoObj.parentNode.removeChild(videoObj);
5938
        }
5939 5940 5941 5942 5943 5944 5945 5946 5947 5948 5949 5950 5951 5952 5953 5954
        if(document.getElementById("play_audio_0")){
            document.getElementById("play_audio_0").pause();
        }
        if(document.getElementById("play_audio_1")){
            document.getElementById("play_audio_1").pause();
        }
        if(document.getElementById("play_audio_2")){
            document.getElementById("play_audio_2").pause();
        }

    }else{
        if(document.getElementById("play_audio_2")){
            document.getElementById("play_audio_2").play();
        }else if(document.getElementById("play_audio_1")){
            document.getElementById("play_audio_1").play();
        }
5955
    }
5956 5957 5958 5959 5960 5961 5962 5963 5964 5965 5966 5967 5968

    CONTENTVIEW.changePageWithoutSlide($("#txtSlider").val() - 1);

    CONTENTVIEW.changeScale(CONTENTVIEW.userScale);

    CONTENTVIEW.flip();

    /* close dialog popuptext */
    CONTENTVIEW.closeDialogPopUpText();
};

CONTENTVIEW.checkDisableButtonRotate = function() {
    
5969
    if($('#rotatebtnR').attr('angle') != '0'){
5970 5971 5972 5973 5974 5975 5976 5977 5978 5979 5980 5981 5982 5983 5984 5985 5986 5987 5988 5989
        $('#imgmemo').unbind('click');
        $('#imgmemo').removeClass();
        $('#imgmemo').addClass('memoDisplay_off');

        /* image add memo */
        $('#imgaddmemo').unbind('click');
        $('#imgaddmemo').removeClass();
        $('#imgaddmemo').addClass('memoAdd_off');

        $('#imgmarking').unbind('click');
        $('#imgmarking').removeClass();
        $('#imgmarking').addClass('marking_off');

        $('#imgmarkingtoolbar').unbind('click');
        $('#imgmarkingtoolbar').removeClass();
        $('#imgmarkingtoolbar').addClass('markingToolbar_off');
    }
};


5990
/* restore screen size */
5991
CONTENTVIEW.screenFit = function() {
5992 5993

    var canvas = document.getElementById('main');
5994
    var offScreen = document.getElementById('offscreen');
5995 5996 5997 5998
    CONTENTVIEW_GENERAL.context_main.clearRect(0, 0, CONTENTVIEW_GENERAL.canvas_main.width, CONTENTVIEW_GENERAL.canvas_main.height);
    CONTENTVIEW.srcRect = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, offScreen.width, offScreen.height);
    CONTENTVIEW.userScale = 1;
    CONTENTVIEW.userScaleNow = 1;
5999

6000 6001
    CONTENTVIEW.moveX = 0;
    CONTENTVIEW.moveY = 0;
6002

6003
    CONTENTVIEW.flip();
6004

6005
    //Start Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
6006
    if(CONTENTVIEW_GETDATA.getPageIndex() < CONTENTVIEW_GENERAL.totalPage - 1){
6007
        CONTENTVIEW.flip(1);
6008
    }
6009

6010
    if(CONTENTVIEW_GETDATA.getPageIndex() > 0){
6011
        CONTENTVIEW.flip(2);
6012 6013
    }
    //End Function : No.4 - Editor : Long - Date : 08/13/2013 - Summary : Fix for zooming
6014

6015
    /* zoom video */
6016
    CONTENTVIEW.zoomVideo();
6017

6018
    CONTENTVIEW.checkDisableButtonZoom();
6019 6020

    /* close dialog popuptext */
6021
    CONTENTVIEW.closeDialogResize();
6022 6023 6024
};

/* change Scale screen*/
6025
CONTENTVIEW.changeScale = function(scale) {
Masaru Abe committed
6026 6027 6028

    //拡大か判定
    var isZoom = false;
6029
    if( CONTENTVIEW.userScaleNow < scale ){
Masaru Abe committed
6030 6031
        isZoom = true;
    }
6032
    CONTENTVIEW.userScaleNow = scale;
Masaru Abe committed
6033

6034 6035 6036
    var canvas = document.getElementById('main');
    var offScreen = document.getElementById('offscreen');

6037
    var sc = CONTENTVIEW.srcRect.center();
6038 6039 6040 6041 6042 6043 6044

    var sw = offScreen.width, sh = offScreen.height;

    var width = offScreen.width;
    var height = offScreen.height;
    var aspect = offScreen.width / offScreen.height;

6045 6046 6047
    if($(rotatebtnR).attr('angle') == '90' || $(rotatebtnR).attr('angle') == '-90'){
        sw = offScreen.height;
        sh = offScreen.width;
6048

6049
        aspect = offScreen.height / offScreen.width;
6050

6051
        if (canvas.width > canvas.height) {
6052

6053 6054 6055 6056 6057 6058 6059 6060 6061 6062
            width = canvas.height;
            height = width * aspect;
            /*if(width > canvas.width) {
            width = canvas.width;
            height = width / aspect;
            }*/
        } else {
            height = canvas.width;
            width = height / aspect;
        }
6063

6064 6065 6066 6067 6068 6069 6070 6071 6072 6073 6074 6075 6076 6077
        if (width > canvas.height) {

            var size = canvas.height / height;
            height = canvas.height;
            width = width * size;
        }

        if (height > canvas.width) {
            var size = canvas.width / width;
            width = canvas.width;
            height = height * size;
        }

        if (height < canvas.width) {
6078
            aspect = offscreen.height / offscreen.width;
6079 6080 6081
            if(offScreen.width < offScreen.height){
                height = height * scale * aspect;
            }else{
6082
                height = height * scale;
6083 6084 6085 6086 6087 6088 6089 6090 6091 6092 6093 6094 6095 6096 6097 6098 6099 6100 6101 6102 6103 6104
            }
            //height = height * scale;
            if (height > canvas.width) {

                sh /= scale;
                sw = sh / (canvas.height / canvas.width);

            } else {
                sh /= scale;
            }

            //}else if(height <= canvas.height){
        } else if (width < canvas.height) {

            width = width * scale;

            if (height > canvas.height) {
                sw /= scale;
                sh = sw / (canvas.width / canvas.height);
            } else {
                sw /= scale;
            }
6105 6106 6107

        } else {
            sh /= scale;
6108
            sw /= scale;
6109 6110
        }

6111 6112 6113 6114 6115 6116
        CONTENTVIEW.srcRect.top = sc.y - Math.round(sw / 2);
        CONTENTVIEW.srcRect.left = sc.x - Math.round(sh / 2);
        CONTENTVIEW.srcRect.bottom = Math.round(CONTENTVIEW.srcRect.left + sw);
        CONTENTVIEW.srcRect.right = Math.round(CONTENTVIEW.srcRect.top + sh);
        CONTENTVIEW.srcRect.width = CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left;
        CONTENTVIEW.srcRect.height = CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top;
6117

6118 6119 6120 6121 6122 6123 6124 6125 6126 6127 6128 6129 6130 6131 6132 6133 6134 6135 6136 6137 6138 6139 6140 6141 6142
        if(scale == 1){
            sw = offScreen.width, sh = offScreen.height;

            CONTENTVIEW.srcRect.left = sc.x - Math.round(sw / 2);
            CONTENTVIEW.srcRect.top = sc.y - Math.round(sh / 2);
            CONTENTVIEW.srcRect.right = Math.round(CONTENTVIEW.srcRect.left + sw);
            CONTENTVIEW.srcRect.bottom = Math.round(CONTENTVIEW.srcRect.top + sh);
            CONTENTVIEW.srcRect.width = CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left;
            CONTENTVIEW.srcRect.height = CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top;
    
        }

    }else{

        if (canvas.width > canvas.height) {
            height = canvas.height;
            width = height * aspect;
            /*if(width > canvas.width) {
            width = canvas.width;
            height = width / aspect;
            }*/
        } else {
            width = canvas.width;
            height = width / aspect;
        }
6143 6144

        if (height > canvas.height) {
6145 6146 6147 6148 6149 6150 6151 6152 6153 6154 6155 6156
            var size = canvas.height / height;
            height = canvas.height;
            width = width * size;
        }

        if (width > canvas.width) {
            var size = canvas.width / width;
            width = canvas.width;
            height = height * size;
        }

        if (width < canvas.width) {
6157

6158 6159 6160 6161 6162 6163 6164 6165 6166 6167 6168 6169 6170 6171 6172 6173 6174 6175 6176 6177 6178 6179 6180 6181
            //if(width >= height){
            width = width * scale;

            if (width > canvas.width) {
                sw /= scale;
                sh = sw / (canvas.width / canvas.height);

            } else {
                sh /= scale;
            }

            //}else if(height <= canvas.height){
        } else if (height < canvas.height) {

            height = height * scale;

            if (height > canvas.height) {
                sh /= scale;
                sw = sh / (canvas.height / canvas.width);


            } else {
                sw /= scale;
            }
6182 6183

        } else {
6184
            sh /= scale;
6185 6186 6187
            sw /= scale;
        }

6188 6189 6190 6191 6192 6193
        CONTENTVIEW.srcRect.left = sc.x - Math.round(sw / 2);
        CONTENTVIEW.srcRect.top = sc.y - Math.round(sh / 2);
        CONTENTVIEW.srcRect.right = Math.round(CONTENTVIEW.srcRect.left + sw);
        CONTENTVIEW.srcRect.bottom = Math.round(CONTENTVIEW.srcRect.top + sh);
        CONTENTVIEW.srcRect.width = CONTENTVIEW.srcRect.right - CONTENTVIEW.srcRect.left;
        CONTENTVIEW.srcRect.height = CONTENTVIEW.srcRect.bottom - CONTENTVIEW.srcRect.top;
6194

6195
    }
Masaru Abe committed
6196
    if( isZoom ){
6197

6198 6199
        //var tempRatioWidth = offScreen.width / CONTENTVIEW_GENERAL.widthEachPageApi;
        var tempRatioWidth = CONTENTVIEW_GENERAL.widthEachPageApi / offScreen.width;
Masaru Abe committed
6200 6201 6202
            if( tempRatioWidth > 1 ){
                tempRatioWidth = 1;
            }
6203 6204
        //var tempRatioHeight = offScreen.height / CONTENTVIEW_GENERAL.heightEachPageApi;
        var tempRatioHeight = CONTENTVIEW_GENERAL.heightEachPageApi / offScreen.height;
Masaru Abe committed
6205 6206 6207
        if( tempRatioHeight > 1 ){
            tempRatioHeight = 1;
        }
6208 6209


Masaru Abe committed
6210 6211
        var tmpX = 0;
        var tmpY = 0;
6212 6213
        if( CONTENTVIEW.srcRect.top > 0 ){
            tmpX = Math.round(CONTENTVIEW.srcRect.top * tempRatioWidth);
Masaru Abe committed
6214
        }
6215 6216
        if( CONTENTVIEW.srcRect.left > 0 ){
            tmpY = Math.round(CONTENTVIEW.srcRect.left * tempRatioHeight);
Masaru Abe committed
6217
        }
6218

6219 6220
        var tmpW = Math.round(CONTENTVIEW.srcRect.width * tempRatioWidth);
        var tmpH = Math.round(CONTENTVIEW.srcRect.height * tempRatioHeight);
6221

Masaru Abe committed
6222 6223
        var zoomX = tmpX + Math.round( tmpH / 2 );
        var zoomY = tmpY + Math.round( tmpW / 2 );
6224

Masaru Abe committed
6225
        //console.log("tempRatio.width:height " + tempRatioWidth + "," + tempRatioHeight);
6226 6227
        //console.log("CONTENTVIEW.srcRect.left:top " + CONTENTVIEW.srcRect.left + "," + CONTENTVIEW.srcRect.top);
        //console.log("CONTENTVIEW.srcRect.width:height " + CONTENTVIEW.srcRect.width + "," + CONTENTVIEW.srcRect.height);
Masaru Abe committed
6228 6229 6230
        //console.log("tmpX.Y " + tmpX + "," + tmpY);
        //console.log("tmpW.H " + tmpW + "," + tmpH);
        //console.log("zoomX.Y " + zoomX + "," + zoomY);
6231

Masaru Abe committed
6232 6233
        //詳細ログ作成
        var objectLog = new ObjectLogEntity();
6234 6235
        objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
        objectLog.pageNo = CONTENTVIEW_GETDATA.getPageIndex() + 1; //0始まりのページ番号
Masaru Abe committed
6236 6237 6238 6239 6240 6241 6242 6243 6244 6245 6246
        objectLog.objectId = 0;
        objectLog.resourceId = "";
        objectLog.mediaType = "";
        objectLog.actionType = "101"; //拡大アクション定数
        objectLog.actionValue = "";
        objectLog.actionTime = "0";
        objectLog.locationX = zoomX;
        objectLog.locationY = zoomY;
        objectLog.locationHeight = "";
        objectLog.locationWidth = "";
        objectLog.eventType = "5"; //暫定でピンチアウト
6247
        COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
Masaru Abe committed
6248 6249
        //---
    }
6250

6251 6252 6253
};

//Start Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary :
6254
CONTENTVIEW.is3DObject = function(pageContent){
6255 6256 6257 6258 6259 6260 6261 6262
    var result = false;
    if(pageContent == null || pageContent == undefined){
        result = false;
    }
    else{
        if(pageContent.actionType == 9 && pageContent.mediaType == 8){
            result = true;
        }
6263
    }
6264 6265
    return result;
};
6266
//End Function : No.9 - Editor : Long - Date : 08/16/2013 - Summary :
Masaru Abe committed
6267

Masaru Abe committed
6268 6269
//コンテンツ差し替えで最大ページ数を超えるデータは削除
CONTENTVIEW.deleteMaxPageOverData = function() {
6270

6271 6272 6273
    if( CONTENTVIEW_GENERAL.totalPage == 0 ){
        return;
    }
6274

6275 6276 6277 6278 6279 6280 6281 6282 6283 6284 6285 6286 6287 6288 6289 6290 6291 6292 6293 6294 6295 6296
    var removeFlag = false;
    //bookmark
    var listBM = [];
    if (ClientData.BookMarkData().length > 0) {
        //get list bookmark
        listBM = ClientData.BookMarkData();
        for(var tmpIndex=0;tmpIndex<10000;tmpIndex++){
            removeFlag = false;
            for (var nIndex = 0; nIndex < listBM.length; nIndex++) {
                //check bookmark belong contentID
                if (listBM[nIndex].contentid == CONTENTVIEW_GENERAL.contentID && listBM[nIndex].pageNo > CONTENTVIEW_GENERAL.totalPage ) {
                    //console.log("remove bookmark:" + CONTENTVIEW_GENERAL.contentID + " p:" + listBM[nIndex].pageNo);
                    listBM.splice(nIndex, 1);
                    removeFlag = true;
                    break;
                }
            }
            if( !removeFlag ){
                break;
            }
        }
        ClientData.BookMarkData(listBM);
6297

6298
    }
6299

6300 6301 6302 6303 6304 6305 6306 6307 6308 6309 6310 6311 6312 6313 6314 6315 6316 6317 6318 6319 6320 6321 6322 6323 6324 6325 6326 6327 6328 6329 6330 6331 6332 6333 6334 6335 6336 6337 6338 6339 6340 6341 6342 6343 6344
    //memo
    var listMemo = [];
    if (ClientData.MemoData().length > 0) {
        //get list memo
        listMemo = ClientData.MemoData();
        for(var tmpIndex=0;tmpIndex<10000;tmpIndex++){
            removeFlag = false;
            for (var nIndex = 0; nIndex < listMemo.length; nIndex++) {
                //check memo belong contentID
                if (listMemo[nIndex].contentid == CONTENTVIEW_GENERAL.contentID && listMemo[nIndex].pageNo > CONTENTVIEW_GENERAL.totalPage ) {
                    //console.log("remove memo:" + CONTENTVIEW_GENERAL.contentID + " p:" + listMemo[nIndex].pageNo);
                    listMemo.splice(nIndex, 1);
                    removeFlag = true;
                    break;
                }
            }
            if( !removeFlag ){
                break;
            }
        }
        ClientData.MemoData(listMemo);
    }

    //marking
    var listMarking = [];
    if (ClientData.MarkingData().length > 0) {
        //get list marking
        listMarking = ClientData.MarkingData();
        for(var tmpIndex=0;tmpIndex<10000;tmpIndex++){
            removeFlag = false;
            for (var nIndex = 0; nIndex < listMarking.length; nIndex++) {
                //check memo belong contentID
                if (listMarking[nIndex].contentid == CONTENTVIEW_GENERAL.contentID && listMarking[nIndex].pageNo > CONTENTVIEW_GENERAL.totalPage ) {
                    //console.log("remove memo:" + CONTENTVIEW_GENERAL.contentID + " p:" + listMarking[nIndex].pageNo);
                    listMarking.splice(nIndex, 1);
                    removeFlag = true;
                    break;
                }
            }
            if( !removeFlag ){
                break;
            }
        }
        ClientData.MarkingData(listMarking);
    }
6345

Masaru Abe committed
6346 6347
};

6348
CONTENTVIEW.cssInit = function(){
6349 6350 6351 6352 6353 6354 6355 6356 6357 6358 6359 6360 6361 6362 6363 6364 6365 6366 6367 6368 6369 6370 6371
    //CSS
    $('html').css({
        'overflow-y':'',
        'overflow': 'hidden'
        });
    $('html,body').css({
        'height':'100%',
        'width':'100%',
        'margin':'',
        'padding':''
        });
    $('html>body').css({
        'font-size':''
        });
    $('body').css({
        'font-family': '"メイリオ", "Meiryo", "ヒラギノ角ゴ Pro W3", "Hiragino Kaku Gothic Pro", "MS Pゴシック", "MS P Gothic", "Osaka", Verdana, Arial, Helvetica, sans-serif',
        'font-size':'',
        'background':'#898989',
        'background-image':'url(./img/viewer/article_bg.png)',
        'color':'',
        'margin':'0',
        'padding':'0'
        });
6372 6373 6374
};

CONTENTVIEW.screenMove = function(){
6375 6376
    CONTENTVIEW.initScreen();
    CONTENTVIEW.ready();
6377 6378 6379 6380 6381
};

//戻る処理
CONTENTVIEW.screenBack = function(){

6382 6383 6384 6385 6386 6387 6388 6389 6390 6391 6392 6393 6394 6395 6396 6397 6398 6399 6400 6401 6402 6403 6404 6405 6406 6407 6408 6409 6410 6411 6412 6413 6414 6415 6416 6417 6418 6419 6420 6421 6422 6423 6424 6425 6426 6427 6428 6429 6430 6431
    //後始末
    CONTENTVIEW.initScreen();

    $("#viewer").hide();
    if( $('#bookshelf').length || $('#list').length ){
        HOME.cssInit();
        $("#header-ws").show();
        $("#ws-body").show();
        $("#topcontrol").show();
        document.title = I18N.i18nText('dspHome') + ' | ' + I18N.i18nText('sysAppTitle');
        //console.log("back HOME.scrollTop:" + HOME.scrollTop);
        //元の位置に戻す
        window.scrollTo(0,HOME.scrollTop);

    } else if( $('#bookmark').length ){
        BOOKMARK.cssInit();
        $("#header-ws").show();
        $("#ws-body").show();
        $("#topcontrol").show();
        document.title = I18N.i18nText('dspShiori') + ' | ' + I18N.i18nText('sysAppTitle');
        //元の位置に戻す
        window.scrollTo(0,BOOKMARK.scrollTop);
        BOOKMARK.refreshView();

    } else if( $('#history').length ){

        HISTORY.cssInit();
        $("#header-ws").show();
        $("#ws-body").show();
        $("#topcontrol").show();
        document.title = I18N.i18nText('dspViewHistory') + ' | ' + I18N.i18nText('sysAppTitle');
        //元の位置に戻す
        window.scrollTo(0,HISTORY.scrollTop);

    } else if( $('#contentsearch').length ){
        CONTENTSEARCH.cssInit();
        $("#header-ws").show();
        $("#ws-body").show();
        $("#topcontrol").show();
         document.title = I18N.i18nText('txtSearchResult') + ' | ' + I18N.i18nText('sysAppTitle');
        //元の位置に戻す
        window.scrollTo(0,CONTENTSEARCH.scrollTop);

    }
    //プッシュメッセージ再開
    // check new push message
    if (COMMON.isAnonymousLogin() == false ) {
        // continue check new push message
        setTimeout(HEADER.getPushMessageNew, HEADER.getTimeWaitCheckNewPushMessage());
    }
6432

6433 6434
    $('#rotatebtnR').attr('angle', '0');

6435 6436
};

6437
CONTENTVIEW.initScreen = function(){
6438

6439 6440 6441 6442 6443 6444 6445 6446 6447 6448 6449 6450 6451 6452 6453 6454 6455 6456 6457 6458
    //画面初期化
    if($('#canvasWrapper').length){
        $('#main').empty();
    }
    if($('#dialog').length){
        $('#dialog').hide();
        $('#dialog').empty();
        $('#dialog').removeClass();
        $('#dialog').removeAttr('style');
        //$('#dialog').attr('style', 'width:');
        $('#dialog').addClass('web_dialog');
    }
    $('#header_toolbar').show();
    $('#txtSearch').val('');
    $('#divCheckExistMarking').hide();
    $('#divCheckExistMemo').hide();
    $('#divCacheLoading').hide();
    $('#overlay').hide();
    $('#dialogPopUp').hide();
    $('#arrow').hide();
6459

6460
    $("#wrapper *").unbind("click");
6461

6462 6463
};

6464
$(function () {
6465
    //CONTENTVIEW.ready();
6466 6467
});

6468
CONTENTVIEW.ready = function(initContentId){
6469

6470 6471 6472 6473 6474 6475 6476 6477 6478 6479 6480 6481 6482 6483 6484 6485 6486 6487 6488 6489 6490 6491
    CONTENTVIEW_CALLAPI.ready();
    CONTENTVIEW_EVENTS.ready();
    CONTENTVIEW_GETDATA.ready();
    CONTENTVIEW_INITOBJECT.ready();
    CONTENTVIEW_CREATEOBJECT.ready();
    CONTENTVIEW_GENERAL.ready(initContentId);
    CONTENTVIEW_MEMO.ready();
    CONTENTVIEW_GOMU.ready();
    CONTENTVIEW_MAKER.ready();
    CONTENTVIEW_PEN.ready();
    CONTENTVIEW_MARKING.ready();
    CONTENTVIEW_POPUPTEXT.ready();
    CONTENTVIEW_PAINT.ready();
    CONTENTVIEW_ANKET.ready();
    CONTENTVIEW_3D.ready();
    CONTENTVIEW_CONTENTTYPENONE.ready();
    CONTENTVIEW_IMAGEPREVIEW.ready();
    //CONTENTVIEW_FILESYSTEM.ready();

    CONTENTVIEW.isPendingContentBGM = false;
    CONTENTVIEW.isZoomingContent = false;
    CONTENTVIEW.isShowVideoContent = false;
6492

6493 6494 6495 6496 6497 6498 6499 6500 6501 6502 6503 6504 6505 6506 6507 6508 6509 6510 6511 6512 6513 6514 6515 6516 6517 6518 6519 6520 6521 6522 6523 6524 6525 6526 6527 6528 6529 6530 6531 6532 6533 6534 6535 6536 6537 6538
    /* init variable */
    CONTENTVIEW.content = new CONTENTVIEW_CREATEOBJECT.Content();
    CONTENTVIEW.srcRect = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
    CONTENTVIEW.destRect = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
    //START TRB00097
    CONTENTVIEW.srcRectNext = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
    CONTENTVIEW.srcRectPrev = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
    CONTENTVIEW.destRectNext = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
    CONTENTVIEW.destRectPrev = new CONTENTVIEW_CREATEOBJECT.Rect(0, 0, 0, 0);
    //END TRB00097
    CONTENTVIEW.moveX = 0;
    CONTENTVIEW.moveY = 0;
    CONTENTVIEW.userScale = 1;
    CONTENTVIEW.userScaleNow = 1;
    CONTENTVIEW.scaleDelta = 0.5;
    CONTENTVIEW.scaleX;
    CONTENTVIEW.scaleY;
    CONTENTVIEW.objType4_5 = [];

    CONTENTVIEW.moveFlag = false;
    CONTENTVIEW.cancelClick = false;

    CONTENTVIEW.isExistDrawing = false;

    CONTENTVIEW.leftCanvas = 0;
    CONTENTVIEW.topCanvas = 0;

    CONTENTVIEW.srcAudioType0 = '';
    CONTENTVIEW.TypeAudio0;
    CONTENTVIEW.srcAudioType1 = '';
    CONTENTVIEW.TypeAudio1;
    CONTENTVIEW.srcAudioType2 = '';
    CONTENTVIEW.TypeAudio2;

    CONTENTVIEW.scaleFactor = 1.1;

    /**
    * constants
    */
    if(ClientData.isStreamingMode() || (CONTENTVIEW_GENERAL.avwUserEnvObj.isMobile() && ClientData.isGetitsMode())){
        CONTENTVIEW.marginX = 13;
        CONTENTVIEW.marginY = 5;
    } else {
        CONTENTVIEW.marginX = 13;
        CONTENTVIEW.marginY = 65;
    }
6539

6540 6541 6542 6543 6544 6545 6546 6547 6548 6549
    if(COMMON.isAuthoringPreview() && CONTENTVIEW_GENERAL.pid != ''){
        //プレビューモード
    } else {
        /* check login */
        if (!AVWEB.avwCheckLogin(COMMON.ScreenIds.Login)) return;
        // Set event to prevent leave
        COMMON.ToogleLogoutNortice();
        //START TRB00048 - EDITOR : Long - Date : 09/18/2013 - Summary : Fix Jumpcontent
        CONTENTVIEW_GETDATA.getContentID();
    }
Masaru Abe committed
6550
    var params = {
6551 6552 6553 6554
            contentId: CONTENTVIEW_GENERAL.contentID,
            sid: CONTENTVIEW.getSessionId(),
            getType: 1,
            isStreaming: ClientData.isStreamingMode()
Masaru Abe committed
6555
    };
vietdo committed
6556

Masaru Abe committed
6557 6558 6559 6560
    AVWEB.avwCmsApi(ClientData.userInfo_accountPath(),
         "webGetContent",
         "GET",
         params,
6561
         function (data) {
Masaru Abe committed
6562
        	 CONTENTVIEW_GENERAL.contentType = data.contentData.contentType;
Masaru Abe committed
6563 6564 6565 6566 6567 6568 6569
        	 if(ClientData.isStreamingMode()){
        		 //リンク、その他は表示出来ないのでここでブロックする
        		 if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Link || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Others){
	            	 CONTENTVIEW.showAlertScreen(I18N.i18nText('msgStreamingOpenError'), null);
	        		 return;
        		 }
        	 }
6570

Masaru Abe committed
6571
            if (CONTENTVIEW_GENERAL.avwUserEnvObj.isIos()) {
6572

6573 6574 6575 6576 6577 6578 6579
                if(ClientData.isStreamingMode() || CONTENTVIEW_GENERAL.avwUserEnvObj.isIphone()){
                    //iPhoneの場合はデフォルトのviewportのほうが良いみたい
                    //ClientData.IsRefresh(true);
                } else {
                    //ストリーミング対応以外では元の設定活かす
                    CONTENTVIEW.setViewportForTouchDevice();
                }
6580

Masaru Abe committed
6581
                if (ClientData.IsRefresh() == true) {
Masaru Abe committed
6582 6583 6584 6585 6586 6587
                    //Check if is pdf content
                    if(CONTENTVIEW.isMediaAndHTMLContent()){
                    	CONTENTVIEW_INITOBJECT.initPageMediaAndHtmlType();
                        document.title = data.contentData.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                    }
                    else{
6588
                        CONTENTVIEW_INITOBJECT.initPage();
Masaru Abe committed
6589
                    }
6590

Masaru Abe committed
6591
                    //ストリーミングならデバイス側に初期表示済通知
6592 6593 6594
                    if(ClientData.isStreamingMode()){
                        CONTENTVIEW_STREAMING.initPageView();
                    }
6595

Masaru Abe committed
6596
                } else {
6597 6598 6599 6600
                    //この処理がないと初回画面描画が出来ない けど点滅する
                    $('body, html').hide();
                    ClientData.IsRefresh(true);
                    location.reload();
Masaru Abe committed
6601 6602 6603 6604 6605
                }
            }
            else {
                //Check if is pdf content
                if(CONTENTVIEW.isMediaAndHTMLContent()){
6606
                    CONTENTVIEW_INITOBJECT.initPageMediaAndHtmlType();
6607 6608 6609 6610

                    //START TRB00059 - EDITOR: Long - Date : 09/19/2013 - Summary : Add title for media and html type
                    document.title = data.contentData.contentName + ' | ' + I18N.i18nText('sysAppTitle');
                    //END TRB00059 - EDITOR: Long - Date : 09/19/2013 - Summary : Add title for media and html type
Masaru Abe committed
6611 6612
                }
                else{
Masaru Abe committed
6613
                    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Exam || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Enquete) {
6614
                        var isShowResult, isSendResult;
Masaru Abe committed
6615
                        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Exam) {
6616 6617 6618 6619 6620 6621 6622 6623 6624 6625 6626 6627 6628
                            if(data.contentData.showResult == 1){
                                isShowResult = true;
                            } else {
                                isShowResult = false;
                            }
                            if(data.contentData.sendResult == 1){
                                isSendResult = true;
                            } else {
                                isSendResult = false;
                            }
                        }
                        var contentId = data.contentData.contentId;
                        var url;
Masaru Abe committed
6629
                        if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_Exam){
6630 6631 6632 6633 6634 6635 6636 6637 6638 6639 6640 6641 6642 6643 6644 6645 6646 6647 6648 6649 6650 6651 6652 6653 6654
                            url = CONTENTVIEW_GETDATA.getURLPageImage("webEnqueteReply/init") + "&abObjectId=&sid=" + CONTENTVIEW.getSessionId()+"&contentId="+contentId+"&isShowResult="+isShowResult+"&isSendResult="+isSendResult;
                        } else {
                            url = CONTENTVIEW_GETDATA.getURLPageImage("webEnqueteReply/init") + "&abObjectId=&sid=" + CONTENTVIEW.getSessionId()+"&contentId="+contentId;
                        }
                        /* init footer toolbar */
                        $('#footer_toolbar_2').hide();
                        $('#footer_toolbar_1').show();

                        /* init pos bottom toolbar*/
                        CONTENTVIEW_INITOBJECT.initDisplayToolbarDevice();

                        // Lock screen
                        if(ClientData.serviceOpt_encryption() != 'Y') {
                                COMMON.LockScreen();
                        }

                        //START TRB00094 - Editor : Long - Date : 09/26/2013 - Summary : Setting log
                        CONTENTVIEW.StartTimerUpdateLog();

                        /* set start log */
                        COMMON.SetStartLog(CONTENTVIEW_GENERAL.contentID);
                        //END TRB00094 - Editor : Long - Date : 09/26/2013 - Summary : Setting log
                        CONTENTVIEW_GENERAL.disableAllControl();
                        //enable SpecifyControl
                        CONTENTVIEW.enableControlForMediaAndHtmlType();
6655
                        CONTENTVIEW.displayOverlayForSpecifyContentType(url);
6656
                        $(window).resize(function () {
6657 6658 6659 6660 6661 6662 6663 6664 6665 6666

                           //Check if content is zooming
                           if(CONTENTVIEW.isZoomingContent){
                               //var $container = $("#dialog");
                              // var w = window.innerWidth;
                               //var h = window.innerHeight;

                               //$container.css('height', h);
                               //$container.css('width', w);
                           }
6667
                        });
6668

6669 6670
                        CONTENTVIEW.handleSliderBar();
                        $('#lblSlider').text('/ ' + 1);
6671

6672
                        if (CONTENTVIEW_GENERAL.avwUserEnvObj.isAndroid() == false) {
6673
                           $("#slider_page").slider("option", "disabled", true);
6674
                        }
6675

6676
                        COMMON.disable('#txtSearch', '#txtSlider');
6677 6678 6679
                     }else {
                        CONTENTVIEW_INITOBJECT.initPage();
                     }
Masaru Abe committed
6680 6681
                }
                //ストリーミングならデバイス側に初期表示済通知
6682 6683 6684
                if(ClientData.isStreamingMode()){
                    CONTENTVIEW_STREAMING.initPageView();
                }
6685 6686

            }
Masaru Abe committed
6687 6688
         },
         function (xmlHttpRequest, txtStatus, errorThrown) {
6689

6690 6691 6692
             //ページジャンプ設定をクリア
             ClientData.JumpQueue([]);
             ClientData.IsJumpBack(false);
6693

6694 6695 6696
             
             //オーサリングプレビュー対応
             if(COMMON.isAuthoringPreview() && CONTENTVIEW_GENERAL.pid != ''){
Masaru Abe committed
6697
                 // Show system error
6698
                 AVWEB.showSystemError();
6699 6700 6701 6702 6703 6704 6705 6706 6707 6708 6709 6710 6711 6712 6713 6714
             } else {
	             var moveScreen = null;
	             if(!ClientData.isStreamingMode() && !ClientData.isGetitsMode()){
	                 moveScreen = COMMON.ScreenIds.Home;
	             }
	             if (xmlHttpRequest.status == 404) {
	                 CONTENTVIEW.showAlertScreen(I18N.i18nText('msgContentNotExist'), moveScreen);
	             }
	             else if(xmlHttpRequest.status == 403) {
	                 //認証エラー
	                 CONTENTVIEW.showAlertScreen(I18N.i18nText('sysErrorCallApi02'), moveScreen);
	             }
	             else {
	                 // Show system error
	                 AVWEB.showSystemError();
	             }
Masaru Abe committed
6715 6716 6717
             }
         }
    );
6718 6719 6720 6721
};


CONTENTVIEW.handleDisplayMobileToolbar = function(){
6722

6723 6724 6725 6726 6727 6728 6729 6730 6731
    if($('#menu').length){
        if ($('#menu').is(':hidden')) {
            // 非表示の場合の処理
            $('#menu').show();
        } else {
            // 表示されている場合の処理
            $('#menu').hide();
        }
    }
6732

6733 6734 6735
};

CONTENTVIEW.getSessionId = function(){
6736

6737
	if(COMMON.isAuthoringPreview()){
6738
        if(ClientData.userInfo_sid_local_preview()){
6739
            return ClientData.userInfo_sid_local_preview();
6740
        }else{
6741 6742 6743 6744 6745 6746 6747 6748 6749 6750 6751
            return ClientData.userInfo_sid_preview();
        }
    }else{
        if (ClientData.userInfo_sid_local()) {
            return ClientData.userInfo_sid_local();
        } else if (ClientData.userInfo_sid_local_bak()) {
            return ClientData.userInfo_sid_local_bak();
        } else {
            return ClientData.userInfo_sid();
        }
    }
6752

6753 6754
};

6755
CONTENTVIEW.resvCustomLog = function(param1,param2,param3,param4,param5){
6756
    //console.log("resvCustomLog:" + param1 + "-" + param2);
6757

6758 6759 6760 6761 6762 6763 6764 6765
    //カスタムログ作成
    var customLog = new CustomLogEntity();
    customLog.contentid = CONTENTVIEW_GENERAL.contentID;
    if(param1 == null){
        customLog.param1 = "";
    } else {
        customLog.param1 = param1;
    }
6766

6767 6768 6769 6770 6771
    if(param2 == null){
        customLog.param2 = "";
    } else {
        customLog.param2 = param2;
    }
6772

6773 6774 6775 6776 6777
    if(param3 == null){
        customLog.param3 = "";
    } else {
        customLog.param3 = param3;
    }
6778

6779 6780 6781 6782 6783 6784 6785 6786 6787 6788 6789
    if(param4 == null){
        customLog.param4 = "";
    } else {
        customLog.param4 = param4;
    }

    if(param5 == null){
        customLog.param5 = "";
    } else {
        customLog.param5 = param5;
    }
6790

6791
    COMMON.SetCustomLog(CONTENTVIEW_GENERAL.contentID, customLog);
6792 6793 6794

};

vietdo committed
6795 6796 6797
CONTENTVIEW.panoLog = function(log, scheme){
	
	if(scheme == "abookdetaillog"){
6798 6799
		
		var panoObjectLog = log;
vietdo committed
6800 6801 6802
		//Panomovieの詳細ログ作成
	    var objectLog = new ObjectLogEntity();
	    objectLog.contentid = CONTENTVIEW_GENERAL.contentID;
vietdo committed
6803
	    objectLog.actionDate = new Date();	    
6804
	    if(CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_PanoMovie || CONTENTVIEW_GENERAL.contentType == COMMON.ContentTypeKeys.Type_ObjectVR){
vietdo committed
6805 6806 6807 6808
	    	objectLog.pageNo = "1";
	    }else{
		    objectLog.pageNo = panoObjectLog.pageNo;
	    }	    
vietdo committed
6809 6810 6811 6812 6813 6814 6815 6816 6817 6818 6819
	    objectLog.objectId = panoObjectLog.objectId;
	    objectLog.resourceId = panoObjectLog.resourceId;
	    objectLog.mediaType = panoObjectLog.mediaType;
	    objectLog.actionType = panoObjectLog.actionType;
	    objectLog.actionTime = "0";
	    objectLog.actionValue = panoObjectLog.actionValue;
	    objectLog.locationX = panoObjectLog.locationX;
	    objectLog.locationY = panoObjectLog.locationY;
	    objectLog.locationHeight = panoObjectLog.locationHeight;
	    objectLog.locationWidth = panoObjectLog.locationWidth;
	    objectLog.eventType = panoObjectLog.eventType;
vietdo committed
6820
	    
vietdo committed
6821
	    COMMON.SetObjectLog(CONTENTVIEW_GENERAL.contentID, objectLog);
6822 6823 6824 6825
	}else if(scheme == "abookmovepage"){
		
		var panoPageLog = log;
		
6826 6827 6828 6829 6830 6831 6832
		//if(panoPageLog.pageNo == null){
		//	CONTENTVIEW_GENERAL.panoPageNo = 1;
		//} else {
		//	CONTENTVIEW_GENERAL.panoPageNo = panoPageLog.pageNo;
		//}
		//COMMON.SetPageLog( CONTENTVIEW_GENERAL.contentID, CONTENTVIEW_GENERAL.panoPageNo);
		
vietdo committed
6833
		CONTENTVIEW_GENERAL.panoPageNo = panoPageLog.pageNo;
6834 6835 6836 6837 6838 6839
		if(panoPageLog.pageNo == null){
			COMMON.SetPageLog( CONTENTVIEW_GENERAL.contentID, 1);
		} else {
			COMMON.SetPageLog( CONTENTVIEW_GENERAL.contentID, CONTENTVIEW_GENERAL.panoPageNo);
		}

vietdo committed
6840 6841 6842
	}
};

6843
CONTENTVIEW.receivePanoLog = function(e) {
6844

6845 6846 6847 6848 6849 6850 6851 6852 6853 6854
	try {
		var log = JSON.parse(e.data);
		if(log.hasOwnProperty('scheme')){
			CONTENTVIEW.panoLog(log, log.scheme);
		}else{
			CONTENTVIEW.panoContentLink(log.contentId, log.page);
		}
	 } catch(err) {
		 AVWEB.avwLog(err);
	 }
6855 6856 6857

};

6858 6859 6860
//360コンテンツにhotspotをクリックする時にログを取得する
window.addEventListener("message", CONTENTVIEW.receivePanoLog, false);

6861
CONTENTVIEW.panoContentLink = function(targetContentId, page){
vietdo committed
6862 6863 6864 6865 6866 6867 6868 6869 6870 6871 6872 6873
	var params = {
    		contentId: targetContentId,
    		sid: CONTENTVIEW.getSessionId(),
    		getType: 1,
    		isStreaming: ClientData.isStreamingMode()
    };

    AVWEB.avwCmsApi(ClientData.userInfo_accountPath(),
         "webGetContent",
         "GET",
         params,
         function (data) {
6874

6875
             //既存ログを送信する
vietdo committed
6876 6877
             COMMON.SetEndLog(CONTENTVIEW_GENERAL.contentID);
             COMMON.RegisterLog();
6878
             if(data.contentData.alertMessageLevel){
vietdo committed
6879 6880 6881 6882 6883 6884 6885 6886 6887 6888 6889 6890

                 if(data.contentData.alertMessageLevel == CONTENTVIEW_CREATEOBJECT.alertMessageLevel.ShowAlert){
                     if(data.contentData.alertMessage){
                        var oldContent = { oldContentID: CONTENTVIEW_GENERAL.contentID, oldPageIndex: CONTENTVIEW_GENERAL.panoPageNo };

                        CONTENTVIEW_CREATEOBJECT.moveContentParam = {};
                        CONTENTVIEW_CREATEOBJECT.moveContentParam = {
                            'preContentId' : targetContentId,
                            'prePageNo' : page,
                            'oldContent' : oldContent
                        };

6891
                        CONTENTVIEW_CREATEOBJECT.showContentConfirmDialog(data.contentData.alertMessageLevel, data.contentData.alertMessage, data.contentData.contentType);
vietdo committed
6892 6893 6894 6895 6896 6897 6898 6899
                     }
                 }
                 else if(data.contentData.alertMessageLevel == CONTENTVIEW_CREATEOBJECT.alertMessageLevel.RequirePassword){

                        var oldContent = { oldContentID: CONTENTVIEW_GENERAL.contentID, oldPageIndex: CONTENTVIEW_GENERAL.panoPageNo };

                        CONTENTVIEW_CREATEOBJECT.moveContentParam = {};
                        CONTENTVIEW_CREATEOBJECT.moveContentParam = {
6900 6901
                            'preContentId' : targetContentId,
                            'prePageNo' : page,
vietdo committed
6902 6903 6904
                            'oldContent' : oldContent
                        };

6905
                        CONTENTVIEW_CREATEOBJECT.showContentConfirmDialog(data.contentData.alertMessageLevel, data.contentData.contentType);
vietdo committed
6906
                 }
6907
                 else if(data.contentData.alertMessageLevel == CONTENTVIEW_CREATEOBJECT.alertMessageLevel.None){
6908 6909 6910
                	 if(data.contentData.contentType == COMMON.ContentTypeKeys.Type_Link){
                		 HEADER.viewLinkContentById(targetContentId);
                		 
6911 6912
                	 }else if(data.contentData.contentType == COMMON.ContentTypeKeys.Type_Others){
                		 HEADER.downloadResourceById(targetContentId);
6913 6914 6915 6916 6917 6918 6919 6920 6921 6922 6923 6924 6925 6926 6927 6928 6929
                	 }else{
                		 ClientData.common_preContentId(targetContentId);
                         ClientData.common_prePageNo(page);

                         //古いページを保存する
                         var oldContent = { oldContentID: CONTENTVIEW_GENERAL.contentID, oldPageIndex: CONTENTVIEW_GENERAL.panoPageNo };
                         var dataJump = ClientData.JumpQueue();
                         dataJump.push(oldContent);
                         ClientData.JumpQueue(dataJump);
                         
                     	 if (CONTENTVIEW_GENERAL.avwUserEnvObj.isMobile() && ClientData.isGetitsMode()) {
                     		 AVWEB.avwScreenMove(COMMON.ScreenIds.ContentViewGetits);
                     	 } else {
                     		 CONTENTVIEW.screenMove();
                     	 }
                	 }

vietdo committed
6930
                 }
6931 6932 6933 6934 6935 6936 6937 6938 6939 6940 6941 6942 6943 6944 6945 6946
             }else{
            	 //コンテンツ警告サビースオプションがチェックされない
            	 ClientData.common_preContentId(targetContentId);
                 ClientData.common_prePageNo(page);

                 //古いページを保存する
                 var oldContent = { oldContentID: CONTENTVIEW_GENERAL.contentID, oldPageIndex: CONTENTVIEW_GENERAL.panoPageNo };
                 var dataJump = ClientData.JumpQueue();
                 dataJump.push(oldContent);
                 ClientData.JumpQueue(dataJump);
                 
             	 if (CONTENTVIEW_GENERAL.avwUserEnvObj.isMobile() && ClientData.isGetitsMode()) {
             		 AVWEB.avwScreenMove(COMMON.ScreenIds.ContentViewGetits);
             	 } else {
             		 CONTENTVIEW.screenMove();
             	 }
vietdo committed
6947 6948 6949 6950 6951 6952 6953 6954 6955 6956 6957 6958 6959
             }

         },
         function (xmlHttpRequest, txtStatus, errorThrown) {
             if (xmlHttpRequest.status == 404) {
            	 CONTENTVIEW.showAlertScreen(I18N.i18nText('msgContentNotExist'), null);
             }
             else {
                 // Show system error
            	 AVWEB.showSystemError();
             }
         }
    );
vietdo committed
6960
};
6961

6962
CONTENTVIEW.receiveSize = function(e) {
6963 6964
	//if (e.origin === "http://hogehoge.com") // for security: set this to the domain of the iframe - use e.uri if you need more specificity
	//	document.getElementById("bar").style.height = e.data + "px";
6965 6966
	//console.log("receiveSize:" + e.data);
	
6967
};
Masaru Abe committed
6968

6969
window.addEventListener("message", CONTENTVIEW.receiveSize, false);
6970 6971 6972 6973 6974 6975 6976 6977 6978 6979 6980 6981 6982 6983 6984 6985 6986 6987 6988 6989 6990 6991 6992 6993 6994

//差し替え画像のアスペクト比維持対応
CONTENTVIEW.adjustAspectRatio = function(drawX, drawY, drawW, drawH, srcImageW, srcImageH){
	
	var drawObj = {};
	drawObj.drawX = drawX;
	drawObj.drawY = drawY;
	drawObj.drawH = drawH;
	drawObj.drawW = drawW;
	
	var tmpRatioImage;
	var tmpX = drawObj.drawX;
	var tmpY = drawObj.drawY;
	var tmpH = drawObj.drawH;
	var tmpW = drawObj.drawW;
	
	//描画エリアが縦長か横長か判定
	if( drawObj.drawW > drawObj.drawH ){
		//描画エリア横長
		if(srcImageW > srcImageH){
			//ソース画像は横長
			
			//描画エリアとソース画像の比率計算
			var drawRatio = drawObj.drawH / drawObj.drawW;
			var srcRatio = srcImageH / srcImageW;
6995 6996
			//console.log("drawRatio:" + drawRatio);
			//console.log("srcRatio:" + srcRatio);
6997 6998 6999 7000 7001 7002 7003 7004 7005 7006 7007 7008 7009 7010 7011 7012 7013 7014 7015 7016 7017 7018 7019 7020 7021 7022 7023 7024 7025 7026 7027 7028 7029
			
			if( drawRatio < srcRatio ){
				tmpH = drawObj.drawH;
				tmpRatioImage = drawObj.drawH / srcImageH;
				tmpW = srcImageW * tmpRatioImage;
			} else {
				tmpW = drawObj.drawW;
				tmpRatioImage = drawObj.drawW / srcImageW;
				tmpH = srcImageH * tmpRatioImage;
			}
			
		} else {
			//ソース画像は縦長か正方形
			tmpRatioImage = drawObj.drawH / srcImageH;
			tmpW = srcImageW * tmpRatioImage;
		}
		
	} else {
		//描画エリア縦長か正方形
		if(srcImageW > srcImageH){
			//ソース画像は横長
			tmpRatioImage = drawObj.drawW / srcImageW;
			tmpH = srcImageH * tmpRatioImage;
			if( tmpH > drawObj.drawH ){
				//補正
				tmpH = drawObj.drawH;
			}
		} else {
			//ソース画像は縦長か正方形
			
			//描画エリアとソース画像の比率計算
			var drawRatio = drawObj.drawW / drawObj.drawH;
			var srcRatio = srcImageW / srcImageH;
7030 7031
			//console.log("drawRatio:" + drawRatio);
			//console.log("srcRatio:" + srcRatio);
7032 7033 7034 7035 7036 7037 7038 7039 7040 7041 7042 7043 7044 7045 7046 7047 7048 7049 7050 7051 7052 7053 7054 7055 7056 7057 7058 7059 7060 7061 7062 7063 7064 7065 7066 7067 7068 7069 7070 7071 7072 7073
			
			if( drawRatio < srcRatio ){
				tmpW = drawObj.drawW;
				tmpRatioImage = drawObj.drawW / srcImageW;
				tmpH = srcImageH * tmpRatioImage;
			} else {
				tmpH = drawObj.drawH;
				tmpRatioImage = drawObj.drawH / srcImageH;
				tmpW = srcImageW * tmpRatioImage;
			}
			//tmpRatioImage = drawObj.drawH / srcImageH;
			//tmpW = srcImageW * tmpRatioImage;
			//if(tmpW > drawObj.drawW){
			//	tmpRatioImage = drawObj.drawW / srcImageW;
			//	tmpH = srcImageH * tmpRatioImage;
			//	tmpW = drawObj.drawW;
			//} else {
			//	//drawObj.drawW = tmpW;
			//}
		}
		
	}
	
	//表示位置調整
	if( drawObj.drawW > tmpW ){
		//横位置調整
		tmpX = tmpX + (drawObj.drawW - tmpW) / 2;
	}
	if( drawObj.drawH > tmpH ){
		//縦位置調整
		tmpY = tmpY + (drawObj.drawH - tmpH) / 2;
	}
	
	drawObj.drawX = tmpX;
	drawObj.drawY = tmpY;
	drawObj.drawW = tmpW;
	drawObj.drawH = tmpH;
	
	return drawObj;
	
};