- Screen name: mauricederegt
mauricederegt's Profile
30 Posts
46 Responses
0
Followers
Show:
- Expanded view
- List view
Private Message
- 22-Feb-2017 07:45 AM
- Forum: Using jQuery
Hi all,
Please see this fiddle: https://jsfiddle.net/8rou42z0/
I am adding a div using jquery. This is the front side of a card (in the original code this is randomly generated so you never know what card you will get). The back side is already there. Now when adding this front card DIV by clicking the turned card, I want it to flip over from the back side to this newly added front side.
The problem atm is that it shows the new DIV immediately and then flips it away. I want it the other way around ofcourse. What am I doing wrong here?
Thanks- 29-Aug-2016 06:41 AM
- Forum: Using jQuery UI
I have some old jquery (UI) code that I want to upgrade to todays standards. Since my code was written for jQuery UI 1.7.3 I've decided to upgrade the code release by release. A release list is found here: https://jqueryui.com/upgrade-guide/
So if I open 1.8 Upgrade Guide I can see what was changed. So far so good. As far as I can see, the following changes apply to my code:
- Renamed _init() to _create()
- Renamed _setData() to _setOption()
- Removed _getData() since it should never be overridden
- $.widget() now accepts a base widget to extend as the second parameter; defaults to $.Widget
Unfortunately I am not sure what to do with
_getData()
. Must I replace this with_Option
or_getOption
?. This is not clear in the guide.Nevertheless, changing my code results in a nonworking application. I hope someone can help me out.
This is (partly) my old code:
_init: function () { var index = this.options.index; var num_ranks = this._RANKS.length; var suit = parseInt(index/num_ranks); this._setData('suit', suit); this._setData('rank', index - (suit * num_ranks)); this.element.addClass('container') .append('<div class="downturned">'); }, _suit: function () { return this._getData('suit'); }, _rank: function () { return this._getData('rank'); },
And further in the code:
$.widget('ui.card', Card); //Create the widget $ui.card.getter = "is_downtunred";
The above I've changed (using the guide) to:
_create: function () { var index = this.options.index; var num_ranks = this._RANKS.length; var suit = parseInt(index/num_ranks); this._setOption('suit', suit); this._setOption('rank', index - (suit * num_ranks)); this.element.addClass('container') .append('<div class="downturned">'); }, _suit: function () { return this._getOption('suit'); }, _rank: function () { return this._getOption('rank'); },
And further in the code (did not change anything here):
$.widget('ui.card', Card); //Create the widget $ui.card.getter = "is_downtunred";
But this brakes the application. Anyone knows why? What am I missing?
Thanks for the help
- Hi all,I have the following working code which is executed onclick:
- $waste.append($stock
- .children('.container:lt(3)')
- .css( 'left', function(i) {return ['0rem', '2rem', '4rem'][i];})
- );
It shows 3 div's positioned 0, 2 and 4 rem from a left div border. This all shows up correct.BUT....I don't want these 3 DIVs just to appear on their given location, I want to move them to that location. How to do this? I've tried things like:- $waste.append($stock
- .children('.container:lt(3)')
- .animate( left: function(i) {return ['0rem', '2rem', '4rem'][i];}, 200)
- );
But this doesn't seem to work. Anyone has an idea how to achieve this?Thanks a lot- 04-Nov-2015 04:03 AM
- Forum: Getting Started
Hi,I have the following working code:- $stock.click(function () {
- $waste.append($stock.children('.container:lt(3)').card('upturn').droppable('disable').css( "left", function(i) {return ["0rem", "2rem", "4rem"][i];}) ); //3 divs
- });
This code adds several classes to 3 div's, except the for the css. Each div gets a different left property using:
- .css( "left", function(i) {return ["0rem", "2rem", "4rem"][i];})
This all works, but I also want to disable the draggable option for the first 2 div's.
I've tried things like (1):
- .draggable('disable', function(i) {return ["true", "true", "false"][i];})
and (2)
- .draggable(function(i) {return ['disable', 'disable', 'enable'][i];})
but try (1) disables all the 3 divs, not just the first 2 and try (2) doesn't work at all.
How can I achieve this?
Thanks a lot
- 28-Oct-2015 11:49 AM
- Forum: Getting Started
Hi,I have the a div with following CSS:- style =" z-index: 3; left: 12rem;
With jQuery I want to grab the left value. I am using this code for it:- positionLeft = $(this).css('left');
But this returns the pixel value (144px) instead of the original 12remWhat can I do to get the 12rem instead of the 144px I get returned now?Thanks- Hi all,I am trying to make a solitaire like game. When I click the cards (read: divs) that are stacked on the deck pile, the top card will turn and move to the left. This all works great. I am using the following code:
- var z = 1;
- $('#deck .card.flipped').on('click', function () {
- if (!$(this).hasClass('dropped')) {
- $('.card').removeClass('ui-front');
- $(this)
- .addClass('ui-front')
- .addClass('on-discard-pile')
- .addClass('dropped')
- .css({'z-index': z++})
- .animate({left: '8rem'}, 200)
- .draggable({ disabled: false})
- .removeClass('flipped');
-
- if (!$(this).is(':first-child')) {
- $('.card').removeClass('under-card');
- $(this).next().addClass('under-card');
- } else {
- $('.card').removeClass('under-card');
- }
- }
- });
Now I want not to turn 1 card from the deck when I click it, but the top 3 cards. Also the first top card will move 8rem to the left (using .animate({left: '8rem'}, 200) ) but the second card should move 10rem to the left en the third and last card 12rem
How can I do this?I have tried :lt() and stuff but can't get it workingSee my fiddle: http://jsfiddle.net/hy2dvL1u/35/I have a DIV with id: TEST that I can drag using jQuery UI. All works, but as soon as I remove it and load the DIV into the HTML dynamically (well to specify more: using SSE to load the DIV into the HTML), the DIV can't be dragged. This is because the jQuery is loaded before the DIV is. How to fix this? Since I use SSE, the DIV is loaded several times over a period of time and must stay draggable.
The DIV looks like this in the TXT file (which is loaded into the HTML)
- <div id="TEST" class="chatmsg" style="left: 200px; top: 200px;"><b>Bami</b>: Pangang<br/></div>
This DIV (with ID: TEST) is loaded into another DIV called dragZone
- <div id="dragZone" name="dragZone"> [div TEST is loaded here] </div>
The jquery code in the HTML:
- $(function() {
- $( "#TEST" ).draggable({
- containment: "parent"
- }).css({'cursor': 'all-scroll', 'z-index': '5'});
- });
The JS code
that loads the SSE (which pushes the content of txt file everytime it changes):
So how can I drag the DIV again everytime the DIV is "pushed" into the HTML?- //HTML5 SSE(Server Sent Event) initilization
- this.initSevr=function(){
- sevr = new EventSource('test.php');
- sevr.onmessage = function(e){
- if(oldata!=e.data){
- dragZone.innerHTML+=e.data;
- oldata = e.data;
- }
- };
- };
I've tried putting the jquery part into the SSE part, but that had no effect
- Hi all,I have the following working form:
- <div id="player_won">
- <form action="insert.php" method="post">
- Firstname: <input type="text" name="firstname" />
- Lastname: <input type="text" name="lastname" />
- Score: <input type="text" name="score" />
- <input type="submit" />
- </form>
- </div>
When clicking submit, it will submit the data to my database. All works great. The only downside is that it will show this insert.php file after a succesfull submit.Now I also have the following trigger:- function gameWon(){
- var $game_board = $("#game_board_container");
- var $player_won = $("#player_won");
- $player_won.show();
- $game_board = $player_won = null;
- };
When this happens, it will show the div where the form is in. Since all the fields are already pre-filled, I also want to submit the form at the same time, automaticly, without needing to press the submit button. (but still show the form/div ofcourse)How to do this? In addition, I also don't want to be forwarded to the insert.php file. I just want the div to pop-up when triggert, submit the form at the same time, and do nothing else (The user can close the pop-up div himself if needed).Hope you guys can help me out!Kind regards,Mauirce- 25-Jun-2011 06:51 PM
- Forum: Using jQuery
Hi there,I was using this script (which works perfectly) to show the mouse coordinates just above the mouse when clicked. I didn't want to use the .click to show the coordinates (or depend on a div area), but have this happen an a event (using .bind). I also included this code into a bigger js file.
This is the working code I put together (with some help):- $(function(){
- var mousePos = [0, 0];
- $(document).mouseover(function(e) {
- mousePos = [e.pageX, e.pageY];
- })
- .bind('found_match', function() {
- $('#status2')
- .html(mousePos[0] + ', ' + mousePos[1])
- .hide()
- .css({
- top: mousePos[1] -10,
- left: mousePos[0] -20,
- opacity: 1,
- marginTop: 0
- })
- .show()
- .stop()
- .delay(200)
- .animate({'marginTop':-75, opacity: 0},1000);
- });
- });
This works, just like the first code, but the div with the coordinates now shows randomly around, under or on top of the mouse and not just like the first code. For example, now with a match, the div appears just right of the mouse and sometimes under the mouse, or over it, it's random where it shows the div. It does however show it near the mouse, but never at the same position (lets say always above the mouse). I would expect the div to always show at the same position of the mouse itself. What is going wrong and how to fix this?Many thanks- 23-Jun-2011 11:22 AM
- Forum: Using jQuery
Hi,After some reading from this tutorial, I have the following partly working code:- $(document).bind ("found_match", function(e){
- $('#status2').html(e.pageX +', '+ e.pageY);
- });
When the event: "found_match happens", it should show the mouse coordinates in the div: "status2" , but it doesn't. Obviously because I am missing the .mousover(). But where to put this in my code to make it work so that it wil show the mouse coordinates on this event?Many thanks- Hi there,I am trying to add some sort of score system to my script, but I have no idea how to get this working. I have two files 1php and 1 javascript (which gets implemented in the php file)What do I need?I want to add a score system to my script.In the javascript there is this part of code:
- function foundMatchingBlocks(event, params){
- var $elements = params.elements;
- $elements.remove();
This removes 2 blocks from a board. When this happens I want to ad +100 points to my score and show this updated score in my php file. (every time 2 blocks get removed it must update the score)But how to do this? Score starts with 0 ofcourse. I think its very easy to put this in, but I was unsuccesfullKind regards,- 13-Mar-2011 10:00 AM
- Forum: Using jQuery
Hi there,I am currently using jQuery tools plugin to show a div on a triggerd event. Only I want to remove this plugin and use jQuery's default fadeIn function. Only I don't get it to work...The jquery tools code:- $(document).bind("game_over.overlay", function(){
- if ( $('#lost_overlay_trigger').data("overlay") ){
- $('#lost_overlay_trigger').data("overlay").load();
- } else {
- $('#lost_overlay_trigger').overlay({
- effect: 'apple',
- load: true
- });
- }
- });
- $(document).bind("game_won.overlay", function(){
- if ( $('#won_overlay_trigger').data("overlay") ){
- $('#won_overlay_trigger').data("overlay").load();
- } else {
- $('#won_overlay_trigger').overlay({
- effect: 'apple',
- load: true
- });
- }
- });
- $("#game_over_shuffle").bind("click.overlay", closeOverlay);
- $("a.again").bind("click", closeOverlay);
I have the following divs:- <div id="player_won_container" class="achievements">
- <div id="player_won"></div>
- <br />
- <a class="again" href="#" onclick="return false">Click here to play again</a>
- </div>
- <div id="player_lost_container" class="achievements">
- <div id="player_lost">
- <h3>No more moves - GAME OVER</h3>
- <a class="again" href="#" onclick="return false">Click here to play again</a> / <a id="game_over_shuffle" href="#" onclick="return false">Or shuffle the board</a>
- </div>
- </div>
- <a href="#" rel="#player_won_container" id="won_overlay_trigger" onclick="return false"></a>
- <a href="#" rel="#player_lost_container" id="lost_overlay_trigger" onclick="return false"></a>
So how to replace this so I wont need jQuery Tools anymore? I was playing around with:- $(".player_lost_container").fadeIn("slow");
But had no luckKind regards- Hi,
I have a php page (intro.php) that loads a div. This div is a menu and contains 2 links:link 1: intro.php?layout=classiclink 2: intro.php
Currently when clicking these links, the page will refresh and the menu re-appears. This is not what I want. When clicking these menu links I want the page to load, but the menu div to be hidden. I think this is possible to use something in the link like: intro.php#hidediv???? And how to do this? Other solutions are also welcome!I hope it's clear what I want.
Code:- <!DOCTYPE html>
- <html>
- <head>
- <style>
- .menu{
- position:absolute;
- background:#pink;
- left:150px;
- top:150px;
- width:760px;
- height:500px;
- }
- .menuholder{
- position:relative;
- background:#green;
- left:260px;
- top:10px;
- width:240px;
- height:360px;
- }
- .menuholder ul{
- list-style:none;
- position:absolute;
- right:0px;
- top:0px;
- margin-top:6px;
- z-index:555555;
- }
- .menuholder ul li a{
- width:230px;
- float: right;
- clear:both;
- font-family:'Myriad Pro',Arial,Helvetica,sans-serif;
- text-decoration:none;
- text-align: center;
- text-transform:uppercase;
- letter-spacing:-1px;
- display:block;
- height:52px;
- line-height:52px;
- background-color:#222;
- margin:1px 3px 1px 0px;
- opacity:0.7;
- color:#f0f0f0;
- font-size:20px;
- border:2px solid #000;
- outline:none;
- text-shadow:-1px 1px 1px #000;
- -moz-border-radius:10px 0px 0px 20px;
- -webkit-border-top-left-radius:10px;
- -webkit-border-bottom-left-radius:20px;
- border-top-left-radius:10px;
- border-top-right-radius:10px;
- border-bottom-left-radius:20px;
- border-bottom-right-radius:20px;
- }
- .menuholder ul li a:hover{
- background-color:#black;
- }
- </style>
- <script src="http://code.jquery.com/jquery-1.5.js"></script>
- <script type="text/javascript">
- <!-- Fade in/out page -->
- $(document).ready(function() {
- $("a.transition").click(function(event){
- event.preventDefault();
- linkLocation = this.href;
- $("body").fadeOut(1000, redirectPage);
- });
- function redirectPage() {
- window.location = linkLocation;
- }
- });
- </script>
- <style type="text/css">
- .block img{
- display: none;
- }
- </style>
- <script type="text/javascript">
- $(document).ready(function() {
- $("body").css("display", "none");
- $("body").fadeIn(2000);
- $("a.transition").click(function(event){
- event.preventDefault();
- linkLocation = this.href;
- $("body").fadeOut(1000, redirectPage);
- });
- function redirectPage() {
- window.location = linkLocation;
- }
- });
- </script>
- </head>
- <body onload="startstop();">
- <div id="outer">
- <div id="inner">
- <div id="container">
- <div id="game-start">
- <div id="game_board_container">
- </div>
- </div>
- </div>
- </div>
- </div>
- <div class="menu" id="menu" >
- <div class="menuholder">
- <ul id="rotmenu">
- <li>
- <a href="intro.php?layout=classic" class="transition">With ? in the link</a>
- </li>
- <li>
- <a href="intro.php" class="transition">Plain php link</a>
- </li>
- </ul>
- </div>
- </div>
- </body>
- </html>
Kind regards,Maurice- Hi there,Currently I am using this very simple tab-script. Took it from: http://jqueryfordesigners.com/jquery-tabs/All works fine, but I want to use the .fadeIn(); option, so that (when I switch tabs) this goes nice and smooth. But where to put this .fadeIn();?The code:
- <script type="text/javascript">
- <!-- Tabs -->
- $(function () {
- var tabContainers = $('div.tabs > div');
- tabContainers.hide().filter(':first').show();
- $('div.tabs ul.tabNavigation a').click(function () {
- tabContainers.hide();
- tabContainers.filter(this.hash).show();
- $('div.tabs ul.tabNavigation a').removeClass('selected');
- $(this).addClass('selected');
- return false;
- }).filter(':first').click();
- });
- </script>
Thanks!Kind regardsps: if anyone knows how to reduce the gabs between the tabs, please let me know too :)- Hi there,I have the following code form the api example:
<!DOCTYPE html> <html> <head> <style> div { position:absolute; background-color:#abc; left:50px; width:90px; height:90px; margin:5px; } </style> <script src="http://code.jquery.com/jquery-1.5.js"></script> </head> <body> <button id="left">«</button> <button id="right">»</button> <div class="block"></div> <script> $("#right").click(function(){ $(".block").animate({"left": "+=250px"}, "slow"); }); $("#left").click(function(){ $(".block").animate({"left": "-=250px"}, "slow"); }); </script> </body> </html>
This moves the div 250px to the right (or left) when clicking the button. Now is the following also possible?I want it so that when I click the button the div moves to the right (250px) then waits for 5 sec and then moves another 250px to the right (whitout needing to click again). And how to do that?Thanks- 04-Jan-2011 06:06 AM
- Forum: Getting Started
Hi there,I have the following code lines in my JavaScript code:- var colors = ["#F08", "#0B8", "#04F", "#FD0", "#808", "#F20"];
This sets the bg colors of my divs. This var is only used here:- function activateItems(callback) {
- var itemsActivated = false;
- for (var i=0;i<cfg.rows;++i) for (var j=0; j<cfg.cols; ++j) {
- var item = itemAt(i,j);
- if(!item) continue;
- if (item.deleted>0) {
- item.style.background=colors[Math.floor(Math.random()*colors.length)];
- itemsActivated = true;
- }
- }
- if (itemsActivated)
- animateAppear(callback ? callback : findPatterns);
- }
and here:- function animateDecor() {
- if(state == 'init' || state == 'game') return;
- for (var i=0;i<cfg.rows;++i) for (var j=0;j<cfg.cols;++j) {
- var item = document.getElementById("decor_"+i+"_"+j)
- if(!item) continue;
- item.style.background=colors[Math.floor(Math.random()*colors.length)];
- }
- animation = setTimeout(animateDecor, 120);
- }
This all works great, only I don't want to use hex (#) colors as background, I want to use images. These are located for example in: images/blue.png, images/red.png, etc. But how to pull this off? Tried several stuff including backgroundImage:url and so, but these where unsuccessful. I am just starting to learn this so some corrected code examples with comments will really help.I think the solution is very simple, but I just don't see it (yet)...Many thanks- Hi all,I have a script, but it's slowing down when using it. Inside the display(elem) function I'm binding event handlers using click(). These event handlers get installed multiple times, which will ultimately cause delays and animation bugs. To solve this I want to use live() to install event handlers at the very beginning, preventing the slow down.The problem is, where do I put this .live() in the script. Tried some options myself, but this resulted in a non working script OR no change at all and the script kept delaying. I would appreciate if someone can show me where to put this .live() or have another (better?) solution to prevent the delays.Any help is appreciated!The script:
- <script type="text/javascript">
$(function() {
/* the index of the current list element */
var current = 1;
/* function to iterate through all the list elements */
var iterate = function(){
var i = parseInt(current+1);
var lis = $('#rotmenu').children('li').size();
if(i>lis) i = 1;
display($('#rotmenu li:nth-child('+i+')'));
}
/* Initially display the first one */
display($('#rotmenu li:first'));
/* if the User clicks on one list item, the auto slider stops */
$('#rotmenu li').bind('click',function(e){
display($(this));
e.preventDefault();
});
/* displays each element associated to the "elem" list element */
function display(elem){
var $this = elem;
var repeat = false;
if(current == parseInt($this.index() + 1))
repeat = true;
/* slide in the current one (li-menu) */
if(!repeat)
$this.parent()
.find('li:nth-child('+current+') a')
.stop(true,true)
.animate({'marginRight':'-20px'},300,function(){
$(this).animate({'opacity':'0.7'},700);
});
current = parseInt($this.index() + 1);
var elem = $('a',$this);
/* slide out the clicked or next one */
elem.stop(true,true).animate({'marginRight':'0px','opacity':'1.0'},300);
/* the heading and description will slide out, change the content and slide back in */
var info_elem = elem.next();
$('#rot1 .heading').animate({'left':'-420px'}, 500,'easeOutCirc',function(){
$('h1',$(this)).html(info_elem.find('.info_heading').html());
$(this).animate({'left':'0px'},400,'easeInOutQuad');
});
$('#rot1 .description').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
$('p',$(this)).html(info_elem.find('.info_description').html());
$(this).animate({'bottom':'0px'},400,'easeInOutQuad');
});
/* open by click */
$('#clickme').click(function() {
$('#rot1 .close').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
});
$('#rot1 .menu').animate({'left':'600px'}, 500,'easeOutCirc',function(){
$('h1',$(this)).html(info_elem.find('.info_heading').html());
$(this).animate({'right':'0px'},400,'easeInOutQuad');
});
$('#rot1 .title').animate({'left':'-420px'}, 500,'easeOutCirc',function(){
$('h1',$(this)).html(info_elem.find('.info_heading').html());
$(this).animate({'left':'0px'},400,'easeInOutQuad');
});
$('#rot1 .content').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
$('p',$(this)).html(info_elem.find('.info_description').html());
$(this).animate({'bottom':'0px'},400,'easeInOutQuad');
});
});
/* close by click */
$('#2').click(function() {
$('#rot1 .close').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
$('p',$(this)).html(info_elem.find('.info_close').html());
$(this).animate({'bottom':'0px'},400,'easeInOutQuad');
});
$('#rot1 .title').animate({'left':'-420px'}, 500,'easeOutCirc',function(){
});
$('#rot1 .menu').animate({'left':'850px'}, 500,'easeOutCirc',function(){
});
$('#rot1 .content').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
});
});
}
});
</script>
- 21-Sep-2010 04:36 PM
- Forum: Using jQuery
Hi,Using jquery, I have some divs sliding into my web-page when clicking a link. When this is done, I can click another link so that the divs slide out again. This all works, but every time I press the links, it seems that the sliding time (time when the divs start to slide in) is delayed by every click/use.For example:Click link 1: divs slide in (1 sec delay before slide in starts)pressing some other (child) divs to slide in outClick link 2: divs slide out(1 sec delay before slide out starts)then I click them again:Click link 1: divs slide in (2 sec delay before slide in starts)pressing some other (child) divs to slide in outClick link 2: divs slide out(2 sec delay before slide out starts)And again:then I click them again:Click link 1: divs slide in (3 sec delay before slide in starts)pressing some other (child) divs to slide in outClick link 2: divs slide out(3 sec delay before slide out starts)etc etcThis ONLY happens when using the other sliding options in the divs (children) that slide in them selves (in the code I think thats this part: /* the heading and description will slide out, change the content and slide back in */). So only clicking the slide in/out links themselves does not slow down the script. As soon as I used another div sliding in to the already slided in div, the slowing begins.Any ideas on how to fix this? I think the other slide in somehow counts/adds his delay to the other slide out/in div, but no idea how to prevent this.This is the part of javascript that is handling the div slide in/out of the web-page:- /* open by click */
$('#clickme').click(function() {
$('#rot1 .close').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
});
$('#rot1 .menu').animate({'left':'600px'}, 500,'easeOutCirc',function(){
$('h1',$(this)).html(info_elem.find('.info_heading').html());
$(this).animate({'right':'0px'},400,'easeInOutQuad');
});
$('#rot1 .title').animate({'left':'-420px'}, 500,'easeOutCirc',function(){
$('h1',$(this)).html(info_elem.find('.info_heading').html());
$(this).animate({'left':'0px'},400,'easeInOutQuad');
});
$('#rot1 .content').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
$('p',$(this)).html(info_elem.find('.info_description').html());
$(this).animate({'bottom':'0px'},400,'easeInOutQuad');
});
});
/* close by click */
$('#2').click(function() {
$('#rot1 .close').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
$('p',$(this)).html(info_elem.find('.info_close').html());
$(this).animate({'bottom':'0px'},400,'easeInOutQuad');
});
$('#rot1 .title').animate({'left':'-420px'}, 500,'easeOutCirc',function(){
});
$('#rot1 .menu').animate({'left':'850px'}, 500,'easeOutCirc',function(){
});
$('#rot1 .content').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
});
});
This works perfect when not having the other animate option used. This is the complete js code:- <script type="text/javascript">
$(function() {
/* the index of the current list element */
var current = 1;
/* function to iterate through all the list elements */
var iterate = function(){
var i = parseInt(current+1);
var lis = $('#rotmenu').children('li').size();
if(i>lis) i = 1;
display($('#rotmenu li:nth-child('+i+')'));
}
/* Initially display the first one */
display($('#rotmenu li:first'));
/* if the User clicks on one list item, the auto slider stops */
$('#rotmenu li').bind('click',function(e){
display($(this));
e.preventDefault();
});
/* displays each element associated to the "elem" list element */
function display(elem){
var $this = elem;
var repeat = false;
if(current == parseInt($this.index() + 1))
repeat = true;
/* slide in the current one (li-menu) */
if(!repeat)
$this.parent()
.find('li:nth-child('+current+') a')
.stop(true,true)
.animate({'marginRight':'-20px'},300,function(){
$(this).animate({'opacity':'0.7'},700);
});
current = parseInt($this.index() + 1);
var elem = $('a',$this);
/* slide out the clicked or next one */
elem.stop(true,true).animate({'marginRight':'0px','opacity':'1.0'},300);
/* the heading and description will slide out, change the content and slide back in */
var info_elem = elem.next();
$('#rot1 .heading').animate({'left':'-420px'}, 500,'easeOutCirc',function(){
$('h1',$(this)).html(info_elem.find('.info_heading').html());
$(this).animate({'left':'0px'},400,'easeInOutQuad');
});
$('#rot1 .description').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
$('p',$(this)).html(info_elem.find('.info_description').html());
$(this).animate({'bottom':'0px'},400,'easeInOutQuad');
});
/* open by click */
$('#clickme').click(function() {
$('#rot1 .close').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
});
$('#rot1 .menu').animate({'left':'600px'}, 500,'easeOutCirc',function(){
$('h1',$(this)).html(info_elem.find('.info_heading').html());
$(this).animate({'right':'0px'},400,'easeInOutQuad');
});
$('#rot1 .title').animate({'left':'-420px'}, 500,'easeOutCirc',function(){
$('h1',$(this)).html(info_elem.find('.info_heading').html());
$(this).animate({'left':'0px'},400,'easeInOutQuad');
});
$('#rot1 .content').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
$('p',$(this)).html(info_elem.find('.info_description').html());
$(this).animate({'bottom':'0px'},400,'easeInOutQuad');
});
});
/* close by click */
$('#2').click(function() {
$('#rot1 .close').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
$('p',$(this)).html(info_elem.find('.info_close').html());
$(this).animate({'bottom':'0px'},400,'easeInOutQuad');
});
$('#rot1 .title').animate({'left':'-420px'}, 500,'easeOutCirc',function(){
});
$('#rot1 .menu').animate({'left':'850px'}, 500,'easeOutCirc',function(){
});
$('#rot1 .content').animate({'bottom':'-270px'},500,'easeOutCirc',function(){
});
});
/* the image will fade out and another will fade in */
$('#rot1').prepend(
$('<img/>',{
style : 'opacity:0',
className : 'bg'
}).load(
function(){
$(this).animate({'opacity':'1'},600);
$('#rot1 img:first').next().animate({'opacity':'0'},700,function(){
$(this).remove();
});
}
).attr('src','images/'+info_elem.find('.info_image').html()).attr('width','800').attr('height','300')
);
}
});
</script>
Any ideas?? Why is my script (sliding) slowing down? I am just learning this stuff, so please bare with me.Kind regards,Maurice- Hi guys,While surfing the net I've found this cool sudoku game. It also has a timer counting the seconds while you are playing the game. In this counter I am interested. How did he create it? I want a similar thing on my site with the same functionality.Click: play game and see the counter/timer in the lower left cornerAlso when you press pause, the timer will stop. When clicking resume game, it will continue.Well how did he do this and how can I get it something exactly like this? I've tried copying the js files but didn't got the timer to work.Any help is appreciatedKind regards,Maurice
- 22-Jun-2010 04:37 PM
- Forum: Using jQuery UI
Hi there,I'll try to explain what I need.Say we have the following 3 divs:[1] [2] [3]When I click div 2 it gets selected, then I click div 1 and they swap getting this:[2] [1] [3]The thing is, I want this animated so that the divs slide gently over each other to the new position. But how to do this?Kind regards,Some code parts:- var lastselected = false;
gamearea.selectable({
filter: '.jewel',
selected: function(event, ui){
var s = $(ui.selected);
if ( lastselected && lastselected.neighbor(s) ) {
s.exchange(lastselected);
var m = [], match;
m[0] = connectCheck(s);
m[1] = connectCheck(lastselected);
if ( m[0] || m[1] ) {
grade.resetCombo();
matchHandle(m);
$('.ui-selected').removeClass('ui-selected');
lastselected = false;
return;
} else {
s.exchange(lastselected);
}
}
$('.ui-selected').not(ui.selected).removeClass('ui-selected');
lastselected = s;
},
unselected: function(event, ui) {
if ( $('.ui-selecting').size() == 0)
lastselected = false;
}
});
- jQuery.fn.neighbor = function( another ) {
var thispos = this.getPosition(),
anotpos = another.getPosition(),
displace = {'i': Math.abs( thispos.i - anotpos.i ),
'j': Math.abs( thispos.j - anotpos.j )};
if ( ( displace.i == 1 && displace.j == 0 ) || ( displace.i == 0 && displace.j == 1) )
return true;
return false;
}
jQuery.fn.changeColor = function ( color ) {
return this.css({'background-color': colors[color]}).data('color',color);
}
jQuery.fn.exchange = function ( another ) {
var p = this.parent(),
j,
jcolor = another.data('color');
j = another.replaceWith(this)
p.empty().append(j.data('color', jcolor));
}
jQuery.fn.getPosition = function( ) {
return this.parent().data('position');
}
- Hi,I have a button and I want it to be disabled (not clickable) after 3 clicks. Also the button text must change at each click.Example:Test (3) <- button with text-click-Test (2) <- button text changed-click-Test (1) <- button text changed-click-Test (0) <- button can't be clicked anymore (non active button now)How to do this?Thanks
- 05-Jun-2010 05:41 PM
- Forum: Using jQuery UI
Hi guys,I have made a div and within this div I've put some draggables. These draggables can only move horizontally or vertically within the box. All is fine and all works.The only problem is that these draggables can overlap each other. How to prevent this? I want it so that when a draggable is blocked in its path by another draggable, it can't move further. At the moment the draggable can move through to other draggable, I want to prevent this.A demo:Kind regards,Maurice- 19-May-2009 08:24 AM
- Forum: Using jQuery
Hi all,
To learn some jquery, I am writing some sort of chatbox. My questions
is: what can I use best to store and retrieve the chat text?? Is it
good to store the chat text in the database, or is it better to save
it into a txt file? Ofcourse only new added chat lines will be taken
and displayed underneeth the old ones.
If you don't have much chatters, a database option is ok, but when you
ahve 1000 chatters (as an excample) trying to get new lines from the
database every second (every second a check for new text is done and
displayed if they are), the database will get slow. Then a txt file
would be better? Or doesn't it realy matter what to choose? A txt file
can get big too.
Does anyone has some experience with this and what is the best
approach: .txt or database?
Kind regards,
Hi,
I have the following function:
function serialize(s)
{
serial = $.SortSerialize(s);
document.getElementById('serial').value=serial.hash.replace(/sort3\
[\]=/gi, '').replace(/&/g, ',');
};
This returns a string like: 1,2,4,6,8
It is possible that there is nothing to sortserialze, so it returns
nothing. When this is the case, I want it to return a "0" instead of "
", but how to do this?
So if there is nothing to serialze return: 0
Thanks
Hi,
I am trying to get some text underneeth each image. I thought it would
work with the excample profided in de zip (php excample), but I cant
seem to get it to work.
This is the code the php file must gather:
<ul>
<div class="imgLM">
<?
// lets see if there is an image for this listing
if($iresult = $phprealty->getIntTableRows($fields="*",
$from="prop_img", $where="p_id=".$res['id']." AND def=1", $sort="",
$dir="", $limit="1", $push=true)){
?>
<li><a href="<? echo $viewPropURL."&propID=".$res['id']; ?>"
title="<? echo ucwords($res['address']).ucwords($res['city']).",
".ucwords($res['state'])." ".$res['zip']; ?>"><img src="<? echo
$phprealty->IMGWWW."th_".$iresult[0]['fn']; ?>" border="0" /><br /><?
echo ucwords($res['address']);?><br /><? echo$cf-- «Prev
- Next »
Moderate user : mauricederegt - <script type="text/javascript">
© 2013 jQuery Foundation
Sponsored by
and others.