From 836fcd44575c22d4e456d5a8c99cf6cd29addba8 Mon Sep 17 00:00:00 2001 From: Uwe Steinmann Date: Fri, 11 Dec 2015 20:29:52 +0100 Subject: [PATCH] remove all javascript from html output and place in a seperate file this requires to change the popover into bootbox --- styles/bootstrap/application.js | 70 -------- views/bootstrap/class.Bootstrap.php | 185 ++++++++++++++++++---- views/bootstrap/class.DocumentChooser.php | 11 +- views/bootstrap/class.ViewDocument.php | 13 +- views/bootstrap/class.ViewFolder.php | 48 ++++-- 5 files changed, 209 insertions(+), 118 deletions(-) diff --git a/styles/bootstrap/application.js b/styles/bootstrap/application.js index a36a3da2c..0b68d7bc8 100644 --- a/styles/bootstrap/application.js +++ b/styles/bootstrap/application.js @@ -128,76 +128,6 @@ $(document).ready( function() { } }); - $('body').on('click', 'button.removedocument', function(ev){ - ev.preventDefault(); - attr_rel = $(ev.currentTarget).attr('rel'); - attr_msg = $(ev.currentTarget).attr('msg'); - attr_formtoken = $(ev.currentTarget).attr('formtoken'); - id = attr_rel; - $.get('../op/op.Ajax.php', - { command: 'deletedocument', id: id, formtoken: attr_formtoken }, - function(data) { -// console.log(data); - if(data.success) { - $('#table-row-document-'+id).hide('slow'); - noty({ - text: attr_msg, - type: 'success', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - timeout: 1500, - }); - } else { - noty({ - text: data.message, - type: 'error', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - timeout: 3500, - }); - } - }, - 'json' - ); - }); - - $('body').on('click', 'button.removefolder', function(ev){ - ev.preventDefault(); - attr_rel = $(ev.currentTarget).attr('rel'); - attr_msg = $(ev.currentTarget).attr('msg'); - attr_formtoken = $(ev.currentTarget).attr('formtoken'); - id = attr_rel; - $.get('../op/op.Ajax.php', - { command: 'deletefolder', id: id, formtoken: attr_formtoken }, - function(data) { -// console.log(data); - if(data.success) { - $('#table-row-folder-'+id).hide('slow'); - noty({ - text: attr_msg, - type: 'success', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - timeout: 1500, - }); - } else { - noty({ - text: data.message, - type: 'error', - dismissQueue: true, - layout: 'topRight', - theme: 'defaultTheme', - timeout: 3500, - }); - } - }, - 'json' - ); - }); - $('body').on('click', 'a.addtoclipboard', function(ev){ ev.preventDefault(); attr_rel = $(ev.currentTarget).attr('rel'); diff --git a/views/bootstrap/class.Bootstrap.php b/views/bootstrap/class.Bootstrap.php index 024ffb2e4..8813b5b07 100644 --- a/views/bootstrap/class.Bootstrap.php +++ b/views/bootstrap/class.Bootstrap.php @@ -98,10 +98,12 @@ background-image: linear-gradient(to bottom, #882222, #111111);; $this->extraheader[$type] .= $head; } /* }}} */ - function htmlEndPage() { /* {{{ */ - $this->footNote(); - if($this->params['showmissingtranslations']) { - $this->missingḺanguageKeys(); + function htmlEndPage($nofooter=false) { /* {{{ */ + if(!$nofooter) { + $this->footNote(); + if($this->params['showmissingtranslations']) { + $this->missingḺanguageKeys(); + } } echo ''."\n"; echo ''."\n"; @@ -122,7 +124,7 @@ $(document).ready(function () { "; } if(method_exists($this, 'js')) - echo ''."\n"; + echo ''."\n"; echo "\n\n"; } /* }}} */ @@ -864,8 +866,8 @@ $(document).ready(function () { } print ""; } /* }}} */ - - function printDocumentChooser($formName) { /* {{{ */ + + function printDocumentChooserHtml($formName) { /* {{{ */ print ""; print "
\n"; print ""; @@ -884,7 +886,11 @@ $(document).ready(function () {
- () { exit; } /* }}} */ + function printNewTreeNavigation($folderid=0, $accessmode=M_READ, $showdocs=0, $formid='form1', $expandtree=0, $orderby='') { /* {{{ */ + $this->printNewTreeNavigationHtml($folderid, $accessmode, $showdocs, $formid, $expandtree, $orderby); +?> + +\n"; + } /* }}} */ + /** * Create a tree of folders using jqtree. * @@ -1147,7 +1178,7 @@ function clearFilename() { * @param boolean $showdocs set to true if tree shall contain documents * as well. */ - function printNewTreeNavigation($folderid=0, $accessmode=M_READ, $showdocs=0, $formid='form1', $expandtree=0, $orderby='') { /* {{{ */ + function printNewTreeNavigationJs($folderid=0, $accessmode=M_READ, $showdocs=0, $formid='form1', $expandtree=0, $orderby='') { /* {{{ */ function jqtree($path, $folder, $user, $accessmode, $showdocs=1, $expandtree=0, $orderby='') { if($path || $expandtree) { if($path) @@ -1210,9 +1241,7 @@ function clearFilename() { $tree = array(array('label'=>$root->getName(), 'id'=>$root->getID(), 'load_on_demand'=>true, 'is_folder'=>true)); } - echo "
\n"; ?> - getID(); $content = ''; - $content .= ''; - $this->addFooterJS(" -$('#delete-document-btn-".$docid."').popover({ - title: '".getMLText("rm_document")."', - placement: 'left', - html: true, - content: \"
".htmlspecialchars(getMLText("confirm_rm_document", array ("documentname" => $document->getName())), ENT_QUOTES)."
\"}); -"); + $content .= ' $document->getName())), ENT_QUOTES).'">'; if($return) return $content; else @@ -1390,6 +1411,56 @@ $('#delete-document-btn-".$docid."').popover({ return ''; } /* }}} */ + function printDeleteDocumentButtonJs(){ /* {{{ */ + echo " + $(document).ready(function () { + $('.delete-document-btn').click(function(ev) { + id = $(ev.currentTarget).attr('rel'); + confirmmsg = $(ev.currentTarget).attr('confirmmsg'); + msg = $(ev.currentTarget).attr('msg'); + formtoken = '".createFormKey('removedocument')."'; + bootbox.dialog(confirmmsg, [{ + \"label\" : \" ".getMLText("rm_document")."\", + \"class\" : \"btn-danger\", + \"callback\": function() { + $.get('../op/op.Ajax.php', + { command: 'deletedocument', id: id, formtoken: formtoken }, + function(data) { + if(data.success) { + $('#table-row-document-'+id).hide('slow'); + noty({ + text: msg, + type: 'success', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 1500, + }); + } else { + noty({ + text: data.message, + type: 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 3500, + }); + } + }, + 'json' + ); + } + }, { + \"label\" : \"".getMLText("cancel")."\", + \"class\" : \"btn-cancel\", + \"callback\": function() { + } + }]); + }); + }); + "; + } /* }}} */ + /** * Print button with link for deleting a folder * @@ -1404,14 +1475,7 @@ $('#delete-document-btn-".$docid."').popover({ function printDeleteFolderButton($folder, $msg, $return=false){ /* {{{ */ $folderid = $folder->getID(); $content = ''; - $content .= ''; - $this->addFooterJS(" -$('#delete-folder-btn-".$folderid."').popover({ - title: '".getMLText("rm_folder")."', - placement: 'left', - html: true, - content: \"
".htmlspecialchars(getMLText("confirm_rm_folder", array ("foldername" => $folder->getName())), ENT_QUOTES)."
\"}); -"); + $content .= ' $folder->getName())), ENT_QUOTES).'">'; if($return) return $content; else @@ -1419,6 +1483,56 @@ $('#delete-folder-btn-".$folderid."').popover({ return ''; } /* }}} */ + function printDeleteFolderButtonJs(){ /* {{{ */ + echo " + $(document).ready(function () { + $('.delete-folder-btn').click(function(ev) { + id = $(ev.currentTarget).attr('rel'); + confirmmsg = $(ev.currentTarget).attr('confirmmsg'); + msg = $(ev.currentTarget).attr('msg'); + formtoken = '".createFormKey('removefolder')."'; + bootbox.dialog(confirmmsg, [{ + \"label\" : \" ".getMLText("rm_folder")."\", + \"class\" : \"btn-danger\", + \"callback\": function() { + $.get('../op/op.Ajax.php', + { command: 'deletefolder', id: id, formtoken: formtoken }, + function(data) { + if(data.success) { + $('#table-row-folder-'+id).hide('slow'); + noty({ + text: msg, + type: 'success', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 1500, + }); + } else { + noty({ + text: data.message, + type: 'error', + dismissQueue: true, + layout: 'topRight', + theme: 'defaultTheme', + timeout: 3500, + }); + } + }, + 'json' + ); + } + }, { + \"label\" : \"".getMLText("cancel")."\", + \"class\" : \"btn-cancel\", + \"callback\": function() { + } + }]); + }); + }); + "; + } /* }}} */ + function printLockButton($document, $msglock, $msgunlock, $return=false) { /* {{{ */ $docid = $document->getID(); if($document->isLocked()) { @@ -2034,11 +2148,10 @@ mayscript> * * @param object $document document */ - protected function printTimeline($timelineurl, $height=300, $start='', $end='', $skip=array()) { /* {{{ */ + protected function printTimelineJs($timelineurl, $height=300, $start='', $end='', $skip=array()) { /* {{{ */ if(!$timelineurl) return; ?> - + protected function printTimelineHtml($height) { /* {{{ */ +?>
\n"; + $this->printTimelineJs($timelineurl, $height, $start, $end, $skip); + echo ""; + $this->printTimelineHtml($height); + } /* }}} */ } ?> diff --git a/views/bootstrap/class.DocumentChooser.php b/views/bootstrap/class.DocumentChooser.php index 71e71a8db..d382e6227 100644 --- a/views/bootstrap/class.DocumentChooser.php +++ b/views/bootstrap/class.DocumentChooser.php @@ -31,6 +31,12 @@ require_once("class.Bootstrap.php"); */ class SeedDMS_View_DocumentChooser extends SeedDMS_Bootstrap_Style { + function js() { /* {{{ */ + $folder = $this->params['folder']; + $form = $this->params['form']; + $this->printNewTreeNavigationJs($folder->getID(), M_READ, 1, $form); + } /* }}} */ + function show() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; @@ -39,9 +45,10 @@ class SeedDMS_View_DocumentChooser extends SeedDMS_Bootstrap_Style { $this->htmlStartPage(getMLText("choose_target_document")); $this->contentContainerStart(); - $this->printNewTreeNavigation($folder->getID(), M_READ, 1, $form); + $this->printNewTreeNavigationHtml($folder->getID(), M_READ, 1, $form); $this->contentContainerEnd(); - echo "\n\n"; + $this->htmlEndPage(true); +// echo "\n\n"; } /* }}} */ } ?> diff --git a/views/bootstrap/class.ViewDocument.php b/views/bootstrap/class.ViewDocument.php index 40cfc854b..df93c9581 100644 --- a/views/bootstrap/class.ViewDocument.php +++ b/views/bootstrap/class.ViewDocument.php @@ -110,6 +110,14 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style { echo json_encode($jsondata); } /* }}} */ + function js() { /* {{{ */ + $document = $this->params['document']; + + header('Content-Type: application/json'); + $this->printTimelineJs('out.ViewDocument.php?action=timelinedata&documentid='.$document->getID(), 300, '', date('Y-m-d')); + $this->printDocumentChooserJs("form1"); + } /* }}} */ + function show() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; @@ -1085,7 +1093,7 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style { - + getAccessMode($user) >= M_READWRITE) { @@ -1171,7 +1179,8 @@ class SeedDMS_View_ViewDocument extends SeedDMS_Bootstrap_Style { } $item['msg'] = $msg; } - $this->printTimeline('out.ViewDocument.php?action=timelinedata&documentid='.$document->getID(), 300, '', date('Y-m-d')); +// $this->printTimeline('out.ViewDocument.php?action=timelinedata&documentid='.$document->getID(), 300, '', date('Y-m-d')); + $this->printTimelineHtml(300); } } ?> diff --git a/views/bootstrap/class.ViewFolder.php b/views/bootstrap/class.ViewFolder.php index ab82b90cf..ad13c1931 100644 --- a/views/bootstrap/class.ViewFolder.php +++ b/views/bootstrap/class.ViewFolder.php @@ -71,6 +71,33 @@ class SeedDMS_View_ViewFolder extends SeedDMS_Bootstrap_Style { } } /* }}} */ + function js() { /* {{{ */ + $user = $this->params['user']; + $folder = $this->params['folder']; + $orderby = $this->params['orderby']; + $expandFolderTree = $this->params['expandFolderTree']; + $enableDropUpload = $this->params['enableDropUpload']; + + header('Content-Type: application/json'); +?> + function folderSelected(id, name) { + window.location = '../out/out.ViewFolder.php?folderid=' + id; + } +printNewTreeNavigationJs($folder->getID(), M_READ, 0, '', $expandFolderTree == 2, $orderby); + + if (0 && $enableDropUpload && $folder->getAccessMode($user) >= M_READWRITE) { + echo "SeedDMSUpload.setUrl('../op/op.Ajax.php');"; + echo "SeedDMSUpload.setAbortBtnLabel('".getMLText("cancel")."');"; + echo "SeedDMSUpload.setEditBtnLabel('".getMLText("edit_document_props")."');"; + echo "SeedDMSUpload.setMaxFileSize(".SeedDMS_Core_File::parse_filesize(ini_get("upload_max_filesize")).");"; + echo "SeedDMSUpload.setMaxFileSizeMsg('".getMLText("uploading_maxsize")."');"; + } + + $this->printDeleteFolderButtonJs(); + $this->printDeleteDocumentButtonJs(); + } /* }}} */ + function show() { /* {{{ */ $dms = $this->params['dms']; $user = $this->params['user']; @@ -89,6 +116,8 @@ class SeedDMS_View_ViewFolder extends SeedDMS_Bootstrap_Style { $folderid = $folder->getId(); + $this->htmlAddHeader(''."\n", 'js'); + $this->htmlStartPage(getMLText("folder_title", array("foldername" => htmlspecialchars($folder->getName())))); $this->globalNavigation($folder); @@ -111,14 +140,7 @@ class SeedDMS_View_ViewFolder extends SeedDMS_Bootstrap_Style { if ($showtree==1){ $this->contentHeading("", true); $this->contentContainerStart(); -?> - -printNewTreeNavigation($folderid, M_READ, 0, '', $expandFolderTree == 2, $orderby); + $this->printNewTreeNavigationHtml($folderid, M_READ, 0, '', $expandFolderTree == 2, $orderby); $this->contentContainerEnd(); } else { $this->contentHeading("", true); @@ -198,11 +220,11 @@ class SeedDMS_View_ViewFolder extends SeedDMS_Bootstrap_Style { echo ""; echo "
"; $this->contentHeading(getMLText("dropupload"), true); - $this->addFooterJS("SeedDMSUpload.setUrl('../op/op.Ajax.php');"); - $this->addFooterJS("SeedDMSUpload.setAbortBtnLabel('".getMLText("cancel")."');"); - $this->addFooterJS("SeedDMSUpload.setEditBtnLabel('".getMLText("edit_document_props")."');"); - $this->addFooterJS("SeedDMSUpload.setMaxFileSize(".SeedDMS_Core_File::parse_filesize(ini_get("upload_max_filesize")).");"); - $this->addFooterJS("SeedDMSUpload.setMaxFileSizeMsg('".getMLText("uploading_maxsize")."');"); +// $this->addFooterJS("SeedDMSUpload.setUrl('../op/op.Ajax.php');"); +// $this->addFooterJS("SeedDMSUpload.setAbortBtnLabel('".getMLText("cancel")."');"); +// $this->addFooterJS("SeedDMSUpload.setEditBtnLabel('".getMLText("edit_document_props")."');"); +// $this->addFooterJS("SeedDMSUpload.setMaxFileSize(".SeedDMS_Core_File::parse_filesize(ini_get("upload_max_filesize")).");"); +// $this->addFooterJS("SeedDMSUpload.setMaxFileSizeMsg('".getMLText("uploading_maxsize")."');"); ?>
:printDocumentChooser("form1");?>printDocumentChooserHtml("form1");?>