Iedere pictureset bestaat uit 9 graphics welke ik op de juiste volgorde wil zetten.
op moment dat de graphics op de juiste positie zijn gedragged/dropped, Wil ik de positie van de graphic kunnen uitlezen en via een php script, de file laten renamen naar de juiste positie.
Dus met andere woorden, als 1.jpg op de positie van graphic9 (9.jpg) komt te staan betekent, dit dat alle graphics renamed moeten worden. Ik kan die rename starten op moment van klikken op de button 'rename' of op moment dat de graphic wordt gedropped op z'n nieuwe locatie.. maar hoe pak ik dit in aan met jquery, waar ik nog nooit mee geprogrammeerd heb (buiten het herbruiken van wat scripts).
Mijn vraag is dus concreet. hoe pak ik dit aan?
Hier staat info van de plugin: https://github.com/ksylvest/jquery-gridly
Dit is de html code:
<!DOCTYPE html>
<html>
<head>
<link href="include/gridly_renameandorder.css" rel="stylesheet" type="text/css">
<link href="include/jquery.gridly.css" rel="stylesheet" type="text/css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js" type="text/javascript"></script>
<script src="include/jquery.gridly.js" type="text/javascript"></script>
</head>
<body>
<?php $thisdir = 'Pictureset1'; //target the directory where the pictures reside. ?>
<div class="gridly">
<div class="picture"><img src="<?php echo $thisdir.'/1.jpg'; ?>" ></div>
<div class="picture"><img src="<?php echo $thisdir.'/2.jpg'; ?>" ></div>
<div class="picture"><img src="<?php echo $thisdir.'/3.jpg'; ?>" ></div>
<div class="picture"><img src="<?php echo $thisdir.'/4.jpg'; ?>" ></div>
<div class="picture"><img src="<?php echo $thisdir.'/5.jpg'; ?>" ></div>
<div class="picture"><img src="<?php echo $thisdir.'/6.jpg'; ?>" ></div>
<div class="picture"><img src="<?php echo $thisdir.'/7.jpg'; ?>" ></div>
<div class="picture"><img src="<?php echo $thisdir.'/8.jpg'; ?>" ></div>
<div class="picture"><img src="<?php echo $thisdir.'/9.jpg'; ?>" ></div>
</div>
<!-- with the rename button I want to compare the initial ordering with the reordered and use a PHP rename scipt to rename the images. -->
<button type="button">Rename</button>
<script>
var reordering = function($elements) {
// Called before the drag and drop starts with the elements in their starting position.
$elements.each(function() {
console.debug($(this).data('position'));
});
};
var reordered = function($elements) {
// Called after the drag and drop ends with the elements in their ending position.
$elements.each(function() {
console.debug($(this).data('position'));
});
};
$('.gridly').gridly({
base: 60, // px base: The number of pixels for a single column span.
gutter: 20, // px - gutter: The number of pixels between columns.
columns: 12 // columns: The total number of columns allowed across.
});
</script>
</body>
</html>