portal:carousel - anyone working with this?

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
12/7/2010 8:40:15 AM
Gravatar
Total Posts 36

Re: portal:carousel - anyone working with this?

I used Firebug and it gave me this error. "$ is not defined
 $(document).ready(function () { "

 

this is my script between the <head> tags

 

<script type="text/javascript">
var current_carousel_position = 1;

$(document).ready(function () {

/* initialize carousel */
$('.mycarousel').jCarouselLite({
btnNext: ".next",
btnPrev: ".prev",
speed: 200,
easing: "easein",
visible: 1,
afterEnd: function (a) {
show_carousel_selected(current_carousel_position);
}
});

show_carousel_selected(current_carousel_position);

if (jQuery.browser.webkit || jQuery.browser.msie) {
$("#mycarousel").css('marginTop', '-16px');
}

/*if(jQuery.browser.webkit){
$("#mycarousel").css('marginTop', '-16px');
}*/


});

/* ***************************************************************************************** */
function show_carousel_selected(index) {
//alert ($('.slideshow .button-holder ul li').size());
index = ((index - 1) % $('.slideshow .button-holder span').size() + 1);
$('.slideshow .button-holder span').removeClass('on');
$('.slideshow .button-holder span#showcase-bullet-' + index).addClass('on');
}

</script>

12/7/2010 8:56:35 AM
Gravatar
Total Posts 18439

Re: portal:carousel - anyone working with this?

You can keep struggling or you can follow the advice I already gave you and read this document:

http://www.mojoportal.com/adding-custom-javascript.aspx

and watch the video of the August mojoPortal User Group meeting

then you will understand how to do it correctly.

Also the way you are adding your css is wrong. You would save yourself some time and struggle by reading the skinning documentation carefully, in particular the document about the style.config file and how to add css files.

 

12/7/2010 10:40:05 AM
Gravatar
Total Posts 355

Re: portal:carousel - anyone working with this?

The error you're receiving is happening because your code's being read in the header before jQuery is being referenced.

It is a good idea to review the documentation Joe's mentioned; it's always good to know "the right way" before experimenting and implementing an alternative solution, the way I have for my "one-off" implementations. wink

Joe - I deeply appreciate all the work you put into the videos, the documentation, and most of all, into MojoPortal itself.  Exploring different ways of implementing functionality is a hallmark of the kind of people drawn to MojoPortal, and sometimes it's good to know "good enough" techniques when there's no time to do a custom control, re-compile, upload, etc.

Dasan - here is working example code of the jQuery horizontal slider on the front page of Rose and Dagger: it should give you an idea of how to do an "on the fly" implementation.  The following code is embedded along with the proper unordered list structures in an HTML control:

/*Main Container*/
.container {
width:872px;
}
.container ul{
list-style-type: none;
margin: 0;
padding:0;
}
.container li{
display: inline;
margin: 0px;
padding:0px;
}
/*Content Container*/
.contentContainer {
padding-left: 0px;
float: left;
width:0px;
height: 398px;
overflow:hidden;
}
.contentWrapper{
}
.contentInnerWrapper{
text-align: justify;
}
/* Handle*/
.handle{
float: left;
width: 84px;
height: 398px;
margin:0;
background: url("/Data/Sites/1/FrontPageSlider/inactive.jpg") no-repeat;
}

.handle img{
position:absolute;
margin-left:-82px;
clip: rect(0px, 164px, 398px, 90px)

/*top, right, bottom, left*/
}

.handleOver{
background: url("hover.jpg") no-repeat;

}
.handleSelected{
background: url("active.jpg") no-repeat;

}

.handleSelected:hover{
background: url("hover.jpg") no-repeat;
}

.handleSelected:hover img{
position:absolute;
margin-left:-82px;
clip: rect(0px, 164px, 398px, 88px)
}

.handleSelected img
{
position:absolute;
margin-left:0px;
clip: rect(0px, 84px, 398px, 4px)

}
.divText
{
width:417px!important;
margin-left:2px;
height:60px;
z-index:85;
padding:10px;
color:#eeeeee;
background-image:url("grey_trans.png");
background-repeat:repeat;
font-size:11px;
} </style>
<script type="text/javascript" src="/ClientScript/hrzAccordion/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="/ClientScript/hrzAccordion/jquery.hrzAccordion.js"></script>
<script type="text/javascript" src="/ClientScript/hrzAccordion/thisInstance.js"></script>

 

It's a big jump from DNN to MojoPortal; I've found Mojo to be a great product, and I'm sure you will, too. Hang in there!

 

12/7/2010 5:37:31 PM
Gravatar
Total Posts 18439

Re: portal:carousel - anyone working with this?

I've been chewing on this thread in the back of my mind today and what I concluded is it should be easier to add a jquery plugin scripts directly in layout.master.

I've changed the logic for the next release so that it will render the main jquery and jqueryui scripts in the head section, and as long as you add your script below the <portal:ScriptLoader, the jquery scripts you add that the plugin depends on will be below the main jquery and jqueryui scripts. So basically where you previously/currently need to create a UserControl and register the script from code to make it come in after the main jquery scripts, that problem will go away in the next release. Actually it is already changed in the source code repository for anyone working directly with the source code.

Hope it helps reduce struggles like this in the future.

Best,

Joe

12/8/2010 9:22:32 AM
Gravatar
Total Posts 36

Re: portal:carousel - anyone working with this?

Thanks Joe, i think i will wait for the next release, unfortunately i have not been able to make it work yet. i keep on getting errors like this one

Firebug's log limit has been reached. 0 entries not shown. Preferences
$(".mycarousel").jCarouselLite is not a function
[Break On This Error] afterEnd: function (a) {
home.aspx (line 330)
$(".mycarousel").jCarouselLite is not a function
[Break On This Error] afterEnd: function (a) {

and im trying to learn how to create an UserControl to register the script but again this is new for me , i was use of just dragging the script link or source to the page.

 

12/8/2010 9:54:58 AM
Gravatar
Total Posts 18439

Re: portal:carousel - anyone working with this?

You can get it working now if you put both your plugin script and your instance script at the bottom just before the closing body tag.

<script type="text/javascript" src="/pathtoyourplugin.js" /

<script type="text/javascript">

$(document).ready(function () {
// wire up your plugin instance

});

</script>
</body>

this way you can be sure that jquery and jqueryui are already loaded above it.

12/8/2010 10:13:54 AM
Gravatar
Total Posts 36

Re: portal:carousel - anyone working with this?

i can just add this in the  Layout.Master? Do i still need to put my .js in the ClientScript folder? Do i need to update mojoPortal?

 

Thank you

12/8/2010 10:18:46 AM
Gravatar
Total Posts 18439

Re: portal:carousel - anyone working with this?

yes in layout.master

you can put the plugin script where you like but under /ClientScript is not a bad idea, that is where I would put it, also the plugin may have css and image files that need to be placed relative to where you place the plugin js so you may need to structure it carefully to make sure it finds what it is looking for. It just depends on the plugin, I don't know much about jcarousellite, we have jcarousel built in to mojoPortal and it can be used much easier.

12/8/2010 10:21:25 AM
Gravatar
Total Posts 18439

Re: portal:carousel - anyone working with this?

no you don't need to update mojoPortal. In the next release it will be more tolerant of where you place the plugin script but for now you can put it at the bottom and it should work because the jquery and jquery ui will already be loaded above it.

 

12/8/2010 10:32:43 AM
Gravatar
Total Posts 36

Re: portal:carousel - anyone working with this?

This is what i have!

 

<div class="toolbarright">
<span class="downarr"><a href="#"></a></span>
<portal:AdminMenuLink ID="lnkAdminMenu" runat="server" />
<portal:FileManagerLink ID="lnkFileManager" runat="server" />
<portal:NewPageLink ID="lnkNewPage" runat="server" />
<portal:PageEditFeaturesLink ID="lnkPageContent" runat="server" />
<portal:PageEditSettingsLink ID="lnkPageSettings" runat="server" />
<asp:ContentPlaceHolder ID="pageEditContent" runat="server">
</asp:ContentPlaceHolder>
</div>
</div>
</portal:AutoHidePanel>
<portal:mojoGoogleAnalyticsScript ID="mojoGoogleAnalyticsScript1" runat="server" />
<portal:Woopra ID="woopra11" runat="server" />
</form>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"</script>
<script type="text/javascript" src="js/jquery.jcarousellite.js"></script>
<script type="text/javascript" src="js/jquery.easing.1.1.js"></script>

<script type="text/javascript">

var current_carousel_position = 1;

$(document).ready(function () {

/* initialize carousel */
$('.mycarousel').jCarouselLite({
btnNext: ".next",
btnPrev: ".prev",
speed: 200,
easing: "easein",
visible: 1,
afterEnd: function (a) {
show_carousel_selected(current_carousel_position);
}
});

show_carousel_selected(current_carousel_position);

});

/* ***************************************************************************************** */
function show_carousel_selected(index) {
//alert ($('.slideshow .button-holder ul li').size());
index = ((index - 1) % $('.slideshow .button-holder span').size() + 1);
$('.slideshow .button-holder span').removeClass('on');
$('.slideshow .button-holder span#showcase-bullet-' + index).addClass('on');
}

</script>
</body>

 

and its giving me this ERROR

 

$(".mycarousel").jCarouselLite is not a function
http://localhost/mojoportal/home.aspx
Line 344

12/8/2010 10:41:23 AM
Gravatar
Total Posts 18439

Re: portal:carousel - anyone working with this?

get rid of the jquery 1.4.2 script since jquery is already loaded by mojoPortal.

If your js folder is in the root then you need to specify the url like /js/jquery.carousellight.js, you are missing the first /

the easing script may need to be above the carousel script

You must sign in to post in the forums. This thread is closed to new posts.