Lines 90-131
var Select2Utils = {
Link Here
|
90 |
initSelect2: function(selects) { |
90 |
initSelect2: function(selects) { |
91 |
if ($.fn.select2) { |
91 |
if ($.fn.select2) { |
92 |
if ( window.CAN_user_parameters_manage_auth_values === undefined || ! CAN_user_parameters_manage_auth_values ) { |
92 |
if ( window.CAN_user_parameters_manage_auth_values === undefined || ! CAN_user_parameters_manage_auth_values ) { |
93 |
$(selects).select2(); |
93 |
$(selects).select2().on("select2:clear", function () { |
94 |
} else { |
|
|
95 |
$(selects).select2({ |
96 |
tags: true, |
97 |
createTag: function (tag) { |
98 |
return { |
99 |
id: tag.term, |
100 |
text: tag.term, |
101 |
newTag: true |
102 |
}; |
103 |
}, |
104 |
templateResult: function(state) { |
105 |
if (state.newTag) { |
106 |
return state.text + " " + __("(select to create)"); |
107 |
} |
108 |
return state.text; |
109 |
} |
110 |
}).on("select2:select", function(e) { |
111 |
if(e.params.data.newTag){ |
112 |
current_select2 = this; |
113 |
var category = $(this).data("category"); |
114 |
$("#avCreate #new_av_category").html(category); |
115 |
$("#avCreate input[name='category']").val(category); |
116 |
$("#avCreate input[name='value']").val(e.params.data.text); |
117 |
$("#avCreate input[name='description']").val(e.params.data.text); |
118 |
|
119 |
$(this).val($(this).find("option:first").val()).trigger('change'); |
120 |
$('#avCreate').modal({show:true}); |
121 |
} |
122 |
}).on("select2:clear", function () { |
123 |
$(this).on("select2:opening.cancelOpen", function (evt) { |
94 |
$(this).on("select2:opening.cancelOpen", function (evt) { |
124 |
evt.preventDefault(); |
95 |
evt.preventDefault(); |
125 |
|
|
|
126 |
$(this).off("select2:opening.cancelOpen"); |
96 |
$(this).off("select2:opening.cancelOpen"); |
127 |
}); |
97 |
}); |
128 |
}); |
98 |
}); |
|
|
99 |
} else { |
100 |
$(selects).each(function(){ |
101 |
if ( !$(this).data("category") ) { |
102 |
$(this).select2().on("select2:clear", function () { |
103 |
$(this).on("select2:opening.cancelOpen", function (evt) { |
104 |
evt.preventDefault(); |
105 |
$(this).off("select2:opening.cancelOpen"); |
106 |
}); |
107 |
}); |
108 |
} else { |
109 |
$(this).select2({ |
110 |
tags: true, |
111 |
createTag: function (tag) { |
112 |
return { |
113 |
id: tag.term, |
114 |
text: tag.term, |
115 |
newTag: true |
116 |
}; |
117 |
}, |
118 |
templateResult: function(state) { |
119 |
if (state.newTag) { |
120 |
return state.text + " " + __("(select to create)"); |
121 |
} |
122 |
return state.text; |
123 |
} |
124 |
}).on("select2:select", function(e) { |
125 |
if(e.params.data.newTag){ |
126 |
current_select2 = this; |
127 |
var category = $(this).data("category"); |
128 |
$("#avCreate #new_av_category").html(category); |
129 |
$("#avCreate input[name='category']").val(category); |
130 |
$("#avCreate input[name='value']").val(e.params.data.text); |
131 |
$("#avCreate input[name='description']").val(e.params.data.text); |
132 |
|
133 |
$(this).val($(this).find("option:first").val()).trigger('change'); |
134 |
$('#avCreate').modal({show:true}); |
135 |
} |
136 |
}).on("select2:clear", function () { |
137 |
$(this).on("select2:opening.cancelOpen", function (evt) { |
138 |
evt.preventDefault(); |
139 |
|
140 |
$(this).off("select2:opening.cancelOpen"); |
141 |
}); |
142 |
}); |
143 |
} |
144 |
}); |
129 |
} |
145 |
} |
130 |
} |
146 |
} |
131 |
} |
147 |
} |
132 |
- |
|
|