contentview_General.js 15.6 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103

/// <reference path="../common/js/jquery-ui-1.8.23.custom.min.js" />

/// <reference path="../common/js/common.js" />

/* init const */
var WIDTH_DIALOG_BOOKMARK = 300;
var HEIGHT_DIALOG_BOOKMARK = 700;
var HEIGHT_DIALOG_BOOKMARK_NO_BOOKMARK = 200;

var WIDTH_DIALOG_INDEX = 300;
var HEIGHT_DIALOG_INDEX = 700;
var HEIGHT_DIALOG_INDEX_NO_INDEX = 200;

var WIDTH_DIALOG_SEARCH = 300;
var HEIGHT_DIALOG_SEARCH = 700;
var HEIGHT_DIALOG_SEARCH_NO_SEARCH = 200;

var WIDTH_DIALOG_COPYTEXT = 300;
var HEIGHT_DIALOG_COPYTEXT = 500;
var HEIGHT_DIALOG_COPYTEXT_NO_COPYTEXT = 200;

/* init variable */
var pageImages = '';
var totalPage = 0;
var pageObjects = [];
var pageObjectsData = [];
var tool;
var isFullScreen = false;
var ctrlMode = false;
var dataWebContentPage;
var dataPageTitle;
var dataJsonType4;
var dataJsonType5;
var contentID;
var isOpenPopUpText = false;
var isOpenPopUpMemo = true;
var objEditMemo;
var isCopyMemo = false;
var isExistCopyMemo = false;
var posXPopupMemo = 0;
var posYPopupMemo = 0;
var contentName = '';
var nCountObjectLoad = 0;
var nAjaxLoad = 0;
var isClearDrawing = false;
var isDrawing = false;
var mediaType4_changeImage = 0;
var isLoadingObject = false;
var isFirstLoad = true;
var nPositionCanvas = [];
var arrImage = [];
var posTxtSearch = [];
var sx, sy;
var imgDrawingTemp;
var imgMarkerTemp;
var isSizingDrawCanvas = false;
var isDisplayBookMarkList = false;
var avwUserEnvObj = new UserEnvironment();
var canvas_marker;
var context_marker;
var canvas_draw;
var context_draw;
var canvas_main;
var context_main;
var canvas_offscreen;
var context_offscreen;
var isAddingMarking;
var penSize;
var penColor;
var makerSize;
var makerColor;
var eraseSize;
var markingType;
var isDisplayCopyText = false;
var isDisplayListIndex = false;
var isChangeSizeScreen = false;
var widthContentImage = 0;
var heightContentImage = 0;
var widthEachPage = 0;
var heightEachPage = 0;
var px = 0;
var py = 0;
var isPressLeftMouse = false;
var isMoveOutDrawCanvas = false;
var typeSelectMemo = 0;
var arrThumbnailsLoaded = [];
var isSendingData = true;
var isPlayBGMUnlock = false;
var isJumpNotFromFirstPage = false;
var standardRatio = 1;
var currentRatio = 1;
var resourceImage = new Image();

//START TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content
//Array of pages size
var contentPageSizeArr = [];
var widthEachNextPage = 0;
var heightEachNextPage = 0;
var widthEachPrevPage = 0;
var heightEachPrevPage = 0;
//END TRB00097 - Editor: Long - Date: 09/30/2013 - Summary : Get All Page size of content

104 105 106 107 108 109 110 111 112
//#11478
var widthEachPageApi = 0;
var heightEachPageApi = 0;
var widthEachNextPageApi = 0;
var heightEachNextPageApi = 0;
var widthEachPrevPageApi = 0;
var heightEachPrevPageApi = 0;
//#11478

113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
/* zoom video */
var pxVideo;
var pyVideo;
var wVideo;
var hVideo;
var videoScale;

//Start Function: No.12
//Content's types

var contentType;

var imageTypeData;

var nextPageImage = '';
var nextPageObjects = [];
var nextContent = new Content();
var prevPageObjects = [];
var prevPageImage = '';
var prevContent = new Content();
var animateTypeKeys = {
    Type_Slide : 0,
    Type_FadeIn : 1
};

var animateType;
var animatePeriod;

function getNextContent(){
    return nextContent;    
};

