[dev] [commit] r1022 - phplib/models templates/admin wwwbase/admin wwwbase/ajax wwwbase/js wwwbase/styles
automailer at dexonline.ro
automailer at dexonline.ro
Thu Oct 17 01:22:53 EEST 2013
Author: grigoroiualex
Date: Thu Oct 17 01:22:52 2013
New Revision: 1022
Log:
Added two tables that show all the images (wether revised or not).
On double click the user will be sent to tagging page where image can be tagged.
TODO: text wrap for the lexemes associated with the image (don't know how to do it) shown in the table
Added:
templates/admin/visualTagging.ihtml
- copied, changed from r1021, templates/admin/visualTag.ihtml
wwwbase/ajax/visualGetImageTags.php
- copied, changed from r1021, wwwbase/ajax/getImageTags.php
Replaced:
templates/admin/visualTag.ihtml
Deleted:
wwwbase/ajax/getImageTags.php
wwwbase/ajax/getSavedTags.php
Modified:
phplib/models/VisualTag.php
wwwbase/admin/visualTag.php
wwwbase/ajax/visualTagsEdit.php
wwwbase/js/dexGallery.js
wwwbase/js/visualTag.js
wwwbase/styles/visualDict.css
Modified: phplib/models/VisualTag.php
==============================================================================
--- phplib/models/VisualTag.php Sat Oct 12 20:42:53 2013 (r1021)
+++ phplib/models/VisualTag.php Thu Oct 17 01:22:52 2013 (r1022)
@@ -10,11 +10,6 @@
$tag->delete();
}
}
-
- /** Paris filter functionality to access the limit query */
- public static function limit($orm, $from, $quantity) {
- return $orm->limit($quantity)->offset($from);
- }
}
?>
Added: templates/admin/visualTag.ihtml
==============================================================================
--- /dev/null 00:00:00 1970 (empty, because file is newly added)
+++ templates/admin/visualTag.ihtml Thu Oct 17 01:22:52 2013 (r1022)
@@ -0,0 +1,14 @@
+<br/>
+<div id="revised">
+ <table id="revisedTable"></table>
+ <div id="revisedPaging"></div>
+</div>
+<div id="unrevised">
+ <table id="unrevisedTable"></table>
+ <div id="unrevisedPaging"></div>
+</div>
+
+<form diplay="none" method="post">
+ <input id="imgToTag" type="hidden" name="imgToTag"/>
+ <input type="hidden" name="tagging" value="1"/>
+</form>
\ No newline at end of file
Copied and modified: templates/admin/visualTagging.ihtml (from r1021, templates/admin/visualTag.ihtml)
==============================================================================
--- templates/admin/visualTag.ihtml Sat Oct 12 20:42:53 2013 (r1021, copy source)
+++ templates/admin/visualTagging.ihtml Thu Oct 17 01:22:52 2013 (r1022)
@@ -1,106 +1,100 @@
<br/>
-{if $anyUntaggedImages}
- {if !$imgLexemeId}
- <div class="visualTagImg">
- <img src="{$imagePath}"/>
- </div>
- <div>
- <form action="visualTag.php" method="post">
- <label>Cuvântul care descrie cel mai bine imaginea:<br/>
- <input type="hidden" name="imageId" value="{$imageId}"/>
- <input id="lexemId" type="hidden" name="imgLexemeId"/>
- <input type="hidden" name="action" value="setImgLexemeId"/>
- </label>
- </form>
- </div>
- <script type="text/javascript">
- $(adminIndexInit);
- </script>
-
- {else}
- {include file="common/bits/prototypes.ihtml"}
- <div id="visualTagCanvas">
- <img src="{$imagePath}" id="jcrop" title="{$imageId}"/>
- <div id="selectionOptions">
- <label>Coordonatele centrului selecției:
- <input id="x" type="text" size="4" name="x"/>
- <input id="y" type="text" size="4" name="y"/>
- </label>
- <button type="button" id="clrSel">Șterge selecția</button>
- <form action="visualTag.php" method="post">
- <input type="hidden" value="{$imageId}" name="imageId"/>
- <button type="submit" name="action" value="finishedTagging">
- Etichetarea este completă
- </button>
- <button id="previewTags" type="button">Previzualizare etichete</button>
- </form>
- <button type="button" id="toggleHelp">Click pentru Ajutor</button>
- <div id="helpText">
- <p>
- Pasul 1: În căsuța „Cuvânt”, scrie cuvântul din interiorul etichetei.<br/>
- Pasul 2: Pe imagine selectează cuvântul de etichetat și apoi apasă primul buton
- „Setează coordonatele”.<br/>
- Pasul 3: Click pe locul din imagine unde cuvântul tocmai selectat indică și
- apasă pe cel de-al doilea buton „Setează coordonatele”.<br/>
- Pasul 4: Click pe butonul „Salvează eticheta”.<br/>
- Pasul 5: După ce toate etichetele au fost introduse,
- click pe butonul „Etichetarea este completă”.
- </p>
- </div>
- </div>
- </div>
+{if !$imgLexemeId}
+ <div class="visualTagImg">
+ <img src="{$imagePath}"/>
+ </div>
+ <div>
+ <form action="visualTag.php" method="post">
+ <label>Cuvântul care descrie cel mai bine imaginea:<br/>
+ <input type="hidden" name="imageId" value="{$imageId}"/>
+ <input id="lexemId" type="hidden" name="imgLexemeId"/>
+ <input type="hidden" name="action" value="setImgLexemeId"/>
+ </label>
+ </form>
+ </div>
+ <script type="text/javascript">
+ $(adminIndexInit);
+ </script>
- <div id="tagOptions">
+{else}
+ {include file="common/bits/prototypes.ihtml"}
+ <div id="visualTagCanvas">
+ <img src="{$imagePath}" id="jcrop" title="{$imageId}"/>
+ <div id="selectionOptions">
+ <label>Coordonatele centrului selecției:
+ <input id="x" type="text" size="4" name="x"/>
+ <input id="y" type="text" size="4" name="y"/>
+ </label>
+ <button type="button" id="clrSel">Șterge selecția</button>
<form action="visualTag.php" method="post">
- <input id="imageId" type="hidden" value="{$imageId}" name="imageId"/>
+ <input type="hidden" value="{$imageId}" name="imageId"/>
+ <button type="submit" name="action" value="finishedTagging">
+ Etichetarea este completă
+ </button>
+ <button id="previewTags" type="button">Previzualizare etichete</button>
+ </form>
+ <button type="button" id="toggleHelp">Click pentru Ajutor</button>
+ <div id="helpText">
<p>
- Informații imagine<br/><br/>
- Imaginea este atribuită cuvântului: {$lexemeName}.
+ Pasul 1: În căsuța „Cuvânt”, scrie cuvântul din interiorul etichetei.<br/>
+ Pasul 2: Pe imagine selectează cuvântul de etichetat și apoi apasă primul buton
+ „Setează coordonatele”.<br/>
+ Pasul 3: Click pe locul din imagine unde cuvântul tocmai selectat indică și
+ apasă pe cel de-al doilea buton „Setează coordonatele”.<br/>
+ Pasul 4: Click pe butonul „Salvează eticheta”.<br/>
+ Pasul 5: După ce toate etichetele au fost introduse,
+ click pe butonul „Etichetarea este completă”.
</p>
- <button type="submit" name="action" value="resetImgLexemeId">Modifică</button>
- </form>
- <form action="visualTag.php" method="post" onsubmit="return validateTag()">
- <input type="hidden" value="{$imageId}" name="imageId"/>
+ </div>
+ </div>
+ </div>
- <p>Informații etichetă</p>
+ <div id="tagOptions">
+ <form action="visualTag.php" method="post">
+ <input id="imageId" type="hidden" value="{$imageId}" name="imageId"/>
+ <p>
+ Informații imagine<br/><br/>
+ Imaginea este atribuită cuvântului: {$lexemeName}.
+ </p>
+ <button type="submit" name="action" value="resetImgLexemeId">Modifică</button>
+ </form>
+ <div>
+ <input id="imageId" type="hidden"/>
+ <p>Informații etichetă</p>
- <label>Cuvânt:
- <input id="lexemId" type="hidden"/>
- </label><br/>
-
- <input id="lexemeId" type="hidden" size="10" name="lexemeId"/>
-
- <label>Text de afișat
- <input id="label" type="text" size="20" name="label"/>
- </label><br/>
-
- <label>Coordonatele centrului etichetei:
- <input id="xTag" type="text" size="4" name="xTag"/>
- <input id="yTag" type="text" size="4" name="yTag"/>
- <button id="setCoordTag" type="button">Setează coordonatele</button>
- </label><br/>
-
- <label>Coordonatele zonei etichetate:
- <input id="xImg" type="text" size="4" name="xImg"/>
- <input id="yImg" type="text" size="4" name="yImg"/>
- <button id="setCoordImg" type="button">Setează coordonatele</button>
- </label><br/>
+ <label>Cuvânt:
+ <input id="lexemId" type="hidden"/>
+ </label><br/>
+
+ <input id="lexemeId" type="hidden"/>
+
+ <label>Text de afișat
+ <input id="label" type="text" size="20"/>
+ </label><br/>
+
+ <label>Coordonatele centrului etichetei:
+ <input id="xTag" type="text" size="4"/>
+ <input id="yTag" type="text" size="4"/>
+ <button id="setCoordTag" type="button">Setează coordonatele</button>
+ </label><br/>
+
+ <label>Coordonatele zonei etichetate:
+ <input id="xImg" type="text" size="4"/>
+ <input id="yImg" type="text" size="4"/>
+ <button id="setCoordImg" type="button">Setează coordonatele</button>
+ </label><br/>
- <button id="saveSel" type="submit" name="action" value="save">Salvează eticheta</button>
- </form>
+ <button id="saveSel" type="button">Salvează eticheta</button>
</div>
+ </div>
- <div id="savedTags">
- <table id="tagsGrid"></table>
- <div id="tagsPaging"></div>
- </div>
-
- <script type="text/javascript">
- $(adminIndexInit);
- $(replaceSubmitEvent);
- </script>
- {/if}
-
-{else}
- <p>Toate imaginile au fost revizuite. Mulțumim!</p>
+ <div id="savedTags">
+ <table id="tagsGrid"></table>
+ <div id="tagsPaging"></div>
+ </div>
+
+ <script type="text/javascript">
+ $(adminIndexInit);
+ $(replaceSubmitEvent);
+ </script>
{/if}
Modified: wwwbase/admin/visualTag.php
==============================================================================
--- wwwbase/admin/visualTag.php Sat Oct 12 20:42:53 2013 (r1021)
+++ wwwbase/admin/visualTag.php Thu Oct 17 01:22:52 2013 (r1022)
@@ -8,40 +8,9 @@
$rootPath = util_getImgRoot() . '/';
$savedTags = '';
$action = util_getRequestParameter('action');
+$tagging = util_getRequestParameter('tagging');
-
-if($action == 'save') {
- $imageId = util_getRequestParameter('imageId');
- $lexemeId = util_getrequestParameter('lexemeId');
- $label = util_getRequestParameter('label');
- $xTag = util_getRequestParameter('xTag');
- $yTag = util_getRequestParameter('yTag');
- $xImg = util_getRequestParameter('xImg');
- $yImg = util_getRequestParameter('yImg');
-
- $line = Model::factory('VisualTag')->create();
- $line->imageId = $imageId;
- $line->lexemeId = $lexemeId;
- $line->label = $label;
- $line->textXCoord = $xTag;
- $line->textYCoord = $yTag;
- $line->imgXCoord = $xImg;
- $line->imgYCoord = $yImg;
- $line->save();
-
- util_redirect(util_getWwwRoot() . 'admin/visualTag.php');
-
-} else if($action == 'delete') {
- $tagId = util_getRequestParameter('savedTagId');
-
- $line = VisualTag::get_by_id($tagId);
- if(!empty($line)) {
- $line->delete();
- }
-
- util_redirect(util_getWwwRoot() . 'admin/visualTag.php');
-
-} else if($action == 'finishedTagging') {
+if($action == 'finishedTagging') {
$imageId = util_getRequestParameter('imageId');
$line = Visual::get_by_id($imageId);
@@ -51,6 +20,7 @@
$line->save();
}
+ FlashMessage::add('Modificările au fost salvate. Mulțumim!');
util_redirect(util_getWwwRoot() . 'admin/visualTag.php');
} else if($action == 'setImgLexemeId') {
@@ -64,7 +34,8 @@
$line->save();
}
- util_redirect(util_getWwwRoot() . 'admin/visualTag.php');
+ $tagging = true;
+ $imgToTag = $line->id;
} else if($action == 'resetImgLexemeId') {
$imageId = util_getRequestParameter('imageId');
@@ -76,12 +47,22 @@
$line->save();
}
- util_redirect(util_getWwwRoot() . 'admin/visualTag.php');
+ $tagging = true;
+ $imgToTag = $line->id;
}
-$line = Visual::get_by_revised(0);
-SmartyWrap::assign('anyUntaggedImages', !empty($line));
-if(!empty($line)) {
+SmartyWrap::assign('sectionTitle', 'Etichetare imagini pentru definiții');
+SmartyWrap::addCss('jcrop', 'select2', 'jqgrid', 'jqueryui', 'gallery');
+SmartyWrap::addJs('jquery', 'jcrop', 'visualTag', 'select2', 'select2Dev', 'jqgrid', 'gallery');
+
+if($tagging) {
+ $imgToTag = isset($imgToTag) ? $imgToTag : util_getRequestParameter('imgToTag');
+ $line = Visual::get_by_id($imgToTag);
+ if($line->revised) {
+ $line->revised = 0;
+ $line->save();
+ }
+
$imagePath = $rootPath . $line->path;
$imageId = $line->id;
$imgLexemeId = $line->lexemeId;
@@ -94,9 +75,9 @@
SmartyWrap::assign('imagePath', $imagePath);
SmartyWrap::assign('imageId', $imageId);
SmartyWrap::assign('imgLexemeId', $imgLexemeId);
-}
-SmartyWrap::assign('sectionTitle', 'Etichetare imagini pentru definiții');
-SmartyWrap::addCss('jcrop', 'select2', 'jqgrid', 'jqueryui', 'gallery');
-SmartyWrap::addJs('jquery', 'jcrop', 'visualTag', 'select2', 'select2Dev', 'jqgrid', 'gallery');
-SmartyWrap::displayAdminPage('admin/visualTag.ihtml');
+ SmartyWrap::displayAdminPage('admin/visualTagging.ihtml');
+
+} else {
+ SmartyWrap::displayAdminPage('admin/visualTag.ihtml');
+}
Deleted: wwwbase/ajax/getImageTags.php
==============================================================================
--- wwwbase/ajax/getImageTags.php Thu Oct 17 01:22:52 2013 (r1021)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,28 +0,0 @@
-<?php
-include('../../phplib/util.php');
-
-$resp = array();
-$tags = array();
-$dims = array();
-
-$imageId = util_getRequestParameter('imageId');
-
-$line = Visual::get_by_id($imageId);
-
-if(!empty($line)) {
- $dims = array('width' => (int)$line->width, 'height' => (int)$line->height);
-}
-
-$lines = VisualTag::get_all_by_imageId($imageId);
-
-foreach($lines as $line) {
- $row = Lexem::get_by_id($line->lexemeId);
- $tags[] = array('textX' => (int)$line->textXCoord, 'textY' => (int)$line->textYCoord,
- 'imgX' => (int)$line->imgXCoord, 'imgY' => (int)$line->imgYCoord,
- 'label' => $line->label, 'lexeme' => $row->formUtf8General);
-}
-
-$resp = array('dims' => $dims, 'tags' => $tags);
-
-echo json_encode($resp);
-?>
Deleted: wwwbase/ajax/getSavedTags.php
==============================================================================
--- wwwbase/ajax/getSavedTags.php Thu Oct 17 01:22:52 2013 (r1021)
+++ /dev/null 00:00:00 1970 (deleted)
@@ -1,23 +0,0 @@
-<?php
-
-require_once("../../phplib/util.php");
-
-$imageId = util_getRequestParameter('imageId');
-$page = util_getRequestParameter('page');
-$limit = util_getRequestParameter('rows');
-$rows = array();
-$total = VisualTag::factory('VisualTag')->where('imageId', $imageId)->count();
-$lines = VisualTag::factory('VisualTag')->where('imageId', $imageId)
- ->filter('limit', ($page - 1) * $limit, $limit)->find_many();
-
-foreach ($lines as $line) {
- $row = Lexem::get_by_id($line->lexemeId);
- $rows[] = array('id' => $line->id, 'label' => $line->label, 'xTag' => $line->textXCoord,
- 'yTag' => $line->textYCoord, 'xImg' => $line->imgXCoord,
- 'yImg' => $line->imgYCoord, 'lexeme' => !empty($row) ? $row->formUtf8General : '');
-}
-
-$resp = array('total' => ceil($total / $limit), 'page' => $page, 'records' => $total, 'rows' => $rows);
-
-echo json_encode($resp);
-?>
\ No newline at end of file
Copied and modified: wwwbase/ajax/visualGetImageTags.php (from r1021, wwwbase/ajax/getImageTags.php)
==============================================================================
--- wwwbase/ajax/getImageTags.php Sat Oct 12 20:42:53 2013 (r1021, copy source)
+++ wwwbase/ajax/visualGetImageTags.php Thu Oct 17 01:22:52 2013 (r1022)
@@ -1,28 +1,37 @@
<?php
-include('../../phplib/util.php');
-$resp = array();
-$tags = array();
-$dims = array();
+require_once('../../phplib/util.php');
$imageId = util_getRequestParameter('imageId');
+$page = util_getRequestParameter('page');
+$limit = util_getRequestParameter('rows');
+$usage = util_getRequestParameter('usage');
+$resp = array();
-$line = Visual::get_by_id($imageId);
-
-if(!empty($line)) {
- $dims = array('width' => (int)$line->width, 'height' => (int)$line->height);
+if($usage == 'table') {
+ $total = Model::factory('VisualTag')->where('imageId', $imageId)->count();
+ $lines = Model::factory('VisualTag')->where('imageId', $imageId)
+ ->limit($limit)->offset(($page - 1) * $limit)->find_many();
+
+} else if($usage == 'gallery') {
+ $image = Visual::get_by_id($imageId);
+ $dims = array('width' => $image->width, 'height' => $image->height);
+ $lines = VisualTag::get_all_by_imageId($imageId);
}
-$lines = VisualTag::get_all_by_imageId($imageId);
-
foreach($lines as $line) {
$row = Lexem::get_by_id($line->lexemeId);
- $tags[] = array('textX' => (int)$line->textXCoord, 'textY' => (int)$line->textYCoord,
- 'imgX' => (int)$line->imgXCoord, 'imgY' => (int)$line->imgYCoord,
- 'label' => $line->label, 'lexeme' => $row->formUtf8General);
+ $tags[] = array('id' => $line->id, 'label' => $line->label, 'textX' => $line->textXCoord,
+ 'textY' => $line->textYCoord, 'imgX' => $line->imgXCoord,
+ 'imgY' => $line->imgYCoord, 'lexeme' => !empty($row) ? $row->formUtf8General : '');
}
-$resp = array('dims' => $dims, 'tags' => $tags);
+if($usage == 'table') {
+ $resp = array('total' => ceil($total / $limit), 'page' => $page, 'records' => $total, 'rows' => $tags);
+
+} else if($usage == 'gallery') {
+ $resp = array('dims' => $dims, 'tags' => $tags);
+}
echo json_encode($resp);
-?>
+?>
\ No newline at end of file
Modified: wwwbase/ajax/visualTagsEdit.php
==============================================================================
--- wwwbase/ajax/visualTagsEdit.php Sat Oct 12 20:42:53 2013 (r1021)
+++ wwwbase/ajax/visualTagsEdit.php Thu Oct 17 01:22:52 2013 (r1022)
@@ -5,6 +5,19 @@
$id = util_getRequestParameter('id');
switch ($oper) {
+ case 'add':
+ $line = VisualTag::factory('VisualTag')->create();
+
+ $line->imageId = util_getRequestParameter('imageId');
+ $line->lexemeId = util_getRequestParameter('lexemeId');
+ $line->label = util_getRequestParameter('label');
+ $line->textXCoord = util_getRequestParameter('xTag');
+ $line->textYCoord = util_getRequestParameter('yTag');;
+ $line->imgXCoord = util_getRequestParameter('xImg');
+ $line->imgYCoord = util_getRequestParameter('yImg');
+ $line->save();
+ break;
+
case 'del':
$line = VisualTag::get_by_id($id);
@@ -14,20 +27,14 @@
break;
case 'edit':
- $xTag = util_getRequestParameter('xTag');
- $yTag = util_getRequestParameter('yTag');
- $xImg = util_getRequestParameter('xImg');
- $yImg = util_getRequestParameter('yImg');
- $label = util_getRequestParameter('label');
-
$line = VisualTag::get_by_id($id);
if(!empty($line)){
- $line->textXCoord = $xTag;
- $line->textYCoord = $yTag;
- $line->imgXCoord = $xImg;
- $line->imgYCoord = $yImg;
- $line->label = $label;
+ $line->textXCoord = util_getRequestParameter('xTag');
+ $line->textYCoord = util_getRequestParameter('yTag');;
+ $line->imgXCoord = util_getRequestParameter('xImg');
+ $line->imgYCoord = util_getRequestParameter('yImg');
+ $line->label = util_getRequestParameter('label');
$line->save();
}
break;
Modified: wwwbase/js/dexGallery.js
==============================================================================
--- wwwbase/js/dexGallery.js Sat Oct 12 20:42:53 2013 (r1021)
+++ wwwbase/js/dexGallery.js Thu Oct 17 01:22:52 2013 (r1022)
@@ -45,8 +45,8 @@
$.ajax({
type: 'POST',
- url: wwwRoot + 'ajax/getImageTags.php',
- data: {imageId: imageId}
+ url: wwwRoot + 'ajax/visualGetImageTags.php',
+ data: {imageId: imageId, usage: 'gallery'}
}).done(function(data) {
data = JSON.parse(data);
var widthScale = parseInt(canvas.attr('width')) / data.dims.width,
Modified: wwwbase/js/visualTag.js
==============================================================================
--- wwwbase/js/visualTag.js Sat Oct 12 20:42:53 2013 (r1021)
+++ wwwbase/js/visualTag.js Thu Oct 17 01:22:52 2013 (r1022)
@@ -21,9 +21,40 @@
closeOnEscape: true,
reloadAfterSubmit: true
};
+ var imagesTable = function(revised, elementId, pagerId, message) {
+ $('#' + elementId).jqGrid({
+ url: wwwRoot + 'ajax/visualGetImages.php',
+ postData: {revised: revised},
+ datatype: 'json',
+ cmTemplate: {sortable: false},
+ colNames: ['Link Imagine', 'Id imagine', 'Lexeme asociat imaginii','Id User', 'User', 'Lățime', 'Înălțime', 'Ultima Modificare'],
+ colModel: [
+ {name: 'link', index: 'link', width: 100},
+ {name: 'imageId', index: 'imageId', hidden: true},
+ {name: 'lexeme', index: 'lexeme', width: 160, align: 'center'},
+ {name: 'userId', index: 'userId', hidden: true},
+ {name: 'user', index: 'user', width: 100, align: 'center'},
+ {name: 'width', index: 'width', width: 70, align: 'center'},
+ {name: 'height', index: 'height', width: 70, align: 'center'},
+ {name: 'latestMod', index: 'latestMod', width: 100, align: 'center'}
+ ],
+ rowNum: 20,
+ recreateForm: true,
+ width: '700px',
+ height: '100%',
+ rowList: [20, 50, 100, 200],
+ pager: $('#' + pagerId),
+ viewrecords: true,
+ caption: 'Imagini a căror etichetare este ' + message,
+ ondblClickRow: function(rowid) {
+ $('#imgToTag').val($(this).jqGrid('getCell', rowid, 'imageId'));
+ $('form').submit();
+ }
+ });
+ }
initJcrop();
- resetCoords();
+ resetAllFields();
function initJcrop() {
$('#jcrop').Jcrop({
@@ -37,31 +68,24 @@
}
function setCoords(c) {
- calculateCentre(c);
+ // Calculates the centre of the selection
+ coords.cx = Math.round((2 * c.x + c.w) / 2);
+ coords.cy = Math.round((2 * c.y + c.h) / 2);
$('#x').val(coords.cx);
$('#y').val(coords.cy);
}
- function calculateCentre(c) {
- coords.cx = Math.round((2 * c.x + c.w) / 2);
- coords.cy = Math.round((2 * c.y + c.h) / 2);
- }
-
/** Clears the actual selection */
$('#clrSel').click(function(e) {
jcrop_api.release();
- resetCoords();
- });
-
- function resetCoords() {
coords.cx = 0;
coords.cy = 0;
$('#x').val('');
$('#y').val('');
- }
+ });
$('#setCoordTag').click(function() {
$('#xTag').val(coords.cx);
@@ -93,9 +117,25 @@
});
});
+ $('#saveSel').click(function() {
+ var data = validateTag();
+
+ if(data) {
+ data.oper = "add";
+ $.ajax({
+ type: 'POST',
+ url: wwwRoot + 'ajax/visualTagsEdit.php',
+ data: data
+ }).done(function() {
+ $('#tagsGrid').trigger('reloadGrid');
+ resetAllFields();
+ });
+ }
+ });
+
$('#tagsGrid').jqGrid({
- url: wwwRoot + 'ajax/getSavedTags.php',
- postData: {imageId: $('#imageId').val()},
+ url: wwwRoot + 'ajax/visualGetImageTags.php',
+ postData: {imageId: $('#imageId').val(), usage: 'table'},
datatype: 'json',
cmTemplate: {sortable: false},
colNames: ['Id', 'Lexem', 'Text afișat', 'X Etichetă', 'Y Etichetă', 'X Imagine', 'Y Imagine'],
@@ -103,10 +143,10 @@
{name: 'id', index: 'id', hidden: true},
{name: 'lexeme', index: 'lexeme', width: 80, align: 'center'},
{name: 'label', index: 'label', width: 120, align: 'center', editable: true},
- {name: 'xTag', index: 'xTag', width: 55, align: 'center', editable: true},
- {name: 'yTag', index: 'yTag', width: 55, align: 'center', editable: true},
- {name: 'xImg', index: 'yImg', width: 55, align: 'center', editable: true},
- {name: 'yImg', index: 'yImg', width: 55, align: 'center', editable: true}
+ {name: 'textX', index: 'textX', width: 55, align: 'center', editable: true},
+ {name: 'textY', index: 'textY', width: 55, align: 'center', editable: true},
+ {name: 'imgX', index: 'imgX', width: 55, align: 'center', editable: true},
+ {name: 'imgY', index: 'imgY', width: 55, align: 'center', editable: true}
],
rowNum: 20,
recreateForm: true,
@@ -120,6 +160,9 @@
ondblClickRow: function(rowid) { $(this).jqGrid('editGridRow', rowid, editOptions); }
})
.navGrid('#tagsPaging', gridOptions, editOptions, addOptions, delOptions);
+
+ imagesTable(1, 'revisedTable', 'revisedPaging', 'completă');
+ imagesTable(0, 'unrevisedTable', 'unrevisedPaging', 'incompletă');
});
/** Replaces the submit event that triggers on change, set in select2Dev.js */
@@ -132,36 +175,40 @@
// Matches only the lexeme, without the description in brackets
text = text.match(/^[^ \(]+/);
- $('#lexemeId').val(id);
$('#label').val(text);
});
}
function validateTag() {
- var label = $('#label').val();
- var xImg = $('#xImg').val();
- var yImg = $('#yImg').val();
- var xTag = $('#xTag').val();
- var yTag = $('#yTag').val();
+ var data = {
+ id: '',
+ lexemeId: $('#lexemId').attr('value'),
+ imageId: $('#imageId').val(),
+ label: $('#label').val(),
+ xTag: $('#xTag').val(),
+ yTag: $('#yTag').val(),
+ xImg: $('#xImg').val(),
+ yImg: $('#yImg').val()
+ };
- if(!label) {
+ if(!data.label) {
alert('Ai uitat să completezi câmpul Cuvânt');
return false;
- } else if(!xTag || !yTag) {
+ } else if(!data.xTag || !data.yTag) {
alert('Ai uitat să completezi câmpurile Coordonatele centrului etichetei');
return false;
- } else if(!xImg || !yImg) {
+ } else if(!data.xImg || !data.yImg) {
alert('Ai uitat să completezi câmpurile Coordonatele zonei etichetate');
return false;
}
+
+ return data;
}
function validateLexeme() {
- var lexeme = $('#imgLexemeId').val();
-
- if(!lexeme) {
+ if(!($('#imgLexemeId').val())) {
alert('Ai uitat să completezi ce lexem descrie cel mai bine imaginea');
return false;
}
@@ -174,3 +221,12 @@
return [true];
}
}
+
+function resetAllFields() {
+ $('#label').val('');
+ $('#xTag').val('');
+ $('#yTag').val('');
+ $('#xImg').val('');
+ $('#yImg').val('');
+ $('#lexemId').select2('data', {id: '', text: ''});
+}
Modified: wwwbase/styles/visualDict.css
==============================================================================
--- wwwbase/styles/visualDict.css Sat Oct 12 20:42:53 2013 (r1021)
+++ wwwbase/styles/visualDict.css Thu Oct 17 01:22:52 2013 (r1022)
@@ -60,3 +60,15 @@
background-color: #fff;
cursor: pointer;
}
+
+#revised {
+ float: left;
+}
+
+#unrevised {
+ float: right;
+}
+
+.mainLexeme {
+ font-weight: bold;
+}
More information about the Dev
mailing list