Sha256: 2d12c6574a1ff7af2e7e147dccba216ae46895baf0e456cdf8ff2c07eeeb31bd

Contents?: true

Size: 577 Bytes

Versions: 7

Compression:

Stored size: 577 Bytes

Contents

function makeSlug(val, sep) { // code largely inspired by http://www.thewebsitetailor.com/jquery-slug-plugin/
	if (typeof val == 'undefined') return('');
	if (typeof sep == 'undefined') sep = '_';
	var alphaNumRegexp = new RegExp('[^a-zA-Z0-9\\' + sep + ']', 'g');	
	var avoidDuplicateRegexp = new RegExp('[\\' + sep + ']{2,}', 'g');
	val = val.replace(/\s/g, sep);
	val = val.replace(alphaNumRegexp, '');
	val = val.replace(avoidDuplicateRegexp, sep);
	return val.toLowerCase();
}

String.prototype.trim = function() {
	return this.replace(/^\s+/g, '').replace(/\s+$/g, '');
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
locomotive_cms-0.0.3.3 public/javascripts/admin/utils.js
locomotive_cms-0.0.3.1 public/javascripts/admin/utils.js
locomotive_cms-0.0.2.9 public/javascripts/admin/utils.js
locomotive_cms-0.0.2.8 public/javascripts/admin/utils.js
locomotive_cms-0.0.2.7 public/javascripts/admin/utils.js
locomotive_cms-0.0.2.6 public/javascripts/admin/utils.js
locomotive_cms-0.0.2.5 public/javascripts/admin/utils.js