# HG changeset patch
# User Dan
# Date 1186775842 14400
# Node ID c162ca39db8f8589280a85053be65dd6b2a23a82
# Parent 7c68a18a27be502748c102f42713ae62b66ee1ec
Finished pagination code (was incomplete in previous revision) and added a few hacks for an upcoming theme
diff -r 7c68a18a27be -r c162ca39db8f includes/clientside/static/comments.js
--- a/includes/clientside/static/comments.js Thu Aug 09 12:26:16 2007 -0400
+++ b/includes/clientside/static/comments.js Fri Aug 10 15:57:22 2007 -0400
@@ -34,7 +34,7 @@
switch(response.mode)
{
case 'fetch':
- document.getElementById('ajaxEditContainer').innerHTML = 'Rendering response...';
+ document.getElementById('ajaxEditContainer').innerHTML = '
Rendering '+response.count_total+' comments...
';
if(response.template)
comment_template = response.template;
setAjaxLoading();
@@ -53,7 +53,7 @@
materializeComment(response);
break;
case 'error':
- alert(response.error);
+ new messagebox(MB_OK|MB_ICONSTOP, ( response.title ? response.title : 'Error fetching comment data' ), response.error);
break;
default:
alert(ajax.responseText);
@@ -183,12 +183,12 @@
if ( this_comment.user_level >= data.user_level.member ) tplvars.USER_LEVEL = 'Member';
if ( this_comment.user_level >= data.user_level.mod ) tplvars.USER_LEVEL = 'Moderator';
if ( this_comment.user_level >= data.user_level.admin ) tplvars.USER_LEVEL = 'Administrator';
-
+
// Send PM link
- tplvars.SEND_PM_LINK=(this_comment.user_id>1)?'Send private message
':'';
+ tplvars.SEND_PM_LINK=(this_comment.user_id>1 && data.logged_in)?'Send private message
':'';
// Add buddy link
- tplvars.ADD_BUDDY_LINK=(this_comment.user_id>1)?'Add to buddy list
':'';
+ tplvars.ADD_BUDDY_LINK=(this_comment.user_id>1 && data.logged_in)?'Add to buddy list
':'';
// Edit link
tplvars.EDIT_LINK='edit';
diff -r 7c68a18a27be -r c162ca39db8f includes/clientside/static/enano-lib-basic.js
--- a/includes/clientside/static/enano-lib-basic.js Thu Aug 09 12:26:16 2007 -0400
+++ b/includes/clientside/static/enano-lib-basic.js Fri Aug 10 15:57:22 2007 -0400
@@ -9,7 +9,7 @@
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
*
- * For more information about Enano, please visit http://www.enanocms.org/.
+ * For more information about Enano, please visit http://enanocms.org/.
* All of the code in these script files may be used freely so long as the above license block is displayed and your
* modified code is distributed under the GPL. See the page Special:About_Enano on this website for more information.
*/
diff -r 7c68a18a27be -r c162ca39db8f includes/clientside/static/paginate.js
--- a/includes/clientside/static/paginate.js Thu Aug 09 12:26:16 2007 -0400
+++ b/includes/clientside/static/paginate.js Fri Aug 10 15:57:22 2007 -0400
@@ -60,19 +60,25 @@
pagin_objects[this.random_id] = this;
}
+/**
+ * Yet another demonstration of the fact that with the right tools, any amount of Javascript can be ported from PHP.
+ * @access private
+ */
+
function _build_paginator(this_page)
{
- var begin = 'Page: | ';
- var block = '{LINK} | ';
+ var div_styling = ( IE ) ? 'width: 1px; margin: 10px auto 10px 0;' : 'display: table; margin: 10px 0 0 auto;';
+ var begin = 'Page: | ';
+ var block = '{LINK} | ';
var end = '
---|
';
var blk = new templateParser(block);
var inner = '';
var cls = 'row2';
- if ( this.offset > 0 )
+ if ( this_page > 0 )
{
- var url = '#';
- var link = "« Prev";
+ var url = '#page_'+(this_page);
+ var link = "« Prev";
cls = ( cls == 'row1' ) ? 'row2' : 'row1';
blk.assign_vars({
CLASS: cls,
@@ -85,8 +91,8 @@
for ( var i = 0; i < this.num_pages; i++ )
{
cls = ( cls == 'row1' ) ? 'row2' : 'row1';
- var url = '#';
var j = i + 1;
+ var url = '#page_'+j;
var link = ( i == this_page ) ? ""+j+"" : ""+j+"";
blk.assign_vars({
CLASS: cls,
@@ -100,10 +106,10 @@
if ( this_page + 5 > this.num_pages )
{
var list = new Array();
- var tp = this_page;
- if ( this_page + 0 == this.num_pages ) tp = tp - 3;
- if ( this_page + 1 == this.num_pages ) tp = tp - 2;
- if ( this_page + 2 == this.num_pages ) tp = tp - 1;
+ var tp = this_page; // The vectors below used to be 3, 2, and 1
+ if ( this_page + 0 == this.num_pages ) tp = tp - 2;
+ if ( this_page + 1 == this.num_pages ) tp = tp - 1;
+ if ( this_page + 2 == this.num_pages ) tp = tp - 0;
for ( var i = tp - 1; i <= tp + 1; i++ )
{
list.push(i);
@@ -119,8 +125,8 @@
list.push(lower + i);
}
}
- var url = '#';
- var link = ( 0 == this.offset ) ? "First" : "« First";
+ var url = '#page_1';
+ var link = ( 0 == this_page ) ? "First" : "« First";
blk.assign_vars({
CLASS: cls,
LINK: link
@@ -140,10 +146,9 @@
if ( i == this.num_pages )
break;
cls = ( cls == 'row1' ) ? 'row2' : 'row1';
- var offset = i * this_page;
- var url = '#';
var j = i + 1;
- var link = ( offset == this.offset ) ? ""+j+"" : ""+j+"";
+ var url = '#page_'+j;
+ var link = ( i == this_page ) ? ""+j+"" : ""+j+"";
blk.assign_vars({
CLASS: cls,
LINK: link
@@ -151,8 +156,6 @@
inner += blk.run();
}
- var total = num_pages * perpage - perpage;
-
if ( this_page < this.num_pages )
{
// $cls = ( $cls == 'row1' ) ? 'row2' : 'row1';
@@ -160,9 +163,8 @@
// $inner .= $blk->run();
cls = ( cls == 'row1' ) ? 'row2' : 'row1';
- var url = '#';
- var j = i + 1;
- var link = ( total == this.offset ) ? "Last" : "Last »";
+ var url = '#page_' + String( this.num_pages-1 );
+ var link = ( ( this.num_pages - 1 ) == this_page ) ? "Last" : "Last »";
blk.assign_vars({
CLASS: cls,
LINK: link
@@ -172,10 +174,10 @@
}
- if ( this.offset < total )
+ if ( this_page < ( this.num_pages - 1 ) )
{
- var url = '#page_' + abs(this.offset + this.perpage);
- var link = "Next »";
+ var url = '#page_' + String(this_page + 2);
+ var link = "Next »";
cls = ( cls == 'row1' ) ? 'row2' : 'row1';
blk.assign_vars({
CLASS: cls,
@@ -194,13 +196,63 @@
function jspaginator_goto(pagin_id, jump_to)
{
var theobj = pagin_objects[pagin_id];
+ var current_div = false;
+ var new_div = false;
for ( var i = 0; i < theobj.num_pages; i++ )
{
- var display = ( i == jump_to ) ? 'block' : 'none';
var thediv = document.getElementById(pagin_id + '_' + i);
- if ( thediv )
- thediv.style.display = display;
+ if ( !thediv )
+ {
+ // if ( window.console )
+ // window.console.error('jspaginator_goto(): got a bad DOM object in loop');
+ return false;
+ }
+ // window.console.debug("Div "+i+' of '+(theobj.num_pages-1)+': ', thediv);
+ if ( thediv.style.display != 'none' )
+ current_div = thediv;
+ else if ( i == jump_to )
+ new_div = thediv;
+ }
+
+ if ( !new_div )
+ {
+ // if ( window.console )
+ // window.console.error('jspaginator_goto(): didn\'t get new div');
+ return false;
+ }
+ if ( !current_div )
+ {
+ // if ( window.console )
+ // window.console.error('jspaginator_goto(): didn\'t get current div');
+ return false;
}
+
+ // window.console.debug(current_div);
+ // window.console.debug(new_div);
+
+ // White-out the old div and fade in the new one
+
+ if ( IE || is_Safari )
+ {
+ current_div.style.display = 'none';
+ new_div.style.display = 'block';
+ }
+ else
+ {
+ var fade_time = 375;
+ var code = 'var old = \'' + current_div.id + '\';';
+ code += 'var newer = \'' + new_div.id + '\';';
+ code += 'document.getElementById(old).style.display = "none";';
+ code += 'changeOpac(0, newer);';
+ code += 'document.getElementById(newer).style.display = "block";';
+ code += 'opacity(newer, 0, 100, '+fade_time+');';
+ // if ( window.console )
+ // window.console.debug('metacode for fader: ', code);
+ opacity(current_div.id, 100, 0, fade_time);
+ setTimeout(code, (fade_time + 50));
+ }
+
+
var pg_control = theobj._build_control(jump_to);
var divs = getElementsByClassName(document, 'div', pagin_id + '_control');
for ( var i = 0; i < divs.length; i++ )
diff -r 7c68a18a27be -r c162ca39db8f includes/clientside/static/toolbar.js
--- a/includes/clientside/static/toolbar.js Thu Aug 09 12:26:16 2007 -0400
+++ b/includes/clientside/static/toolbar.js Fri Aug 10 15:57:22 2007 -0400
@@ -40,7 +40,10 @@
{
if ( !document.getElementById('pagebar_main') )
return false;
- if(typeof(document.getElementById('mdgToolbar_'+which)) == 'object')
+ var dom = document.getElementById('mdgToolbar_'+which);
+ if ( !dom )
+ return false;
+ if(typeof(dom) == 'object')
{
unselectAllButtonsMajor();
document.getElementById('mdgToolbar_'+which).className = 'selected';
diff -r 7c68a18a27be -r c162ca39db8f includes/comment.php
--- a/includes/comment.php Thu Aug 09 12:26:16 2007 -0400
+++ b/includes/comment.php Fri Aug 10 15:57:22 2007 -0400
@@ -85,7 +85,15 @@
$data = decode_unicode_array($data);
if ( !isset($data['mode']) )
{
- return $parser->encode(Array('mode'=>'error','error'=>'No mode defined!'));
+ $ret = Array('mode'=>'error','error'=>'No mode defined!');
+ echo $parser->encode($ret);
+ return $ret;
+ }
+ if ( getConfig('enable_comments') == '0' )
+ {
+ $ret = Array('mode'=>'error','error'=>'Comments are not enabled on this site.');
+ echo $parser->encode($ret);
+ return $ret;
}
$ret = Array();
$ret['mode'] = $data['mode'];
diff -r 7c68a18a27be -r c162ca39db8f includes/functions.php
--- a/includes/functions.php Thu Aug 09 12:26:16 2007 -0400
+++ b/includes/functions.php Fri Aug 10 15:57:22 2007 -0400
@@ -731,7 +731,7 @@
if ( $paths->namespace != 'Special' && $paths->namespace != 'Admin' )
{
- echo '
---|