Permalink
Browse files

Few fixes. Display or not of stuffs is now contingent on user having …

…js active in browser. Check for jQuery, etc., etc., blah, blah, blah
  • Loading branch information...
1 parent 96b9770 commit c10ea16becadfe358c9d7d9ece5d1493b042a5e8 @rmcgirr83 rmcgirr83 committed Jun 20, 2011
Showing with 135 additions and 38 deletions.
  1. +2 −0 .gitattributes
  2. +59 −20 contrib/subsilver2.xml
  3. +56 −18 install_mod.xml
  4. 0 README → readme.md
  5. +18 −0 root/js/jquery-1.6.1.min.js
View
@@ -0,0 +1,2 @@
+readme.md export-ignore
+.gitattributes export-ignore
View
@@ -37,7 +37,7 @@
</contributions-group>
</author>
</author-group>
- <mod-version>1.0.1</mod-version>
+ <mod-version>1.0.2</mod-version>
<installation>
<level>easy</level>
<time>300</time>
@@ -57,6 +57,13 @@
<changelog lang="en">
<change><![CDATA[Validation fixes]]></change>
</changelog>
+ </entry>
+ <entry>
+ <date>2011-06-20</date>
+ <rev-version>1.0.2</rev-version>
+ <changelog lang="en">
+ <change><![CDATA[Preload images and check for jQuery present]]></change>
+ </changelog>
</entry>
</history>
<link-group>
@@ -68,7 +75,11 @@
<edit>
<comment lang="en"><![CDATA[If you already have jQuery in use within your overall header file you do not need this edit.]]></comment>
<find><![CDATA[</head>]]></find>
- <action type="before-add"><![CDATA[<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>]]></action>
+ <action type="before-add"><![CDATA[<script type="text/javascript">
+// ]]>&lt;![CDATA[<![CDATA[
+ !window.jQuery && document.write('<script type="text\/javascript" src="{ROOT_PATH}js\/jquery-1.6.1.min.js"><\/script>');
+// ]]>]]&gt;<![CDATA[
+</script>]]></action>
</edit>
</open>
<open src="styles/subsilver2/template/viewtopic_body.html">
@@ -78,29 +89,57 @@
// ]]>&lt;![CDATA[<![CDATA[
var hideDetails = '{LA_HIDEDETAILS}';
var showDetails = '{LA_SHOWDETAILS}';
-showDisplay = function(id)
+var imageOpen = '{ROOT_PATH}images/open.png';
+var imageClose = '{ROOT_PATH}images/close.png';
+$(function(){
+ var cache = [];
+ // Arguments are image paths relative to the current page.
+ $.preLoadImages = function() {
+ var args_len = arguments.length;
+ for (var i = args_len; i--;) {
+ var cacheImage = document.createElement('img');
+ cacheImage.src = arguments[i];
+ cache.push(cacheImage);
+ }
+ };
+ $.preLoadImages(imageOpen, imageClose);
+
+ $("div[id*='show_']").each(function(){
+ $(this).show();
+ });
+ $("span[id*='hide_']").each(function(){
+ $(this).css({'display' : 'none'});
+ });
+});
+
+// close open details
+var closeDisplay = function()
{
// close open details
$('span[id*=hide_]').each(function(){
- if ($(this).is(':visible'))
- {
- var divid = $(this).attr('id').replace('hide_','');
- $('#hide_' + divid).hide();
- $('a#href_' + divid).replaceWith('<a href="#" id="href_'+divid+'" onclick="showDisplay('+divid+'); return false;"><img src="{ROOT_PATH}images/open.png" alt="'+showDetails+'" title="'+showDetails+'" height="16px" width="16px" /></a>');
- }
+ var divid = $(this).attr('id').replace('hide_','');
+ $('#show_' + divid).show();
+ $('a#href_' + divid).replaceWith('<a href="#" id="href_'+divid+'" onclick="showDisplay('+divid+'); return false;"><img src="'+imageOpen+'" height="16" width="16" alt="'+showDetails+'" title="'+showDetails+'" /></a>');
+ $(this).slideUp();
});
-
- $('#show_' + id).find('a#href_' + id).replaceWith('<a href="#" id="href_' +id+'" onclick="hideDisplay('+id+'); return false;"><img src="{ROOT_PATH}images/close.png" alt="'+hideDetails+'" title="'+hideDetails+'" height="16px" width="16px" /></a>');
- $('#hide_' + id).fadeIn();
};
-
+showDisplay = function(id)
+{
+ closeDisplay();
+ $('#hide_' + id).slideDown('slow', function(){
+ $('a#href_' + id).replaceWith('<a href="#" id="href_'+id+'" onclick="hideDisplay('+id+'); return false;"><img src="'+imageClose+'" height="16" width="16" alt="'+hideDetails+'" title="'+hideDetails+'" /></a>');
+ });
+}
hideDisplay = function(id)
{
- $('#hide_' + id).fadeOut();
- $('a#href_' + id).replaceWith('<a href="#" id="href_'+id+'" onclick="showDisplay('+id+'); return false;"><img src="{ROOT_PATH}images/open.png" alt="'+showDetails+'" title="'+showDetails+'" height="16px" width="16px" /></a>');
+ $('#hide_' + id).slideUp('slow', function(){
+ $('a#href_' + id).replaceWith('<a href="#" id="href_'+id+'" onclick="showDisplay('+id+'); return false;"><img src="'+imageOpen+'" height="16" width="16" alt="'+showDetails+'" title="'+showDetails+'" /></a>');
+ });
}
+
// ]]>]]&gt;<![CDATA[
-</script>]]></action>
+</script>
+]]></action>
</edit>
<edit>
<find><![CDATA[ <tr>
@@ -109,16 +148,16 @@ hideDisplay = function(id)
<!-- ENDIF -->
</table>]]></find>
<action type="after-add"><![CDATA[ <!-- IF not S_IS_BOT && postrow.U_POST_AUTHOR -->
- <div id="show_{postrow.POST_ID}">
- <b>{L_USERDETAILS}:</b>&nbsp;<a href="#" id="href_{postrow.POST_ID}" onclick="showDisplay({postrow.POST_ID}); return false;"><img src="{ROOT_PATH}images/open.png" alt="{L_USERDETAILS}" title="{L_USERDETAILS}" height="16px" width="16px" /></a>
+ <div id="show_{postrow.POST_ID}" style="display:none;">
+ <b>{L_USERDETAILS}:</b>&nbsp;<a href="#" id="href_{postrow.POST_ID}" onclick="showDisplay({postrow.POST_ID}); return false;"><img src="{ROOT_PATH}images/open.png" alt="{L_SHOWDETAILS}" title="{L_SHOWDETAILS}" height="16px" width="16px" /></a>
</div>
<!-- ENDIF -->]]></action>
</edit>
<edit>
<find><![CDATA[<span class="postdetails">]]></find>
- <action type="replace-with"><![CDATA[ <span class="postdetails" style="display:none;" id="hide_{postrow.POST_ID}">]]></action>
+ <action type="replace-with"><![CDATA[ <span class="postdetails" id="hide_{postrow.POST_ID}">]]></action>
</edit>
</open>
- <diy-instructions lang="en"><![CDATA[Refresh the template in the ACP (ACP->Styles->Templates->Refresh).]]></diy-instructions>
+ <diy-instructions lang="en"><![CDATA[Refresh the subsilver2 template in the ACP (ACP->Styles->Templates->Refresh).]]></diy-instructions>
</action-group>
</mod>
View
@@ -37,7 +37,7 @@
</contributions-group>
</author>
</author-group>
- <mod-version>1.0.1</mod-version>
+ <mod-version>1.0.2</mod-version>
<installation>
<level>easy</level>
<time>300</time>
@@ -57,6 +57,13 @@
<changelog lang="en">
<change><![CDATA[Validation fixes]]></change>
</changelog>
+ </entry>
+ <entry>
+ <date>2011-06-20</date>
+ <rev-version>1.0.2</rev-version>
+ <changelog lang="en">
+ <change><![CDATA[Preload images and check for jQuery present]]></change>
+ </changelog>
</entry>
</history>
<link-group>
@@ -65,7 +72,7 @@
</header>
<action-group>
<copy>
- <file from="root/images/*.*" to="images/*.*" />
+ <file from="root/*.*" to="*.*" />
</copy>
<open src="language/en/viewtopic.php">
<edit>
@@ -80,10 +87,13 @@ $lang = array_merge($lang, array(
</edit>
</open>
<open src="styles/prosilver/template/overall_header.html">
- <edit>
- <comment lang="en"><![CDATA[If you already have jQuery in use within your overall header file you do not need this edit.]]></comment>
+ <edit>
<find><![CDATA[</head>]]></find>
- <action type="before-add"><![CDATA[<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>]]></action>
+ <action type="before-add"><![CDATA[<script type="text/javascript">
+// ]]>&lt;![CDATA[<![CDATA[
+ !window.jQuery && document.write('<script type="text\/javascript" src="{ROOT_PATH}js\/jquery-1.6.1.min.js"><\/script>');
+// ]]>]]&gt;<![CDATA[
+</script>]]></action>
</edit>
</open>
<open src="styles/prosilver/template/viewtopic_body.html">
@@ -93,31 +103,59 @@ $lang = array_merge($lang, array(
// ]]>&lt;![CDATA[<![CDATA[
var hideDetails = '{LA_HIDEDETAILS}';
var showDetails = '{LA_SHOWDETAILS}';
-showDisplay = function(id)
+var imageOpen = '{ROOT_PATH}images/open.png';
+var imageClose = '{ROOT_PATH}images/close.png';
+$(function(){
+ var cache = [];
+ // Arguments are image paths relative to the current page.
+ $.preLoadImages = function() {
+ var args_len = arguments.length;
+ for (var i = args_len; i--;) {
+ var cacheImage = document.createElement('img');
+ cacheImage.src = arguments[i];
+ cache.push(cacheImage);
+ }
+ };
+ $.preLoadImages(imageOpen, imageClose);
+
+ $("dt[id*='show_']").each(function(){
+ $(this).show();
+ });
+ $("dt[id*='hide_']").each(function(){
+ $(this).css({'display' : 'none'});
+ });
+});
+
+// close open details
+var closeDisplay = function()
{
// close open details
$('dt[id*=hide_]').each(function(){
- if ($(this).is(':visible'))
- {
- var divid = $(this).attr('id').replace('hide_','');
- $('#hide_' + divid).hide();
- $('a#href_' + divid).replaceWith('<a href="#" id="href_'+divid+'" onclick="showDisplay('+divid+'); return false;"><img src="{ROOT_PATH}images/open.png" alt="'+showDetails+'" title="'+showDetails+'" height="16px" width="16px" /></a>');
- }
+ var divid = $(this).attr('id').replace('hide_','');
+ $('#show_' + divid).show();
+ $('a#href_' + divid).replaceWith('<a href="#" id="href_'+divid+'" onclick="showDisplay('+divid+'); return false;"><img src="'+imageOpen+'" height="16" width="16" alt="'+showDetails+'" title="'+showDetails+'" /></a>');
+ $(this).slideUp();
});
-
- $('#show_' + id).find('a#href_' + id).replaceWith('<a href="#" id="href_' +id+'" onclick="hideDisplay('+id+'); return false;"><img src="{ROOT_PATH}images/close.png" alt="'+hideDetails+'" title="'+hideDetails+'" height="16px" width="16px" /></a>');
- $('#hide_' + id).fadeIn();
};
+showDisplay = function(id)
+{
+ closeDisplay();
+ $('#hide_' + id).slideDown('slow', function(){
+ $('a#href_' + id).replaceWith('<a href="#" id="href_'+id+'" onclick="hideDisplay('+id+'); return false;"><img src="'+imageClose+'" height="16" width="16" alt="'+hideDetails+'" title="'+hideDetails+'" /></a>');
+ });
+}
hideDisplay = function(id)
{
- $('#hide_' + id).fadeOut();
- $('a#href_' + id).replaceWith('<a href="#" id="href_'+id+'" onclick="showDisplay('+id+'); return false;"><img src="{ROOT_PATH}images/open.png" alt="'+showDetails+'" title="'+showDetails+'" height="16px" width="16px" /></a>');
+ $('#hide_' + id).slideUp('slow', function(){
+ $('a#href_' + id).replaceWith('<a href="#" id="href_'+id+'" onclick="showDisplay('+id+'); return false;"><img src="'+imageOpen+'" height="16" width="16" alt="'+showDetails+'" title="'+showDetails+'" /></a>');
+ });
}
// ]]>]]&gt;<![CDATA[
</script>]]></action>
</edit>
<edit>
+ <comment lang="en"><![CDATA[We must remove all dd for this mod to work. You can add additional items but you must remove the <dd> and replace the </dd> with a <br />]]></comment>
<find><![CDATA[ <dd>&nbsp;</dd>
<!-- IF postrow.POSTER_POSTS != '' --><dd><strong>{L_POSTS}:</strong> {postrow.POSTER_POSTS}</dd><!-- ENDIF -->
@@ -153,6 +191,6 @@ hideDisplay = function(id)
<!-- ENDIF -->]]></action>
</edit>
</open>
- <diy-instructions lang="en"><![CDATA[Refresh the template in the ACP (ACP->Styles->Templates->Refresh).]]></diy-instructions>
+ <diy-instructions lang="en"><![CDATA[Refresh the prosilver template in the ACP (ACP->Styles->Templates->Refresh).]]></diy-instructions>
</action-group>
</mod>
View
File renamed without changes.

Large diffs are not rendered by default.

Oops, something went wrong.

0 comments on commit c10ea16

Please sign in to comment.