function getPrevContent(){
    return prevContent;  
};


//End Function: No.12


//Start Function : No.20
var _moveFlag = false;
var _moveNum = false;
var _isPageNaviTouch = false;
var _isPageZoomTouch = false;
var _clickFirstPos = null;
var _clickLastPos = null;
var _touchFirstPos = null;
var _touchLastPos = null;
var touchStartedTime = null;
var _touchMoveTimePeriod = 0; // 0 s
var _touchMoveTimePeriodInvalid = 5000; // 5 s
var _bHasNext = false; 
var _bHasPrev = false; 
var _startPoints = [];
var _bufferPoints = [];
var _bImageMainReload = true;   // to not run onload again on the next time on set src value 
var _bImageMainPreReload = true;    // to not run onload again on the next time on set src value
var _bImageMainNextReload = true;   // to not run onload again on the next time on set src value
var _lastDist = 0;
var _lastScaleDelta = 0;

var _bWin8TouchEnabled = false;
var _bTransitionEnable = true;
177 178
var _bTouchDeviceEnabled = false;

179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280
//End Function : No.20


//Start Function : No.9 
var _object3DImageArr = [];

//End Function : No.9
/*disable all control on page */
function disableAllControl() {
    /* 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');
    $("#firstpage").css('cursor', 'default');
    $("#prevpage").css('cursor', 'default');
    $("#nextpage").css('cursor', 'default');
    $("#lastpage").css('cursor', 'default');
    $("#zoomfit").css('cursor', 'default');
    $("#zoomin").css('cursor', 'default');
    $("#zoomout").css('cursor', 'default');
    $("#control_screen").css('cursor', 'default');
    $("#control_screen_2").css('cursor', 'default');
    $("#slider_page").css('cursor', 'default');
    $(".ui-slider-handle").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');

    $('#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');

    $('#zoomfit').unbind('click');
    $('#zoomfit').removeClass();
    $('#zoomfit').addClass('fit_off');
    $('#zoomin').unbind('click');
    $('#zoomin').removeClass();
    $('#zoomin').addClass('expansion_off');
    $('#zoomout').unbind('click');
    $('#zoomout').removeClass();
    $('#zoomout').addClass('reduction_off');
    if (avwUserEnvObj.os != "android") {
        $("#slider_page").slider("option", "disabled", true);
    }

Masaru Abe committed
281
    COMMON.disable('#txtSearch', '#txtSlider');
282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378

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

};

/*enable all control on page */
function enableAllControl() {
    disableAllControl();

    /* set cursor pointer*/
    $("#imgHome").css('cursor', 'pointer');
    $("#imgBack").css('cursor', 'pointer');
    $("#listbookmark").css('cursor', 'pointer');
    $("#imgbookmark").css('cursor', 'pointer');

    //Start Function: No.12
    if (contentType == ContentTypeKeys.Type_PDF) {
        $("#listindex").css('cursor', 'pointer');
        $("#copytext").css('cursor', 'pointer');
    }
    //End Function: No.12

    $("#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');
    $("#zoomfit").css('cursor', 'pointer');
    // $("#zoomin").css('cursor', 'pointer');
    // $("#zoomout").css('cursor', 'pointer');
    $("#control_screen").css('cursor', 'pointer');
    $("#control_screen_2").css('cursor', 'pointer');

    //Start Function: No.12
    if (contentType == ContentTypeKeys.Type_PDF || contentType == ContentTypeKeys.Type_NoFile) {
        $("#slider_page").css('cursor', 'pointer');
        $(".ui-slider-handle").css('cursor', 'pointer');
    }
    //End Function: No.12

    $("#liAddMemo").css('cursor', 'pointer');
    $("#liCopyMemo").css('cursor', 'pointer');
    $("#liDeleteMemo").css('cursor', 'pointer');

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

    $('#imgHome').bind('click', imgHome_click);
    $('#imgHome').removeClass();

    $('#imgBack').bind('click', imgBack_click);
    $('#imgBack').removeClass();

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


    $('#imgbookmark').bind('click', bookmarkPage);
    $('#imgbookmark').removeClass();

    //Start Function: No.12
    if (contentType == ContentTypeKeys.Type_PDF) {
        $('#listindex').bind('click', showListPageIndex);
        $('#listindex').removeClass();

        $('#copytext').bind('click', showCopyText);
        $('#copytext').removeClass();
    }
    //End Function: No.12

    /* image memo */
    $('#imgmemo').bind('click', handleMemo);
    $('#imgmemo').removeClass();

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

    $('#imgmarking').bind('click', imgmarking_click);
    $('#imgmarking').removeClass();

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

    checkDisableButtonZoom();
    //Start Function: No.12
    if (contentType == ContentTypeKeys.Type_PDF || contentType == ContentTypeKeys.Type_NoFile) {
        $("#slider_page").slider("option", "disabled", false);
        
        if(contentType == ContentTypeKeys.Type_PDF){
Masaru Abe committed
379
            COMMON.enable('#txtSearch', '#txtSlider'); 
380 381
        }        
        else if(contentType == ContentTypeKeys.Type_NoFile){
Masaru Abe committed
382
            COMMON.enable('#txtSlider');
383 384 385 386 387 388 389 390 391
        }               
    }
   
    
    if (avwUserEnvObj.os != "ipad" && avwUserEnvObj.os != "android") {
        $('#button_next_canvas').css('display', 'block');
        $('#button_pre_canvas').css('display', 'block');
    }

Masaru Abe committed
392
    if (COMMON.isTouchDevice() == true) {/* set css for device */
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504
        $('#imgHome').addClass('home_device');
        $('#imgBack').addClass('back_device');

        $("#control_screen").addClass('toolbar_device');
        //$("#control_screen_2").addClass('toolbar_device');
        $("#control_screen_2").addClass('toolbar_close_device');

        var nBookmarkId = isExistBookmark();
        if (nBookmarkId == -1) {
            $('#imgbookmark').addClass('bmAdd_device');
        } else {
            $('#imgbookmark').addClass('bmAdd_hover');
        }

        if (isDisplayBookMarkList == true) {
            $('#listbookmark').addClass('bmList_hover');
        } else {
            $('#listbookmark').addClass('bmList_device');
        }

        if (isDisplayCopyText == true) {
            $('#copytext').addClass('copy_hover');
        } else {
            $('#copytext').addClass('copy_device');
        }

        if (isDisplayListIndex == true) {
            $('#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');
        $("#control_screen").addClass('toolbar');
        $("#control_screen_2").addClass('toolbar_close');

        var nBookmarkId = isExistBookmark();
        if (nBookmarkId == -1) {
            $('#imgbookmark').addClass('bmAdd');
        } else {
            $('#imgbookmark').addClass('bmAdd_hover');
        }

        if (isDisplayBookMarkList == true) {
            $('#listbookmark').addClass('bmList_hover');
        } else {
            $('#listbookmark').addClass('bmList');
        }

        if (isDisplayCopyText == true) {
            $('#copytext').addClass('copy_hover');
        } else {
            $('#copytext').addClass('copy');
        }

        if (isDisplayListIndex == true) {
            $('#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');
            }
        }
    }
Masaru Abe committed
505 506 507 508 509 510 511 512 513 514 515 516
    
    if( ClientData.isGetitsMode() == true ){
        $('#imgHome').unbind('click');
        $('#imgHome').removeClass();
        $('#imgHome').addClass('home_off');

        /* back button */
        $('#imgBack').unbind('click');
        $('#imgBack').removeClass();
        $('#imgBack').addClass('back_off');
    }
    
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550
    checkExistNextPrePage();
};

/*
Clear canvas
*/
function clearCanvas(targetCanvas) {
    targetCanvas.width = targetCanvas.width;
};

function encode(data) {
    var str = String.fromCharCode.apply(null, data);
    return btoa(str).replace(/.{76}(?=.)/g, '$&\n');
};

function showDialog(modal) {
    $("#overlay").show();
    $("#dialog").fadeIn(300);

    if (modal) {
        $("#overlay").unbind("click");
    }
    else {
        $("#overlay").click(function (e) {
            hideDialog();
        });
    }
};

function hideDialog() {
    $("#overlay").hide();
    $("#dialog").fadeOut(200);
    $('#dialog').children().remove();
};