X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=manifold%2Fjs%2Fplugin.js;h=84ebbc4f145986c133c3b01e0bcbf6ca1522162a;hb=e445cc0ae92f3927e7d29e9d271fea7f8dee05a6;hp=5d3df742cb6d6db2255bfa3392cc6b22469ef270;hpb=3e3c5579b2c4ebec46d03b29594fdd7ac27ff276;p=myslice.git diff --git a/manifold/js/plugin.js b/manifold/js/plugin.js index 5d3df742..84ebbc4f 100644 --- a/manifold/js/plugin.js +++ b/manifold/js/plugin.js @@ -77,12 +77,14 @@ var Plugin = Class.extend({ }, listen_query: function(query_uuid, prefix) { - this.query_handler_prefix = (typeof prefix === 'undefined') ? '' : (prefix + '_'); + this.query_handler_prefix = (typeof prefix === 'undefined') ? '' : (prefix + manifold.separator); this.$element.on(manifold.get_query_channel(query_uuid), $.proxy(this._query_handler, this)); }, default_options: {}, + /* Helper functions for naming HTML elements (ID, classes), with support for filters and fields */ + id: function() { var ret = this.options.plugin_uuid; @@ -129,4 +131,28 @@ var Plugin = Class.extend({ return filter[0] + ' ' + filter[1] + ' ' + filter[2]; }, + array_from_id: function(id) + { + var ret = id.split(manifold.separator); + ret.shift(); // remove plugin_uuid at the beginning + return ret; + }, + + id_from_field: function(field) + { + return 'field' + manifold.separator + field; + }, + + field_from_id: function(id) + { + var array; + if (typeof id === 'string') { + array = id.split(manifold.separator); + } else { // We suppose we have an array ('object') + array = id; + } + // array = ['field', FIELD_NAME] + return array[1]; + }, + });