| 1 |
|
| 2 |
/*global jQuery, document, redux*/ |
| 3 |
|
| 4 |
(function ($) { |
| 5 |
'use strict'; |
| 6 |
|
| 7 |
redux.field_objects = redux.field_objects || {}; |
| 8 |
redux.field_objects.animation = redux.field_objects.animation || {}; |
| 9 |
|
| 10 |
$(document).ready( |
| 11 |
function () { |
| 12 |
//redux.field_objects.animation.init(); |
| 13 |
} |
| 14 |
); |
| 15 |
|
| 16 |
redux.field_objects.animation.init = function (selector) { |
| 17 |
|
| 18 |
if (!selector) { |
| 19 |
selector = $(document).find('.redux-container-animation:visible'); |
| 20 |
} |
| 21 |
$(selector).each( |
| 22 |
function () { |
| 23 |
var el = $(this); |
| 24 |
var parent = el; |
| 25 |
if (!el.hasClass('redux-field-container')) { |
| 26 |
parent = el.parents('.redux-field-container:first'); |
| 27 |
} |
| 28 |
if (parent.is(':hidden')) { // Skip hidden fields |
| 29 |
return; |
| 30 |
} |
| 31 |
if (parent.hasClass('redux-field-init')) { |
| 32 |
parent.removeClass('redux-field-init'); |
| 33 |
} else { |
| 34 |
return; |
| 35 |
} |
| 36 |
var default_params = { |
| 37 |
width: 'resolve', |
| 38 |
triggerChange: true, |
| 39 |
allowClear: true |
| 40 |
}; |
| 41 |
|
| 42 |
var select2_handle = el.find('.select2_params'); |
| 43 |
|
| 44 |
if (select2_handle.size() > 0) { |
| 45 |
var select2_params = select2_handle.val(); |
| 46 |
|
| 47 |
select2_params = JSON.parse(select2_params); |
| 48 |
default_params = $.extend({}, default_params, select2_params); |
| 49 |
} |
| 50 |
|
| 51 |
el.find('.redux-animation-options').select2(default_params); |
| 52 |
|
| 53 |
el.find('.redux-animation-action').select2(default_params); |
| 54 |
|
| 55 |
el.find('.redux-animation-speed').select2(default_params); |
| 56 |
|
| 57 |
|
| 58 |
el.on('change', '.redux-animation-options,.redux-animation-action,.redux-animation-speed', function (e) { |
| 59 |
|
| 60 |
redux_change($(this)); |
| 61 |
|
| 62 |
}); |
| 63 |
|
| 64 |
} |
| 65 |
); |
| 66 |
|
| 67 |
|
| 68 |
}; |
| 69 |
})(jQuery); |