Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
mahara
mahara
Commits
3f0564ba
Commit
3f0564ba
authored
Mar 18, 2016
by
Son Nguyen
Committed by
Gerrit Code Review
Mar 18, 2016
Browse files
Merge "Bug 1530613: Getting excluded tags to work with Select2 4.0.1"
parents
a6f1e203
1f9bbefe
Changes
3
Hide whitespace changes
Inline
Side-by-side
htdocs/artefact/blog/blocktype/taggedposts/lib.php
View file @
3f0564ba
...
...
@@ -329,10 +329,10 @@ class PluginBlocktypeTaggedposts extends MaharaCoreBlocktype {
if
(
$tagrecords
)
{
foreach
(
$tagrecords
as
$tag
)
{
if
(
$tag
->
tagtype
==
PluginBlocktypeTaggedposts
::
TAGTYPE_INCLUDE
)
{
$tagselect
[]
=
$tag
->
tag
;
$tagselect
[]
=
hsc
(
$tag
->
tag
)
;
}
else
{
$tagselect
[]
=
'-'
.
$tag
->
tag
;
$tagselect
[]
=
'-'
.
hsc
(
$tag
->
tag
)
;
}
}
}
...
...
@@ -340,9 +340,12 @@ class PluginBlocktypeTaggedposts extends MaharaCoreBlocktype {
$excludetag
=
get_string
(
'excludetag'
,
'blocktype.blog/taggedposts'
);
$formatSelection
=
<<<EOF
function (item, container) {
item.title = item.id;
if (item.id[0] == "-") {
container.parent().addClass("tagexcluded");
item.text = '<span class="sr-only">{$excludetag}</span>' + item.text;
container.addClass("tagexcluded");
if (!item.text.match(/sr\-only/)) {
return '<span class="sr-only">{$excludetag}</span>' + item.text;
}
}
return item.text;
}
...
...
@@ -361,7 +364,11 @@ EOF;
'blockconfig'
=>
true
,
'help'
=>
true
,
'mininputlength'
=>
0
,
'extraparams'
=>
array
(
'formatSelection'
=>
"
$formatSelection
"
),
'extraparams'
=>
array
(
'templateSelection'
=>
"
$formatSelection
"
,
// We'll escape the text on the PHP side, so select2 doesn't need to
'escapeMarkup'
=>
'function(textToEscape) { return textToEscape; }'
,
),
);
$elements
[
'count'
]
=
array
(
'type'
=>
'text'
,
...
...
@@ -396,7 +403,9 @@ EOF;
return
<<<EOF
jQuery(function($) {
$('#instconf_tagselect').on('change', function() {
updatetagbuttons();
// Need a small delay so that MultipleSelection.prototype.update will
// fire before updatetagbuttons
setTimeout(updatetagbuttons, 1000);
});
updatetagbuttons();
...
...
@@ -406,12 +415,12 @@ EOF;
e.stopPropagation();
e.preventDefault();
var li = $(this).parent();
var
val =
$('#instconf_tagselect').select2('
val');
var index = val.indexOf(
li[0].title)
;
if (index > -1) {
val.splice(index, 1
);
}
$('#instconf_tagselect').select2('val', val
);
var
new_data = jQuery.grep(
$('#instconf_tagselect').select2('
data'), function (value) {
if (value['id'] ==
li[0].title)
{
$("#instconf_tagselect option[value='" + value['id'] + "']").remove();
$('#instconf_tagselect').trigger('change'
);
}
}
);
});
}
});
...
...
htdocs/artefact/blog/blocktype/taggedposts/taggedposts.json.php
View file @
3f0564ba
...
...
@@ -51,8 +51,10 @@ while ($alltags !== false && $more && count($tmptags) < $tagsperpage) {
continue
;
}
if
(
stripos
(
$tag
->
tag
,
$request
)
!==
false
||
$request
===
''
)
{
$tmptags
[]
=
(
object
)
array
(
'id'
=>
$tagexcluded
.
$tag
->
tag
,
'text'
=>
$tag
->
tag
);
$tmptags
[]
=
(
object
)
array
(
'id'
=>
hsc
(
$tagexcluded
.
$tag
->
tag
),
'text'
=>
hsc
(
$tag
->
tag
),
);
}
}
$page
++
;
...
...
htdocs/theme/raw/sass/lib/_select2.scss
View file @
3f0564ba
...
...
@@ -221,6 +221,9 @@ Version: 4.0.0 Timestamp: Jul 1 13:43:36 EDT 2015
white-space
:
nowrap
;
text-overflow
:
ellipsis
;
width
:
auto
;
}
.select2-container--default
.select2-selection--multiple
.tagexcluded
{
background
:
#ffd9d9
!
important
;
}
.select2-container--default
.select2-selection--multiple
.select2-selection__choice__remove
{
background
:
none
;
border
:
none
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment