From cdc093a463e8f8a925cbb9f2b55bedf0a1d8e7e8 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Sat, 12 Feb 2011 08:58:11 -0800 Subject: reformated multiline trinary expressions to have a leading ?/:. --- src/Angular.js | 28 ++++++++++++++++------------ src/apis.js | 5 +++-- src/directives.js | 20 +++++++++++--------- src/jqLite.js | 12 ++++++------ src/parser.js | 17 +++++++++-------- src/scenario/Scenario.js | 6 +++--- src/validators.js | 5 +++-- src/widgets.js | 12 ++++++------ 8 files changed, 57 insertions(+), 48 deletions(-) (limited to 'src') diff --git a/src/Angular.js b/src/Angular.js index 99a4528d..87be29a7 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -30,12 +30,14 @@ var uppercase = function (string){ return isString(string) ? string.toUpperCase( var manualLowercase = function (s) { - return isString(s) ? s.replace(/[A-Z]/g, - function (ch) {return fromCharCode(ch.charCodeAt(0) | 32); }) : s; + return isString(s) + ? s.replace(/[A-Z]/g, function (ch) {return fromCharCode(ch.charCodeAt(0) | 32); }) + : s; }; var manualUppercase = function (s) { - return isString(s) ? s.replace(/[a-z]/g, - function (ch) {return fromCharCode(ch.charCodeAt(0) & ~32); }) : s; + return isString(s) + ? s.replace(/[a-z]/g, function (ch) {return fromCharCode(ch.charCodeAt(0) & ~32); }) + : s; }; @@ -89,7 +91,9 @@ var _undefined = undefined, jQuery, // delay binding slice = Array.prototype.slice, push = Array.prototype.push, - error = window[$console] ? bind(window[$console], window[$console]['error'] || noop) : noop, + error = window[$console] + ? bind(window[$console], window[$console]['error'] || noop) + : noop, /** @name angular */ angular = window[$angular] || (window[$angular] = {}), @@ -417,13 +421,13 @@ function isElement(node) { */ function HTML(html, option) { this.html = html; - this.get = lowercase(option) == 'unsafe' ? - valueFn(html) : - function htmlSanitize() { - var buf = []; - htmlParser(html, htmlSanitizeWriter(buf)); - return buf.join(''); - }; + this.get = lowercase(option) == 'unsafe' + ? valueFn(html) + : function htmlSanitize() { + var buf = []; + htmlParser(html, htmlSanitizeWriter(buf)); + return buf.join(''); + }; } if (msie) { diff --git a/src/apis.js b/src/apis.js index 437cd6e0..6435affb 100644 --- a/src/apis.js +++ b/src/apis.js @@ -637,8 +637,9 @@ var angularArray = { return 0; } function reverse(comp, descending) { - return toBoolean(descending) ? - function(a,b){return comp(b,a);} : comp; + return toBoolean(descending) + ? function(a,b){return comp(b,a);} + : comp; } function compare(v1, v2){ var t1 = typeof v1; diff --git a/src/directives.js b/src/directives.js index 06a99149..53601a4f 100644 --- a/src/directives.js +++ b/src/directives.js @@ -243,15 +243,17 @@ function compileBindTemplate(template){ var bindings = []; forEach(parseBindings(template), function(text){ var exp = binding(text); - bindings.push(exp ? function(element){ - var error, value = this.$tryEval(exp, function(e){ - error = toJson(e); - }); - elementError(element, NG_EXCEPTION, error); - return error ? error : value; - } : function() { - return text; - }); + bindings.push(exp + ? function(element){ + var error, value = this.$tryEval(exp, function(e){ + error = toJson(e); + }); + elementError(element, NG_EXCEPTION, error); + return error ? error : value; + } + : function() { + return text; + }); }); bindTemplateCache[template] = fn = function(element, prettyPrintJson){ var parts = [], self = this, diff --git a/src/jqLite.js b/src/jqLite.js index 40994161..8a507212 100644 --- a/src/jqLite.js +++ b/src/jqLite.js @@ -5,12 +5,12 @@ var jqCache = {}, jqName = 'ng-' + new Date().getTime(), jqId = 1, - addEventListenerFn = (window.document.addEventListener ? - function(element, type, fn) {element.addEventListener(type, fn, false);} : - function(element, type, fn) {element.attachEvent('on' + type, fn);}), - removeEventListenerFn = (window.document.removeEventListener ? - function(element, type, fn) {element.removeEventListener(type, fn, false); } : - function(element, type, fn) {element.detachEvent('on' + type, fn); }); + addEventListenerFn = (window.document.addEventListener + ? function(element, type, fn) {element.addEventListener(type, fn, false);} + : function(element, type, fn) {element.attachEvent('on' + type, fn);}), + removeEventListenerFn = (window.document.removeEventListener + ? function(element, type, fn) {element.removeEventListener(type, fn, false); } + : function(element, type, fn) {element.detachEvent('on' + type, fn); }); function jqNextId() { return (jqId++); } diff --git a/src/parser.js b/src/parser.js index f2ca7a80..a8bd21e4 100644 --- a/src/parser.js +++ b/src/parser.js @@ -107,9 +107,9 @@ function lex(text, parseStringsForObjects){ function throwError(error, start, end) { end = end || index; throw Error("Lexer Error: " + error + " at column" + - (isDefined(start) ? - "s " + start + "-" + index + " [" + text.substring(start, end) + "]" : - " " + end) + + (isDefined(start) + ? "s " + start + "-" + index + " [" + text.substring(start, end) + "]" + : " " + end) + " in expression [" + text + "]."); } @@ -199,8 +199,9 @@ function lex(text, parseStringsForObjects){ index++; tokens.push({index:start, text:rawString, string:string, json:true, fn:function(){ - return (string.length == dateParseLength) ? - angular['String']['toDate'](string) : string; + return (string.length == dateParseLength) + ? angular['String']['toDate'](string) + : string; }}); return; } else { @@ -588,9 +589,9 @@ function parser(text, json){ } var fnPtr = fn(self) || noop; // IE stupidity! - return fnPtr.apply ? - fnPtr.apply(self, args) : - fnPtr(args[0], args[1], args[2], args[3], args[4]); + return fnPtr.apply + ? fnPtr.apply(self, args) + : fnPtr(args[0], args[1], args[2], args[3], args[4]); }; } diff --git a/src/scenario/Scenario.js b/src/scenario/Scenario.js index 81c85a61..a70948cc 100644 --- a/src/scenario/Scenario.js +++ b/src/scenario/Scenario.js @@ -309,9 +309,9 @@ function browserTrigger(element, type) { */ _jQuery.fn.bindings = function(name) { function contains(text, value) { - return value instanceof RegExp ? - value.test(text) : - text && text.indexOf(value) >= 0; + return value instanceof RegExp + ? value.test(text) + : text && text.indexOf(value) >= 0; } var result = []; this.find('.ng-binding:visible').each(function() { diff --git a/src/validators.js b/src/validators.js index e2a9d7f6..265d95de 100644 --- a/src/validators.js +++ b/src/validators.js @@ -181,8 +181,9 @@ extend(angularValidator, { return (date && date.getFullYear() == fields[3] && date.getMonth() == fields[1]-1 && - date.getDate() == fields[2]) ? - _null : "Value is not a date. (Expecting format: 12/31/2009)."; + date.getDate() == fields[2]) + ? _null + : "Value is not a date. (Expecting format: 12/31/2009)."; }, /** diff --git a/src/widgets.js b/src/widgets.js index 14d6fe10..ce877c71 100644 --- a/src/widgets.js +++ b/src/widgets.js @@ -337,9 +337,9 @@ function valueAccessor(scope, element) { invalidWidgets.markValid(element); } else { var error, validateScope = inherit(scope, {$element:element}); - error = required && !value ? - 'Required' : - (value ? validator(validateScope, value) : _null); + error = required && !value + ? 'Required' + : (value ? validator(validateScope, value) : _null); elementError(element, NG_VALIDATION_ERROR, error); lastError = error; if (error) { @@ -940,9 +940,9 @@ angularWidget("@ng:repeat", function(expression, element){ childScope[valueIdent] = collection[key]; if (keyIdent) childScope[keyIdent] = key; childScope.$index = index; - childScope.$position = index == 0 ? - 'first' : - (index == collectionLength - 1 ? 'last' : 'middle'); + childScope.$position = index == 0 + ? 'first' + : (index == collectionLength - 1 ? 'last' : 'middle'); lastElement.after(cloneElement = element.cloneNode()); cloneElement.attr('ng:repeat-index', index); linker(childScope, cloneElement); -- cgit v1.2.3