From eaf95fa99d7eac9f94434099b8a621bd680722cc Mon Sep 17 00:00:00 2001 From: vargenau Date: Sat, 14 Feb 2009 16:39:01 +0000 Subject: [PATCH] Put flipAll Javascript function in wikicommon.js git-svn-id: svn://svn.code.sf.net/p/phpwiki/code/trunk@6500 96ab9672-09ca-45d6-a79d-3d69d39ca109 --- lib/PageList.php | 23 +---------------------- lib/WikiTheme.php | 1 + themes/default/wikicommon.js | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 22 deletions(-) create mode 100644 themes/default/wikicommon.js diff --git a/lib/PageList.php b/lib/PageList.php index 78f3418f6..63ec12ccf 100644 --- a/lib/PageList.php +++ b/lib/PageList.php @@ -1417,12 +1417,6 @@ class PageList { $table->pushContent(HTML::caption(array('align'=>'top'), $caption)); } - //Warning: This is quite fragile. It depends solely on a private variable - // in ->_addColumn() - if (!empty($this->_columns_seen['checkbox'])) { - $table->pushContent($this->_jsFlipAll()); - } - $row = HTML::tr(); $table_summary = array(); $i = 1; // start with 1! @@ -1464,21 +1458,6 @@ class PageList { } } - function _jsFlipAll() { - return JavaScript(" -function flipAll(formObj) { - var isFirstSet = -1; - for (var i=0; i < formObj.length; i++) { - fldObj = formObj.elements[i]; - if ((fldObj.type == 'checkbox') && (fldObj.name.substring(0,2) == 'p[')) { - if (isFirstSet == -1) - isFirstSet = (fldObj.checked) ? true : false; - fldObj.checked = (isFirstSet) ? false : true; - } - } -}"); - } - /* recursive stack for private sublist options (azhead, cols) */ function _saveOptions($opts) { $stack = array('pages' => $this->_pages); @@ -1682,7 +1661,7 @@ function flipAll(formObj) { }; /* List pages with checkboxes to select from. - * The [Select] button toggles via _jsFlipAll + * The [Select] button toggles via Javascript flipAll */ class PageList_Selectable diff --git a/lib/WikiTheme.php b/lib/WikiTheme.php index 0fc902fad..fd92351c1 100644 --- a/lib/WikiTheme.php +++ b/lib/WikiTheme.php @@ -217,6 +217,7 @@ class WikiTheme { } if ($noinit) return; + $this->addMoreHeaders(JavaScript('',array('src' => $this->_findData("wikicommon.js")))); $script_url = deduce_script_name(); if ((DEBUG & _DEBUG_REMOTE) and isset($_GET['start_debug'])) $script_url .= ("?start_debug=".$_GET['start_debug']); diff --git a/themes/default/wikicommon.js b/themes/default/wikicommon.js new file mode 100644 index 000000000..9f3674541 --- /dev/null +++ b/themes/default/wikicommon.js @@ -0,0 +1,14 @@ +// Common Javascript support functions. +// $Id: toolbar.js 6204 2008-08-26 15:12:03Z vargenau $ + +function flipAll(formObj) { + var isFirstSet = -1; + for (var i=0; i < formObj.length; i++) { + fldObj = formObj.elements[i]; + if ((fldObj.type == 'checkbox') && (fldObj.name.substring(0,2) == 'p[')) { + if (isFirstSet == -1) + isFirstSet = (fldObj.checked) ? true : false; + fldObj.checked = (isFirstSet) ? false : true; + } + } +} -- 2.45.0