Skip to content

Commit

Permalink
Jquery Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
malamalca committed Oct 6, 2024
1 parent 688f51d commit 35c5871
Show file tree
Hide file tree
Showing 10 changed files with 1,265 additions and 717 deletions.
13 changes: 7 additions & 6 deletions src/Controller/ProfilesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace App\Controller;

use Cake\Core\Configure;
use Cake\Event\EventInterface;
use Cake\Http\Exception\NotFoundException;
use Cake\ORM\TableRegistry;
Expand Down Expand Up @@ -330,9 +331,9 @@ public function reorderChildren($id = null)
*/
public function autocomplete()
{
$term = $this->getRequest()->getQuery('q');
if ($this->getRequest()->is(['ajax', 'get']) && $term) {
$ret = '';
$term = $this->getRequest()->getQuery('term');
if ((Configure::read('debug') || $this->getRequest()->is(['ajax', 'get'])) && $term) {
$ret = [];

// fire autocomplete with at least 2 characters
if (strlen($term) > 1) {
Expand All @@ -343,11 +344,11 @@ public function autocomplete()
->all();

foreach ($profiles as $p) {
//$ret[] = ['label' => $p->d_n, 'value' => $p->id];
$ret .= $p->id . '|' . h($p->d_n) . chr(10);
$ret[] = ['label' => $p->d_n, 'value' => $p->id];
//$ret .= $p->id . '|' . h($p->d_n) . chr(10);
}
}
$this->response = $this->response->withStringBody($ret);
$this->response = $this->response->withStringBody(json_encode($ret));

return $this->response;
} else {
Expand Down
18 changes: 11 additions & 7 deletions templates/Attachments/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,12 @@
echo '</div>';
echo $this->Form->end();

echo $this->Html->script('jquery.imgareaselect-0.8.min');
echo $this->Html->script('jquery.imgareaselect.js');
echo $this->Html->script('jquery.imgnotes-0.2');

echo $this->Html->script('ui.core');
echo $this->Html->script('ui.autocomplete');
//echo $this->Html->script('ui.core');
//echo $this->Html->script('ui.autocomplete');
echo $this->Html->script('jquery-ui-personalized.min');
echo $this->Html->css('imgnotes');
echo $this->Html->css('ui.all');
?>
Expand All @@ -147,7 +148,7 @@

$(document).ready(function() {
$('#ImgnoteNote').autocomplete({
url: '<?= $this->Url->build(['controller' => 'Profiles', 'action' => 'autocomplete']) ?>',
source: '<?= $this->Url->build(['controller' => 'Profiles', 'action' => 'autocomplete']) ?>',
dataType: "text",
width: "240px",
formatResult: function(row) {
Expand Down Expand Up @@ -178,7 +179,7 @@
$('#NoteForm').hide();
});

$('#AddNoteLink').click(function() {
$('#AddNoteLink').click(function(e) {
<?php
$large_sizes = $attachment->getImageSize('large');

Expand All @@ -191,17 +192,20 @@
$y1 = round($large_sizes['height'] / 2 - $h / 2);
$y2 = $y1 + $h;

printf('var frame = {onSelectChange: ShowAddNote, handles: true, x1:%1$s, x2:%2$s, y1:%3$s, y2:%4$s, width:%5$s, height:%6$s};', $x1, $x2, $y1, $y2, $w, $h).PHP_EOL;
printf('var frame = {onSelectChange: ShowAddNote, handles: true, x1:%1$s, x2:%2$s, y1:%3$s, y2:%4$s, width:%5$s, height:%6$s};', $x1, $x2, $y1, $y2, $w, $h) . PHP_EOL;
?>

ShowAddNote('#AttachmentImage', frame);

$('#NoteForm').show();
$('#AttachmentImage').imgAreaSelect(frame);
$("#AttachmentImage").imgAreaSelect(frame);

<?php
}
?>

e.preventDefault();

return false;
});

Expand Down
2 changes: 1 addition & 1 deletion templates/Profiles/reorder_children.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
?>
<h1><?= __('Reorder Children') ?></h1>
<?php
echo $this->Html->script('jquery-ui-personalized-1.6rc6.min');
echo $this->Html->script('jquery-ui-personalized.min');
?>
<style type="text/css">
.sortable { margin: 0; padding: 0; width: 60%; margin-bottom: 0; }
Expand Down
4 changes: 2 additions & 2 deletions templates/Profiles/tree.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<?php echo $this->Html->css('tree') . PHP_EOL; ?>

<?php echo $this->Html->script('jquery.min') . PHP_EOL; ?>
<?php echo $this->Html->script('jquery.disable.text.select') . PHP_EOL; ?>
<?php echo $this->Html->script('jquery-ui-personalized.min') . PHP_EOL; ?>
</head>
<body>
<?php
Expand Down Expand Up @@ -370,7 +370,7 @@
var body = document.getElementsByTagName("body")[0];
sel.collapse(body, 0);
}
$('#tree_window').disableTextSelect();
$('#tree_window').disableSelection();

<?php
if ($highlightedProfile = $this->getRequest()->getQuery('highlight')) {
Expand Down
7 changes: 4 additions & 3 deletions templates/Profiles/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -562,9 +562,10 @@
</div>
<?php
echo $this->Html->script('jquery.textarearesizer.min') . PHP_EOL;
echo $this->Html->script('ui.core') . PHP_EOL;
echo $this->Html->script('ui.draggable') . PHP_EOL;
echo $this->Html->script('ui.droppable') . PHP_EOL;
//echo $this->Html->script('ui.core') . PHP_EOL;
//echo $this->Html->script('ui.draggable') . PHP_EOL;
//echo $this->Html->script('ui.droppable') . PHP_EOL;
echo $this->Html->script('jquery-ui-personalized.min');
echo $this->Html->css('ui.all');
?>

Expand Down
61 changes: 0 additions & 61 deletions webroot/js/jquery-ui-personalized-1.6rc6.min.js

This file was deleted.

6 changes: 6 additions & 0 deletions webroot/js/jquery-ui-personalized.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 35c5871

Please sign in to comment.