Permalink
Browse files

Several conditionals in the framework use the old SC.browser properti…

…es and coerce the String version into a Boolean instead of just using the matching Boolean property. I changed the conditionals to use the Boolean property, since the update SC.browser always returns Strings for versions. These properties are deprecated and so should all the code that relies on them be, since the only use for much of SC.browser is for hacky workarounds.
  • Loading branch information...
1 parent 08c7641 commit 2f10728cce78dabe57a0db388a452c16b7bf40b8 @publickeating publickeating committed Feb 1, 2012
Showing with 855 additions and 838 deletions.
  1. +13 −13 frameworks/ajax/system/response.js
  2. +7 −7 frameworks/bootstrap/system/browser.js
  3. +13 −13 frameworks/bootstrap/system/loader.js
  4. +3 −3 frameworks/core_foundation/system/event.js
  5. +11 −11 frameworks/core_foundation/system/root_responder.js
  6. +8 −8 frameworks/core_foundation/tests/system/render_context/helpers_style.js
  7. +17 −16 frameworks/core_foundation/tests/system/render_context/update.js
  8. +9 −9 frameworks/core_foundation/views/view.js
  9. +3 −3 frameworks/debug/core.js
  10. +12 −12 frameworks/desktop/panes/picker.js
  11. +15 −15 frameworks/desktop/panes/sheet.js
  12. +85 −84 frameworks/desktop/tests/views/date_field/ui.js
  13. +2 −2 frameworks/desktop/tests/views/progress/ui.js
  14. +60 −58 frameworks/desktop/views/button.js
  15. +48 −48 frameworks/desktop/views/date_field.js
  16. +137 −145 frameworks/desktop/views/list.js
  17. +147 −147 frameworks/desktop/views/split.js
  18. +21 −21 frameworks/experimental/frameworks/designer/views/drawing.js
  19. +2 −2 frameworks/experimental/frameworks/scroll_view/views/desktop/scroll.js
  20. +26 −12 frameworks/foundation/system/user_defaults.js
  21. +20 −20 frameworks/foundation/system/utils/string_metric_optimization.js
  22. +102 −101 frameworks/foundation/tests/views/text_field/ui.js
  23. +1 −1 frameworks/foundation/views/image.js
  24. +57 −53 frameworks/foundation/views/inline_text_field.js
  25. +7 −5 frameworks/foundation/views/text_field.js
  26. +11 −11 frameworks/jquery/jquery-buffer.js
  27. +16 −16 frameworks/runtime/system/run_loop.js
  28. +2 −2 frameworks/template_view/mixins/template_helpers/text_field_support.js
