From 37aca1ec064eae332270c0a4e6220042fe307e0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C4=8Ciha=C5=99?= Date: Tue, 13 Apr 2010 13:34:51 +0200 Subject: [PATCH] Convert PDF pages designer to use jQuery. --- js/functions.js | 51 +++++++++++++++++++++++++------------------------ pdf_pages.php | 4 ++-- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/js/functions.js b/js/functions.js index c0cca6712..ce7ebde72 100644 --- a/js/functions.js +++ b/js/functions.js @@ -1421,8 +1421,8 @@ function getElement(e,f){ * Refresh the WYSIWYG-PDF scratchboard after changes have been made */ function refreshDragOption(e) { - myid = getElement(e); - if (myid.style.visibility == 'visible') { + var elm = $('#' + e); + if (elm.css('visibility') == 'visible') { refreshLayout(); } } @@ -1431,35 +1431,35 @@ function refreshDragOption(e) { * Refresh/resize the WYSIWYG-PDF scratchboard */ function refreshLayout() { - myid = getElement('pdflayout'); + var elm = $('#pdflayout') + var orientation = $('#orientation_opt').val(); + var paper = $('#paper_opt').val(); - if (document.pdfoptions.orientation.value == 'P') { - posa = 'x'; - posb = 'y'; - } else { - posa = 'y'; - posb = 'x'; - } - - myid.style.width = pdfPaperSize(document.pdfoptions.paper.value, posa) + 'px'; - myid.style.height = pdfPaperSize(document.pdfoptions.paper.value, posb) + 'px'; + if (orientation == 'P') { + posa = 'x'; + posb = 'y'; + } else { + posa = 'y'; + posb = 'x'; + } + elm.css('width', pdfPaperSize(paper, posa) + 'px'); + elm.css('height', pdfPaperSize(paper, posb) + 'px'); } /** * Show/hide the WYSIWYG-PDF scratchboard */ function ToggleDragDrop(e) { - myid = getElement(e); - - if (myid.style.visibility == 'hidden') { - init(); - myid.style.visibility = 'visible'; - myid.style.display = 'block'; - document.edcoord.showwysiwyg.value = '1'; + var elm = $('#' + e); + if (elm.css('visibility') == 'hidden') { + PDFinit(); /* Defined in pdf_pages.php */ + elm.css('visibility', 'visible'); + elm.css('display', 'block'); + $('#showwysiwyg').val('1') } else { - myid.style.visibility = 'hidden'; - myid.style.display = 'none'; - document.edcoord.showwysiwyg.value = '0'; + elm.css('visibility', 'hidden'); + elm.css('display', 'none'); + $('#showwysiwyg').val('0') } } @@ -1468,10 +1468,11 @@ function ToggleDragDrop(e) { * the fields inside the scratchboard. */ function dragPlace(no, axis, value) { + var elm = $('#table_' + no); if (axis == 'x') { - getElement("table_" + no).style.left = value + 'px'; + elm.css('left', value + 'px'); } else { - getElement("table_" + no).style.top = value + 'px'; + elm.css('top', value + 'px'); } } diff --git a/pdf_pages.php b/pdf_pages.php index b7f93c533..9227d741b 100644 --- a/pdf_pages.php +++ b/pdf_pages.php @@ -381,7 +381,7 @@ foreach ($array_sh_page AS $key => $temp_sh_page) {