remove custom data-toggle=disable in favor of working but ugly collapse

fixes #24
This commit is contained in:
Sjon Hortensius 2015-03-15 22:09:06 +01:00
parent 845e459de8
commit b52f76e9bf
2 changed files with 4 additions and 70 deletions

View File

@ -43,70 +43,4 @@ $(function() {
// Trigger change to open currently selected item
selects.trigger('change');
};
});
// Custom handler for data-toggle=disable
+function ($) {
'use strict';
var Disable = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, Disable.DEFAULTS, options)
this.$trigger = $(this.options.trigger).filter('[href="#' + element.id + '"], [data-target="#' + element.id + '"]')
this.transitioning = null
}
Disable.VERSION = '1.0'
Disable.DEFAULTS = {
trigger: '[data-toggle="disable"]'
}
Disable.prototype.show = function () {
this.$element
.prop('disabled', false);
}
Disable.prototype.hide = function () {
this.$element
.prop('disabled', true);
}
Disable.prototype.toggle = function () {
this[this.$element.prop('disabled') ? 'show' : 'hide']()
}
function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('disable')
var options = $.extend({}, Disable.DEFAULTS, $this.data(), typeof option == 'object' && option)
if (!data) $this.data('disable', (data = new Disable(this, options)))
if (typeof option == 'string') data[option]()
})
}
var old = $.fn.disable
$.fn.disable = Plugin
$.fn.disable.Constructor = Disable
$.fn.disable.noConflict = function () {
$.fn.disable = old
return this
}
$(document).on('click.disable.data-api', '[data-toggle="disable"]', function (e) {
var $this = $(this)
if (!$this.attr('data-target')) e.preventDefault()
var $target = $($this.attr('data-target'))
var data = $target.data('disable')
var option = data ? 'toggle' : $.extend({}, $this.data(), { trigger: this })
Plugin.call($target, option)
})
}(jQuery);
});

View File

@ -302,7 +302,7 @@ $group->add(new Form_Checkbox(
'HTTP',
($pconfig['webguiproto']=='http'),
'http'
))->displayAsRadio()->setAttribute('data-toggle', 'disable')->setAttribute('data-target', '#ssl-certificate');
))->displayAsRadio()->setAttribute('data-toggle', 'collapse')->setAttribute('data-target', '#ssl-certificate');
$group->add($input = new Form_Checkbox(
'protocol',
@ -310,7 +310,7 @@ $group->add($input = new Form_Checkbox(
'HTTPS',
($pconfig['webguiproto']=='https'),
'https'
))->displayAsRadio()->setAttribute('data-toggle', 'disable')->setAttribute('data-target', '#ssl-certificate');
))->displayAsRadio()->setAttribute('data-toggle', 'collapse')->setAttribute('data-target', '#ssl-certificate');
$section->add($group);
@ -333,7 +333,7 @@ if (!$certs_available)
));
if ($pconfig['webguiproto'] == 'http')
$input->setAttribute('disabled');
$input->addClass('collapse');
}
$section->addInput(new Form_Input(