Documente Academic
Documente Profesional
Documente Cultură
*
* Fifteen game jQuery plugin
*
* Licensed under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*
* Copyright 2012, Script Tutorials
* http://www.script-tutorials.com/
*/
// When the squares swap places, the moving square must always appear on top
var zi = 1; // We increment z-index each time a square is shifted
$.fn.extend({ fifteen:
function(square_size) {
// Grab the id of the HTML element into which we are placing the game,
// it is the selector - "#game_object" from $
("#game_object").fifteen(175);
var gameObjectElement = '#' + $(this).attr('id');
// Swap x/y between the clicked square and the currently empty square
var oldx = $('#board').children("div:nth-child(" + EmptySquare +
")").css('left');
var oldy = $('#board').children("div:nth-child(" + EmptySquare +
")").css('top');
if (movable) {
// Increment zindex so the new tile is always on top of all others
$(clicked_square).css('z-index', zi++);