123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- (function($) {
- $(document).bind('cobalt-load', function(evt, cobalt) {
- var plugin = {
- 'version': 0,
- 'catalogs': {},
- 'handlers': []
- };
- plugin['catalogs']['vocabularies'] = {
- 'update': function(last_update, callback) {
- $.getJSON(Drupal.settings.basePath + 'cobalt/data/taxonomy_json', {}, function (data) {
- cobalt.emptyCatalog('vocabularies');
- var access = data.access ? 'w' : '';
- for (var id in data.vocabularies) {
- cobalt.addEntry({id:id, name:data.vocabularies[id], information:access, catalog:'vocabularies', classname:'vocabulary'});
- }
- cobalt.emptyCatalog('terms');
- for (var id in data.terms) {
- cobalt.addEntry({id:id, name:data.terms[id][0], information:{'perm': access, 'vid': data.terms[id][1]}, catalog:'terms', classname:'term'});
- }
- callback(false);
- });
- },
- 'install': function() {
- },
- 'uninstall': function() {
- },
- 'update_rate': 60000
- };
- // Insert empty catalog, the update function is handled for both catalogs in
- // the vocabularies catalog.
- plugin['catalogs']['terms'] = {};
- // Register handlers
- plugin['handlers'].push({
- 'id': 'vocabulary_list',
- 'name': Drupal.t('List terms'),
- 'data_class': 'vocabulary',
- 'applicable': function(text, item) {
- return item.information == 'w';
- },
- 'handler': function(text, item) {
- window.location.href = Drupal.settings.basePath + 'admin/structure/taxonomy/' + item.id + '/list';
- }
- });
- plugin['handlers'].push({
- 'id': 'vocabulary_edit',
- 'name': Drupal.t('Edit'),
- 'data_class': 'vocabulary',
- 'applicable': function(text, item) {
- return item.information == 'w';
- },
- 'handler': function(text, item) {
- window.location.href = Drupal.settings.basePath + 'admin/structure/taxonomy/edit/vocabulary/' + item.id + '?destination=' + Drupal.settings.cobalt.path;
- }
- });
- plugin['handlers'].push({
- 'id': 'vocabulary_add',
- 'name': Drupal.t('Add terms'),
- 'data_class': 'vocabulary',
- 'applicable': function(text, item) {
- return item.information == 'w';
- },
- 'handler': function(text, item) {
- window.location.href = Drupal.settings.basePath + 'admin/structure/taxonomy/' + item.id + '/list/add';
- }
- });
- plugin['handlers'].push({
- 'id': 'term_view',
- 'name': Drupal.t('View'),
- 'data_class': 'term',
- 'handler': function(text, item) {
- window.location.href = Drupal.settings.basePath + 'taxonomy/term/' + item.id;
- }
- });
- plugin['handlers'].push({
- 'id': 'term_edit',
- 'name': Drupal.t('Edit'),
- 'data_class': 'term',
- 'applicable': function(text, item) {
- return item.information.perm == 'w';
- },
- 'handler': function(text, item) {
- window.location.href = Drupal.settings.basePath + 'taxonomy/term/' + item.id + '/edit?destination=' + Drupal.settings.cobalt.path;
- }
- });
- cobalt.registerPlugin('cobalttaxonomy', plugin);
- });
- })(jQuery);
|