diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 2fd7ab6a..3556d617 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -25,6 +25,7 @@ //= require ./src/views/room //= require ./src/JIT //= require ./src/Metamaps +//= require ./src/Metamaps.Admin //= require ./src/Metamaps.Import //= require ./src/Metamaps.JIT //= require_directory ./shims diff --git a/app/assets/javascripts/src/Metamaps.Admin.js.erb b/app/assets/javascripts/src/Metamaps.Admin.js.erb new file mode 100644 index 00000000..a0192012 --- /dev/null +++ b/app/assets/javascripts/src/Metamaps.Admin.js.erb @@ -0,0 +1,54 @@ +/* global Metamaps, $ */ + +/* + * Metamaps.Admin.js.erb + * + * Dependencies: none! + */ + +Metamaps.Admin = { + selectMetacodes: [], + allMetacodes: [], + init: function () { + var self = Metamaps.Admin + + $('#metacodes_value').val(self.selectMetacodes.toString()) + }, + selectAll: function () { + var self = Metamaps.Admin + + $('.editMetacodes li').removeClass('toggledOff') + self.selectMetacodes = self.allMetacodes.slice(0) + $('#metacodes_value').val(self.selectMetacodes.toString()) + }, + deselectAll: function () { + var self = Metamaps.Admin + + $('.editMetacodes li').addClass('toggledOff') + self.selectMetacodes = [] + $('#metacodes_value').val(0) + }, + liClickHandler: function () { + var self = Metamaps.Admin + + 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 () { + var self = Metamaps.Admin + + if (self.selectMetacodes.length == 0) { + alert('Would you pretty please select at least one metacode for the set?') + return false + } + } +} diff --git a/app/assets/javascripts/src/Metamaps.js.erb b/app/assets/javascripts/src/Metamaps.js.erb index 9c35c6ec..c9415cfa 100644 --- a/app/assets/javascripts/src/Metamaps.js.erb +++ b/app/assets/javascripts/src/Metamaps.js.erb @@ -5516,57 +5516,3 @@ Metamaps.Mapper = { }); } }; // end Metamaps.Mapper - - -/* - * - * ADMIN - * - */ - -Metamaps.Admin = { - selectMetacodes: [], - allMetacodes: [], - init: function () { - var self = Metamaps.Admin; - - $('#metacodes_value').val(self.selectMetacodes.toString()); - }, - selectAll: function () { - var self = Metamaps.Admin; - - $('.editMetacodes li').removeClass('toggledOff'); - self.selectMetacodes = self.allMetacodes.slice(0); - $('#metacodes_value').val(self.selectMetacodes.toString()); - }, - deselectAll: function () { - var self = Metamaps.Admin; - - $('.editMetacodes li').addClass('toggledOff'); - self.selectMetacodes = []; - $('#metacodes_value').val(0); - }, - liClickHandler: function () { - var self = Metamaps.Admin; - - 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 () { - var self = Metamaps.Admin; - - if (self.selectMetacodes.length == 0) { - alert('Would you pretty please select at least one metacode for the set?'); - return false; - } - } -};