SproutCore 0.9.5
I just released SproutCore 0.9.5 today. Get it by running:
sudo gem update sproutcore
This includes some major new features for both the build tools and the JavaScript framework. Here is the list:
Build Tools
This release includes some major new functionality to support localization.
- Now you can load any localized version of your project simply by visiting http://localhost:4020/appname/lang. For example, to get the french version you might do: http://localhost:4020/appname/fr. This functionality was planned from the beginning but a few bugs kept it from functioning properly. Now it should work for your project.
- The build tools now support build-time localization. To localize a string in your RHTML files, just use the ruby code loc(”KeyName”). This works just like “KeyName”.loc() in the JavaScript world except that the key will be localized when your HTML file is built instead of later once the file is downloaded to the client. Just like the JavaScript, this helper will pull its localization key from the strings.js file found in your .lproj directories.
- In support of the build-time localization, the build tools now also support special build-only language keys. Any loc key beginning with “@@” in your strings.js file will be removed when the strings.js file is built for your web browser. This way you can add loc strings intended only for use at build time and they will not be sent to the web browser with the rest of the loc strings.
- Along the lines of localization, the build tools now automatically set the String.preferredLanguage property in your JavaScript to the current active language. This is different from String.browserLanguage, which returns the language that is auto-detected from the browser. The JavaScript loc() method has been updated to use the strings from the preferred language instead of the browser language by default.
- You can use the same URLs that will be used at production time to manually request resources and sc-server will build them for you. This makes it easy to reference resources without using the static_url() helper. This approach is not recommended but sometimes in is necessary for various reasons and now it will work.
- The build tools no longer automatically merge .html files into the index.html file. They only merge files ending in .rhtml and .html.erb. This allows you to include static .html files if you need.
JavaScript Framework
The framework now supports a variety of new features related to localization and a delegate for the collection view that can give you a way to provide fine grained control over how the collection view will handle drag and drop, deletion, etc:
- Collection View now supports selectOnMouseDown which can be turned off to provide better drag and drop behavior on SourceList. SC.SourceListView now turns this off by default.
- SC.CollectionView now supports selectAll (Ctrl+A)
- SC.CollectionView now supports the delete key to remove items. Also added delegate methods to the collection view delegate to give you control over how deletions happen.
- SC.window can now properly capture the backspace key in Firefox. To activate this feature you must declare SC.CAPTURE_BACKSPACE_KEY = YES in your core.js file. Capturing the backspace key will prevent the browser from going to previous page when the user hits backspace, which can lead to data loss. To capture this key, SC.window will directly set the document.onkeypress handler.
- SC.GridView now supports dropping ON items.
- SC.ListView now supports dropping ON items.
- Removed the try/catch() that was placed around property notifiers. This is not only faster but it will make it easier to debug these exceptions in Firebug and IE.
- [FIX] SC.InlineTextFieldView was using the _frame property even though that is used by a parent class. Changed to _optframe
- Improved some documentation here and there.
- [FIX] SC.View will recache its frames when isVisibleInWindow changes. This will help to ensure we always have the correct dimensions when bringing views on and offscreen. — All unit tests now pass again.
- Collection View now supports dropping items ON item views as well as between them.
- Collection Views now support a delegate object that can be used to control drag and drop and selection behavior. See mixins/collection_view_delegate.js for a complete description of the new methods.
- SC.ArrayController now supports the useControllersForContent property. If set to YES, then getting an objectAt() will return a controller for the value instead of the value itself. This is useful for those times you are using an array controller to manage a set of objects you want to control. Previously this feature was always used by array controllers and could not be disabled. This is now off by default.
- [FIX] SC.ArrayController and SC.ObjectController now will properly observe their own content, even when the content is set on init.
Other
Miscellaneous improvements to the packaging system and sample apps.
- Added mongrel as a required dependency of SproutCore. If you have something like thin installed this is technically not required, but several people were experiencing trouble installing the gem.
- Lots of Safari-specific features for Photos just to demo some of its capabilities. Client-side storage support is also provided but currently does not save changes you make.
- Initial changes to SampleControls to add a form-view demo. None of the controls are wired up yet.
- Improves Photos sample to include support for adding/deleting albums and drag and drop into albums.
