Permalink
Browse files

remove helpers

  • Loading branch information...
1 parent f5cacf2 commit dfcd3c2c10f5210a6a8e7adc65a0a87d353fcd42 @jpmckinney jpmckinney committed Apr 13, 2013
Showing with 0 additions and 254 deletions.
  1. +0 −76 helpers/ajaxsolr.support.js
  2. +0 −146 helpers/ajaxsolr.theme.js
  3. +0 −32 helpers/jquery/ajaxsolr.theme.js
@@ -1,76 +0,0 @@
-// $Id$
-
-/**
- * Strip whitespace from the beginning and end of a string.
- *
- * @returns {String} The trimmed string.
- */
-String.prototype.trim = function () {
- return this.replace(/^ +/, '').replace(/ +$/, '');
-};
-
-/**
- * A utility method for escaping HTML tag characters.
- * <p>From Ruby on Rails.</p>
- *
- * @returns {String} The escaped string.
- */
-String.prototype.htmlEscape = function () {
- return this.replace(/"/g, '&quot;').replace(/>/g, '&gt;').replace(/</g, '&lt;').replace(/&/g, '&amp;');
-};
-
-/**
- * Escapes the string without affecting existing escaped entities.
- * <p>From Ruby on Rails.</p>
- *
- * @returns {String} The escaped string
- */
-String.prototype.escapeOnce = function () {
- return this.replace(/"/g, '&quot;').replace(/>/g, '&gt;').replace(/</g, '&lt;').replace(/&(?!([a-zA-Z]+|#\d+);)/g, '&amp;');
-};
-
-/**
- * <p>From Ruby on Rails.</p>
- *
- * @see http://www.w3.org/TR/html4/types.html#type-name
- */
-String.prototype.sanitizeToId = function () {
- return this.replace(/\]/g, '').replace(/[^-a-zA-Z0-9:.]/g, '_');
-};
-
-/**
- * Does the string end with the specified <tt>suffix</tt>?
- * <p>From Ruby on Rails.</p>
- *
- * @param {String} suffix The specified suffix.
- * @returns {Boolean}
- */
-String.prototype.endsWith = function (suffix) {
- return this.substring(this.length - suffix.length) == suffix;
-};
-
-/**
- * Does the string start with the specified <tt>prefix</tt>?
- * <p>From Ruby on Rails.</p>
- *
- * @param {String} prefix The speficied prefix.
- * @returns {Boolean}
- */
-String.prototype.startsWith = function (prefix) {
- return this.substring(0, prefix.length) == prefix;
-};
-
-/**
- * Equivalent to PHP's two-argument version of strtr.
- *
- * @see http://php.net/manual/en/function.strtr.php
- * @param {Object} replacePairs An associative array in the form: {'from': 'to'}
- * @returns {String} A translated copy of the string.
- */
-String.prototype.strtr = function (replacePairs) {
- var str = this;
- for (var from in replacePairs) {
- str = str.replace(new RegExp(from, 'g'), replacePairs[from]);
- }
- return str;
-};
View
@@ -1,146 +0,0 @@
-// $Id$
-
-/**
- * Requires ajaxsolr.support.js.
- */
-
-/**
- * Accepts a container and returns a string of option tags.
- *
- * <p>If the container is an object, the object's properties serve as option
- * values and the values of the object's properties serve as option text.</p>
- *
- * <p>If the container is an array: Given a container where the elements are
- * two-element arrays, the first elements serve as option text and the second
- * elements serve as option values.</p>
- *
- * <p>If <tt>selected</tt> is specified, the matching option value or element
- * will get the selected option-tag. <tt>selected</tt> may also be an array of
- * values to be selected when using a multiple select.</p>
- *
- * <p>From Ruby on Rails.</p>
- *
- * @param {Array|Object} container
- * @param {Array|String} selected
- * @returns {String} The option tags.
- */
-AjaxSolr.theme.prototype.options_for_select = function (container, selected) {
- var tags = [];
-
- var options = [];
- if (AjaxSolr.isArray(container)) {
- options = container;
- }
- else {
- for (var value in container) {
- options.push([ container[value], value ]);
- }
- }
-
- for (var i = 0, l = options.length; i < l; i++) {
- var text, value;
-
- if (AjaxSolr.isArray(options[i])) {
- text = options[i][0].toString(), value = options[i][1].toString();
- }
- else {
- text = options[i].toString(), value = options[i].toString();
- }
-
- var selectedAttribute = AjaxSolr.optionValueSelected(value, selected) ? ' selected="selected"' : '';
- tags.push('<option value="' + value.htmlEscape() +'"' + selectedAttribute + '>' + text.htmlEscape() + '</option>');
- }
-
- return tags.join('\n');
-};
-
-/**
- * <p>From Ruby on Rails.</p>
- */
-AjaxSolr.theme.prototype.select_tag = function (name, optionTags, options) {
- options = options || {};
- var htmlName = options.multiple && !name.endsWith('[]') ? name + '[]' : name;
- options.name = options.name || htmlName;
- options.id = options.id || name.sanitizeToId();
- return AjaxSolr.theme('content_tag_string', 'select', optionTags, options);
-};
-
-/**
- * <p>From Ruby on Rails.</p>
- */
-AjaxSolr.theme.prototype.content_tag_string = function (name, content, options, escape) {
- var tagOptions = '';
-
- if (escape === undefined) {
- escape = true;
- }
-
- if (options) {
- tagOptions = AjaxSolr.tagOptions(options, escape)
- }
-
- return '<' + name + tagOptions + '>' + content + '</' + name + '>';
-};
-
-/**
- * <p>From Ruby on Rails.</p>
- *
- * @field
- * @private
- */
-AjaxSolr.booleanAttributes = [ 'disabled', 'readonly', 'multiple', 'checked' ];
-
-/**
- * <p>From Ruby on Rails.</p>
- *
- * @static
- */
-AjaxSolr.optionValueSelected = function (value, selected) {
- if (AjaxSolr.isArray(selected)) {
- return AjaxSolr.inArray(value, selected) != -1;
- }
- else {
- return selected == value;
- }
-};
-
-/**
- * <p>From Ruby on Rails.</p>
- *
- * @static
- */
-AjaxSolr.tagOptions = function (options, escape) {
- options = options || {};
-
- if (escape === undefined) {
- escape = true;
- }
-
- var attrs = [];
-
- if (escape) {
- for (var key in options) {
- if (AjaxSolr.inArray(key, AjaxSolr.booleanAttributes) != -1) {
- if (options[key]) {
- attrs.push(key + '="' + key + '"');
- }
- }
- else {
- if (options[key]) {
- attrs.push(key + '="' + options[key].escapeOnce() + '"');
- }
- }
- }
- }
- else {
- for (var key in options) {
- attrs.push(key + '="' + options[key] + '"');
- }
- }
-
- if (attrs.length) {
- return ' ' + attrs.sort().join(' ');
- }
-
- return '';
-};
@@ -1,32 +0,0 @@
-// $Id$
-
-/**
- * Appends the given items to the given list, optionally inserting a separator
- * between the items in the list.
- *
- * @param {String} list The list to append items to.
- * @param {Array} items The list of items to append to the list.
- * @param {String} [separator] A string to add between the items.
- * @todo Return HTML rather than modify the DOM directly.
- */
-AjaxSolr.theme.prototype.list_items = function (list, items, separator) {
- jQuery(list).empty();
- for (var i = 0, l = items.length; i < l; i++) {
- var li = jQuery('<li></li>');
- if (AjaxSolr.isArray(items[i])) {
- for (var j = 0, m = items[i].length; j < m; j++) {
- if (separator && j > 0) {
- li.append(separator);
- }
- li.append(items[i][j]);
- }
- }
- else {
- if (separator && i > 0) {
- li.append(separator);
- }
- li.append(items[i]);
- }
- jQuery(list).append(li);
- }
-};

0 comments on commit dfcd3c2

Please sign in to comment.