Here you can find the source of trunc()
// This is a manifest file that'll be compiled into application.js, which will include all the files // listed below.//from w w w. j av a2 s.c o m // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. // // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details // about supported directives. // //= require jquery //= require jquery_ujs //= require_tree ../../../vendor/assets/javascripts/ //= require script-gun //= require_tree . // Patching String pro. for truncation of long mechanic names String.prototype.trunc = String.prototype.trunc || function(n){ return this.length>n ? this.substr(0,n-1)+'...' : this; };
String.prototype.trunc = function( n, useWordBoundary ){ var isTooLong = this.length > n, s_ = isTooLong ? this.substr(0,n-1) : this; s_ = (useWordBoundary && isTooLong) ? s_.substr(0,s_.lastIndexOf(' ')) : s_; return isTooLong ? s_ + '…' : s_; };
String.prototype.trunc = function(n){ return this.substr(0,n-1)+(this.length>n?'…':''); };
String.prototype.trunc = function (n, useWordBoundary) { var toLong = this.length > n, s_ = toLong ? this.substr(0, n - 1) : this; s_ = useWordBoundary && toLong ? s_.substr(0, s_.lastIndexOf(' ')) : s_; return toLong ? s_ + '...' : s_; }; String.prototype.nl2br = function () { ...
String.prototype.trunc = String.prototype.trunc || function(n){ return (this.length > n) ? this.substr(0,n-1)+'…' : this; };
String.prototype.trunc = String.prototype.trunc || function(n){ return this.length>n ? this.substr(0,n-1)+'?' : this; };
String.prototype.trunc = function(len,suffix) { return this.length > len ? this.slice(0, len) + (suffix||'…') : this; };
String.prototype.trunc = String.prototype.trunc || function(len,suffix) { return this.length > len ? this.slice(0, len) + (suffix||'…') : this; };
String.prototype.trunc = function(length, options) { var defaults = Ext.Object.merge({omission: "..."}, options || {}); var stop = length - defaults.omission.length; return (this.length > length ? this.substring(0, stop) + defaults.omission : this).toString(); };
String.prototype.trunc = function(n) { 'use strict'; return this.length > n ? this.substr(0, n-1) + '...' : this; };