Commit 0f47f77b authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge remote-tracking branch 'origin/B10117TypeAheadAfterSaveJSONIsShown' into F9517TagInput

parents 221ee74e 4e0a1025
......@@ -11,7 +11,7 @@
"toggleElement": "",
"disabled": false,
"tooltip": "Draw with a pencil",
"icon": "glyphicon-pencil"
"icon": "fa-pencil"
},
{
"name": "highlight",
......@@ -24,7 +24,7 @@
"toggleElement": "",
"disabled": false,
"tooltip": "Highlighter",
"icon": "glyphicon-pencil"
"icon": "fa-paint-brush"
},
{
......@@ -38,7 +38,7 @@
"toggleElement": "emojiContainer",
"disabled": false,
"tooltip": "Emojis",
"icon": "glyphicon-ice-lolly-tasted"
"icon": "fa-smile-o"
},
{
"name": "rectangle",
......@@ -51,7 +51,7 @@
"toggleElement": "",
"disabled": false,
"tooltip": "Draw a rectangle to highlight areas",
"icon": "glyphicon-stop"
"icon": "fa-square-o"
},
{
"name": "write",
......@@ -64,7 +64,7 @@
"toggleElement": "",
"disabled": false,
"tooltip": "Adds a customizable text to canvas",
"icon": "glyphicon-text-height"
"icon": "fa-i-cursor"
},
{
"name": "move",
......@@ -77,7 +77,7 @@
"toggleElement": "",
"disabled": false,
"tooltip": "Move the viewport, useful if zoomed",
"icon": "glyphicon-move"
"icon": "fa-arrows"
},
{
"name": "delete",
......@@ -90,7 +90,7 @@
"toggleElement": "",
"disabled": false,
"tooltip": "Delete selected object",
"icon": "glyphicon-trash"
"icon": "fa-eraser"
},
{
"name": "zoom",
......@@ -103,7 +103,7 @@
"toggleElement": "",
"disabled": false,
"tooltip": "Zoom viewport",
"icon": "glyphicon-search"
"icon": "fa-search-plus"
},
{
"name": "freeMouse",
......@@ -116,7 +116,7 @@
"toggleElement": "",
"disabled": false,
"tooltip": "Normal mouse to select objects in canvas",
"icon": "glyphicon-hand-up"
"icon": "fa-mouse-pointer"
},
{
"name": "undo",
......@@ -129,7 +129,7 @@
"toggleElement": "",
"disabled": true,
"tooltip": "Undo",
"icon": "glyphicon-repeat icon-flipped"
"icon": "fa-undo"
},
{
"name": "redo",
......@@ -142,7 +142,7 @@
"toggleElement": "",
"disabled": true,
"tooltip": "Redo",
"icon": "glyphicon-repeat"
"icon": "fa-repeat"
}
],
......
......@@ -79,6 +79,7 @@ var QfqNS = QfqNS || {};
$element.attr(attributeName, attributeValue);
if (attributeName.toLowerCase() === "value") {
$element.val(attributeValue);
$element.trigger('qfqChange');
}
};
......
......@@ -98,8 +98,8 @@ $(function (n) {
id: o.selector,
class: 'btn btn-default'
});
var $symbol = $("<span>", {
class: 'glyphicon ' + o.icon
var $symbol = $("<i>", {
class: 'fa ' + o.icon
});
$button.append($symbol);
if (o.name === that.myModes.currentMode) {
......
......@@ -62,9 +62,16 @@ var QfqNS = QfqNS || {};
var suggestions = new Bloodhound(bloodhoundConfiguration);
suggestions.initialize();
// create actual input field
var $inputField = $('<input/>', {
type: 'text',
class: $element.attr('class')
});
$element.after($inputField);
// prevent form submit when enter key is pressed
$element.off('keyup');
$element.on('keypress keyup', function (e) {
$inputField.off('keyup');
$inputField.on('keypress keyup', function (e) {
var code = e.keyCode || e.which;
if (code === 13) {
e.preventDefault();
......@@ -91,9 +98,9 @@ var QfqNS = QfqNS || {};
};
// initialize tagsManager
var tagApi = $element.tagsManager({
var tagApi = $inputField.tagsManager({
deleteTagsOnBackspace: false,
hiddenTagListName: $element.attr('name'),
hiddenTagListName: '',
tagClass: 'qfq-typeahead-tag',
delimiters: delimiters,
validator: !!$element.data('typeahead-pedantic') ? pedanticValidator : null,
......@@ -110,13 +117,21 @@ var QfqNS = QfqNS || {};
});
// when the hidden input field changes, overwrite value with tag object list
tagApi.bind('tm:hiddenUpdate', function (e, tags, hiddenInput) {
tagApi.bind('tm:hiddenUpdate', function (e, tags) {
var tagObjects = $.map(tags, function (t) {
return existingTags.filter(function (tt) {return tt.value === t;})[0];
});
hiddenInput.val(JSON.stringify(tagObjects));
$element.val(JSON.stringify(tagObjects));
});
// if value of hidden field is changed externally, update tagManager
$element.on('qfqChange', function () {
existingTags = $element.val() !== '' ? JSON.parse($element.val()) : [];
tagApi.tagsManager('empty');
$.each(existingTags, function (i, tag) {
tagApi.tagsManager('pushTag', tag.value);
});
});
$element.removeAttr('name');
// add existing tags
$.each(existingTags, function (i, tag) {
......@@ -124,7 +139,7 @@ var QfqNS = QfqNS || {};
});
// add typahead
$element.typeahead({
$inputField.typeahead({
// options
hint: n.TypeAhead.getHint($element),
highlight: n.TypeAhead.getHighlight($element),
......@@ -140,20 +155,20 @@ var QfqNS = QfqNS || {};
// No message if field is not set to pedantic.
notFound: (function ($_) {
return function (obj) {
if (!!$_.data('typeahead-pedantic'))
if (!!$element.data('typeahead-pedantic'))
return "<div>'" + n.TypeAhead.htmlEncode(obj.query) + "' not found";
};
})($element)
})($inputField)
}
});
// directly add tag when clicked on in typahead menu
$element.bind('typeahead:selected', function (event, sugg) {
$inputField.bind('typeahead:selected', function (event, sugg) {
tagApi.tagsManager("pushTag", sugg.value);
});
// update typahead list when typahead changes
$element.bind('typeahead:render', function (event, sugg) {
$inputField.bind('typeahead:render', function (event, sugg) {
typeaheadList.length = 0;
typeaheadList.push.apply(typeaheadList, sugg);
});
......
......@@ -141,7 +141,7 @@
</div>
<div class="col-md-6">
<input id="tags1" type="text" class="form-control qfq-typeahead" name="tags1"
<input id="tags1" type="hidden" class="form-control qfq-typeahead" name="tags1"
data-typeahead-sip="abcdef"
data-typeahead-limit="10"
data-typeahead-minlength="1"
......@@ -160,7 +160,7 @@
</div>
<div class="col-md-6">
<input id="tags2" type="text" class="form-control qfq-typeahead" name="tags2"
<input id="tags2" type="hidden" class="form-control qfq-typeahead" name="tags2"
data-typeahead-sip="abcdef"
data-typeahead-limit="10"
data-typeahead-minlength="1"
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment