2016-09-22 07:21:59 +00:00
|
|
|
/* global $ */
|
2016-04-13 08:04:15 +00:00
|
|
|
|
2016-09-22 07:21:59 +00:00
|
|
|
const Admin = {
|
2016-04-13 08:04:15 +00:00
|
|
|
selectMetacodes: [],
|
|
|
|
allMetacodes: [],
|
|
|
|
init: function () {
|
2016-09-22 09:00:12 +00:00
|
|
|
var self = Admin
|
2016-04-13 08:04:15 +00:00
|
|
|
|
|
|
|
$('#metacodes_value').val(self.selectMetacodes.toString())
|
|
|
|
},
|
|
|
|
selectAll: function () {
|
2016-09-22 09:00:12 +00:00
|
|
|
var self = Admin
|
2016-04-13 08:04:15 +00:00
|
|
|
|
|
|
|
$('.editMetacodes li').removeClass('toggledOff')
|
|
|
|
self.selectMetacodes = self.allMetacodes.slice(0)
|
|
|
|
$('#metacodes_value').val(self.selectMetacodes.toString())
|
|
|
|
},
|
|
|
|
deselectAll: function () {
|
2016-09-22 09:00:12 +00:00
|
|
|
var self = Admin
|
2016-04-13 08:04:15 +00:00
|
|
|
|
|
|
|
$('.editMetacodes li').addClass('toggledOff')
|
|
|
|
self.selectMetacodes = []
|
|
|
|
$('#metacodes_value').val(0)
|
|
|
|
},
|
|
|
|
liClickHandler: function () {
|
2016-09-22 09:00:12 +00:00
|
|
|
var self = Admin
|
2016-04-13 08:04:15 +00:00
|
|
|
|
|
|
|
if ($(this).attr('class') != 'toggledOff') {
|
|
|
|
$(this).addClass('toggledOff')
|
|
|
|
var value_to_remove = $(this).attr('id')
|
|
|
|
self.selectMetacodes.splice(self.selectMetacodes.indexOf(value_to_remove), 1)
|
|
|
|
$('#metacodes_value').val(self.selectMetacodes.toString())
|
|
|
|
}
|
|
|
|
else if ($(this).attr('class') == 'toggledOff') {
|
|
|
|
$(this).removeClass('toggledOff')
|
|
|
|
self.selectMetacodes.push($(this).attr('id'))
|
|
|
|
$('#metacodes_value').val(self.selectMetacodes.toString())
|
|
|
|
}
|
|
|
|
},
|
|
|
|
validate: function () {
|
2016-09-22 09:00:12 +00:00
|
|
|
var self = Admin
|
2016-04-13 08:04:15 +00:00
|
|
|
|
|
|
|
if (self.selectMetacodes.length == 0) {
|
2016-10-04 15:38:32 +00:00
|
|
|
window.alert('Would you pretty please select at least one metacode for the set?')
|
2016-04-13 08:04:15 +00:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-09-22 07:21:59 +00:00
|
|
|
|
|
|
|
export default Admin
|