Repository URL to install this package:
Version:
2.23.0 ▾
|
$(document).on 'click', "#btn-toggle-social-accounts", (e) ->
e.preventDefault()
unless $(@).hasClass('prevent')
$tab = $(".tab-card-list:visible")
buttonText = ''
$(document).on "click", ".btn-cancel-attach", (e) ->
e.preventDefault()
clearSearchBox()
$('.btn-select-all, .btn-cancel-attach').hide()
$('.add-list').html('').css("height", "0")
attachText = $('.active .attach-button-done').attr('data-label')
$('.active .attach-button-done').removeClass("attach-button-done").html attachText
cardFilter.rearrangeCards($('select.sortable').val())
$(document).on "click", ".btn-select-all", (e) ->
e.preventDefault()
$this = $(@)
if $this.hasClass('deselect')
$('.add-list input[type=checkbox]').prop('checked', false)
$this.removeClass('deselect')
$this.html($this.attr('data-select-label'))
else
$('.add-list input[type=checkbox]').prop('checked', true)
$this.addClass('deselect')
$this.html($this.attr('data-deselect-label'))
clearSearchBox = ->
searchBox = $('input.filter')
searchBox.val('')
searchBox.keyup()
checkedCards = ->
$checkBoxes = $(".add-list .card:not(.dummy-card) .assign_checkbox")
totalCheckBoxes = $checkBoxes.length
unChecked = $checkBoxes.not(':checked').length
$button = $('.btn-select-all')
if unChecked == 0
$button.addClass('deselect')
$button.html($button.attr('data-deselect-label'))
else
$button.removeClass('deselect')
$button.html($button.attr('data-select-label'))
$(document).on "click", ".tab-content .attach-button", (e) ->
## Update Client Membersips for the client
unless $(this).hasClass('prevent')
$attachButton = ($ @)
$attachButton.attr('disabled', true); #disable the button
container = $attachButton.closest(".tab-pane")
tabHeight = container.parent().outerHeight() - container.find(".tab-controls-bar").outerHeight()
attachTab = container.find(".add-list")
if @className.indexOf("attach-button-done") < 0 #Show Option Cards
buttonText = $attachButton.html()
$.ajax
url: $attachButton.data("href")
context: $attachButton
success: (content) ->
attachTab.html(content).css("height", "#{tabHeight}px")
oldLabel = $attachButton.html()
$attachButton.addClass("attach-button-done").attr("data-label", oldLabel).html "<span class='icon-check icon-white'> </span> "+I18n.t("common.done")+""
$('.btn-select-all, .btn-cancel-attach').show()
checkedCards()
svgFill()
clearSearchBox()
$attachButton.attr('disabled', false);
cardFilter.rearrangeAttachCards($('select.sortable').val())
else #Hide/Save/Done
link = location.href
$('.btn-select-all, .btn-cancel-attach').hide()
attachTab.find("form").submit (e)->
e.preventDefault()
self = $(this)
$.ajax
method: self.find("input[name='_method']").val()
url: self.attr("action")
data: self.serialize()
dataType: "json"
error: ->
location.reload()
success: (data) ->
if data.message? and data.status?
noty
type: data.status
text: data.message
tab = $(".nav-tabs li.active a")
window.tabOperator.loadTab(tab, ->
tabFullName = tab.html()
tabName = tabFullName.substr(0, tabFullName.indexOf("("))
count = $(".tab-pane.active .tab-card-list").find(".card:not(.dummy-card)").length
activeProjectCard = $('.project-card.selected')
clearSearchBox()
$attachButton.attr('disabled', false);
cardFilter.rearrangeCards($('select.sortable').val())
updateCardCount(count)
)
cardFilter.showHideCardSection()
$attachButton.removeClass("attach-button-done").html buttonText
attachTab.css("height", "0").find("form").triggerHandler "submit"
@firstTimeValidation = ->
clientCard = $('.client-card')
activeClientCard = $('.client-card.selected')
activeProjectCard = $('.project-card.selected')
dummyCard = $('.tab-card-list').find('.dummy-card')
infoMessage = $('.tab-card-list').find('.info-text')
attachButton = $('.tab-content').find('.attach-button')
navTab = $('.nav-tabs li.active')
navTabFor = (navTab.attr('class').split(' '))[0]
projectListCardsContainer = $('.projects-container')
clientMemberCount = parseInt(clientCard.find('.members').html())
clientSocialAccountCount = parseInt(clientCard.find('.accounts').html())
clientQueueCount = parseInt(clientCard.find('.queues').html())
clientProjectCount = parseInt(clientCard.find('.client-project-count').html())
projectMemberCount = parseInt(activeProjectCard.find('.members').html())
projectSocialAccountCount = parseInt(activeProjectCard.find('.accounts').html())
projectQueueCount = parseInt(activeProjectCard.find('.queues').html())
@hideAll = ->
dummyCard.addClass('hide')
infoMessage.addClass('hide')
@showDummyHideInfo = ->
dummyCard.removeClass('hide')
infoMessage.addClass('hide')
attachButton.removeClass('disabled prevent')
@hideDummyShowInfo = ->
dummyCard.addClass('hide')
infoMessage.removeClass('hide')
if projectListCardsContainer.length
activeProjectCards = projectListCardsContainer.find('.list-card.active')
suspendedProjectCards = projectListCardsContainer.find('.list-card.suspended')
closedProjectCards = projectListCardsContainer.find('.list-card.closed')
projectDummyCard = projectListCardsContainer.find('.dummy-card')
projectCounter = $('#project-list-filter')
projectCounter.find('.active-count').html("("+activeProjectCards.length+")")
projectCounter.find('.suspended-count').html("("+suspendedProjectCards.length+")")
projectCounter.find('.closed-count').html("("+closedProjectCards.length+")")
if activeProjectCards.length
projectDummyCard.hide()
else
projectDummyCard.show()
if activeClientCard.length
if navTab.hasClass('accounts') and clientSocialAccountCount == 0 then showDummyHideInfo()
else if navTab.hasClass('members') and clientMemberCount == 0 then showDummyHideInfo()
else if navTab.hasClass('queues') and clientQueueCount == 0
if $('.btn-new-queue').hasClass('disabled') then hideDummyShowInfo() else showDummyHideInfo()
else hideAll()
if activeProjectCard.length
switch navTabFor
when 'members'
if projectMemberCount > 0 then hideDummyShowInfo() else showDummyHideInfo()
when 'accounts'
if clientSocialAccountCount == 0
hideDummyShowInfo()
else if projectSocialAccountCount == 0
showDummyHideInfo()
else
hideAll()
when 'queues'
if clientQueueCount == 0
hideDummyShowInfo()
else if projectQueueCount == 0
showDummyHideInfo()
else
hideAll()
else
hideAll()
attachButton.removeClass('disabled prevent')