2011-07-17 08:05:43 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
2010-04-05 18:46:53 +00:00
|
|
|
var browserSingleton;
|
2011-08-10 09:51:24 +00:00
|
|
|
|
2010-09-22 21:37:17 +00:00
|
|
|
angularService('$browser', function($log){
|
2010-04-05 18:46:53 +00:00
|
|
|
if (!browserSingleton) {
|
feat($browser): jQuery style url method, onUrlChange event
This is just basic implementation of $browser.url, $browser.onUrlChange methods:
$browser.url() - returns current location.href
$browser.url('/new') - set url to /new
If supported, history.pushState is used, location.href property otherwise.
$browser.url('/new', true) - replace current url with /new
If supported, history.replaceState is used, location.replace otherwise.
$browser.onUrlChange is only fired when url is changed from the browser:
- user types into address bar
- user clicks on back/forward button
- user clicks on link
It's not fired when url is changed using $browser.url()
Breaks Removed $browser.setUrl(), $browser.getUrl(), use $browser.url()
Breaks Removed $browser.onHashChange(), use $browser.onUrlChange()
2011-06-22 17:57:22 +00:00
|
|
|
// TODO(vojta): inject $sniffer service when implemented
|
2011-01-05 01:54:37 +00:00
|
|
|
browserSingleton = new Browser(window, jqLite(window.document), jqLite(window.document.body),
|
feat($browser): jQuery style url method, onUrlChange event
This is just basic implementation of $browser.url, $browser.onUrlChange methods:
$browser.url() - returns current location.href
$browser.url('/new') - set url to /new
If supported, history.pushState is used, location.href property otherwise.
$browser.url('/new', true) - replace current url with /new
If supported, history.replaceState is used, location.replace otherwise.
$browser.onUrlChange is only fired when url is changed from the browser:
- user types into address bar
- user clicks on back/forward button
- user clicks on link
It's not fired when url is changed using $browser.url()
Breaks Removed $browser.setUrl(), $browser.getUrl(), use $browser.url()
Breaks Removed $browser.onHashChange(), use $browser.onUrlChange()
2011-06-22 17:57:22 +00:00
|
|
|
XHR, $log, {});
|
2010-04-06 03:53:33 +00:00
|
|
|
browserSingleton.bind();
|
2010-04-05 18:46:53 +00:00
|
|
|
}
|
|
|
|
|
return browserSingleton;
|
2010-12-09 00:52:08 +00:00
|
|
|
}, {$inject:['$log']});
|
2010-04-05 18:46:53 +00:00
|
|
|
|
2011-07-12 00:31:29 +00:00
|
|
|
|
2010-04-05 18:46:53 +00:00
|
|
|
extend(angular, {
|
2011-04-18 23:33:30 +00:00
|
|
|
// disabled for now until we agree on public name
|
|
|
|
|
//'annotate': annotate,
|
2010-04-05 18:46:53 +00:00
|
|
|
'compile': compile,
|
|
|
|
|
'scope': createScope,
|
|
|
|
|
'copy': copy,
|
|
|
|
|
'extend': extend,
|
2010-07-19 19:29:24 +00:00
|
|
|
'equals': equals,
|
2011-01-08 06:02:23 +00:00
|
|
|
'forEach': forEach,
|
Introduced injector and $new to scope, and injection into link methods and controllers
- added angular.injector(scope, services, instanceCache) which returns inject
- inject method can return, instance, or call function which have $inject
property
- initialize services with $creation=[eager|eager-publish] this means that
only some of the services are now globally accessible
- upgraded $become on scope to use injector hence respect the $inject property
for injection
- $become should not be run multiple times and will most likely be removed
in future version
- added $new on scope to create a child scope
- $inject is respected on constructor function
- simplified scopes so that they no longer have separate __proto__ for
parent, api, behavior and instance this should speed up execution since
scope will now create one __proto__ chain per scope (not three).
BACKWARD COMPATIBILITY WARNING:
- services now need to have $inject instead of inject property for proper
injection this breaks backward compatibility
- not all services are now published into root scope
(only: $location, $cookie, $window)
- if you have widget/directive which uses services on scope
(such as this.$xhr), you will now have to inject that service in
(as it is not published on the root scope anymore)
2010-10-09 00:30:13 +00:00
|
|
|
'injector': createInjector,
|
2010-04-05 18:46:53 +00:00
|
|
|
'noop':noop,
|
2010-04-15 21:17:33 +00:00
|
|
|
'bind':bind,
|
2010-07-20 23:55:32 +00:00
|
|
|
'toJson': toJson,
|
|
|
|
|
'fromJson': fromJson,
|
2010-04-05 18:46:53 +00:00
|
|
|
'identity':identity,
|
|
|
|
|
'isUndefined': isUndefined,
|
|
|
|
|
'isDefined': isDefined,
|
|
|
|
|
'isString': isString,
|
|
|
|
|
'isFunction': isFunction,
|
2010-05-07 19:09:14 +00:00
|
|
|
'isObject': isObject,
|
2010-04-05 18:46:53 +00:00
|
|
|
'isNumber': isNumber,
|
2011-07-12 00:31:29 +00:00
|
|
|
'isArray': isArray,
|
2011-08-24 14:58:07 +00:00
|
|
|
'version': version,
|
|
|
|
|
'isDate': isDate,
|
|
|
|
|
'lowercase': lowercase,
|
|
|
|
|
'uppercase': uppercase
|
2010-04-05 18:46:53 +00:00
|
|
|
});
|
|
|
|
|
|
2011-02-05 00:42:21 +00:00
|
|
|
//try to bind to jquery now so that one can write angular.element().read()
|
|
|
|
|
//but we will rebind on bootstrap again.
|
|
|
|
|
bindJQuery();
|
|
|
|
|
|
|
|
|
|
|