Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge 9dbba4d into a932d56
  • Loading branch information
javierjulio committed Nov 30, 2016
2 parents a932d56 + 9dbba4d commit 1e852a1
Show file tree
Hide file tree
Showing 141 changed files with 2,265 additions and 2,331 deletions.
1 change: 1 addition & 0 deletions .hound.yml
Expand Up @@ -9,6 +9,7 @@ java_script:

scss:
enabled: false
config_file: .scss-style.yml

Metrics/LineLength:
Max: 110
145 changes: 145 additions & 0 deletions .scss-style.yml
@@ -0,0 +1,145 @@
scss_files: "app/assets/styleshheets/*.scss"
linters:
BangFormat:
enabled: true
space_before_bang: true
space_after_bang: false
BorderZero:
enabled: false
convention: zero
ColorKeyword:
enabled: true
severity: warning
ColorVariable:
enabled: true
Comment:
enabled: true
DebugStatement:
enabled: true
DeclarationOrder:
enabled: true
DuplicateProperty:
enabled: true
ElsePlacement:
enabled: true
style: same_line
EmptyLineBetweenBlocks:
enabled: true
ignore_single_line_blocks: true
EmptyRule:
enabled: true
FinalNewline:
enabled: true
present: true
HexLength:
enabled: false
style: short
HexNotation:
enabled: true
style: lowercase
HexValidation:
enabled: true
IdSelector:
enabled: true
ImportantRule:
enabled: true
ImportPath:
enabled: true
leading_underscore: false
filename_extension: false
Indentation:
enabled: true
allow_non_nested_indentation: false
character: space
width: 2
LeadingZero:
enabled: true
style: include_zero
MergeableSelector:
enabled: true
force_nesting: true
NameFormat:
enabled: true
allow_leading_underscore: true
convention: hyphenated_lowercase
NestingDepth:
enabled: true
max_depth: 4
severity: warning
PlaceholderInExtend:
enabled: false
PropertyCount:
enabled: false
include_nested: false
max_properties: 10
PropertySortOrder:
enabled: true
ignore_unspecified: false
severity: warning
separate_groups: false
PropertySpelling:
enabled: true
extra_properties: []
QualifyingElement:
enabled: true
allow_element_with_attribute: true
allow_element_with_class: true
allow_element_with_id: false
severity: warning
SelectorDepth:
enabled: true
max_depth: 4
severity: warning
SelectorFormat:
enabled: true
convention: hyphenated_lowercase
Shorthand:
enabled: false
severity: warning
SingleLinePerProperty:
enabled: true
allow_single_line_rule_sets: true
SingleLinePerSelector:
enabled: true
SpaceAfterComma:
enabled: true
SpaceAfterPropertyColon:
enabled: true
style: one_space
SpaceAfterPropertyName:
enabled: true
SpaceBeforeBrace:
enabled: true
style: space
allow_single_line_padding: false
SpaceBetweenParens:
enabled: true
spaces: 0
StringQuotes:
enabled: true
style: double_quotes
TrailingSemicolon:
enabled: true
TrailingZero:
enabled: false
UnnecessaryMantissa:
enabled: true
UnnecessaryParentReference:
enabled: true
UrlFormat:
enabled: true
UrlQuotes:
enabled: true
VariableForProperty:
enabled: false
properties: []
VendorPrefixes:
enabled: true
identifier_list: bourbon
include: []
exclude: []
ZeroUnit:
enabled: true
severity: warning
Compass::PropertyWithMixin:
enabled: false
Binary file not shown.
Binary file removed app/assets/images/active_admin/nested_menu_arrow.gif
Binary file not shown.
Binary file not shown.
Binary file removed app/assets/images/active_admin/orderable.png
Binary file not shown.

This file was deleted.