@@ -24,14 +24,14 @@ SC.Response = SC.Object.extend(
/**
Walk like a duck
-
+
@type Boolean
*/
isResponse: YES,
-
+
/**
Becomes true if there was a failure. Makes this into an error object.
-
+
@type Boolean
@default NO
*/
@@ -67,7 +67,7 @@ SC.Response = SC.Object.extend(
@default null
*/
request: null,
-
+
/**
The request object that originated this request series. Mostly this is
useful if you are looking for a reference to the original request. To
@@ -83,7 +83,7 @@ SC.Response = SC.Object.extend(
return ret ;
}.property('request').cacheable(),
- /**
+ /**
Type of request. Must be an HTTP method. Based on the request.
@field
@@ -106,7 +106,7 @@ SC.Response = SC.Object.extend(
}.property('request').cacheable(),
/**
- If set then will attempt to automatically parse response as JSON
+ If set then will attempt to automatically parse response as JSON
regardless of headers.
@field
@@ -212,7 +212,7 @@ SC.Response = SC.Object.extend(
@default null
*/
timedOut: null,
-
+
/**
The timer tracking the timeout
@@ -224,7 +224,7 @@ SC.Response = SC.Object.extend(
// ..........................................................
// METHODS
- //
+ //
/**
Called by the request manager when its time to actually run. This will
@@ -241,7 +241,7 @@ SC.Response = SC.Object.extend(
req.freeze();
// if the source did not cancel the request, then invoke the transport
- // to actually trigger the request. This might receive a response
+ // to actually trigger the request. This might receive a response
// immediately if it is synchronous.
if (!this.get('isCancelled')) { this.invokeTransport(); }
@@ -410,10 +410,10 @@ SC.Response = SC.Object.extend(
handled = this._notifyListeners(listeners, status);
if (!handled && baseStat !== status) { handled = this._notifyListeners(listeners, baseStat); }
if (!handled && status !== 0) { handled = this._notifyListeners(listeners, 0); }
-
+
return this ;
},
-
+
/**
String representation of the response object
@@ -513,7 +513,7 @@ SC.XHRResponse = SC.Response.extend(
async = !!this.getPath('request.isAsynchronous');
if (async) {
- if (!SC.browser.msie && !SC.browser.opera) {
+ if (!SC.browser.isIE && !SC.browser.isOpera) {
SC.Event.add(rawRequest, 'readystatechange', this,
this.finishRequest, rawRequest);
} else {
@@ -614,7 +614,7 @@ SC.XHRResponse = SC.Response.extend(
}, this);
// Avoid memory leaks
- if (!SC.browser.msie && !SC.browser.opera) {
+ if (!SC.browser.isIE && !SC.browser.isOpera) {
SC.Event.remove(rawRequest, 'readystatechange', this, this.finishRequest);
} else {
rawRequest.onreadystatechange = null;
@@ -225,15 +225,15 @@ SC.detectBrowser = function(userAgent, language) {
@name SC.browser.isWindows
@type Boolean
*/
- browser.windows = browser.isWindows = browser.os === SC.BROWSER.windows;
+ browser.windows = browser.isWindows = browser.os === SC.OS.windows;
/** @deprecated Since version 1.7. Use browser.os === SC.OS.mac.
@name SC.browser.isMac
@type Boolean
*/
- browser.mac = browser.isMac = browser.os === SC.BROWSER.mac;
+ browser.mac = browser.isMac = browser.os === SC.OS.mac;
- /** @deprecated Since version 1.7. Use browser.os === SC.OS.mac && browser.compareVersion(browser.osVersion, 10.7) == 0
+ /** @deprecated Since version 1.7. Use browser.os === SC.OS.mac && browser.compare(browser.osVersion, '10.7') == 0
@name SC.browser.isLion
@type Boolean
*/
@@ -263,7 +263,7 @@ SC.detectBrowser = function(userAgent, language) {
*/
browser.iOS = browser.isiOS = browser.os === SC.OS.ios;
- /** @deprecated Since version 1.7. Use browser.os === SC.OS.android or browser.name === SC.BROWSER.android or browser.device === SC.BROWSER.android.
+ /** @deprecated Since version 1.7. Use browser.os === SC.OS.android or browser.name === SC.BROWSER.android or browser.device === SC.DEVICE.android.
@name SC.browser.isAndroid
@type Boolean
*/
@@ -287,13 +287,13 @@ SC.detectBrowser = function(userAgent, language) {
*/
browser.msie = browser.name === SC.BROWSER.ie ? browser.version : '0';
- /** @deprecated Since version 1.7. Use browser.name === SC.BROWSER.ie.
+ /** @deprecated Since version 1.7. Use browser.engine === SC.ENGINE.trident.
@name SC.browser.isIE
@type Boolean
*/
- browser.isIE = browser.name === SC.BROWSER.ie;
+ browser.isIE = browser.engine === SC.ENGINE.trident;
- /** @deprecated Since version 1.7. Use browser.compareVersion(browser.version, 8) <= 0.
+ /** @deprecated Since version 1.7. Use browser.compare(browser.version, '8') <= 0.
@name SC.browser.isIE8OrLower
@type Boolean
*/
@@ -11,38 +11,38 @@ SC.setupBodyClassNames = function() {
var el = document.body,
browser, platform, shadows, borderRad, classNames, style, ieVersion;
if (!el) return ;
-
+
browser = SC.browser.current ;
platform = SC.browser.windows ? 'windows' : SC.browser.mac ? 'mac' : 'other-platform' ;
style = document.documentElement.style;
- shadows = (style.MozBoxShadow !== undefined) ||
+ shadows = (style.MozBoxShadow !== undefined) ||
(style.webkitBoxShadow !== undefined) ||
(style.oBoxShadow !== undefined) ||
(style.boxShadow !== undefined);
-
- borderRad = (style.MozBorderRadius !== undefined) ||
+
+ borderRad = (style.MozBorderRadius !== undefined) ||
(style.webkitBorderRadius !== undefined) ||
(style.oBorderRadius !== undefined) ||
(style.borderRadius !== undefined);
-
+
classNames = el.className ? el.className.split(' ') : [] ;
if(shadows) classNames.push('box-shadow');
if(borderRad) classNames.push('border-rad');
classNames.push(browser, platform) ;
-
- ieVersion = parseInt(SC.browser.msie,10);
- if (ieVersion) {
- if (ieVersion === 7) {
+
+ ieVersion = SC.browser.engineVersion;
+ if (SC.browser.isIE) {
+ if (SC.browser.compare(ieVersion, '7') === 0) {
classNames.push('ie7');
- }
- else if (ieVersion === 8) {
+ }
+ else if (SC.browser.compare(ieVersion, '8') === 0) {
classNames.push('ie8');
}
- else if (ieVersion === 9) {
+ else if (SC.browser.compare(ieVersion, '9') === 0) {
classNames.push('ie9');
}
}
-
+
if(browser==="safari" || browser==="chrome") classNames.push('webkit');
if (SC.browser.mobileSafari) classNames.push('mobile-safari') ;
if ('createTouch' in document) classNames.push('touch');
@@ -82,15 +82,15 @@ SC.Event = function(originalEvent) {
var deltaMultiplier = SC.Event.MOUSE_WHEEL_MULTIPLIER;
// normalize wheelDelta, wheelDeltaX, & wheelDeltaY for Safari
- if (SC.browser.engine === SC.ENGINE.webkit && originalEvent.wheelDelta !== undefined) {
+ if (SC.browser.isWebkit && originalEvent.wheelDelta !== undefined) {
this.wheelDelta = 0-(originalEvent.wheelDeltaY || originalEvent.wheelDeltaX);
this.wheelDeltaY = 0-(originalEvent.wheelDeltaY||0);
this.wheelDeltaX = 0-(originalEvent.wheelDeltaX||0);
// normalize wheelDelta for Firefox (all Mozilla browsers)
// note that we multiple the delta on FF to make it's acceleration more
// natural.
- } else if (!SC.none(originalEvent.detail) && SC.browser.engine === SC.ENGINE.gecko) {
+ } else if (!SC.none(originalEvent.detail) && SC.browser.isMozilla) {
if (originalEvent.axis && (originalEvent.axis === originalEvent.HORIZONTAL_AXIS)) {
this.wheelDeltaX = originalEvent.detail;
this.wheelDeltaY = this.wheelDelta = 0;
@@ -101,7 +101,7 @@ SC.Event = function(originalEvent) {
// handle all other legacy browser
} else {
- this.wheelDelta = this.wheelDeltaY = SC.browser.name === SC.BROWSER.ie || SC.browser.name === SC.BROWSER.opera ? 0-originalEvent.wheelDelta : originalEvent.wheelDelta ;
+ this.wheelDelta = this.wheelDeltaY = SC.browser.isIE || SC.browser.isOpera ? 0-originalEvent.wheelDelta : originalEvent.wheelDelta ;
this.wheelDeltaX = 0 ;
}
@@ -650,7 +650,7 @@ SC.RootResponder = SC.Object.extend(
// handle special case for keypress- you can't use normal listener to block
// the backspace key on Mozilla
if (this.keypress) {
- if (SC.CAPTURE_BACKSPACE_KEY && SC.browser.mozilla) {
+ if (SC.CAPTURE_BACKSPACE_KEY && SC.browser.isMozilla) {
var responder = this ;
document.onkeypress = function(e) {
e = SC.Event.normalizeEvent(e);
@@ -667,7 +667,7 @@ SC.RootResponder = SC.Object.extend(
['drag', 'selectstart'].forEach(function(keyName) {
var method = this[keyName] ;
if (method) {
- if (SC.browser.msie) {
+ if (SC.browser.isIE) {
var responder = this ;
document.body['on' + keyName] = function(e) {
// return method.call(responder, SC.Event.normalizeEvent(e));
@@ -688,7 +688,7 @@ SC.RootResponder = SC.Object.extend(
var mousewheel = 'mousewheel';
// Firefox emits different mousewheel events than other browsers
- if (SC.browser.name === SC.BROWSER.firefox) {
+ if (SC.browser.isMozilla) {
// For Firefox < 3.5, subscribe to DOMMouseScroll events
if (SC.browser.compare(SC.browser.engineVersion, '1.9.1') < 0) {
mousewheel = 'DOMMouseScroll';
@@ -1598,7 +1598,7 @@ SC.RootResponder = SC.Object.extend(
keydown: function(evt) {
if (SC.none(evt)) return YES;
var keyCode = evt.keyCode;
- if(SC.browser.mozilla && evt.keyCode===9){
+ if(SC.browser.isMozilla && evt.keyCode===9){
this.keydownCounter=1;
}
// Fix for IME input (japanese, mandarin).
@@ -1619,7 +1619,7 @@ SC.RootResponder = SC.Object.extend(
}
// Firefox does NOT handle delete here...
- if (SC.browser.mozilla && (evt.which === 8)) return true ;
+ if (SC.browser.isMozilla && (evt.which === 8)) return true ;
// modifier keys are handled separately by the 'flagsChanged' event
// send event for modifier key changes, but only stop processing if this
@@ -1640,7 +1640,7 @@ SC.RootResponder = SC.Object.extend(
// processing.
// Arrow keys are handled in keypress for firefox
- if (keyCode>=37 && keyCode<=40 && SC.browser.mozilla) return YES;
+ if (keyCode>=37 && keyCode<=40 && SC.browser.isMozilla) return YES;
ret = this.sendEvent('keyDown', evt) ;
@@ -1668,9 +1668,9 @@ SC.RootResponder = SC.Object.extend(
keypress: function(evt) {
var ret,
keyCode = evt.keyCode,
- isFirefox = !!SC.browser.mozilla;
+ isFirefox = SC.browser.isMozilla;
- if(SC.browser.mozilla && evt.keyCode===9){
+ if(isFirefox && evt.keyCode===9){
this.keydownCounter++;
if(this.keydownCounter==2) return YES;
}
@@ -1916,7 +1916,7 @@ SC.RootResponder = SC.Object.extend(
return YES;
}
- if (SC.browser.msie) {
+ if (SC.browser.isIE) {
if (this._lastMoveX === evt.clientX && this._lastMoveY === evt.clientY) return;
}
@@ -1933,7 +1933,7 @@ SC.RootResponder = SC.Object.extend(
// drags send their own events, e.g. drag[Moved|Entered|Exited]
if (this._drag) {
//IE triggers mousemove at the same time as mousedown
- if(SC.browser.msie){
+ if(SC.browser.isIE){
if (this._lastMouseDownX !== evt.clientX || this._lastMouseDownY !== evt.clientY) {
this._drag.tryToPerform('mouseDragged', evt);
}
@@ -1980,7 +1980,7 @@ SC.RootResponder = SC.Object.extend(
// also, if a mouseDownView exists, call the mouseDragged action, if
// it exists.
if (this._mouseDownView) {
- if(SC.browser.msie){
+ if(SC.browser.isIE){
if (this._lastMouseDownX !== evt.clientX && this._lastMouseDownY !== evt.clientY) {
this._mouseDownView.tryToPerform('mouseDragged', evt);
}
@@ -11,7 +11,7 @@ var context = null;
// ..........................................................
// styles
-//
+//
module("SC.RenderContext#styles", {
setup: function() {
context = SC.RenderContext() ;
@@ -37,22 +37,22 @@ test("returns styles if set", function() {
test("clone on next retrieval if styles(foo) set with cloneOnModify=YES", function() {
var styles = { foo: 'bar' };
context.styles(styles, YES);
-
+
var result = context.styles();
ok(result !== styles, "styles is NOT same instance");
same(result, styles, "but styles are equivalent");
-
+
equals(result, context.styles(), "2nd retrieval is same instance");
});
test("extracts styles from element on first retrieval", function() {
var elem = document.createElement('div');
SC.$(elem).attr('style', 'color: black; height: 20px; border-top: 1px solid hotpink; -webkit-column-count: 3');
context = SC.RenderContext(elem);
-
+
var result = context.styles();
-
- if(SC.browser.msie){
+
+ if(SC.browser.isIE){
same(result, { color: 'black', height: '20px', borderTop: 'hotpink 1px solid', WebkitColumnCount: '3' }, 'extracted style. This is failing in IE8 because it return styles like cOLOR.');
}else{
same(result, { color: 'black', height: '20px', borderTop: '1px solid hotpink', WebkitColumnCount: '3' }, 'extracted style. This is failing in IE8 because it return styles like cOLOR.');
@@ -62,7 +62,7 @@ test("extracts styles from element on first retrieval", function() {
// ..........................................................
// addStyle
-//
+//
module("SC.RenderContext#addStyle", {
setup: function() {
context = SC.RenderContext().styles({ foo: 'foo' }) ;
@@ -86,7 +86,7 @@ test("should return receiver", function() {
test("should create styles hash if needed", function() {
context = SC.RenderContext();
equals(context._styles, null, 'precondition - has no styles');
-
+
context.addStyle('foo', 'bar');
equals('bar', context.styles().foo, 'has styles');
});
Oops, something went wrong.

0 comments on commit 2f10728

Please sign in to comment.