Last active
December 16, 2015 04:48
-
-
Save jpmckinney/5379478 to your computer and use it in GitHub Desktop.
AJAX-Solr theming and support functions.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Define theme functions to separate, as much as possible, your HTML from your | |
* JavaScript. Theme functions provided by AJAX Solr are defined in the | |
* AjaxSolr.theme.prototype namespace, e.g. AjaxSolr.theme.prototype.select_tag. | |
* | |
* To override a theme function provided by AJAX Solr, define a function of the | |
* same name in the AjaxSolr.theme namespace, e.g. AjaxSolr.theme.select_tag. | |
* | |
* To retrieve the HTML output by AjaxSolr.theme.prototype.select_tag(...), call | |
* AjaxSolr.theme('select_tag', ...). | |
* | |
* @param {String} func | |
* The name of the theme function to call. | |
* @param ... | |
* Additional arguments to pass along to the theme function. | |
* @returns | |
* Any data the theme function returns. This could be a plain HTML string, | |
* but also a complex object. | |
* | |
* @static | |
* @throws Exception if the theme function is not defined. | |
* @see http://cvs.drupal.org/viewvc.py/drupal/drupal/misc/drupal.js?revision=1.58 | |
*/ | |
AjaxSolr.theme = function (func) { | |
if (AjaxSolr.theme[func] || AjaxSolr.theme.prototype[func] == undefined) { | |
window.console && console.log && console.log('Theme function "' + func + '" is not defined.'); | |
} | |
else { | |
for (var i = 1, args = []; i < arguments.length; i++) { | |
args.push(arguments[i]); | |
} | |
return (AjaxSolr.theme[func] || AjaxSolr.theme.prototype[func]).apply(this, args); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment