Skip to content
Snippets Groups Projects
Commit 99807c8e authored by Mauricio Giacomini Girardello's avatar Mauricio Giacomini Girardello
Browse files

Merge branch 'master' of gitlab.c3sl.ufpr.br:portalmec/portalmec

parents e2665a14 60b63cbc
No related branches found
No related tags found
No related merge requests found
$ ->
$('.default_btn').toggleClass 'active_btn'
$('.add_to_collection').popover
html: true
container: 'body'
content: ->
url = $(this).data('poload')
$('*[data-poload]').click ->
e = $(this)
e.popover({content: "Carregando..."}).popover('show')
all = undefined
objects = undefined
url = $(this).data('poload')
$.get '/collections.json', (d) ->
all = d
$.get url, (d) ->
$.parseJSON d
object = d
# generate a lookup table for object's collections id
lookup = {}
i = 0
len = object.length
while i < len
lookup[object[i].id] = object[i]
i++
# mark checked objects
i = 0
len = all.length
html = ''
while i < len
name = 'collection_' + all[i].id.split(':').slice(-1)[0]
html += '<input type="checkbox" id="' + name + '" value="' + all[i].id + '"'
if lookup[all[i].id] != undefined
html += " checked"
html += '>'
html += '<label for="' + name + '">' + all[i].name + '</label><br/>'
++i
$('.popover-content').html(html)
return
return
return
$ ->
$('.add_to_collection').on 'click', (e) ->
$('.add_to_collection').removeClass 'active'
......@@ -17,4 +45,4 @@ $ ->
$ ->
$(document).on 'ajax:success', 'a.vote', (status, data, xhr) ->
$('.votes-count[data-id=\'' + data.id + '\']').text data.count
return
\ No newline at end of file
return
......@@ -44,4 +44,15 @@ var nav_content = function () {
$(document).ready(function () {
nav_content();
// fix bootstrap popover click to dismiss - http://stackoverflow.com/a/14857326
$('body').on('click', function (e) {
$('[data-toggle="popover"]').each(function () {
//the 'is' for buttons that trigger popups
//the 'has' for icons within a button that triggers a popup
if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
$(this).popover('hide');
}
});
});
});
<a tabindex="0" class="btn btn-default btn-xs add_to_collection" role="button" data-toggle="popover" data-placement="left" data-trigger="focus" title="Adicionar as coleções" data-poload="/learning_objects/<%= learning_object.id %>/collections.json">
<a tabindex="0" class="btn btn-default btn-xs add_to_collection" role="button" data-toggle="popover" data-placement="left" title="Adicionar as coleções" data-poload="/learning_objects/<%= ERB::Util.url_encode(learning_object.id) %>/collections.json">
<span class="glyphicon glyphicon-list" aria-hidden="true"></span>
</a>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment