From c949174a2e8c324e3e463a9d10e9e6dc07b0ba9e Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Wed, 22 Jun 2011 21:05:17 +0200 Subject: Fix and refactor ajax.js * Move file to qsearch.js * Rename object to dw_qsearch * Remove unnecessary usage of Delay * Use $ prefix for jQuery objects * Fix result list hiding on click * Fix namespace shorting --- lib/scripts/helpers.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'lib/scripts/helpers.js') diff --git a/lib/scripts/helpers.js b/lib/scripts/helpers.js index 129964d29..77e7ffc4a 100644 --- a/lib/scripts/helpers.js +++ b/lib/scripts/helpers.js @@ -144,3 +144,22 @@ function hasFlash(version){ if(ver >= version) return true; return false; } + +/** + * A PHP-style substr_replace + * + * Supports negative start and length and omitting length, but not + * str and replace arrays. + * See http://php.net/substr-replace for further documentation. + */ +function substr_replace(str, replace, start, length) { + var a2, b1; + a2 = (start < 0 ? str.length : 0) + start; + if (typeof length === 'undefined') { + length = str.length - a2; + } else if (length < 0 && start < 0 && length <= start) { + length = 0; + } + b1 = (length < 0 ? str.length : a2) + length; + return str.substring(0, a2) + replace + str.substring(b1); +} -- cgit v1.2.3