@@ -1,6 +1,6 @@
$(document).on 'ready page:load turbolinks:load', ->
# Clear Filters button
$('.clear_filters_btn').click (e) ->
$('.js-clear-filters-button').click (e) ->
params = window.location.search.slice(1).split('&')
regex = /^(q\[|q%5B|q%5b|page|commit)/
if typeof Turbolinks != 'undefined'
Expand All @@ -10,13 +10,13 @@ $(document).on 'ready page:load turbolinks:load', ->
window.location.search = (param for param in params when not param.match(regex)).join('&')

# Filter form: don't send any inputs that are empty
$('.filter_form').submit (e) ->
$('.filter-form').submit (e) ->
$(@).find(':input').filter(-> @value is '').prop 'disabled', true
if typeof Turbolinks != 'undefined'
Turbolinks.visit(window.location.href.split('?')[0] + '?' + $( this ).serialize())
e.preventDefault()

# Filter form: for filters that let you choose the query method from
# a dropdown, apply that choice to the filter input field.
$('.filter_form_field.select_and_search select').change ->
$('.filter-form-field.select-and-search select').change ->
$(@).siblings('input').prop name: "q[#{@value}]"
@@ -1,3 +1,3 @@
$(document).on 'ready page:load turbolinks:load', ->
# Tab navigation
$('#active_admin_content .tabs').tabs()
$('#js-active-admin-content .tabs').tabs()
10 changes: 5 additions & 5 deletions app/assets/javascripts/active_admin/lib/batch_actions.js.coffee
Expand Up @@ -27,13 +27,13 @@ $(document).on 'ready page:load turbolinks:load', ->

if $(".batch_actions_selector").length && $(":checkbox.toggle_all").length

if $(".paginated_collection table.index_table").length
$(".paginated_collection table.index_table").tableCheckboxToggler()
if $(".js-index-table").length
$(".js-index-table").tableCheckboxToggler()
else
$(".paginated_collection").checkboxToggler()
$(".paginated-collection").checkboxToggler()

$(document).on 'change', '.paginated_collection :checkbox', ->
if $(".paginated_collection :checkbox:checked").length
$(document).on 'change', '.paginated-collection :checkbox', ->
if $(".paginated-collection :checkbox:checked").length
$(".batch_actions_selector").each -> $(@).aaDropdownMenu("enable")
else
$(".batch_actions_selector").each -> $(@).aaDropdownMenu("disable")
Expand Up @@ -23,15 +23,17 @@ class ActiveAdmin.CheckboxToggler
@toggle_all_checkbox.change => @_didChangeToggleAllCheckbox()

_didChangeCheckbox: (checkbox)->
switch @checkboxes.filter(':checked').length
when @checkboxes.length - 1 then @toggle_all_checkbox.prop checked: null
when @checkboxes.length then @toggle_all_checkbox.prop checked: true
numChecked = @checkboxes.filter(':checked').length

allChecked = numChecked == @checkboxes.length
someChecked = numChecked > 0 && numChecked < @checkboxes.length

@toggle_all_checkbox.prop checked: allChecked, indeterminate: someChecked

_didChangeToggleAllCheckbox: ->
setting = if @toggle_all_checkbox.prop 'checked' then true else null
@checkboxes.each (index, el)=>
$(el).prop checked: setting
@_didChangeCheckbox(el)
setting = @toggle_all_checkbox.prop 'checked'
@checkboxes.prop checked: setting
setting

option: (key, value) ->
if $.isPlainObject(key)
Expand Down
37 changes: 3 additions & 34 deletions app/assets/javascripts/active_admin/lib/dropdown-menu.js.coffee
Expand Up @@ -12,20 +12,17 @@ class ActiveAdmin.DropdownMenu
@options = $.extend defaults, @options
@isOpen = false

@$menuButton = @$element.find '.dropdown_menu_button'
@$menuList = @$element.find '.dropdown_menu_list_wrapper'
@$menuButton = @$element.find '.button'
@$menuList = @$element.find '.dropdown-menu'

@_buildMenuList()
@_bind()

open: ->
@isOpen = true
@$menuList.fadeIn @options.fadeInDuration

@_position()
@


close: ->
@isOpen = false
@$menuList.fadeOut this.options.fadeOutDuration
Expand Down Expand Up @@ -56,8 +53,6 @@ class ActiveAdmin.DropdownMenu
# Private

_buildMenuList: ->
@$nipple = $('<div class="dropdown_menu_nipple"></div>')
@$menuList.prepend @$nipple
@$menuList.hide()

_bind: ->
Expand All @@ -69,33 +64,7 @@ class ActiveAdmin.DropdownMenu
if @isOpen then @close() else @open()
false

_position: ->
@$menuList.css 'top', @$menuButton.position().top + @$menuButton.outerHeight() + 10

button_left = @$menuButton.position().left
button_center = @$menuButton.outerWidth() / 2
button_right = button_left + button_center * 2
menu_center = @$menuList.outerWidth() / 2
nipple_center = @$nipple.outerWidth() / 2
window_right = $(window).width()

centered_menu_left = button_left + button_center - menu_center
centered_menu_right = button_left + button_center + menu_center

if centered_menu_left < 0
# Left align with button
@$menuList.css 'left', button_left
@$nipple.css 'left', button_center - nipple_center
else if centered_menu_right > window_right
# Right align with button
@$menuList.css 'right', window_right - button_right
@$nipple.css 'right', button_center - nipple_center
else
# Center align under button
@$menuList.css 'left', centered_menu_left
@$nipple.css 'left', menu_center - nipple_center

$.widget.bridge 'aaDropdownMenu', ActiveAdmin.DropdownMenu

$(document).on 'ready page:load turbolinks:load', ->
$('.dropdown_menu').aaDropdownMenu()
$('.dropdown').aaDropdownMenu()
4 changes: 2 additions & 2 deletions app/assets/javascripts/active_admin/lib/flash.js.coffee
Expand Up @@ -7,8 +7,8 @@ ActiveAdmin.flash =
reference: ->
@reference
constructor: (@message, @type = "notice", close_after) ->
@reference = jQuery("<div>").addClass("flash flash_#{@type}").text(@message)
jQuery ".flashes"
@reference = jQuery("<div>").addClass("flash flash-#{@type}").text(@message)
jQuery ".js-flash-messages"
.append @reference
@close_after close_after if close_after?
close_after: (close_after) ->
Expand Down
20 changes: 10 additions & 10 deletions app/assets/javascripts/active_admin/lib/has_many.js.coffee
Expand Up @@ -2,18 +2,18 @@ $ ->
# Provides a before-removal hook:
# $ ->
# # This is a good place to tear down JS plugins to prevent memory leaks.
# $(document).on 'has_many_remove:before', '.has_many_container', (e, fieldset, container)->
# $(document).on 'has_many_remove:before', '.has-many-container', (e, fieldset, container)->
# fieldset.find('.select2').select2 'destroy'
#
# # If you need to do anything after removing the items you can use the
# has_many_remove:after hook
# $(document).on 'has_many_remove:after', '.has_many_container', (e, fieldset, container)->
# list_item_count = container.find('.has_many_fields').length
# $(document).on 'has_many_remove:after', '.has-many-container', (e, fieldset, container)->
# list_item_count = container.find('.has-many-fields').length
# alert("There are now #{list_item_count} items in the list")
#
$(document).on 'click', 'a.button.has_many_remove', (e)->
e.preventDefault()
parent = $(@).closest '.has_many_container'
parent = $(@).closest '.has-many-container'
to_remove = $(@).closest 'fieldset'
recompute_positions parent

Expand All @@ -24,18 +24,18 @@ $ ->
# Provides before and after creation hooks:
# $ ->
# # The before hook allows you to prevent the creation of new records.
# $(document).on 'has_many_add:before', '.has_many_container', (e, container)->
# $(document).on 'has_many_add:before', '.has-many-container', (e, container)->
# if $(@).children('fieldset').length >= 3
# alert "you've reached the maximum number of items"
# e.preventDefault()
#
# # The after hook is a good place to initialize JS plugins and the like.
# $(document).on 'has_many_add:after', '.has_many_container', (e, fieldset, container)->
# $(document).on 'has_many_add:after', '.has-many-container', (e, fieldset, container)->
# fieldset.find('select').chosen()
#
$(document).on 'click', 'a.button.has_many_add', (e)->
e.preventDefault()
parent = $(@).closest '.has_many_container'
parent = $(@).closest '.has-many-container'
parent.trigger before_add = $.Event('has_many_add:before'), [parent]

unless before_add.isDefaultPrevented()
Expand All @@ -49,15 +49,15 @@ $ ->
recompute_positions parent
parent.trigger 'has_many_add:after', [fieldset, parent]

$(document).on 'change','.has_many_container[data-sortable] :input[name$="[_destroy]"]', ->
$(document).on 'change','.has-many-container[data-sortable] :input[name$="[_destroy]"]', ->
recompute_positions $(@).closest '.has_many'

init_sortable()
$(document).on 'has_many_add:after', '.has_many_container', init_sortable
$(document).on 'has_many_add:after', '.has-many-container', init_sortable


init_sortable = ->
elems = $('.has_many_container[data-sortable]:not(.ui-sortable)')
elems = $('.has-many-container[data-sortable]:not(.ui-sortable)')
elems.sortable \
items: '> fieldset',
handle: '> ol > .handle',
Expand Down
16 changes: 11 additions & 5 deletions app/assets/javascripts/active_admin/lib/modal_dialog.js.coffee
Expand Up @@ -38,8 +38,14 @@ ActiveAdmin.modal_dialog = (message, inputs, callback)->
$('body').trigger 'modal_dialog:after_open', [form]
dialogClass: 'active_admin_dialog'
buttons:
OK: ->
callback $(@).serializeObject()
$(@).dialog('close')
Cancel: ->
$(@).dialog('close').remove()
OK:
text: 'OK'
class: 'button button-primary'
click: ->
callback $(@).serializeObject()
$(@).dialog('close')
Cancel:
text: 'Cancel'
class: 'button button-default'
click: ->
$(@).dialog('close').remove()

0 comments on commit 1e852a1

Please sign in to comment.