|
From: <dj...@us...> - 2013-03-31 23:56:13
|
Revision: 11335
http://sourceforge.net/p/xoops/svn/11335
Author: djculex
Date: 2013-03-31 23:56:08 +0000 (Sun, 31 Mar 2013)
Log Message:
-----------
NEW : adding smallworld_settings to sql file. If using old version accessing admin will automaticly add this if not existing
NEW : Adding streamlines code to class publicUplades to show only public posts
NEW : Adding user privacy settings to templates, index, user page etc etc
UPDATE : upgrading file uploader
UPDATE : Updating jquery.Oembed
UPDATE : jQuery.countdown to v1.5.10
Bugfix : Fileuploader onClick reaction
Bugfix : Adjusting various css selectors
Bugfix : Changing || to && in javascript check for existing image
Bugfix : Removing maxsize from update textarea. Maximum is now undefined so basically you could post the ikea catelogue there
Bugfix : Sharepage will only be usable on public posts
Bugfix : Including Sizzle.js to jquery 1.9.1 to refactor depreseated functionality
NEW LANGUAGE FILES
main.php
---------
define ("_SMALLWORLD_SHOWIFPUBLICORPRIVATE","Privacy settings. What to show if wall is public");
define ("_SMALLWORLD_SHOWMYPOSTS","Show my posts");
define ("_SMALLWORLD_SHOWMYCOMMENTS","Show my comments");
define ("_SMALLWORLD_MENU_PRIVSET","Pri. Settings");
define ("_SMALLWORLD_MESSAGE_PRIVSETPOSTS","Posts from this user are only visible for followers or friends...Please register.");
define ("_SMALLWORLD_MESSAGE_PRIVSETCOMMENTS","Comments from this user are only visible for followers or friends...Please register.");
Modified Paths:
--------------
XoopsModules/smallworld/trunk/smallworld/admin/index.php
XoopsModules/smallworld/trunk/smallworld/admin/main.php
XoopsModules/smallworld/trunk/smallworld/class/publicWall.php
XoopsModules/smallworld/trunk/smallworld/class/user.php
XoopsModules/smallworld/trunk/smallworld/class/wall.php
XoopsModules/smallworld/trunk/smallworld/css/smallworld.css
XoopsModules/smallworld/trunk/smallworld/index.php
XoopsModules/smallworld/trunk/smallworld/js/jquery.bookmark.js
XoopsModules/smallworld/trunk/smallworld/js/jquery.countdown.js
XoopsModules/smallworld/trunk/smallworld/js/jquery.history.js
XoopsModules/smallworld/trunk/smallworld/js/jquery.min.js
XoopsModules/smallworld/trunk/smallworld/js/main.js
XoopsModules/smallworld/trunk/smallworld/js/smallworld.js
XoopsModules/smallworld/trunk/smallworld/js/wall.js
XoopsModules/smallworld/trunk/smallworld/language/danish/modinfo.php
XoopsModules/smallworld/trunk/smallworld/language/english/main.php
XoopsModules/smallworld/trunk/smallworld/language/english/modinfo.php
XoopsModules/smallworld/trunk/smallworld/language/french/modinfo.php
XoopsModules/smallworld/trunk/smallworld/language/french_iso/modinfo.php
XoopsModules/smallworld/trunk/smallworld/language/russian/modinfo.php
XoopsModules/smallworld/trunk/smallworld/loadmore.php
XoopsModules/smallworld/trunk/smallworld/publicindex.php
XoopsModules/smallworld/trunk/smallworld/smallworldshare.php
XoopsModules/smallworld/trunk/smallworld/sql/mysql.sql
XoopsModules/smallworld/trunk/smallworld/templates/getStat.html
XoopsModules/smallworld/trunk/smallworld/templates/getlastcom.html
XoopsModules/smallworld/trunk/smallworld/templates/getlastmsg.html
XoopsModules/smallworld/trunk/smallworld/templates/getmore.html
XoopsModules/smallworld/trunk/smallworld/templates/getmorepublic.html
XoopsModules/smallworld/trunk/smallworld/templates/smallworld_index.html
XoopsModules/smallworld/trunk/smallworld/templates/smallworld_permalink.html
XoopsModules/smallworld/trunk/smallworld/templates/smallworld_publicindex.html
XoopsModules/smallworld/trunk/smallworld/templates/smallworld_share.html
XoopsModules/smallworld/trunk/smallworld/templates/smallworld_userprofile_edittemplate.html
XoopsModules/smallworld/trunk/smallworld/templates/smallworld_userprofile_regtemplate.html
XoopsModules/smallworld/trunk/smallworld/templates/smallworld_userprofile_template.html
XoopsModules/smallworld/trunk/smallworld/userprofile.php
XoopsModules/smallworld/trunk/smallworld/xoops_version.php
Added Paths:
-----------
XoopsModules/smallworld/trunk/smallworld/admin/upgrade.php
XoopsModules/smallworld/trunk/smallworld/css/uploader/index.html
XoopsModules/smallworld/trunk/smallworld/js/cors/index.html
XoopsModules/smallworld/trunk/smallworld/js/uploader/index.html
XoopsModules/smallworld/trunk/smallworld/js/vendor/index.html
XoopsModules/smallworld/trunk/smallworld/settings.php
XoopsModules/smallworld/trunk/smallworld/templates/settings.html
Modified: XoopsModules/smallworld/trunk/smallworld/admin/index.php
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/admin/index.php 2013-03-31 23:21:54 UTC (rev 11334)
+++ XoopsModules/smallworld/trunk/smallworld/admin/index.php 2013-03-31 23:56:08 UTC (rev 11335)
@@ -197,5 +197,4 @@
echo $indexAdmin->addNavigation('index.php');
echo $indexAdmin->renderIndex();
-include "admin_footer.php";
-?>
\ No newline at end of file
+include "admin_footer.php";
\ No newline at end of file
Modified: XoopsModules/smallworld/trunk/smallworld/admin/main.php
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/admin/main.php 2013-03-31 23:21:54 UTC (rev 11334)
+++ XoopsModules/smallworld/trunk/smallworld/admin/main.php 2013-03-31 23:56:08 UTC (rev 11335)
@@ -184,4 +184,3 @@
$xoTheme->addScript(XOOPS_URL . '/modules/smallworld/js/adminsmallworld.js');
xoops_cp_footer();
-?>
Added: XoopsModules/smallworld/trunk/smallworld/admin/upgrade.php
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/admin/upgrade.php (rev 0)
+++ XoopsModules/smallworld/trunk/smallworld/admin/upgrade.php 2013-03-31 23:56:08 UTC (rev 11335)
@@ -0,0 +1,41 @@
+<?php
+// Upgrade functions used when adding or altering tables etc between versions
+/**
+ * Function to do the creatind
+ *
+ */
+function smallworld_doUpgrade () {
+ global $xoopsDB, $xoopsUser;
+ varcharToBlog ();
+ if (smallworld_DoTableExists($xoopsDB->prefix('smallworld_settings'))) {
+ // Table exists
+ Return false;
+ } else {
+ // Table does not exist -> create
+
+ $sql = "CREATE TABLE IF NOT EXISTS ".$xoopsDB->prefix('smallworld_settings')." (";
+ $sql .= "`id` int(11) NOT NULL AUTO_INCREMENT,";
+ $sql .= "`userid` int(11) NOT NULL,";
+ $sql .= "`value` text NOT NULL,";
+ $sql .= "PRIMARY KEY (`id`)";
+ $sql .= ") ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ;";
+ $result = $xoopsDB->queryF($sql);
+ }
+}
+
+function smallworld_DoTableExists($tablename) {
+ global $xoopsDB;
+ $result = $xoopsDB->queryF("SHOW TABLES LIKE '$tablename'");
+ return ($xoopsDB->getRowsNum($result) > 0);
+}
+
+/**
+ * Alter table messages from varchar(200) to text()
+ * @return void
+ */
+function varcharToBlog () {
+ global $xoopsDB;
+ $sql ="ALTER TABLE ".$xoopsDB->prefix('smallworld_messages')." CHANGE message message TEXT";
+ $result = $xoopsDB->queryF($sql);
+}
+?>
\ No newline at end of file
Modified: XoopsModules/smallworld/trunk/smallworld/class/publicWall.php
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/class/publicWall.php 2013-03-31 23:21:54 UTC (rev 11334)
+++ XoopsModules/smallworld/trunk/smallworld/class/publicWall.php 2013-03-31 23:56:08 UTC (rev 11335)
@@ -39,7 +39,29 @@
}
}
+
/**
+ * Get arry of users being inspected
+ *
+ *
+ */
+
+ function inspected () {
+ global $xoopsDB;
+ $sql = "SELECT userid FROM ".$xoopsDB->prefix('smallworld_admin'). " WHERE (inspect_start+inspect_stop) > ".time()."";
+ $result = $xoopsDB->queryF($sql);
+ $data = array();
+ while ($row = $xoopsDB->fetchArray($result)) {
+ $data[]=$row;
+ }
+ if (!empty($data)) {
+ $sub = implode(",",Smallworld_array_flatten(array_unique($data),0));
+ } else {
+ $sub = 0;
+ }
+ return $sub;
+ }
+ /**
* @Get array of updates
* @param int $last
* @param int $uid
@@ -47,49 +69,29 @@
* @return array
*/
public function Updates($last,$moderators) {
- global $xoopsUser, $xoopsDB, $moduleConfig;
+ global $xoopsUser, $xoopsDB, $moduleConfig, $xoopsLogger;
$hm = smallworld_GetModuleOption('msgtoshow');
$set = smallworld_checkPrivateOrPublic ();
$mods = implode(",",Smallworld_array_flatten(array_unique($moderators),0));
+ $inspected = $this->inspected();
+
$i=0;
//Get array of users permitted to post on public index page (normally admin moderators etc etc)
if ($last == 0) {
$query = "SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM ".$xoopsDB->prefix('smallworld_messages')
- . " M, ".$xoopsDB->prefix('smallworld_user')." U WHERE M.uid_fk=U.userid and M.priv = '0'";
+ . " M, ".$xoopsDB->prefix('smallworld_user')." U WHERE M.uid_fk=U.userid and M.uid_fk in (".$mods.") and M.uid_fk NOT IN (".$inspected.") and M.priv = '0'";
} elseif ($last > 0) {
$query = "SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM "
. $xoopsDB->prefix('smallworld_messages')." M, ".$xoopsDB->prefix('smallworld_user')
- . " U WHERE M.uid_fk=U.userid and M.priv = '0' and M.msg_id < '".$last."'";
+ . " U WHERE M.uid_fk=U.userid and M.uid_fk in (".$mods.") and M.uid_fk NOT IN (".$inspected.") and M.priv = '0' and M.msg_id < '".$last."'";
} elseif ($last == 'a') {
$query = "SELECT M.msg_id, M.uid_fk, M.priv, M.message, M.created, U.username FROM "
. $xoopsDB->prefix('smallworld_messages')." M, ".$xoopsDB->prefix('smallworld_user')
- . " U WHERE M.uid_fk=U.userid and M.priv = '0'";
+ . " U WHERE M.uid_fk=U.userid and M.uid_fk in (".$mods.") and M.uid_fk NOT IN (".$inspected.") and M.priv = '0'";
}
-
- if (is_array($moderators)){
- foreach ($moderators as $k => $v) {
- if ($last>0) {
- $query .= " OR M.uid_fk=U.userid and M.uid_fk= '".$v."' and M.priv= '0' and M.msg_id < '".$last."'";
- } elseif ($last == 0) {
- $query .= " OR M.uid_fk=U.userid and M.uid_fk= '".$v."' and M.priv= '0' ";
- } elseif ($last == 'a') {
- $query .= " OR M.uid_fk=U.userid and M.uid_fk= '".$v."' and M.priv= '0' ";
- }
- $i++;
- }
- }
- if (!is_array($moderators)) {
- if ($last > 0) {
- $query .= " OR M.uid_fk=U.userid and M.uid_fk= '".$moderators."' and M.priv= '0' and M.msg_id < '".$last."'";
- } elseif ($last == 0) {
- $query .= " OR M.uid_fk=U.userid and M.uid_fk= '".$moderators."' and M.priv= '0' ";
- } elseif ($last == 'a') {
- $query .= " OR M.uid_fk=U.userid and M.uid_fk= '".$moderators."' and M.priv= '0' ";
- }
- }
-
+
if ($last>0) {
$query .= " order by created DESC LIMIT ".$hm;
} elseif ($last == 'a') {
@@ -121,9 +123,10 @@
public function Comments($msg_id)
{
global $xoopsUser, $xoopsDB;
+ $inspected = $this-> inspected();
$query = "SELECT C.msg_id_fk, C.com_id, C.uid_fk, C.comment, C.created, U.username FROM "
. $xoopsDB->prefix('smallworld_comments')." C, ".$xoopsDB->prefix('smallworld_user')
- . " U WHERE C.uid_fk=U.userid and C.msg_id_fk='".$msg_id."' order by C.com_id asc ";
+ . " U WHERE C.uid_fk=U.userid and C.msg_id_fk='".$msg_id."' and C.uid_fk NOT IN (".$inspected.") order by C.com_id asc ";
$result = $xoopsDB->queryF($query);
$i = $xoopsDB->getRowsNum($result);
while ($row = $xoopsDB->fetchArray($result)) {
Modified: XoopsModules/smallworld/trunk/smallworld/class/user.php
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/class/user.php 2013-03-31 23:21:54 UTC (rev 11334)
+++ XoopsModules/smallworld/trunk/smallworld/class/user.php 2013-03-31 23:56:08 UTC (rev 11335)
@@ -188,9 +188,26 @@
function spousexist($name) {
global $xoopsUser, $xoopsDB;
$sql = "SELECT * FROM ".$xoopsDB->prefix('smallworld_user')." WHERE username = '".$name."'";
- $result = $xoopsDB->queryf($sql);
+ $result = $xoopsDB->queryF($sql);
$i = $xoopsDB->getRowsNum($result);
return $i;
}
+
+ /**
+ * Get all users
+ * @return array
+ */
+
+ function allUsers () {
+ global $xoopsDB;
+ $sql = "SELECT userid FROM ".$xoopsDB->prefix('smallworld_user')." ORDER BY userid";
+ $result = $xoopsDB->queryF($sql);
+ while ($r = $xoopsDB->fetchArray($result)) {
+ $data[]=$r;
+ }
+ if (!empty($data)) {
+ return Smallworld_array_flatten($data,0);
+ }
+ }
}
?>
\ No newline at end of file
Modified: XoopsModules/smallworld/trunk/smallworld/class/wall.php
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/class/wall.php 2013-03-31 23:21:54 UTC (rev 11334)
+++ XoopsModules/smallworld/trunk/smallworld/class/wall.php 2013-03-31 23:56:08 UTC (rev 11335)
@@ -43,9 +43,8 @@
global $xoopsUser, $xoopsDB, $moduleConfig;
$hm = smallworld_GetModuleOption('msgtoshow');
$set = smallworld_checkPrivateOrPublic ();
- $pub = smallworld_GetModuleOption('smallworldshowPoPubPage', $repmodule='smallworld');
- $nfollow = array_unique(array_merge($pub, $followers));
- $followers = Smallworld_array_flatten($nfollow,0);
+ $followers = (is_array($followers)) ? $followers : array($followers);
+ $followers = array_unique(Smallworld_array_flatten($followers,0));
$i=0;
if ($last == 0) {
@@ -378,7 +377,9 @@
*/
public function UpdatesSharelink($updid,$ownerID)
{
- global $xoopsUser, $xoopsDB, $moduleConfig;
+ global $xoopsUser, $xoopsDB, $moduleConfig, $xoopsLogger;
+ $xoopsLogger->activated = false;
+ //error_reporting(E_ALL);
$query = "SELECT M.msg_id, M.uid_fk, M.message, M.created, M.priv, U.username FROM "
. $xoopsDB->prefix('smallworld_messages')." M, ".$xoopsDB->prefix('smallworld_user')
. " U WHERE M.uid_fk=U.userid and M.uid_fk='".$ownerID."' and M.priv = 0";
Modified: XoopsModules/smallworld/trunk/smallworld/css/smallworld.css
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/css/smallworld.css 2013-03-31 23:21:54 UTC (rev 11334)
+++ XoopsModules/smallworld/trunk/smallworld/css/smallworld.css 2013-03-31 23:56:08 UTC (rev 11335)
@@ -786,7 +786,7 @@
min-height:50px;
word-wrap:break-word;
overflow:hidden;
- padding:5px;
+ padding:0 5px 0;
display:block;
font-size:11px;
width:75%;
@@ -1070,10 +1070,10 @@
font-family: Verdana;
font-size: 12px;
font-weight: bold;
- left: 20%;
margin: 25px 0 5px;
padding: 25px 10px;
position: relative;
+ text-align: center;
}
.hasCountdown {
@@ -1244,9 +1244,10 @@
background-color: transparent;
border: none;
}
-/* -------------- count down -------------- */
+/* -------------- countdown -------------- */
.hasCountdown {
-width: 350px;
+width: 250px;
+margin: 15px 15% 0;
}
.countdown_rtl {
direction: rtl;
Added: XoopsModules/smallworld/trunk/smallworld/css/uploader/index.html
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/css/uploader/index.html (rev 0)
+++ XoopsModules/smallworld/trunk/smallworld/css/uploader/index.html 2013-03-31 23:56:08 UTC (rev 11335)
@@ -0,0 +1 @@
+<script>history.go(-1);</script>
\ No newline at end of file
Modified: XoopsModules/smallworld/trunk/smallworld/index.php
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/index.php 2013-03-31 23:21:54 UTC (rev 11334)
+++ XoopsModules/smallworld/trunk/smallworld/index.php 2013-03-31 23:56:08 UTC (rev 11335)
@@ -23,23 +23,24 @@
include_once(XOOPS_ROOT_PATH."/modules/smallworld/include/functions.php");
include_once(XOOPS_ROOT_PATH."/modules/smallworld/class/class_collector.php");
include_once(XOOPS_ROOT_PATH."/modules/smallworld/class/publicWall.php");
-global $xoopsUser, $xoTheme,$xoopsConfig,$xoopsLogger;
- $xoopsLogger->activated = true;
-/* error_reporting(E_ALL); */
+global $xoopsUser, $xoTheme,$xoopsConfig,$xoopsLogger, $xoopsModule;
$set = smallworld_checkPrivateOrPublic ();
if ($xoopsUser) {
$xoopsOption['template_main'] = 'smallworld_index.html';
-} elseif (!$xoopsUser || $set['access'] == 1) {
+} elseif (!$xoopsUser && $set['access'] == 1) {
$xoopsOption['template_main'] = 'smallworld_publicindex.html';
} else {
redirect_header(XOOPS_URL . "/user.php", 5, _NOPERM);
}
include_once(XOOPS_ROOT_PATH."/header.php");
- if ($set['access'] == 1) {
+ $xoopsLogger->activated = false;
+ /* error_reporting(E_ALL); */
+ if ($xoopsUser || $set['access'] == 1) {
$id = ($xoopsUser) ? $xoopsUser->getVar('uid'):0;
$user = new XoopsUser($id);
-
+ $dBase = new SmallWorldDB;
+
// Check if inspected userid -> redirect to userprofile and show admin countdown
$inspect = Smallworld_isInspected ($id);
if ($inspect['inspect'] == 'yes') {
@@ -54,7 +55,13 @@
} else {
$xoopsTpl->assign('isadminuser', 'NO');
}
-
+
+ // Create form for private settings
+ $form = new SmallWorldForm;
+ $usersettings = $form->usersettings ($id, $selected=null);
+ $xoopsTpl->assign('usersetting', $usersettings);
+
+
$username = $user->getVar('uname');
$check = new SmallWorldUser;
$profile = ($xoopsUser) ? $check->checkIfProfile($id) : 0;
@@ -69,9 +76,9 @@
}
// Things to do with wall
- $Wall = ($xoopsUser) ? new Wall_Updates() : new Public_Wall_Updates;
+ $Wall = ($profile > 0) ? new Wall_Updates() : new Public_Wall_Updates;
if (!$xoopsUser && $set['access'] == 1) {
- $pub = smallworld_GetModuleOption('smallworldshowPoPubPage', $repmodule='smallworld');
+ $pub = $check->allUsers();
$updatesarray = $Wall->updates(0, $pub);
} else {
// Follow array here
@@ -90,9 +97,28 @@
//Loading Comments link with load_updates.php
if (!empty($updatesarray)) {
foreach ($updatesarray as $data) {
- $wm['msg_id'] = $data['msg_id'];
- $wm['orimessage'] = str_replace(array("\r", "\n"), '',Smallworld_stripWordsKeepUrl($data['message']));
- $wm['message'] = nl2br(smallworld_tolink(htmlspecialchars_decode($data['message']), $data['uid_fk']));
+
+ $USW = array();
+ $USW['posts'] = 0;
+ $USW['comments'] = 0;
+
+ if ($xoopsUser) {
+
+ if ($xoopsUser->isAdmin($xoopsModule->getVar('mid')) && $data['uid_fk'] == $id) {
+ $USW['posts'] = 1;
+ $USW['comments'] = 1;
+ } else {
+ $USW = json_decode($dBase->GetSettings($data['uid_fk']), true);
+ }
+ }
+
+ if (!$xoopsUser) {
+ $USW = json_decode($dBase->GetSettings($data['uid_fk']), true);
+ }
+
+ $wm['msg_id'] = $data['msg_id'];
+ $wm['orimessage'] = ($USW['posts'] == 1) ? str_replace(array("\r", "\n"), '',Smallworld_stripWordsKeepUrl($data['message'])):'';
+ $wm['message'] = ($USW['posts'] == 1) ? nl2br(smallworld_tolink(htmlspecialchars_decode($data['message']), $data['uid_fk'])):_SMALLWORLD_MESSAGE_PRIVSETPOSTS;
$wm['message'] = str_replace(array('<','>'),array('<','>'), $wm['message']);
$wm['created'] = smallworld_time_stamp($data['created']);
$wm['username'] = $data['username'];
@@ -112,13 +138,32 @@
$wm['sharelink'] = $Wall->GetSharing ($wm['msg_id'],$wm['priv']);
$wm['sharediv'] = $Wall->GetSharingDiv ($wm['msg_id'],$wm['priv'], $wm['sharelinkurl'],$wm['orimessage'],$wm['usernameTitle']);
$wm['commentsarray'] = $Wall->Comments($data['msg_id']);
- $xoopsTpl->append('walldata', $wm);
+ $xoopsTpl->append('walldata', $wm);
- if (!empty($wm['commentsarray'])){
+ if (!empty($wm['commentsarray'])){
foreach($wm['commentsarray'] as $cdata) {
- $wc['msg_id_fk'] = $cdata['msg_id_fk'];
+
+ $USC = array();
+ $USC['posts'] = 0;
+ $USC['comments'] = 0;
+
+ if ($xoopsUser) {
+
+ if ($xoopsUser->isAdmin($xoopsModule->getVar('mid')) && $cdata['uid_fk'] == $id) {
+ $USC['posts'] = 1;
+ $USC['comments'] = 1;
+ } else {
+ $USC = json_decode($dBase->GetSettings($cdata['uid_fk']), true);
+ }
+ }
+
+ if (!$xoopsUser) {
+ $USC = json_decode($dBase->GetSettings($cdata['uid_fk']), true);
+ }
+
+ $wc['msg_id_fk'] = $cdata['msg_id_fk'];
$wc['com_id'] = $cdata['com_id'];
- $wc['comment'] = nl2br(smallworld_tolink(htmlspecialchars_decode($cdata['comment']),$cdata['uid_fk']));
+ $wc['comment'] = ($USC['comments'] == 1) ? nl2br(smallworld_tolink(htmlspecialchars_decode($cdata['comment']),$cdata['uid_fk'])):_SMALLWORLD_MESSAGE_PRIVSETCOMMENTS;
$wc['time'] = smallworld_time_stamp($cdata['created']);
$wc['username'] = $cdata['username'];
$wc['uid'] = $cdata['uid_fk'];
@@ -132,12 +177,12 @@
$wc['compl_msg_lnk'] .= "&updid=".$cdata['msg_id_fk']."#".$cdata['com_id']."'>"._SMALLWORLD_COMP_MSG_LNK_DESC."</a>";
$wc['vote_up'] = $Wall->countVotesCom ('com', 'up', $cdata['msg_id_fk'],$cdata['com_id']);
$wc['vote_down'] = $Wall->countVotesCom ('com', 'down', $cdata['msg_id_fk'],$cdata['com_id']);
- $xoopsTpl->append('comm', $wc);
+ $xoopsTpl->append('comm', $wc);
}
}
+
}
}
-
if ($profile > 0) {
$xoopsTpl->assign('menu_home',$menu_home);
$xoopsTpl->assign('menu_profile',$menu_profile);
@@ -162,11 +207,13 @@
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.avatar_helper.js');
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.bookmark.js');
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/oembed.css');
+ $xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/colorbox.css');
$xoTheme->addScript(XOOPS_URL.'/modules/smallworld/js/jquery.colorbox.js');
$xoTheme->addStylesheet(XOOPS_URL.'/modules/smallworld/css/smallworld.css');
- } elseif ($set['access'] == 0) {
- redirect_header(XOOPS_URL . "/user.php", 1, _NOPERM);
+ } elseif ($profile <= 0 && $set['access'] == 0) {
+ redirect_header(XOOPS_URL . "/modules/smallworld/register.php");
+ } else {
+ redirect_header(XOOPS_URL . "/user.php", 1, _NOPERM);
}
-include(XOOPS_ROOT_PATH."/footer.php");
-?>
\ No newline at end of file
+include(XOOPS_ROOT_PATH."/footer.php");
\ No newline at end of file
Added: XoopsModules/smallworld/trunk/smallworld/js/cors/index.html
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/js/cors/index.html (rev 0)
+++ XoopsModules/smallworld/trunk/smallworld/js/cors/index.html 2013-03-31 23:56:08 UTC (rev 11335)
@@ -0,0 +1 @@
+<script>history.go(-1);</script>
\ No newline at end of file
Modified: XoopsModules/smallworld/trunk/smallworld/js/jquery.bookmark.js
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/js/jquery.bookmark.js 2013-03-31 23:21:54 UTC (rev 11334)
+++ XoopsModules/smallworld/trunk/smallworld/js/jquery.bookmark.js 2013-03-31 23:56:08 UTC (rev 11335)
@@ -7,10 +7,10 @@
/* Allow your page to be shared with various bookmarking sites.
Attach the functionality with options like:
- xoops_smallworld('div selector').bookmark({sites: ['delicious', 'digg']});
+ $('div selector').bookmark({sites: ['delicious', 'digg']});
*/
-(function(xoops_smallworld) { // Hide scope, no xoops_smallworld conflict
+(function($) { // Hide scope, no $ conflict
var PROP_NAME = 'bookmark';
@@ -77,14 +77,20 @@
url: 'http://cgi.fark.com/cgi/fark/submit.pl?new_url={u}&new_comment={t}'},
'google': {display: 'Google', icon: 12, lang: 'en', category: 'bookmark',
url: 'http://www.google.com/bookmarks/mark?op=edit&bkmk={u}&title={t}'},
+ 'googlereader': {display: 'Google Reader', icon: 13, lang: 'en', category: 'tools',
+ url: 'http://www.google.com/reader/link?url={u}&title={t}&srcTitle={u}'},
'hotmail': {display: 'Hotmail', icon: 14, lang: 'en', category: 'mail',
url: 'http://www.hotmail.msn.com/secure/start?action=compose&to=&body={u}&subject={t}'},
'linkedin': {display: 'LinkedIn', icon: 15, lang: 'en', category: 'social',
url: 'http://www.linkedin.com/shareArticle?mini=true&url={u}&title={t}&ro=false&summary={d}&source='},
+ 'mixx': {display: 'Mixx', icon: 16, lang: 'en', category: 'news',
+ url: 'http://www.mixx.com/submit/story?page_url={u}&title={t}'},
'multiply': {display: 'Multiply', icon: 17, lang: 'en', category: 'social',
url: 'http://multiply.com/gus/journal/compose/addthis?body=&url={u}&subject={t}'},
'myspace': {display: 'MySpace', icon: 18, lang: 'en', category: 'social',
url: 'http://www.myspace.com/Modules/PostTo/Pages/?u={u}&t={t}'},
+ 'netvibes': {display: 'Netvibes', icon: 19, lang: 'en', category: 'news',
+ url: 'http://www.netvibes.com/share?url={u}&title={t}'},
'newsvine': {display: 'Newsvine', icon: 20, lang: 'en', category: 'news',
url: 'http://www.newsvine.com/_wine/save?u={u}&h={t}'},
'reddit': {display: 'reddit', icon: 21, lang: 'en', category: 'news',
@@ -95,8 +101,12 @@
url: 'http://www.technorati.com/faves?add={u}'},
'tipd': {display: 'Tip\'d', icon: 24, lang: 'en', category: 'news',
url: 'http://tipd.com/submit.php?url={u}'},
+ 'tumblr': {display: 'tumblr', icon: 25, lang: 'en', category: 'blog',
+ url: 'http://www.tumblr.com/share?v=3&u={u}&t={t}'},
'twitter':{display: 'twitter', icon: 26, lang: 'en', category: 'blog',
url: 'http://twitter.com/home?status={t}%20{u}'},
+ 'windows': {display: 'Windows Live', icon: 27, lang: 'en', category: 'bookmark',
+ url: 'https://favorites.live.com/quickadd.aspx?marklet=1&mkt=en-us&url={u}&title={t}'},
'wishlist': {display: 'Amazon WishList', icon: 28, lang: 'en', category: 'shopping',
url: 'http://www.amazon.com/wishlist/add?u={u}&t={t}'},
'yahoo': {display: 'Yahoo Bookmarks', icon: 29, lang: 'en', category: 'bookmark',
@@ -110,7 +120,7 @@
}
}
-xoops_smallworld.extend(Bookmark.prototype, {
+$.extend(Bookmark.prototype, {
/* Class name added to elements to indicate already configured with bookmarking. */
markerClassName: 'hasBookmark',
@@ -153,7 +163,7 @@
@param target (element) the bookmark container
@param settings (object) the settings for this container */
_attachBookmark: function(target, settings) {
- target = xoops_smallworld(target);
+ target = $(target);
if (target.hasClass(this.markerClassName)) {
return;
}
@@ -167,7 +177,7 @@
(string) a single setting name
@param value (any) the single setting's value */
_changeBookmark: function(target, settings, value) {
- target = xoops_smallworld(target);
+ target = $(target);
if (!target.hasClass(this.markerClassName)) {
return;
}
@@ -183,30 +193,30 @@
@param target (element) the bookmark container
@param settings (object) the settings for this container */
_updateBookmark: function(target, settings) {
- var oldSettings = xoops_smallworld.data(target[0], PROP_NAME) || xoops_smallworld.extend({}, this._defaults);
+ var oldSettings = $.data(target[0], PROP_NAME) || $.extend({}, this._defaults);
settings = extendRemove(oldSettings, settings || {});
- xoops_smallworld.data(target[0], PROP_NAME, settings);
+ $.data(target[0], PROP_NAME, settings);
var sites = settings.sites;
if (sites.length == 0) { // All sites
- xoops_smallworld.each(xoops_smallworld.bookmark._sites, function(id) {
+ $.each($.bookmark._sites, function(id) {
sites.push(id);
});
sites.sort();
}
else {
- xoops_smallworld.each(sites, function(index, value) {
+ $.each(sites, function(index, value) {
var lang = value.match(/lang:(.*)/); // Select by language
if (lang) {
- xoops_smallworld.each(xoops_smallworld.bookmark._sites, function(id, site) {
- if (site.lang == lang[1] && xoops_smallworld.inArray(id, sites) == -1) {
+ $.each($.bookmark._sites, function(id, site) {
+ if (site.lang == lang[1] && $.inArray(id, sites) == -1) {
sites.push(id);
}
});
}
var category = value.match(/category:(.*)/); // Select by category
if (category) {
- xoops_smallworld.each(xoops_smallworld.bookmark._sites, function(id, site) {
- if (site.category == category[1] && xoops_smallworld.inArray(id, sites) == -1) {
+ $.each($.bookmark._sites, function(id, site) {
+ if (site.category == category[1] && $.inArray(id, sites) == -1) {
sites.push(id);
}
});
@@ -217,44 +227,44 @@
var container = target;
if (settings.popup) {
target.append('<a href="#" class="bookmark_popup_text">' + settings.popupText + '</a>');
- container = xoops_smallworld('<div class="bookmark_popup"></div>').appendTo(target);
+ container = $('<div class="bookmark_popup"></div>').appendTo(target);
}
- var details = xoops_smallworld.bookmark._getSiteDetails(settings);
- var list = xoops_smallworld('<ul class="bookmark_list' +
+ var details = $.bookmark._getSiteDetails(settings);
+ var list = $('<ul class="bookmark_list' +
(settings.compact ? ' bookmark_compact' : '') + '"></ul>').appendTo(container);
if (settings.addFavorite) {
- xoops_smallworld.bookmark._addOneSite(settings, list, settings.favoriteText, settings.favoriteIcon, '#', function() {
- xoops_smallworld.bookmark._addFavourite(details.url.replace(/'/g, '\\\''), details.title.replace(/'/g, '\\\''));
+ $.bookmark._addOneSite(settings, list, settings.favoriteText, settings.favoriteIcon, '#', function() {
+ $.bookmark._addFavourite(details.url.replace(/'/g, '\\\''), details.title.replace(/'/g, '\\\''));
return false;
});
}
if (settings.addEmail) {
- xoops_smallworld.bookmark._addOneSite(settings, list, settings.emailText, settings.emailIcon,
+ $.bookmark._addOneSite(settings, list, settings.emailText, settings.emailIcon,
'mailto:?subject=' + encodeURIComponent(settings.emailSubject) +
'&body=' + encodeURIComponent(settings.emailBody.
replace(/\{u\}/, details.url).replace(/\{t\}/, details.title).replace(/\{d\}/, details.desc)));
}
- xoops_smallworld.bookmark._addSelectedSites(sites, details, settings, list);
+ $.bookmark._addSelectedSites(sites, details, settings, list);
if (settings.addShowAll) {
var count = 0;
- for (var n in xoops_smallworld.bookmark._sites) {
+ for (var n in $.bookmark._sites) {
count++;
}
var showAll = settings.showAllText.replace(/\{n\}/, count);
- xoops_smallworld.bookmark._addOneSite(settings, list, showAll, settings.showAllIcon, '#', function() {
- xoops_smallworld.bookmark._showAll(this, settings);
+ $.bookmark._addOneSite(settings, list, showAll, settings.showAllIcon, '#', function() {
+ $.bookmark._showAll(this, settings);
return false;
}, showAll);
}
if (settings.popup) {
target.find('.bookmark_popup_text').click(function() {
- var target = xoops_smallworld(this).parent();
+ var target = $(this).parent();
var offset = target.offset();
target.find('.bookmark_popup').css('left', offset.left).
css('top', offset.top + target.outerHeight()).toggle();
return false;
});
- xoops_smallworld(document).click(function(event) { // Close on external click
+ $(document).click(function(event) { // Close on external click
target.find('.bookmark_popup').hide();
});
}
@@ -266,10 +276,10 @@
@param settings (object) the bookmark settings
@param list (jQuery) the list to add to */
_addSelectedSites: function(sites, details, settings, list) {
- xoops_smallworld.each(sites, function(index, id) {
- var site = xoops_smallworld.bookmark._sites[id];
+ $.each(sites, function(index, id) {
+ var site = $.bookmark._sites[id];
if (site) {
- xoops_smallworld.bookmark._addOneSite(settings, list, site.display, site.icon, (settings.onSelect ? '#' :
+ $.bookmark._addOneSite(settings, list, site.display, site.icon, (settings.onSelect ? '#' :
site.url.replace(/\{u\}/, details.url2 + (details.sourceTag ? details.sourceTag + id : '')).
replace(/\{t\}/, details.title2).replace(/\{d\}/, details.desc2)),
function() {
@@ -279,10 +289,10 @@
replace(/\{u\}/, details.url).replace(/\{r\}/, details.relUrl).
replace(/\{t\}/, details.title));
}
- xoops_smallworld('#bookmark_all').remove();
- xoops_smallworld(document).unbind('click.bookmark');
+ $('#bookmark_all').remove();
+ $(document).unbind('click.bookmark');
if (settings.onSelect) {
- xoops_smallworld.bookmark._selected(xoops_smallworld(this).closest('.' + xoops_smallworld.bookmark.markerClassName)[0], id);
+ $.bookmark._selected($(this).closest('.' + $.bookmark.markerClassName)[0], id);
return false;
}
return true;
@@ -313,23 +323,23 @@
'background: transparent url(' + settings.icons + ') no-repeat ') + '-' +
((icon % settings.iconCols) * settings.iconSize) + 'px -' +
(Math.floor(icon / settings.iconCols) * settings.iconSize) + 'px;' +
- (xoops_smallworld.browser.mozilla && xoops_smallworld.browser.version < '1.9' ?
+ ($.browser.mozilla && $.browser.version < '1.9' ?
' padding-left: ' + settings.iconSize + 'px; padding-bottom: ' +
(Math.max(0, settings.iconSize - 16)) + 'px;' : '') + '"></span>';
}
else {
html += '<img src="' + icon + '" alt="' + title + '" title="' +
- title + '"' + ((xoops_smallworld.browser.mozilla && xoops_smallworld.browser.version < '1.9') ||
- (xoops_smallworld.browser.msie && xoops_smallworld.browser.version < '7.0') ?
+ title + '"' + (($.browser.mozilla && $.browser.version < '1.9') ||
+ ($.browser.msie && $.browser.version < '7.0') ?
' style="vertical-align: bottom;"' :
- (xoops_smallworld.browser.msie ? ' style="vertical-align: middle;"' :
- (xoops_smallworld.browser.opera || xoops_smallworld.browser.safari ?
+ ($.browser.msie ? ' style="vertical-align: middle;"' :
+ ($.browser.opera || $.browser.safari ?
' style="vertical-align: baseline;"' : ''))) + '/>';
}
html += (settings.compact ? '' : ' ');
}
html += (settings.compact ? '' : display) + '</a></li>';
- html = xoops_smallworld(html).appendTo(list);
+ html = $(html).appendTo(list);
if (onclick) {
html.find('a').click(onclick);
}
@@ -338,21 +348,21 @@
/* Remove the bookmarking widget from a div.
@param target (element) the bookmark container */
_destroyBookmark: function(target) {
- target = xoops_smallworld(target);
+ target = $(target);
if (!target.hasClass(this.markerClassName)) {
return;
}
target.removeClass(this.markerClassName).empty();
- xoops_smallworld.removeData(target[0], PROP_NAME);
+ $.removeData(target[0], PROP_NAME);
},
/* Callback when selected.
@param target (element) the target div
@param siteID (string) the selected site ID */
_selected: function(target, siteID) {
- var settings = xoops_smallworld.data(target, PROP_NAME);
- var site = xoops_smallworld.bookmark._sites[siteID];
- var details = xoops_smallworld.bookmark._getSiteDetails(settings);
+ var settings = $.data(target, PROP_NAME);
+ var site = $.bookmark._sites[siteID];
+ var details = $.bookmark._getSiteDetails(settings);
settings.onSelect.apply(target, [siteID, site.display, site.url.replace(/&/g,'&').
replace(/\{u\}/, details.url2 + (details.sourceTag ? details.sourceTag + siteID : '')).
replace(/\{t\}/, details.title2).replace(/\{d\}/, details.desc2)]);
@@ -362,7 +372,7 @@
@param url (string) the URL to bookmark
@param title (string) the title to bookmark */
_addFavourite: function(url, title) {
- if (xoops_smallworld.browser.msie) {
+ if ($.browser.msie) {
window.external.addFavorite(url, title);
}
else {
@@ -375,23 +385,23 @@
@param settings (object) the bookmark settings */
_showAll: function(elem, settings) {
var sites = [];
- xoops_smallworld.each(xoops_smallworld.bookmark._sites, function(id) {
+ $.each($.bookmark._sites, function(id) {
sites.push(id);
});
sites.sort();
- var details = xoops_smallworld.bookmark._getSiteDetails(settings);
- var list = xoops_smallworld('<ul class="bookmark_list"></ul>');
+ var details = $.bookmark._getSiteDetails(settings);
+ var list = $('<ul class="bookmark_list"></ul>');
var saveCompact = settings.compact;
settings.compact = false;
- xoops_smallworld.bookmark._addSelectedSites(sites, details, settings, list);
+ $.bookmark._addSelectedSites(sites, details, settings, list);
settings.compact = saveCompact;
- var all = xoops_smallworld('<div id="bookmark_all"><p>' + settings.showAllTitle + '</p></div>').
+ var all = $('<div id="bookmark_all"><p>' + settings.showAllTitle + '</p></div>').
append(list).appendTo('body');
- all.css({left: (xoops_smallworld(window).width() - all.width()) / 2, top: (xoops_smallworld(window).height() - all.height()) / 2}).show();
- xoops_smallworld(document).bind('click.bookmark', function(event) {
- if (xoops_smallworld(event.target).closest(elem).length == 0 && xoops_smallworld(event.target).closest('#bookmark_all').length == 0) {
- xoops_smallworld('#bookmark_all').remove();
- xoops_smallworld(document).unbind('click.bookmark');
+ all.css({left: ($(window).width() - all.width()) / 2, top: ($(window).height() - all.height()) / 2}).show();
+ $(document).bind('click.bookmark', function(event) {
+ if ($(event.target).closest(elem).length == 0 && $(event.target).closest('#bookmark_all').length == 0) {
+ $('#bookmark_all').remove();
+ $(document).unbind('click.bookmark');
}
});
},
@@ -401,8 +411,8 @@
@return (object) the site details */
_getSiteDetails: function(settings) {
var url = settings.url || window.location.href;
- var title = settings.title || document.title || xoops_smallworld('h1:first').text();
- var desc = settings.description || xoops_smallworld('meta[name="description"]').attr('content') || '';
+ var title = settings.title || document.title || $('h1:first').text();
+ var desc = settings.description || $('meta[name="description"]').attr('content') || '';
var sourceTag = (!settings.sourceTag ? '' :
encodeURIComponent((url.indexOf('?') > -1 ? '&' : '?') + settings.sourceTag + '='));
return {url: url, title: title, desc: desc, relUrl: url.replace(/^.*\/\/[^\/]*\//, ''),
@@ -413,7 +423,7 @@
/* jQuery extend now ignores nulls! */
function extendRemove(target, props) {
- xoops_smallworld.extend(target, props);
+ $.extend(target, props);
for (var name in props) {
if (props[name] == null) {
target[name] = null;
@@ -426,28 +436,29 @@
@param command (string) the command to run (optional, default 'attach')
@param options (object) the new settings to use for these bookmarking instances
@return (jQuery object) for chaining further calls */
-xoops_smallworld.fn.bookmark = function(options) {
+$.fn.bookmark = function(options) {
var otherArgs = Array.prototype.slice.call(arguments, 1);
return this.each(function() {
if (typeof options == 'string') {
- if (!xoops_smallworld.bookmark['_' + options + 'Bookmark']) {
+ if (!$.bookmark['_' + options + 'Bookmark']) {
throw 'Unknown operation: ' + options;
}
- xoops_smallworld.bookmark['_' + options + 'Bookmark'].
- apply(xoops_smallworld.bookmark, [this].concat(otherArgs));
+ $.bookmark['_' + options + 'Bookmark'].
+ apply($.bookmark, [this].concat(otherArgs));
}
else {
- xoops_smallworld.bookmark._attachBookmark(this, options || {});
+ $.bookmark._attachBookmark(this, options || {});
}
});
};
/* Initialise the bookmarking functionality. */
-xoops_smallworld.bookmark = new Bookmark(); // singleton instance
+$.bookmark = new Bookmark(); // singleton instance
})(jQuery);
+
// Limit scope pollution from any deprecated API
-(function() {
+(function(jQuery) {
var matched, browser;
@@ -508,4 +519,4 @@
return jQuerySub;
};
-})();
+});
\ No newline at end of file
Modified: XoopsModules/smallworld/trunk/smallworld/js/jquery.countdown.js
===================================================================
--- XoopsModules/smallworld/trunk/smallworld/js/jquery.countdown.js 2013-03-31 23:21:54 UTC (rev 11334)
+++ XoopsModules/smallworld/trunk/smallworld/js/jquery.countdown.js 2013-03-31 23:56:08 UTC (rev 11335)
@@ -11,7 +11,17 @@
{until: new Date(2009, 1 - 1, 1, 0, 0, 0), onExpiry: happyNewYear}); */
(function($) { // Hide scope, no xoops_smallworld conflict
+/* http://keith-wood.name/countdown.html
+ Countdown for jQuery v1.6.1.
+ Written by Keith Wood (kbwood{at}iinet.com.au) January 2008.
+ Available under the MIT (https://github.com/jquery/jquery/blob/master/MIT-LICENSE.txt) license.
+ Please attribute the author if you use it. */
+/* Display a countdown timer.
+ Attach it with options like:
+ $('div selector').countdown(
+ {until: new Date(2009, 1 - 1, 1, 0, 0, 0), onExpiry: happyNewYear}); */
+
/* Countdown manager. */
function Countdown() {
this.regional = []; // Available regional settings, indexed by language code
@@ -20,8 +30,9 @@
labels: ['Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'],
// The display texts for the counters if only one
labels1: ['Year', 'Month', 'Week', 'Day', 'Hour', 'Minute', 'Second'],
- compactLabels: ['y', 'm', 'w', 'd','hrs', 'min', 'sec'], // The compact texts for the counters
+ compactLabels: ['y', 'm', 'w', 'd'], // The compact texts for the counters
whichLabels: null, // Function to determine which labels to use
+ digits: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9'], // The digits to display
timeSeparator: ':', // Separator for time periods
isRTL: false // True for right-to-left languages, false for left-to-right
};
@@ -55,27 +66,34 @@
this._serverSyncs = [];
// Shared timer for all countdowns
function timerCallBack(timestamp) {
- var drawStart = (timestamp || Date.now());
+ var drawStart = (timestamp < 1e12 ? // New HTML5 high resolution timer
+ (drawStart = performance.now ?
+ (performance.now() + performance.timing.navigationStart) : Date.now()) :
+ // Integer milliseconds since unix epoch
+ timestamp || new Date().getTime());
if (drawStart - animationStartTime >= 1000) {
- $.countdown._updateTargets();
+ plugin._updateTargets();
animationStartTime = drawStart;
}
requestAnimationFrame(timerCallBack);
}
- var requestAnimationFrame = window.requestAnimationFrame || window.webkitRequestAnimationFrame ||
- window.mozRequestAnimationFrame || window.oRequestAnimationFrame ||
- window.msRequestAnimationFrame || null; // this is when we expect a fall-back to setInterval as it's much more fluid
- var animationStartTime = window.mozAnimationStartTime || Date.now();
- if (!requestAnimationFrame) {
- setInterval(function() { $.countdown._updateTargets(); }, 980); // Fall back to good old setInterval
+ var requestAnimationFrame = window.requestAnimationFrame ||
+ window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame ||
+ window.oRequestAnimationFrame || window.msRequestAnimationFrame || null;
+ // This is when we expect a fall-back to setInterval as it's much more fluid
+ var animationStartTime = 0;
+ if (!requestAnimationFrame || $.noRequestAnimationFrame) {
+ $.noRequestAnimationFrame = null;
+ setInterval(function() { plugin._updateTargets(); }, 980); // Fall back to good old setInterval
}
else {
+ animationStartTime = window.animationStartTime ||
+ window.webkitAnimationStartTime || window.mozAnimationStartTime ||
+ window.oAnimationStartTime || window.msAnimationStartTime || new Date().getTime();
requestAnimationFrame(timerCallBack);
}
}
-var PROP_NAME = 'countdown';
-
var Y = 0; // Years
var O = 1; // Months
var W = 2; // Weeks
@@ -87,7 +105,24 @@
$.extend(Countdown.prototype, {
/* Class name added to elements to indicate already configured with countdown. */
markerClassName: 'hasCountdown',
+ /* Name of the data property for instance settings. */
+ propertyName: 'countdown',
+ /* Class name for the right-to-left marker. */
+ _rtlClass: 'countdown_rtl',
+ /* Class name for the countdown section marker. */
+ _sectionClass: 'countdown_section',
+ /* Class name for the period amount marker. */
+ _amountClass: 'countdown_amount',
+ /* Class name for the countdown row marker. */
+ _rowClass: 'countdown_row',
+ /* Class name for the holding countdown marker. */
+ _holdingClass: 'countdown_holding',
+ /* Class name for the showing countdown marker. */
+ _showClass: 'countdown_show',
+ /* Class name for the description marker. */
+ _descrClass: 'countdown_descr',
+
/* List of currently active countdown targets. */
_timerTargets: [],
@@ -95,7 +130,7 @@
@param options (object) the new settings to use as defaults */
setDefaults: function(options) {
this._resetExtraLabels(this._defaults, options);
- extendRemove(this._defaults, options || {});
+ $.extend(this._defaults, options || {});
},
/* Convert a date/time to UTC.
@@ -140,31 +175,17 @@
periods[3] * 86400 + periods[4] * 3600 + periods[5] * 60 + periods[6];
},
- /* Retrieve one or more settings values.
- @param name (string, optional) the name of the setting to retrieve
- or 'all' for all instance settings or omit for all default settings
- @return (any) the requested setting(s) */
- _settingsCountdown: function(target, name) {
- if (!name) {
- return $.countdown._defaults;
- }
- var inst = $.data(target, PROP_NAME);
- return (name == 'all' ? inst.options : inst.options[name]);
- },
-
/* Attach the countdown widget to a div.
@param target (element) the containing division
@param options (object) the initial settings for the countdown */
- _attachCountdown: function(target, options) {
- var $target = $(target);
- if ($target.hasClass(this.markerClassName)) {
+ _attachPlugin: function(target, options) {
+ target = $(target);
+ if (target.hasClass(this.markerClassName)) {
return;
}
- $target.addClass(this.markerClassName);
- var inst = {options: $.extend({}, options),
- _periods: [0, 0, 0, 0, 0, 0, 0]};
- $.data(target, PROP_NAME, inst);
- this._changeCountdown(target);
+ var inst = {options: $.extend({}, this._defaults), _periods: [0, 0, 0, 0, 0, 0, 0]};
+ target.addClass(this.markerClassName).data(this.propertyName, inst);
+ this._optionPlugin(target, options);
},
/* Add a target to the list of active ones.
@@ -196,24 +217,57 @@
}
},
+ /* Reconfigure the settings for a countdown div.
+ @param target (element) the control to affect
+ @param options (object) the new options for this instance or
+ (string) an individual property name
+ @param value (any) the individual property value (omit if options
+ is an object or to retrieve the value of a setting)
+ @return (any) if retrieving a value */
+ _optionPlugin: function(target, options, value) {
+ target = $(target);
+ var inst = target.data(this.propertyName);
+ if (!options || (typeof options == 'string' && value == null)) { // Get option
+ var name = options;
+ options = (inst || {}).options;
+ return (options && name ? options[name] : options);
+ }
+
+ if (!target.hasClass(this.markerClassName)) {
+ return;
+ }
+ options = options || {};
+ if (typeof options == 'string') {
+ var name = options;
+ options = {};
+ options[name] = value;
+ }
+ this._resetExtraLabels(inst.options, options);
+ $.extend(inst.options, options);
+ this._adjustSettings(target, inst);
+ var now = new Date();
+ if ((inst._since && inst._since < now) || (inst._until && inst._until > now)) {
+ this._addTarget(target[0]);
+ }
+ this._updateCountdown(target, inst);
+ },
+
/* Redisplay the countdown with an updated display.
@param target (jQuery) the containing division
@param inst (object) the current settings for this instance */
_updateCountdown: function(target, inst) {
var $target = $(target);
- inst = inst || $.data(target, PROP_NAME);
+ inst = inst || $target.data(this.propertyName);
if (!inst) {
return;
}
- $target.html(this._generateHTML(inst));
- $target[(this._get(inst, 'isRTL') ? 'add' : 'remove') + 'Class']('countdown_rtl');
- var onTick = this._get(inst, 'onTick');
- if (onTick) {
+ $target.html(this._generateHTML(inst)).toggleClass(this._rtlClass, inst.options.isRTL);
+ if ($.isFunction(inst.options.onTick)) {
var periods = inst._hold != 'lap' ? inst._periods :
- this._calculatePeriods(inst, inst._show, this._get(inst, 'significant'), new Date());
- var tickInterval = this._get(inst, 'tickInterval');
- if (tickInterval == 1 || this.periodsToSeconds(periods) % tickInterval == 0) {
- onTick.apply(target, [periods]);
+ this._calculatePeriods(inst, inst._show, inst.options.significant, new Date());
+ if (inst.options.tickInterval == 1 ||
+ this.periodsToSeconds(periods) % inst.options.tickInterval == 0) {
+ inst.options.onTick.apply(target, [periods]);
}
}
var expired = inst._hold != 'pause' &&
@@ -221,22 +275,19 @@
inst._now.getTime() >= inst._until.getTime());
if (expired && !inst._expiring) {
inst._expiring = true;
- if (this._hasTarget(target) || this._get(inst, 'alwaysExpire')) {
+ if (this._hasTarget(target) || inst.options.alwaysExpire) {
this._removeTarget(target);
- var onExpiry = this._get(inst, 'onExpiry');
- if (onExpiry) {
- onExpiry.apply(target, []);
+ if ($.isFunction(inst.options.onExpiry)) {
+ inst.options.onExpiry.apply(target, []);
}
- var expiryText = this._get(inst, 'expiryText');
- if (expiryText) {
- var layout = this._get(inst, 'layout');
- inst.options.layout = expiryText;
+ if (inst.options.expiryText) {
+ var layout = inst.options.layout;
+ inst.options.layout = inst.options.expiryText;
this._updateCountdown(target, inst);
inst.options.layout = layout;
}
- var expiryUrl = this._get(inst, 'expiryUrl');
- if (expiryUrl) {
- window.location = expiryUrl;
+ if (inst.options.expiryUrl) {
+ window.location = inst.options.expiryUrl;
}
}
inst._expiring = false;
@@ -244,37 +295,9 @@
else if (inst._hold == 'pause') {
this._removeTarget(target);
}
- $.data(target, PROP_NAME, inst);
+ $target.data(this.propertyName, inst);
},
- /* Reconfigure the settings for a countdown div.
- @param target (element) the containing division
- @param options (object) the new settings for the countdown or
- (string) an individual property name
- @param value (any) the individual property value
- (omit if options is an object) */
- _changeCountdown: function(target, options, value) {
- options = options || {};
- if (typeof options == 'string') {
- var name = options;
- options = {};
- options[name] = value;
- }
- var inst = $.data(target, PROP_NAME);
- if (inst) {
- this._resetExtraLabels(inst.options, options);
- extendRemove(inst.options, options);
- this._adjustSettings(target, inst);
- $.data(target, PROP_NAME, inst);
- var now = new Date();
- if ((inst._since && inst._since < now) ||
- (inst._until && inst._until > now)) {
- this._addTarget(target);
- }
- this._updateCountdown(target, inst);
- }
- },
-
/* Reset any extra labelsn and compactLabelsn entries if changing labels.
@param base (object) the options to be updated
@param options (object) the new option values */
@@ -288,7 +311,7 @@
}
if (changingLabels) {
for (var n in base) { // Remove custom numbered labels
- if (n.match(/[Ll]abels[0-9]/)) {
+ if (n.match(/[Ll]abels[02-9]/)) {
base[n] = null;
}
}
@@ -300,35 +323,35 @@
@param inst (object) the current settings for this instance */
_adjustSettings: function(target, inst) {
var now;
- var serverSync = this._get(inst, 'serverSync');
var serverOffset = 0;
var serverEntry = null;
for (var i = 0; i < this._serverSyncs.length; i++) {
- if (this._serverSyncs[i][0] == serverSync) {
+ if (this._serverSyncs[i][0] == inst.options.serverSync) {
serverEntry = this._serverSyncs[i][1];
break;
}
}
if (serverEntry != null) {
- serverOffset = (serverSync ? serverEntry : 0);
+ serverOffset = (inst.options.serverSync ? serverEntry : 0);
now = new Date();
}
else {
- var serverResult = (serverSync ? serverSync.apply(target, []) : null);
+ var serverResult = ($.isFunction(inst.options.serverSync) ?
+ inst.options.serverSync.apply(target, []) : null);
now = new Date();
serverOffset = (serverResult ? now.getTime() - serverResult.getTime() : 0);
- this._serverSyncs.push([serverSync, serverOffset]);
+ this._serverSyncs.push([inst.options.serverSync, serverOffset]);
}
- var timezone = this._get(inst, 'timezone');
+ var timezone = inst.options.timezone;
timezone = (timezone == null ? -now.getTimezoneOffset() : timezone);
- inst._since = this._get(inst, 'since');
+ inst._since = inst.options.since;
if (inst._since != null) {
inst._since = this.UTCDate(timezone, this._determineTime(inst._since, null));
if (inst._since && serverOffset) {
inst._since.setMilliseconds(inst._since.getMilliseconds() + serverOffset);
}
}
- inst._until = this.UTCDate(timezone, this._determineTime(this._get(inst, 'until'), now));
+ inst._until = this.UTCDate(timezone, this._determineTime(inst.options.until, now));
if (serverOffset) {
inst._until.setMilliseconds(inst._until.getMilliseconds() + serverOffset);
}
@@ -337,33 +360,32 @@
/* Remove the countdown widget from a div.
@param target (element) the containing division */
- _destroyCountdown: function(target) {
- var $target = $(target);
- if (!$target.hasClass(this.markerClassName)) {
+ _destroyPlugin: function(target) {
+ target = $(target);
+ if (!target.hasClass(this.markerClassName)) {
return;
}
- this._removeTarget(target);
- $target.removeClass(this.markerClassName).empty();
- $.removeData(target, PROP_NAME);
+ this._removeTarget(target[0]);
+ target.removeClass(this.markerClassName).empty().removeData(this.propertyName);
},
/* Pause a countdown widget at the current time.
Stop it running but remember and display the current time.
@param target (element) the containing division */
- _pauseCountdown: function(target) {
+ _pausePlugin: function(target) {
this._hold(target, 'pause');
},
/* Pause a countdown widget at the current time.
Stop the display but keep the countdown running.
@param target (element) the containing division */
- _lapCountdown: function(target) {
+ _lapPlugin: function(target) {
this._hold(target, 'lap');
},
/* Resume a paused countdown widget.
@param target (element) the containing division */
- _resumeCountdown: function(target) {
+ _resumePlugin: function(target) {
this._hold(target, null);
},
@@ -371,7 +393,7 @@
@param target (element) the containing division
@param hold (string) the new hold setting */
_hold: function(target, hold) {
- var inst = $.data(target, PROP_NAME);
+ var inst = $.data(target, this.propertyName);
if (inst) {
if (inst._hold == 'pause' && !hold) {
inst._periods = inst._savePeriods;
@@ -385,7 +407,7 @@
}
inst._hold = hold;
inst._savePeriods = (hold == 'pause' ? inst._periods : null);
- $.data(target, PROP_NAME, inst);
+ $.data(target, this.propertyName, inst);
this._updateCountdown(target, inst);
}
},
@@ -393,21 +415,12 @@
/* Return the current time periods.
@param target (element) the containing division
@return (number[7]) the current periods for the countdown */
- _getTimesCountdown: function(target) {
- var inst = $.data(target, PROP_NAME);
+ _getTimesPlugin: function(target) {
+ var inst = $.data(target, this.propertyName);
return (!inst ? null : (!inst._hold ? inst._periods :
- this._calculatePeriods(inst, inst._show, this._get(inst, 'significant'), new Date())));
+ this._calculatePeriods(inst, inst._show, inst.options.significant, new Date())));
},
- /* Get a setting value, defaulting if necessary.
- @param inst (object) the current settings for this instance
- @param name (string) the name of the required setting
- @return (any) the setting's value or a default if not overridden */
- _get: function(inst, name) {
- return (inst.options[name] != null ?
- inst.options[name] : $.countdown._defaults[name]);
- },
-
/* A time may be specified as an exact value or a relative one.
@param setting (string or number or Date) - the date/time value
as a relative or absolute value
@@ -439,11 +452,11 @@
case 'w': day += parseInt(matches[1], 10) * 7; break;
case 'o':
month += parseInt(matches[1], 10);
- day = Math.min(day, $.countdown._getDaysInMonth(year, month));
+ day = Math.min(day, plugin._getDaysInMonth(year, month));
break;
case 'y':
year += parseInt(matches[1], 10);
- day = Math.min(day, $.countdown._getDaysInMonth(year, month));
+ day = Math.min(day, plugin._getDaysInMonth(year, month));
break;
}
matches = pattern.exec(offset);
@@ -476,14 +489,14 @@
@param inst (object) the current settings for this instance
@return (string) the new HTML for the countdown display */
_generateHTML: function(inst) {
+ var self = this;
// Determine what to show
- var significant = this._get(inst, 'significant');
inst._periods = (inst._hold ? inst._periods :
- this._calculatePeriods(inst, inst._show, significant, new Date()));
+ this._calculatePeriods(inst, inst._show, inst.options.significant, new Date()));
// Show all 'asNeeded' after first non-zero value
var shownNonZero = false;
var showCount = 0;
- var sigCount = significant;
+ var sigCount = inst.options.significant;
var show = $.extend({}, inst._show);
for (var period = Y; period <= S; period++) {
shownNonZero |= (inst._show[period] == '?' && inst._periods[period] > 0);
@@ -503,41 +516,40 @@
}
}
}
- var compact...
[truncated message content] |