mirror of
https://github.com/e107inc/e107.git
synced 2025-06-02 00:45:03 +02:00
Ability to use bs-switch in menu-manager config modals.
This commit is contained in:
parent
c86f8d23ad
commit
7e66f694d1
@ -42,38 +42,27 @@ require_once("../class2.php");
|
||||
|
||||
if(e_MENUMANAGER_ACTIVE === false )
|
||||
{
|
||||
e107::library('load', 'bootstrap.switch');
|
||||
e107::js('footer', '{e_WEB}js/bootstrap.switch.init.js', 'jquery', 5);
|
||||
|
||||
if(!deftrue("e_DEBUG"))
|
||||
{
|
||||
e107::getJs()->inlineCSS('
|
||||
|
||||
body { overflow:hidden }
|
||||
|
||||
|
||||
body { overflow:hidden }
|
||||
');
|
||||
}
|
||||
else
|
||||
{
|
||||
e107::js('footer-inline',"
|
||||
|
||||
$('#menu_iframe').attr('scrolling','no');
|
||||
$('#menu_iframe').load(function() {
|
||||
// $('#menu_iframe').bind('load', function() {
|
||||
|
||||
var height = this.contentWindow.document.body.offsetHeight + 400 + 'px';
|
||||
|
||||
// $(this).css('overflow-y','visible');
|
||||
var height = this.contentWindow.document.body.offsetHeight + 400 + 'px';
|
||||
$(this).css('height',height);
|
||||
// alert(this.style.height);
|
||||
|
||||
});
|
||||
|
||||
|
||||
");
|
||||
|
||||
}
|
||||
|
||||
e107::getJs()->inlineCSS("
|
||||
|
||||
.menu-manager-items { padding-right:15px}
|
||||
.menu-manager-items div.item { padding:5px; margin:5px 0; border:1px solid rgba(255,255,255,0.3); border-radius:3px; cursor: move }
|
||||
.menu-manager-sticky {
|
||||
@ -118,7 +107,6 @@ if(e_MENUMANAGER_ACTIVE === false )
|
||||
}
|
||||
|
||||
ul.dropdown-menu.e-mm-selector { padding: 10px; margin-top: -2px; margin-right:-2px; }
|
||||
|
||||
");
|
||||
}
|
||||
|
||||
|
@ -2391,25 +2391,25 @@ class e_form
|
||||
|
||||
}
|
||||
|
||||
$switchName = $name.'__switch';
|
||||
$switchName = $name . '__switch';
|
||||
|
||||
$js_options = array(
|
||||
// Each form element has its own options.
|
||||
$switchName => array(
|
||||
'size' => $options['switch'],
|
||||
'onText' => $labels['on'],
|
||||
'offText' => $labels['off'],
|
||||
'inverse' => !empty($options['inverse']),
|
||||
),
|
||||
$switchAttributes = array(
|
||||
'data-type' => 'switch',
|
||||
'data-name' => $name,
|
||||
'data-size' => $options['switch'],
|
||||
'data-on' => $labels['on'],
|
||||
'data-off' => $labels['off'],
|
||||
'data-inverse' => (int) !empty($options['inverse']),
|
||||
);
|
||||
|
||||
$options += $switchAttributes;
|
||||
|
||||
if(e_ADMIN_AREA === true)
|
||||
{
|
||||
$js_options[$switchName]['wrapperClass'] = 'wrapper form-control';
|
||||
$options['data-wrapper'] = 'wrapper form-control';
|
||||
}
|
||||
|
||||
e107::library('load', 'bootstrap.switch');
|
||||
e107::js('settings', array('bsSwitch' => $js_options));
|
||||
e107::js('footer', '{e_WEB}js/bootstrap.switch.init.js', 'jquery', 5);
|
||||
|
||||
$text = $this->hidden($name, (int) $value);
|
||||
|
67
e107_web/js/bootstrap.switch.init.js
vendored
67
e107_web/js/bootstrap.switch.init.js
vendored
@ -3,63 +3,52 @@ var e107 = e107 || {'settings': {}, 'behaviors': {}};
|
||||
(function ($)
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @type {{attach: e107.behaviors.bootstrapSwitchInit.attach}}
|
||||
*/
|
||||
e107.behaviors.bootstrapSwitchInit = {
|
||||
attach: function (context, settings)
|
||||
{
|
||||
if(typeof settings.bsSwitch === 'undefined' || settings.bsSwitch.length == 0)
|
||||
if(typeof $.fn.bootstrapSwitch === 'undefined')
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$.each(settings.bsSwitch, function (name, options)
|
||||
$('input[data-type="switch"]', context).once('bootstrap-switch-init').each(function ()
|
||||
{
|
||||
$('input[name="' + name + '"]', context).once('bootstrap-switch-init').each(function ()
|
||||
var $this = $(this);
|
||||
|
||||
if($this.attr('type') != 'hidden')
|
||||
{
|
||||
if($(this).attr('type') != 'hidden')
|
||||
$this.bootstrapSwitch({
|
||||
size: $this.data('size') || 'mini',
|
||||
onText: $this.data('on') || null,
|
||||
offText: $this.data('off') || null,
|
||||
wrapperClass: $this.data('wrapper') || null
|
||||
});
|
||||
|
||||
$this.on('switchChange.bootstrapSwitch', function (event, state)
|
||||
{
|
||||
$(this).bootstrapSwitch({
|
||||
size: options.size || 'mini',
|
||||
onText: options.onText || null,
|
||||
offText: options.offText || null,
|
||||
wrapperClass: options.wrapperClass || null,
|
||||
// disabled: false
|
||||
// state: $('input[type="hidden"][name="' + name + '"]').data('on')
|
||||
// inverse: options.inverse // this is 'reverse' - default values but reversed order.
|
||||
});
|
||||
var name = $this.data('name');
|
||||
var checked = true;
|
||||
|
||||
if(state === false)
|
||||
{
|
||||
checked = false;
|
||||
}
|
||||
|
||||
var value = checked ? 1 : 0;
|
||||
|
||||
$(this).on('switchChange.bootstrapSwitch', function (event, state) {
|
||||
if($this.data('inverse') == 1)
|
||||
{
|
||||
value = checked ? 0 : 1;
|
||||
}
|
||||
|
||||
var tmp = $(this).attr('name').split('__');
|
||||
$('input[type="hidden"][name="' + name + '"]').val(value).trigger('change');
|
||||
|
||||
var name = tmp[0]; // $(this).attr('name');
|
||||
var checked = true;
|
||||
|
||||
if(state === false)
|
||||
{
|
||||
checked = false;
|
||||
}
|
||||
|
||||
var value = checked ? 1 : 0;
|
||||
|
||||
if(options.inverse)
|
||||
{
|
||||
value = checked ? 0 : 1;
|
||||
}
|
||||
|
||||
$('input[type="hidden"][name="' + name + '"]').val(value);
|
||||
|
||||
// event.preventDefault();
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user