Joined: Aug 25, 2006 Posts: 24 Location: Verona (ITALY)
Posted:
Wed Jan 06, 2010 1:08 am
I am currently using each jquery and some jquery scripts for a module of mine.
These scrips are called using the new define RN_MODULE_HEAD, and they need jquery to work properly.
Besides, looking at the code and reading in forums, jquery is used as the "de facto" javascript library in RavenNuke.
So I want to use it whitout calling it in my script. The problem is that in RN 2.4 the include for jquery is at the end of the "head part", or, at least, after the code called from RN_MODULE_HEAD include, as you can see from the following piece of code.
So my question is: is it possible move the "jquery include call" at the beginning of the head section?
Code:
meta name="GENERATOR" content="RavenNuke(tm) Copyright (c) 2002-2009 by Gaylen Fraley. This is free software, and you may redistribute it under the GPL (http://www.gnu.org/licenses/gpl-2.0.txt). RavenNuke(tm) is supported by the RavenNuke(tm) Team at http://ravenphpscripts.com." />
<link rel="alternate" type="application/rss+xml" title="Forums" href="http://localhost/rn_24/modules.php?name=Feeds&fid=2&type=RSS20" /><link rel="alternate" type="application/rss+xml" title="News" href="http://localhost/rn_24/modules.php?name=Feeds&fid=1&type=RSS20" />
/* <![CDATA[ */
$(document).ready(
function () {
$(".schedule_row").hover(function() {
$(this).fadeOut(100);
$(this).fadeIn(500);
$(this).addClass("schedule_hover");
}, function() {
$(this).removeClass("schedule_hover");
});
}
);
/* ]]> */
</script><link rel="StyleSheet" href="./themes/ravennuke.css" type="text/css" />
<link rel="StyleSheet" href="includes/jquery/css/colorbox.css" type="text/css" />
<link rel="StyleSheet" href="includes/nukeSEO/nukePIE.css" type="text/css" />
<link rel="StyleSheet" href="includes/jquery/css/nukeNAV.css" type="text/css" />
<script type="text/javascript" language="JavaScript" src="includes/rn.js"></script>
<script type="text/javascript">
<!--
function openwindow(){
window.open ('modules/League/copyright.php','Copyright','toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=400,height=200');
}
//-->
</script>
Joined: Dec 02, 2006 Posts: 1364 Location: Texas, USA
Posted:
Wed Jan 06, 2010 6:15 am
the custom includes are included after the jquery script is included.
6 Include jquery, tabcontent, ajaxtabs, nukePIEhdr, nukeFEEDhdr (add CSS and JS to arrays)
7 Include includes/addons/head-xxx.php and includes/addons/body-xxx.php, if they exist (site-level add-ons)
8 If defined, include module’s RN_MODULE_HEAD (add module-level CSS and JS to arrays)
Only registered users can see links on this board! Get registered or login to the forums!
Joined: Aug 25, 2006 Posts: 24 Location: Verona (ITALY)
Posted:
Wed Jan 06, 2010 8:42 am
spasticdonkey wrote:
the custom includes are included after the jquery script is included.
6 Include jquery, tabcontent, ajaxtabs, nukePIEhdr, nukeFEEDhdr (add CSS and JS to arrays)
[...]
8 If defined, include module’s RN_MODULE_HEAD (add module-level CSS and JS to arrays)
Sorry but IMHO this is not true: I have written in my code:
Code:
define('RN_MODULE_HEAD', 'my_head.php');
and the code inside this file appears before the call of jquery library.
The "rules" you have written are right, but the script isn't working as expected
i actually haven't used RN_MODULE_HEAD but use RN_MODULE_CSS without trouble. Another approach might be to create
includes/addons/head-aaa.php
something like
Code:
if (stristr(htmlentities($_SERVER['PHP_SELF']), 'head-aaa.php')) {
Header('Location: ../../index.php');
die();
}
global $name, $user;
// user only scripts
if(is_user($user)){
addJSToHead('js/user-only.js', 'file');
}else{
addJSToHead('js/anony-only.js', 'file');
}
// by module
if ($name == 'Your_Module') {
addCSSToHead('css/yourcss.css', 'file');
addJSToHead('js/yourjs.js', 'file');
}
Now you can still use the RN_MODULE_HEAD, but if you want your JS to load properly you need to use these functions within your "my_head.php" file.
ALSO it is import to remember that you should always call the main jQuery library. You should not assume that it will always be loaded. If you use the addJSToHead() function it is smart enough not to load jquery.js multiple times.
includes/addons/head-xxx.php should only be used for SITE level modifications and should not be used for a per module approach.
Joined: Mar 30, 2006 Posts: 2456 Location: Pittsburgh, Pennsylvania
Posted:
Wed Jan 06, 2010 1:39 pm
I never noticed this line
Quote:
Modify mainfile.php to include 4 new functions: addCSSToHead, addJSToHead, addJSToBody, and writeHead. The functions use an array each and check the array before adding to prevent loading duplicate externally-defined files.
So I guess it is pretty much all there. I still think it is a little hard for someone new to understand. Especially how the actual functions work. At least without looking in mainfile.php.
Joined: Aug 29, 2004 Posts: 9136 Location: Arizona
Posted:
Thu Jan 07, 2010 6:41 am
kguske, BTW, I hadn't noticed this before, but what are your thoughts on possibly wanting to switch these two in sequence:
Quote:
5. Include javascript.php (to allow site administrators to follow an add-on instructions to load JS here)
6. Include jquery, tabcontent, ajaxtabs, nukePIEhdr, nukeFEEDhdr (add CSS and JS to arrays)
Was just thinking/wondering if ALL core RN components should always be loaded first? Not 100% sure, it just struck me as something to think about more.
Joined: Aug 29, 2004 Posts: 9136 Location: Arizona
Posted:
Thu Jan 07, 2010 6:58 am
Palbin, sorry, I am not clear so want to make sure it is clear. Are you referring specifically to RN_MODULE_HEAD and RN_MODULE_CSS or something else? TIA for clearing it up in my mind.
Joined: Mar 30, 2006 Posts: 2456 Location: Pittsburgh, Pennsylvania
Posted:
Thu Jan 07, 2010 7:57 am
Quote:
5. Include javascript.php (to allow site administrators to follow an add-on instructions to load JS here)
6. Include jquery, tabcontent, ajaxtabs, nukePIEhdr, nukeFEEDhdr (add CSS and JS to arrays)
Now I didn't look at the files, but I would assume that they can all be replaced with the new method.
The approach was designed to support add ons that were written before this was developed. In an ideal world, yes, this could all be restructured and much, if not all, of this could be eliminated. But remember that one of the benefits to Nuke is the availability of so many tweaks, etc., and unlike some other CMS / frameworks I've seen, doesn't require an advanced degree in computer science to understand / develop.
Also, I can't remember (yes, getting old), but I believe we did replace with the new method.
I will search for an example add on I made that provides an example of how to implement these changes.
Joined: Mar 30, 2006 Posts: 2456 Location: Pittsburgh, Pennsylvania
Posted:
Thu Jan 07, 2010 11:27 am
I realize that this was done to support what was existing. As you suggested I was just referring to an idealized situation.
I don't know what is in the nukePIEhdr & nukeFEEDhdr files, but I am sure what is in jquery, tabcontent, and ajaxtabs files could be moved directly into the modules in question instead of loading them in the header. I know there are if statements in there that control the loading of content, but ultimately these files should not be needed. Not that there is anything wrong with the current structure just looking for uniformity.
Joined: Aug 29, 2004 Posts: 9136 Location: Arizona
Posted:
Sat Jan 09, 2010 8:27 am
I still think we need the includes/javascript.php file as a "stub" within our distribution and it should be attempted to be loaded somewhere (or, possibly more preferred to have it as includes/custom_files/custom_javascript.txt along with some other "custom" stubs that folks can change from .txt to .php and use) as there could be blocks that require JS be loaded in the head to use.
My original comment was more just thinking about the order of load. Just thinking all the core JS should go first for sure, then it is a matter of should site-wide JS (such as javascript.php) includes go before module added JS?
Joined: Aug 30, 2005 Posts: 3186 Location: near Albany NY
Posted:
Sun Jan 17, 2010 10:59 am
In this thread, I asked about using tooltips:
Only registered users can see links on this board! Get registered or login to the forums!
SpasticDonkey, Kguske and others provided some helpful information and links. I've managed to get an elemental tooltip to work using the title attribute but I'm still puzzled by how to get the Jquery version to work.
I can use Palbin's suggestions, earlier in this thread to get css and javascript included "inline" in my script.
Note however that this gets included BEFORE jquery.php gets included by virtue of the logic in header.php.
However to take advantage of jquery's cluetip capabilities I'm trying to include some simple code that does this:
$("li.title").cluetip({splitTitle: "|"});
I took this from the jquery page one of you referred us to but changed the anchor a.title to a list item. Don't know if this will work but I can't see unless I get it included in the right place and there's the rub.
where rc_header.php is a file I set up in my module that has the li.title Javascript. Unfortunately when I look at view source it gets included by header.php before jquery.php gets included. What gives? Here is a little section of my view source that shows that my rc_header.php file is getting place right after the meta tags and before any of the inline JS or CSS is executed.
Quote:
<meta name="RATING" content="GENERAL" />
<meta name="GENERATOR" content="RavenNuke(tm) Copyright (c) 2002-2009 by Gaylen Fraley. This is free software, and you may redistribute it under the GPL (http://www.gnu.org/licenses/gpl-2.0.txt). RavenNuke(tm) is supported by the RavenNuke(tm) Team at
Only registered users can see links on this board! Get registered or login to the forums!
Ok I don't know exactly what your files look like, but lets say for example that you don't have a rc_header.php and have it all in say index.php. It would l0ook something like this.
Joined: Aug 30, 2005 Posts: 3186 Location: near Albany NY
Posted:
Sun Jan 17, 2010 2:00 pm
Palbin, SpasticDonkey, thanks again. I have tried both your suggestions without success. The problem remains (I think) that the cluetip js gets put too early in the header.php despite the fact that it doesn't appear from the header.php code that it should.
I'll just post my entire code here: you can ignore most of it but it will show the context in which I am doing things.
I have tried this both with and without the document.ready thing. Also, to answer a question Palbin asked, you can see that I have some inline Javascript code ... that is needed to deal with differences between the way Mozilla deals with some of the inline css code and the way IE does. The "basic" code works well ... it displays the form with the formatting controlled by the css which I appropriated from the web page I looked on. However getting the cluetip working with jquery features is proving daunting.
Perhaps down the road we could put a jquery_demo module into Ravennuke where we could put some examples of working code and how it is laid out? It could be just a simple "hello world" module with just one example of the main features of jquery we want to use. Like one form with just one input field that is say, an email and an example of how you'd use jquery validation. Or a form with one field with one title attribute and applying jquery to do a cluetip on that. Having a complete working example would be GREAT. I'LL BE happy to help out once you guys can get it through my thick skull how to make it work in the first place.[/code]
Joined: Aug 30, 2005 Posts: 3186 Location: near Albany NY
Posted:
Sun Jan 17, 2010 2:03 pm
Oh I meant to include my complete view source. If you look at the area right below the meta tags near the top you will see that my intended jquery cluetip js gets put way up there.
<td><font class="block-title"><strong>Languages</strong></font></td>
</tr>
</table></td>
</tr>
<tr>
<td bgcolor="#F4F6FB"><table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
<td><center>We're sorry but there are no language translations available. Please contact the Webmaster for further help.</center></td>
<tr>
<td><div style="text-align:center"> <em> Complete a Ride Report</em></div><form method="post" class="leader_report" name="leader_report" action="modules.php?name=Ride_Calendar&file=update_leader_report"><input type="hidden" name="__csrf_magic" value="sid:2a362a6dc102459fdf5fd5a93616e2416df5dfd0,1263757631" /><fieldset><ol><li>Your MHCC membership information together with the ride name, date and description are listed below. Please be sure you are submitting a ride report for the correct ride. Please use the problem email address on the home page of this site to report any discrepancies</li>
<li>Frank Kelly
Only registered users can see links on this board! Get registered or login to the forums!
</li><li>Rensselaer County Rides</li><li>ride description: Multi-paced rides; all riders welcome</li><li>ride date: 2005-05-03</li></ol>
<ol><li>
<label for="members">Number of MHCC members:</label>
Joined: Aug 30, 2005 Posts: 3186 Location: near Albany NY
Posted:
Sun Jan 17, 2010 4:32 pm
Working on this further, I see a missing file in my local apache error log. This was based on Palbin's earlier suggestion:
Quote:
Ok I don't know exactly what your files look like, but lets say for example that you don't have a rc_header.php and have it all in say index.php. It would l0ook something like this.
Then I was thinking "well I am trying to apply a cluetip to a label tag and there may be no class for it in the cluetip.css. So let's go back to the basics and just emulate exactly the code off the jquery web page. So I put in an anchor tag as per:
Code:
echo '<a class="title" href="modules.php?name=Ride_Calendar&file=index" title="back to select rides | index.php" >Back to Select Rides</a>';
Unfortunately, this picks up the title class from the fisubice theme.css file rather than from cluetip.css. So I go in and temporarily modify the title class in the fisubice file but that does nothing except reduce the font size and bolding of the a tag.
View next topic View previous topic
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum