Convert PDF pages designer to use jQuery.

This commit is contained in:
Michal Čihař
2010-04-13 13:34:51 +02:00
parent 4bc0c8aafe
commit 37aca1ec06
2 changed files with 28 additions and 27 deletions

View File

@@ -1421,8 +1421,8 @@ function getElement(e,f){
* Refresh the WYSIWYG-PDF scratchboard after changes have been made * Refresh the WYSIWYG-PDF scratchboard after changes have been made
*/ */
function refreshDragOption(e) { function refreshDragOption(e) {
myid = getElement(e); var elm = $('#' + e);
if (myid.style.visibility == 'visible') { if (elm.css('visibility') == 'visible') {
refreshLayout(); refreshLayout();
} }
} }
@@ -1431,35 +1431,35 @@ function refreshDragOption(e) {
* Refresh/resize the WYSIWYG-PDF scratchboard * Refresh/resize the WYSIWYG-PDF scratchboard
*/ */
function refreshLayout() { function refreshLayout() {
myid = getElement('pdflayout'); var elm = $('#pdflayout')
var orientation = $('#orientation_opt').val();
var paper = $('#paper_opt').val();
if (document.pdfoptions.orientation.value == 'P') { if (orientation == 'P') {
posa = 'x'; posa = 'x';
posb = 'y'; posb = 'y';
} else { } else {
posa = 'y'; posa = 'y';
posb = 'x'; posb = 'x';
} }
elm.css('width', pdfPaperSize(paper, posa) + 'px');
myid.style.width = pdfPaperSize(document.pdfoptions.paper.value, posa) + 'px'; elm.css('height', pdfPaperSize(paper, posb) + 'px');
myid.style.height = pdfPaperSize(document.pdfoptions.paper.value, posb) + 'px';
} }
/** /**
* Show/hide the WYSIWYG-PDF scratchboard * Show/hide the WYSIWYG-PDF scratchboard
*/ */
function ToggleDragDrop(e) { function ToggleDragDrop(e) {
myid = getElement(e); var elm = $('#' + e);
if (elm.css('visibility') == 'hidden') {
if (myid.style.visibility == 'hidden') { PDFinit(); /* Defined in pdf_pages.php */
init(); elm.css('visibility', 'visible');
myid.style.visibility = 'visible'; elm.css('display', 'block');
myid.style.display = 'block'; $('#showwysiwyg').val('1')
document.edcoord.showwysiwyg.value = '1';
} else { } else {
myid.style.visibility = 'hidden'; elm.css('visibility', 'hidden');
myid.style.display = 'none'; elm.css('display', 'none');
document.edcoord.showwysiwyg.value = '0'; $('#showwysiwyg').val('0')
} }
} }
@@ -1468,10 +1468,11 @@ function ToggleDragDrop(e) {
* the fields inside the scratchboard. * the fields inside the scratchboard.
*/ */
function dragPlace(no, axis, value) { function dragPlace(no, axis, value) {
var elm = $('#table_' + no);
if (axis == 'x') { if (axis == 'x') {
getElement("table_" + no).style.left = value + 'px'; elm.css('left', value + 'px');
} else { } else {
getElement("table_" + no).style.top = value + 'px'; elm.css('top', value + 'px');
} }
} }

View File

@@ -381,7 +381,7 @@ foreach ($array_sh_page AS $key => $temp_sh_page) {
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA[ //<![CDATA[
function init() { function PDFinit() {
refreshLayout(); refreshLayout();
myid = getElement('pdflayout'); myid = getElement('pdflayout');
<?php echo $draginit; ?> <?php echo $draginit; ?>
@@ -479,7 +479,7 @@ function resetDrag() {
echo "\n" . ' </table>' . "\n"; echo "\n" . ' </table>' . "\n";
echo "\n" . ' <input type="hidden" name="c_table_rows" value="' . ($i + 1) . '" />'; echo "\n" . ' <input type="hidden" name="c_table_rows" value="' . ($i + 1) . '" />';
echo ($cfg['WYSIWYG-PDF'] ? "\n" . ' <input type="hidden" name="showwysiwyg" value="' . ((isset($showwysiwyg) && $showwysiwyg == '1') ? '1' : '0') . '" />' : ''); echo ($cfg['WYSIWYG-PDF'] ? "\n" . ' <input type="hidden" id="showwysiwyg" name="showwysiwyg" value="' . ((isset($showwysiwyg) && $showwysiwyg == '1') ? '1' : '0') . '" />' : '');
echo "\n" . ' <input type="checkbox" name="with_field_names" ' . (isset($with_field_names) ? 'checked="checked"' : ''). ' />' . $strColumnNames . '<br />'; echo "\n" . ' <input type="checkbox" name="with_field_names" ' . (isset($with_field_names) ? 'checked="checked"' : ''). ' />' . $strColumnNames . '<br />';
echo "\n" . ' <input type="submit" value="' . $strSave . '" />'; echo "\n" . ' <input type="submit" value="' . $strSave . '" />';
echo "\n" . '</form>' . "\n\n"; echo "\n" . '</form>' . "\n\n";