diff --git a/Core.Tests/Core.Tests.csproj b/Core.Tests/Core.Tests.csproj
index 93a6dc2..c2a80a5 100644
--- a/Core.Tests/Core.Tests.csproj
+++ b/Core.Tests/Core.Tests.csproj
@@ -30,8 +30,8 @@
4
-
- ..\packages\NUnit.3.0.1\lib\net45\nunit.framework.dll
+
+ ..\packages\NUnit.3.2.1\lib\net45\nunit.framework.dllTrue
@@ -66,10 +66,10 @@
PreserveNewest
- PreserveNewest
+ PreserveNewest
diff --git a/Core.Tests/packages.config b/Core.Tests/packages.config
index b183023..1ff5a2d 100644
--- a/Core.Tests/packages.config
+++ b/Core.Tests/packages.config
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/Core/Core.csproj b/Core/Core.csproj
index b257d4c..ca5b09b 100644
--- a/Core/Core.csproj
+++ b/Core/Core.csproj
@@ -30,12 +30,12 @@
4
-
- ..\packages\AutoMapper.4.2.0\lib\net45\AutoMapper.dll
+
+ ..\packages\AutoMapper.4.2.1\lib\net45\AutoMapper.dllTrue
- ..\packages\CsvHelper.2.13.2.0\lib\net40-client\CsvHelper.dll
+ ..\packages\CsvHelper.2.14.2\lib\net45\CsvHelper.dllTrue
@@ -55,7 +55,7 @@
True
- ..\packages\NLog.4.2.3\lib\net45\NLog.dll
+ ..\packages\NLog.4.3.3\lib\net45\NLog.dllTrue
diff --git a/Core/packages.config b/Core/packages.config
index 527df52..506c342 100644
--- a/Core/packages.config
+++ b/Core/packages.config
@@ -1,10 +1,10 @@
-
-
+
+
-
+
\ No newline at end of file
diff --git a/Web.Tests/Web.Tests.csproj b/Web.Tests/Web.Tests.csproj
index 6a8cebf..979ee30 100644
--- a/Web.Tests/Web.Tests.csproj
+++ b/Web.Tests/Web.Tests.csproj
@@ -30,8 +30,8 @@
4
-
- ..\packages\NUnit.3.0.0\lib\net45\nunit.framework.dll
+
+ ..\packages\NUnit.3.2.1\lib\net45\nunit.framework.dllTrue
diff --git a/Web.Tests/app.config b/Web.Tests/app.config
index 3a4dafb..df675d5 100644
--- a/Web.Tests/app.config
+++ b/Web.Tests/app.config
@@ -10,6 +10,10 @@
+
+
+
+
\ No newline at end of file
diff --git a/Web.Tests/packages.config b/Web.Tests/packages.config
index 653bfb7..1ff5a2d 100644
--- a/Web.Tests/packages.config
+++ b/Web.Tests/packages.config
@@ -1,4 +1,4 @@
-
+
\ No newline at end of file
diff --git a/Web/App_Start/BundleConfig.cs b/Web/App_Start/BundleConfig.cs
index ca89069..2a6b3cf 100644
--- a/Web/App_Start/BundleConfig.cs
+++ b/Web/App_Start/BundleConfig.cs
@@ -1,4 +1,5 @@
-using Backload.Bundles;using System.Web.Optimization;
+using System.Web.Optimization;
+using Backload.Bundles;
namespace LeafWeb.Web.App_Start
{
diff --git a/Web/Backload/Config/Web.Backload.xsd b/Web/Backload/Config/Web.Backload.xsd
index fd13164..46e93e9 100644
--- a/Web/Backload/Config/Web.Backload.xsd
+++ b/Web/Backload/Config/Web.Backload.xsd
@@ -2,22 +2,48 @@
-
+
- Basic settings for the Backload. component library. TIP: You do not need to include any of these setting in your web.config or external config file, if these default settings suit your needs.
+ Basic settings for the Backload component library. TIP: You do not need to include any of these setting in your web.config or external config file, if these default settings suit your needs.
- Sets the attributes for Filesystem storage
+ Sets the attributes for filesystem storage
- Root upload folder. If the value starts with '~/' (e.g. ~/files) the path is relative to the web root, otherwise set an absolute local path (e.g. d:/files) [Default: "~/Files"]
- Special subfolder within the filesRoot to store user related files like photos etc. Set it to usersRoot="" if you do not need this subfolder [Default: ""]
+ Root upload folder. If the value starts with '~/' (e.g. ~/files) the path is relative to the web application root, otherwise set an absolute local path (e.g. d:\files) and also set a the virtual path name in the "virtualDirectory" attribute [Default: "~/Files"]
+ Name of virtual directory in your IIS application to an external storage location (unc or full file system path). If filesRoot is relative to the web application root (starts with '~/', see filesRoot), you do not need to set this value. If filesRoot is an absolute path, you usually set a virtual path in IIS to this external location. In this case, the virtualDirectory attribute must be set to the name of the virtual path and filesRoot to the external path. Example: If the virtual path is z:\files and the name is "files", set filesRoot="z:\files" and virtualDirectory="/files" [Default: "/"]Subfolder within the filesRoot. Set it to objectsRoot="" if you do not need a subfolder [Default: ""]Root of a folder where Backload stores a copy of an uploaded file, if set to a none empty string. If the value is empty ("") not copies are stored. If the value starts with '~/' (e.g. ~/copies) the path is relative to the web root. if the value not starts with '~/' and it isn't an absolute local path, the value will be treated as a subfolder to filesRoot ('copies' -> ~/files/copies). Otherwise set an absolute local path (e.g. d:/backup) [Default: ""]
- Temporäry folder prefix if file chunks are uploaded into the upload folder before they are merged [Default: "_____"].
+ Temporäry folder prefix if file chunks are uploaded into the upload folder before they are merged [Default: "$$"].
+ Subfolder for supporting files (previews, mappings, etc). If "auxFilesFolder" is not empty (e.g. auxFilesFolder="_aux") supporting files will be stored in an external path ([filesRoot]\[auxFilesFolder]\). In this case the main upload directories only contain the uploaded files. [Default: ""].
+
+
+
+
+ Provides setting for database configuration. Supports codeless storage (no application code needed), Entity Framework, Sql FileStreams, Sql FileTables and external file storage (filesystem).
+
+
+ Name of the database connection (see Web.config). Can also be a connection string. [Default: "FilesContext"]
+ Name of the underlying database table [Default: "Files"]
+ Name of the SqlFileTable if a SqlFileTable is running on Sql Server. In a SqlFileTable, files will be stored outside of the database file in a filesystem directory, but managed by the database engine. This allows to store very large files. In contrast to SqlFileStreams, SqlFileTable files can be accessed, created and deleted directly within the file system as normal files. This allows us for example to copy a file with the explorer to the FileTable's directory in the file system where Sql Server catches the file and manages it. When you create a virtual path in IIS to the FileTable directory in the filesystem, A client can download the files in the SqlFileTable directly from the browser. FileTables (SQL Server). [Default: "FileTable"].
+ Defines if files are stored within the database file or as SqlFiieStream. SqlFIleStreams are stored outside of the database file as blob within the file system, but they are managed by the database engine. When using SqlFileStreams, SQL Server and the database must enable the SqlFileStream feature. More info: FILESTREAM (SQL Server). [Default: "Internal"]
+
+
+ Files will be stored within the database (default).
+ Files will be stored as SqlFileStream outside of the database file in a filesystem directory, but managed by the database engine. This allows us to store very large files. More info: FILESTREAM (SQL Server). Unlike SqlFileTable, files (blobs) cannot be accessed directly on the file system.
+ Like SqlFileStreams, files will be stored in a SqlFileTable outside of the database file in a filesystem directory, but managed by the database engine. This allows us to store very large files. More info: FileTables (SQL Server). Unlike SqlFileStreams FileTable files can be accessed, created and deleted within the file system as normal file. This allows us for example to copy a file with the explorer to the FileTable's directory in the file system where Sql Server catches the file and manages it. You can also enable a client to directory download the file if you create a virtual path from IIS to the FileTable directory.
+ Files will be stored on the filesystem. A virtual path in the database points to the file.
+
+
+
+ Storage mode "SqlFileTable" or "FileSystem" only. This setting is only needed if direct download of files is enabled in the configuration with the setting filesUrlPattern="{url}" (default: {backload}). Note: Direct download of files is only available in the storage modes "SqlFileTable" and "FileSystem", because in these modes files are stored as regular files on the file system. As in standard filesystem storage, VirtualDirectory needs to be set as the name of a virtual directory in IIS or an absolute url //if the file system to download files is outside the web application (e.g. UNC shares). VirtualDirectory represents the name of virtual path in your IIS application to an external storage location. If filesRoot is relative to the web application root (starts with '~/', see filesRoot), you do not need to set this value. If filesRoot is an absolute path, you usually set a virtual path in IIS to this external location. In this case, the virtualDirectory attribute must be set to the name of the virtual path and filesRoot to the absolute path. Example: If the virtual path is z:\files and the name is "files", set filesRoot="z:\files" and virtualDirectory="/files" [Default: "/"]
+ Root path of the file directory when using external file storage (storageMode: SqlFileTable or FileSystem) (SqlFileTable example: "\\Server\SQLEXPRESS\FILES\Uploads\" where "FILES" is the database and "Uploads" is the name of the SqlFileTable.) (FilePath example: z:\Uploads). NOTE: If rootPath is not configured in storageMode "SqlFileTable", rootPath will be automatically retrieved from Sql Server. [Default: "~/Files"]
+ If set to a none empty string, this setting is used to store file chunks, before the full uploaded file will be stored into the database. If you use chunked file uploads, it is recommend to store the chunks in a temporary directory to get best performance. (Examples: "~/Files/Temp/" (app relative), "z:\dbstorage\temp\" (absolute), "\\server\dbstorage\temp\" (unc)) [Default: ""]
+ If the data model has different column names than the defaults (e.g. FileId instead of the default Id), a column mapping for column names can be set. Example: columnMapping="{Id=FileId,Name=FileName,Original=OriginalName}". See also the database demo package. [Default: ""]
+ Name of the plugin file, e.g. extension="Backload.Plugin.Database.dll". If this is an empty string the extension name will be automatically set to: "Backload.Plugin.Database.dll [Default: "Backload.Plugin.Database.dll"]
@@ -25,8 +51,23 @@
Sets the attributes for cloud storage
-
-
+
+
+
+ Microsoft Azure File storage settings
+
+
+ Root upload folder. If the value starts with '~/' (e.g. ~/files) the path is relative to the web application root, otherwise set an absolute local path (e.g. d:\files) and also set a the virtual path name in the "virtualDirectory" attribute [Default: "~/Files"]
+ Name of virtual path in your IIS application to an external storage location (unc or full file system path). If filesRoot is relative to the web application root (starts with '~/', see filesRoot), you do not need to set this value. If filesRoot is an absolute path, you usually set a virtual path in IIS to this external location. In this case, the virtualDirectory attribute must be set to the name of the virtual path and filesRoot to the external path. Example: If the virtual path is z:\files and the name is "files", set filesRoot="z:\files" and virtualDirectory="/files" [Default: "/"]
+ Special subfolder within the filesRoot to store user related files like photos etc. Set it to usersRoot="" if you do not need this subfolder [Default: ""]
+ Subfolder within the filesRoot. Set it to objectsRoot="" if you do not need a subfolder [Default: ""]
+ Root of a folder where Backload stores a copy of an uploaded file, if set to a none empty string. If the value is empty ("") not copies are stored. If the value starts with '~/' (e.g. ~/copies) the path is relative to the web root. If the value not starts with '~/' and it isn't an absolute local path, the value will be treated as a subfolder to filesRoot ('copies' -> ~/files/copies). Otherwise set an absolute local path (e.g. d:/backup) [Default: ""]
+ Temporary folder prefix if file chunks are uploaded into the upload folder before they are merged [Default: "$$"].
+ Subfolder for supporting files (previews, mappings, etc). If "auxFilesFolder" is not empty (e.g. auxFilesFolder="_aux") supporing files will be stored in an external path ([filesRoot]\[auxFilesFolder]\). In this case the main upload directories only contain the uploaded files. [Default: ""].
+ Name of the plugin file, e.g. extension="Backload.Plugin.AzureFileStorage.dll". If this is an empty string the extension name will be automatically set to: "Backload.Plugin.AzureFileStorage.dll [Default: "Backload.Plugin.AzureFileStorage.dll"]
+
+
+ Microsoft Azure Blob storage settings
@@ -41,12 +82,47 @@
No public access.Anyone with the url can get or list, but not store or delete files.
- Ad-hoc shared access signature (SAS). Storage access requires a valid access token.
+ Ad-hoc shared access signature (SAS). Storage access requires a valid access token [Default].A shared (stored) access policy will be used. Define a name of the stored policy within the storedPolicyName attribute. Note: Note: Your code is responsable to renew the policy before it expires!
+ Sets the container existence checking and auto creation behavior [Default: "auto"]
+
+
+ Container existence is verified on first access, created it if neccessary, after that assumed that the container exists (Default).
+ Verify container exsistence on every request and try to create it if it not exists.
+ No checks for container exsistence. The containers (files, previews, [archives]) must be available (pre-created) on a request.
+
+
+ If accessType is set to "storedPolicy", this is the name of the shared access policy. Note: Your code is responsable to renew the policy before it expires! [Default: "backload"]
+ Name of the plugin file, e.g. extension="Backload.Plugin.AzureBlobStorage.dll". If this is an empty string the extension name will be automatically set to: "Backload.Plugin.AzureBlobStorage.dll [Default: "Backload.Plugin.AzureBlobStorage.dll"]
+
+
+
+
+
+ Google Drive storage settings
+
+ Azure Storage Service connection string name, usually located in the .cscfg file or Web.config. If this is an empty string, the local storage emulator will be used [Default: "StorageConnectionString"]
+ Name of the files upload container. Example: uploadContainer="files". Must start with a lowercase letter. Automatically created if it doesn't exist [Default: "files"]
+ Azure Storage Service connection string name, usually located in the .cscfg file or Web.config. If this is an empty string, the local storage emulator will be used [Default: "StorageConnectionString"]
+ Virtual subfolder within the uploadContainer. Set it to objectsRoot="" if you do not need a subfolder [Default: ""]
+ Sas access type only. Time period (in minutes) before the shared access token expires. [Default: "60"]
+ Sas access type only. Time period (in minutes) before the shared access token expires. [Default: "60"]
+ Root upload folder. [Default: "Files"]
+ Subfolder within the filesRoot. Set it to objectsRoot="" if you do not need a subfolder [Default: ""]
+ Public access type to the uploaded files [Default: "token"]
+
+
+ All files are stored on a central Google Drive accout in the same upload folder. All users have access to all uploaded files.
+ All files are stored on a central Google Drive accout into an user individual folder. User only has access to his uploaded files.
+ Files are stored in the users Google Drive account. The user must have a Google Drive account.
+
+
+
+ Name of the plugin file, e.g. extension="Backload.Plugin.GoogleDrive.dll". If this is an empty string the extension name will be automatically set to: "Backload.Plugin.GoogleDrive.dll [Default: "Backload.Plugin.GoogleDrive.dll"]
@@ -54,10 +130,11 @@
Microsoft Azure Blob storage provider
+ Microsoft Azure File storage provider
+ Google Drive storage provider
- Name of the extension file, e.g. extension="Backload.Plugin.AzureBlobStorage.dll". If this is an empty string the extension name will be automatically set to: "Backload.Plugin.[serviceProvider].dll [Default: ""]
@@ -74,10 +151,10 @@
Setting for the handling of uploaded images.
- Width or max width (depends on resizeMode) of the resulting image [Range: 20-5000, Default: "1024"]
- Height or max height (depends on resizeMode) of the resulting image [Range: 20-5000, Default: "768"]
- Resolution of the resulting image (dots per inch) [Range: 72-600, Default: "96"]
- Background color of the canvas. Only used when resize mode is fit and the image ratio of the source and target image differ. You can also use argb (rgb with alpha channel, e.g. background: #00ffffff (transparent), #80ffffff (white, 50% transparency), #ffffffff (white, opaque)) [Default: #ffffff]
+ Width or max width (depends on resizeMode) of the resulting image [Range: 1-100000, Default: "1024"]
+ Height or max height (depends on resizeMode) of the resulting image [Range: 1-100000, Default: "768"]
+ Resolution of the resulting image (dots per inch). If set to -1 resolution of the original image is used. [Range: 1-2400, Default: "96"]
+ Background color of the canvas. Only used when resize mode is fit and the image ratio of the source and target image differ. You can also use argb (rgb with alpha channel, e.g. background: #00ffffff (transparent), #80ffffff (white, 50% transparency), #ffffffff (white, opaque)) [Default: #ffffff]Sets the resize mode if the image should be resized into a max width or height canvas [Default: "none"]
@@ -99,6 +176,7 @@
Files with .tif or .tiff extensionFiles with .gif extensionMicrosoft bitmap format.
+ JPEG extended range (MS Photo) format
@@ -121,10 +199,11 @@
Setting for the handling of thumbnails.
+ If set to "true" (default), preview images are stored physically. If this attribute is set to false and you request preview images (e.g. in a plugin ui) thumbnails have to be created on every request. If you usually use preview images it is recommed to set this attribute to "true". [Default: "true"]Location of the thumbnail subfolder within the folder where the main file is stored (thumbnails only). Set to an empty string (path="") to avoid physical storage. [Default: "_thumbs"]
- Width or max width (depends on resizeMode) of the resulting thumbnail [Range: 20-500, Default: "80"]
- Height or max height (depends on resizeMode) of the resulting thumbnail [Range: 20-500, Default: "60"]
- Resolution of the resulting thumbnail (dots per inch) [Range: 72-600, Default: "96"]
+ Width or max width (depends on resizeMode) of the resulting thumbnail [Range: 16-10000, Default: "80"]
+ Height or max height (depends on resizeMode) of the resulting thumbnail [Range: 16-10000, Default: "60"]
+ Resolution of the resulting thumbnail (dots per inch) If set to -1 resolution of the original image is used. If set to -1 resolution of the original image is used. [Range: 72-2400, Default: "96"]Background color of the canvas. Only used when resize mode is fit and the image ratio of the source and target image differ. You can also use argb (rgb with alpha channel, e.g. background: #00ffffff (transparent), #80ffffff (white, 50% transparency), #ffffffff (white, opaque)) [Default: #ffffff]Sets the resize mode if the thumbnail should be resized into a max width or height of a thumbnail canvas [Default: "place"]
@@ -241,9 +320,10 @@
Name of an external config file [Default: "Web.Backload.config"]
- In your custom code you can bind a handler to events. If set to true (default), events will be fired [Default="false"].
+ In your custom code you can bind a handler to events. If set to true (default), events will be fired [Default: false].
+ Enables tracing support. Note that tracing consumes some system resources and should only be enabled during development or to find errors in production. [Default: false].Max length of a base64 encoded embedded data url. Only required if a url pattern is set to return a base64 string (e.g. thumbsUrlPattern="{base64}") [Default="1000"].
- This attribute sets the pattern of the url for the DELETE request returned back to the client in order to delete the file. You can use the shortcuts described in the config file. If you do not set this attribute, a link to the Backload component is returned by default. If you do not want to return a url, set this to an empty string or use the shortcut {none} (e.g. deleteUrlPattern="{none}" [Default="{Backload}"].
+ This attribute sets the pattern of the url for the DELETE request returned back to the client in order to delete the file. You can use the shortcuts described in the config file. If you do not set this attribute, a link to the Backload component is returned by default. If you do not want to return a url, set this to an empty string or use the shortcut {none} (e.g. deleteUrlPattern="{none}" [Default="{backload}"].By default the internal file upload handler is running and ready to receive incoming files or requests. This enables us zero configuration. If you want to set up your own controller in order to do some business logic, set this to "false". [Default: "true"]This setting determines the behaviour, if a file in a GET or DELETE request is not found [Default: "auto"]
@@ -257,14 +337,14 @@
This attribute sets the pattern of the url (File) returned back to the client in order to download the file. You can use the shortcuts described in the config file. If you do not set this attribute, a direct link is returned by default. If you do not want to return a url, set this to an empty string or use the shortcut {none} (e.g. thumbsUrlPattern="{none}" [Default="{url}"].On a GET request (return links to uploaded files) only the upload root folder (default filesRoot) is searched for uploaded files. Set to true in order to include subfolders. (Example: A content-type specific subfolder is set to "pdffiles" the search will find files within this subfolder. There are several ways set up subfolders, e.g. uploadContext and objectContext) [Default: "false"]Only applies if you use the uniqueFileNames option. If set to true, the original file name will be stored (subfolder: _mappings) [Default: "false"]
- Defines the default Json output format. You can overwrite the Json output within your OutgoingResponse extension. See examples [Default: "JQueryFileUpload"]
+ Defines the default Json output format. You can overwrite the Json output in your code or within the OutgoingResponseCreated event. See examples [Default: "JQueryFileUpload"]Generates Json for the jQuery FileUpload plugin from blueimp [Default]Generates Json for the PlUpload plugin from MoxiecodeGenerates Json for the Fine Uploader from Widen Enterprises
- Send a (not case sensitive) plugin=[JQueryFileUpload|PlUpload|Custom] querystring with your request (Example: plugin=plupload). This the same as the extensions by convetion based approach to select extensions (See example 09)
- Does not generate an output before calling the OutgoingResponse extension manager. You have to generate your own output in an OutgoingResponse extension. Otherwise Backload returns a Json null string to the client.
+ Send a (not case sensitive) plugin=[JQueryFileUpload|PlUpload|Custom] querystring with your request (Example: plugin=plupload). Because this is request based you can change the JSON output with every ajax request.
+ Does not generate an output before calling the OutgoingResponseCreated event and you have to generate your own output in this event.
@@ -277,17 +357,26 @@
- Files may be stored in the file system or in a cloud storage [Default: "Filesystem"]
+ Files may be stored in the file system or in a cloud storage [Default: "Filesystem"]
- Saves uploaded files in the file system (or SMB/unc shared folder) [Default]
+ Saves uploaded files in the file system (or SMB/unc shared folder) [Default]
+ Saves uploaded files to a database and enables the database configuration element. Supports codeless storage (no application code needed), Entity Framework, Sql FileStreams, Sql FileTables and external file storage (filesystem).Saves uploaded files to a cloud storage.This attribute sets the pattern of the url (Thumbnail) returned back to the client in order to download the thumbnail. You can use the shortcuts described in the config file. If you do not set this attribute, a direct link is returned by default. If you do not want to return a url, set this to an empty string or use the shortcut {none} (e.g. thumbsUrlPattern="{none}" [Default="{url}"].Generates unique file names based on guids [Default: "false"]
- Leave this an empty string, if filesRoot is relative to the web root (starts with '~/', see filesRoot). If filesRoot is an absolute local path (see filesRoot), the Backload handler cannot calculate a web path. Only in this case you must set an absolute web url to the files root, in order a correct filestpath can returned (e. g. "http://myfiles.filestore.com/files/" [Default: ""]
+ Obsolete. Use "virtualDirectory" in the FileSystem element instead. This attribute will be removed in a future release.
+ If set to "global" (default) the IWebConfig configuration instance in IFile_config is static, so if a property is changed in code (e.g. event handler), all subsequent requests use the new setting. If set to "request" a property change in code is only available in this single request. Other concurrent or subsequest requests use the original (global) setting.
+
+
+ IFile_config returns the global settings used in all reuqests
+ IFile_config returns a request based configuration instance. Note: The GlobalConfig property in IFile_config has a reference to the global configuration.
+
+
+
\ No newline at end of file
diff --git a/Web/Backload/Config/_Defaults/Defaults.txt b/Web/Backload/Config/_Defaults/Defaults.txt
index 1f57fd4..1f8a148 100644
--- a/Web/Backload/Config/_Defaults/Defaults.txt
+++ b/Web/Backload/Config/_Defaults/Defaults.txt
@@ -1,203 +1,264 @@
-
-
+CLIENT SIDE AND SERVER SIDE SETTINGS
+Server side settings: filesRoot, objectsRoot and content type specific subfolders (see "Settings and Default Values" below):
+filesRoot is the root folder for all uploads. objectsRoot is a subfolder an can be ignored if you do not need it.
+Set up content type specific sub folders, if you want to filter and store files of a specific content into separate subfolders. Example: Store images into an images subfolder (content-types: images/jpeg, images/png, etc. typeFragment: images/). See also example in the contentTypes section.
+Client side parameters: objectContext and uploadContext (see Example):
+The parameters objectContext and uploadContext are optional client side parameters). You do not have to include them in the request.
+Basically they influence the storage location on the server, regardless if it is a database or folder structure.
+
+Example:
+You want to set up an artist library were users are able to store content (songs, images, videos, other files).
+You want to store the different content in separate subfolders of a root artist folder, where any content belongs to this specific artist is stored.
+Your servers folder structure: [filesRoot]/[objectsRoot]/[objectContext]/[uploadContext] (e.g. ~/files/artists/michealjackson/videos) where [filesRoot] and [objectsRoot] are set up server side in the Web.Backload.config file.
+ObjectContext will be the artist. It must be a unique name (e.g. michealjackson) or an id. Any uploaded files related to this artist will be stored within a location of this unique id or name.
+UploadContext values are the different content types in this example (e.g. songs, images, videos, other) and result into a subfolder.
+The client side parameters (objectContext, uploadContext and fileName) can be send in the url as a querystring or in the body (form) and will be used by the server side handler to determine the storage location.
+Note: The subfolder structure can be even more complex: uploadContext supports subfolders within subfolders (e.g. /songs/mp3, /songs/wav, etc.). Simply separate the subfolders by semicolon. Use this example pattern as the value of uploadContext: uploadContext="songs;mp3" or uploadContext="documents;pdf".
+Note also: You can also set up automatic storage into content type specific subfolders where Backload stores files based on their content type (e.g. pdf files into a "documents" subfolder) (see below).
+
+
+SETTINGS AND DEFAULT VALUES (2.2):
-
-
+
+ backload: // Basic settings for the Backload component library. TIP: You do not need to include any of these setting in your web.config or external config file, if these default settings fit your needs.
+ storageContext: // Files can be stored in the file system to a cloud storage or to a database [Default: "Filesystem"]
+ Filesystem // Saves uploaded files in the file system (or SMB/unc shared folder) [Default]
+ CloudStorage // Saves uploaded files to a cloud storage and enables the coud configuration element.
+ Database // Saves uploaded files to a database and enables the database configuration element. Supports codeless storage (no application code needed), Entity Framework, Sql FileStreams, Sql FileTables and external file storage (filesystem).
+ eventing // In your custom code you can bind an handler to events. If this option is set to true, events will be fired [Default="false"].
+ tracing // Enables tracing support. Note that tracing consumes some system resources and should only be enabled during development or to find errors in production. [Default: false].
+ enableIntegratedHandler // By default the internal file upload handler is running and ready to receive incoming files or requests. This enables us zero configuration. If you want to set up your own controller in order to do some business logic, set this to "false". [Default: "true"]
+ webFilesRoot // Obsolete. Use "virtualDirectory" in the FileSystem or database element instead. This attribute will be removed in a future release.
+ uniqueFileNames // Generates unique file names based on guids [Default: "false"]
+ keepOrgFileNames // Only applies, if you use the uniqueFileNames option. If set to true, the original file name will be stored (subfolder: _mappings) [Default: "false"]
+ getInclSubFolders // On a GET request (return links to uploaded files) only the upload root folder (default filesRoot) is searched for uploaded files. Set to true in order to include subfolders. (Example: A content-type specific subfolder is set to "pdffiles" the search will find files within this subfolder. There are several ways set up subfolders, e.g. uploadContext and objectContext) [Default: "false"]
+ returnExtraInfo // We use this setting, to return internal information for the jQuery File Upload Plugin. If you do not want this, set it to "none" [Default: "basic"]
+ plugin // Defines the default Json output format. You can overwrite the Json output within the OutgoingResponseCreated event. See examples [Default: "Auto"]
+ JQueryFileUpload // Generates Json for the jQuery FileUpload plugin from blueimp [Default].
+ PlUpload // Generates Json for PlUpload plugin from Moxiecode.
+ FineUploader // Generates Json for the Fine Uploader from Widen Enterprises
+ Auto // Send a plugin=[JQueryFileUpload|PlUpload|Custom] querystring (not case sensitive) with your request (Example: plugin=plupload). Because this is request based you can change the JSON output with every ajax request.
+ Custom // Does not generate an output before calling the OutgoingResponseCreated event and you have to generate your own output in this event.
+ base64MaxSize // Max length of a base64 encoded embedded data url. Only required if a url pattern is set to return a base64 string in kb (e.g. thumbsUrlPattern="{base64}") [Default="1000" = 1MB].
+ deleteUrlPattern,
+ fileUrlPattern,
+ thumbsUrlPattern: // This attribute sets the pattern of the url returned back to the client in order to download or delete a file. You can use the shortcuts described below. If you do not set this attribute, a direct link is returned by default. If you do not want to return a url, set this to an empty string or use the shortcut {none} (e.g. thumbsUrlPattern="{none}" [Default (GET):"{url}", Default (DELETE):"{backload}"].
+ [not set],{url} // If you want a direct link to download the file, do NOT set this value or set the shortcut {url} (e.g. fileUrlPattern="{url}". You do not need to set this value as this is the default for GET requests (DELETE requests: if not set {backload} is the default).
+ [empty],{none} // If you do not want a url to be returned for GET or DELETE requests, set this attribute to an empty string or use the shortcut {none} (e.g. fileUrlPattern="").
+ {backload} // If you want the file to be returned/deleted by the Backload component, set it to the shortcut {backload} (Default for the deleteUrlPattern. An explicit file single file request (GET/DELETE with a filename) will now be handled as any other request by the Backload component. You can use your extensions like you are used to. We added an additional extension for the Get file requests: IGetFileRequest. Backloads internal handler has the following pattern (see below) fileUrlPattern="~/Backload/UploadHandler?{fileName}&{objectContext}&{uploadContext}&{content} (empty values are not send back). "{Backload}" is the default for the deleteUrlPattern.
+ [pattern] // You can define your own pattern for urls returned to the client, for example if you want to use your own download handler.
+ // Use the shortcuts below (Example: thumbsUrlPattern="http://downloads.myweb.com?file={fileName}&path={full}&preview&foo={query:bar}")
+ // "~/": Relative to web root (Replacement example http://localhost/).
+ // {name}: Resolves to name of the file (Example:{name} => somepic.jpg).
+ // {fileName}: Resolves to name of the file as a full query (Example:{fileName} => fileName=somepic.jpg).
+ // {original}: Resolves to original name of the file (can be used when the name has changed dureing processing) (Example:{originalName} => originalname.jpg).
+ // {originalName}: Resolves to original name of the file (can be used when the name has changed dureing processing) as a full query (Example:{originalName} => fileName=originalname.jpg).
+ // {root}: Resovles to relative root storage folder path (Replacement example: files/uploads/)
+ // {objectContext} If you send an objectContext with your request, this will be the value of the objectContext parameter (see examples for more on this)
+ // {uploadContext} If you send an uploadContext with your request, this will be the value of the uploadContext parameter(see examples for more on this)
+ // {content} For a content type subfolders, if you set up this feature
+ // {full} Shortcut for [root]/[objectContext]/[uploadContext]/[content]/
+ // {base64} Encodes the data (bytes) as a base64 string and includes it in the JSON response. Limited to 256 kb file size, switches to {Backload} if bigger. Saves file requests but blows up the JSON output (not deleteUrlPattern).
+ // {query:all} If you send custom querystrings along with your request all will be returned in the url.
+ // {query:key} The custom querystring with this key will be returned. (Example: {query:foo} => &foo=bar)
+ xmlns:*, xsi:* // No custom setting. Used for schema validation and Visual Studio intellisence.
+
+
+
+
+
+
+
+ fileSystem: // Sets the parameters for the dedicated storage location Filesystem or Database (EntityFramework):
+ filesRoot // Root upload folder. If the value starts with '~/' (e.g. ~/files) the path is relative to the web application root, otherwise set an absolute local path (e.g. d:\files) and also set a virtual path name in the "virtualDirectory" attribute [Default: "~/Files"]
+ objectsRoot // Subfolder within the filesRoot. Set it to objectsRoot="" if you do not need a subfolder [Default: ""].
+ copiesRoot // Root of a folder where Backload stores a copy of an uploaded file, if set to a none empty string. If the value is empty ("") not copies are stored. If the value starts with '~/' (e.g. ~/copies) the path is relative to the web root. If the value not starts with '~/' and it isn't an absolute local path, the value will be treated as a subfolder to filesRoot ('copies' -> ~/files/copies). Otherwise set an absolute local path (e.g. d:/backup) [Default: ""].
+ chunkPathPrefix // Temporary folder prefix if file chunks are uploaded into the upload folder before they are merged [Default: "$$"].
+ virtualDirectory // Name of virtual directory in your IIS application to an external storage location (unc or full file system path). If filesRoot is relative to the web application root (starts with '~/', see filesRoot), you do not need to set this value. If filesRoot is an absolute path, you usually set a virtual path in IIS to this external location. In this case, the virtualDirectory attribute must be set to the name of the virtual path and filesRoot to the external path. Example: If the virtual path is z:\files and the name is "files", set filesRoot="z:\files" and virtualDirectory="/files" [Default: "/"]
+ auxFilesFolder // Subfolder for supporting files (previews, mappings, etc). If "auxFilesFolder" is not empty (e.g. auxFilesFolder="_aux") supporting files will be stored in an external path ([filesRoot]\[auxFilesFolder]\). In this case the main upload directories only contain the uploaded files. [Default: ""].
+
+
+
+
+
+
+ database: // Provides setting for database configuration. Supports codeless storage (no application code needed), Entity Framework, Sql FileStreams, Sql FileTables and external file storage (filesystem).
+ connection // Name of the database connection (see Web.config). Can also be a connection string. [Default: "FilesContext"]
+ tableName // Name of the underlying database table [Default: "Files"].
+ storageMode: // Defines if files are stored within the database file or as SqlFiieStream. SqlFIleStreams are stored outside of the database file as blob within the file system, but they are managed by the database engine. When using SqlFileStreams, SQL Server and the database must enable the SqlFileStream feature. More info: FILESTREAM (SQL Server). [Default: "Internal"].
+ Internal // Files will be stored within the database (default).
+ SqlFileStream // Files will be stored as SqlFileStream outside of the database file in a filesystem directory, but managed by the database engine. This allows us to store very large files. More info: FILESTREAM (SQL Server). Unlike SqlFileTable, files (blobs) cannot be accessed directly on the file system.
+ SqlFileTable // Like SqlFileStreams, files will be stored in a SqlFileTable outside of the database file in a filesystem directory, but managed by the database engine. This allows us to store very large files. More info: FileTables (SQL Server). Unlike SqlFileStreams FileTable files can be accessed, created and deleted within the file system as normal file. This allows us for example to copy a file with the explorer to the FileTable's directory in the file system where Sql Server catches the file and manages it. You can also enable a client to directory download the file if you create a virtual path from IIS to the FileTable directory.
+ FileSystem // Files will be stored on the filesystem. A virtual path in the database points to the file.
+ fileTableName // Name of the SqlFileTable if a SqlFileTable is running on Sql Server. In a SqlFileTable, files will be stored outside of the database file in a filesystem directory, but managed by the database engine. This allows to store very large files. In contrast to SqlFileStreams, SqlFileTable files can be accessed, created and deleted directly within the file system as normal files. This allows us for example to copy a file with the explorer to the FileTable's directory in the file system where Sql Server catches the file and manages it. When you create a virtual path in IIS to the FileTable directory in the filesystem, A client can download the files in the SqlFileTable directly from the browser. FileTables (SQL Server). [Default: "FileTable"].
+ rootPath // Root path of the file directory when using external file storage (storageMode: SqlFileTable or FileSystem) (SqlFileTable example: "\\Server\SQLEXPRESS\FILES\Uploads\" where "FILES" is the database and "Uploads" is the name of the SqlFileTable.) (FilePath example: z:\Uploads). NOTE: If rootPath is not configured in storageMode "SqlFileTable", rootPath will be automatically retrieved from Sql Server. [Default: "~/Files"]
+ tempFolder // If set to a none empty string, this setting is used to store file chunks, before the full uploaded file will be stored into the database. If you use chunked file uploads, it is recommend to store the chunks in a temporary directory to get best performance. (Examples: "~/Files/Temp/" (app relative), "z:\dbstorage\temp\" (absolute), "\\server\dbstorage\temp\" (unc)) [Default: ""]
+ columnMapping // If the data model has different column names than the defaults (e.g. FileId instead of the default Id), a column mapping for column names can be set. Example: columnMapping="{Id=FileId,Name=FileName,Original=OriginalName}". This setting can also be done within the context. See also the database demo package. [Default: ""]
+ virtualDirectory // Storage mode "SqlFileTable" or "FileSystem" only. This setting is only needed if direct download of files is enabled in the configuration with the setting filesUrlPattern="{url}" (default: {backload}). Note: Direct download of files is only available in the storage modes "SqlFileTable" and "FileSystem", because in these modes files are stored as regular files on the file system. As in standard filesystem storage, VirtualDirectory needs to be set as the name of a virtual directory in IIS or an absolute url //if the file system to download files is outside the web application (e.g. UNC shares). VirtualDirectory represents the name of virtual path in your IIS application to an external storage location. If filesRoot is relative to the web application root (starts with '~/', see filesRoot), you do not need to set this value. If filesRoot is an absolute path, you usually set a virtual path in IIS to this external location. In this case, the virtualDirectory attribute must be set to the name of the virtual path and filesRoot to the absolute path. Example: If the virtual path is z:\files and the name is "files", set filesRoot="z:\files" and virtualDirectory="/files" [Default: "/"]
+ extension // Name of the plugin file, e.g. extension="Backload.Plugin.Database.dll". If this is an empty string the extension name will be automatically set to: "Backload.Plugin.Database.dll [Default: "Backload.Plugin.Database.dll"]
+
+
+
+
+
+
+ cloudStorage: // Sets the attributes for cloud storage
+ serviceProvider // Storage service provider. [Default: "AzureBlobStorage]
+ AzureBlobStorage // Microsoft Azure Blob storage service
+ extension // Name of the extension file, e.g. extension="Backload.Plugin.AzureBlobStorage.dll". If this is an empty string the extension name will be automatically set to: "Backload.Plugin.[serviceProvider].dll [Default: ""]
+
+ azureBlobStorage: // Microsoft Azure Blob storage settings
+ connectionString // Azure Storage Service connection string name, usually located in the .cscfg file or Web.config. If this is an empty string, the local storage emulator will be used [Default: "StorageConnectionString"]
+ [not set] // Backload looks for the connectionstring "StorageConnectionString" in Azure service definition file (.cscfg) or Web.config
+ [empty], ""] // Internally resolved to "UseDevelopmentStorage=true". Uses the storage emulator
+ {string} // Backload looks for a custom name in the Azure service definition file (.cscfg) or in Web.config
+ uploadContainer // Name of the files upload container. Example: uploadContainer="files". Must start with a lowercase letter. Automatically created if it doesn't exist [Default: "files"]
+ accessType: // Public access type to the uploaded files [Default: "token"]
+ private // No public access.
+ public // Anyone with the url can get or list, but not store or delete files.
+ token // Ad-hoc shared access signature (SAS). Storage access requires a valid access token. [Default].
+ storedPolicy // A shared (stored) access policy will be used. Define a name of the stored policy within the storedPolicyName attribute. Note: Note: Your code is responsable to renew the policy before it expires!
+ storedPolicyName // If accessType is set to "storedPolicy", this attribute is the name of the shared access policy. Note: Your code is responsable to renew the policy before it expires! [Default: "backload"]
+ tokenExpires // Sas access type only. Time period (in minutes) before the shared access token expires. [Default: "60"]
+ objectsRoot // Virtual subfolder within the uploadContainer. Set it to objectsRoot="" if you do not need a subfolder [Default: ""]
+ copiesContainer // Name of a copy container. [Default: ""]
+ containerCreation // Sets the container existence checking and auto creation behavior [Default: "auto"]
+ auto // Container existence is verified on first access, created it if neccessary, after that assumed that the container exists (Default).
+ always // Verify container exsistence on every request and try to create it if it not exists.
+ never // No checks for container exsistence. The containers (files, previews, [archives]) must be available (pre-created) on a request.
+
+
+
+
+
+
+
+
+
+ security: // Security related settings. By default there are no restrictions. If you need a deeper control, set up your own controller to receive the request, do the authentication/authorization and then call the handler.
+ forceObjectContext // A request must always include an none empty objectContext parameter (query or form) to be valid. If you use "objectContext" to store/retirieve user related files, a malicious request could reveal some other users files, if forceObjectContext is false [Default:"false"]
+ allowAnonymous // True: Anyone is allowed, false: The user must be authenticated [Default: "true"]
+ allowedDownloadRole // By default there are no restrictions on who can download files by a GET request. You can change this by adding a comma separated list of roles [Default: "*"]
+ allowedUploadRoles // By default there are no restrictions on who can upload files whithin a POST/PUT request. You can change this by adding a comma separated list of roles [Default: "*"]
+ allowedDeleteRoles // By default there are no restrictions on who can delete files by a DELETE request. You can change this by adding a comma separated list of roles [Default: "*"]
-
-
-
-
-
-
-
+ cors: // Enables/disables and configures CROSS-ORIGIN RESOURCE SHARING (CORS). CORS is used in environments, where file requests (e.g. GET) come from diffenrent domains (e.g. client: http://www.yourwebsite.com, Backload: http://fileservice.com/Backload/Filehandler).
+ enabled // To enable CORS requests set this attribute to true [Default=°false°]
+ allowedDomains // Comma-separated list of allowed domains for client side requests or "*" to allow all client side cors requests. Example: allowedOrigin="http://www.myservice.com". [Default="*"]
+ allowedMethods // C omma-separated list of allowed http methods. [Default="GET,POST,DELETE"]
+ allowedHeaders // Comma-separated list of allowed (none simple) headers. [Default=""]
+ credentials // Specifies if a request should send credentials by setting credentials="true" [Default="false"]
+ maxAge // Validity period of cors permission settings (in seconds) before the client makes a new request for permissions. Note: Not all clients use this value [Default="36000"]
+
-
-
- watermark: // Optional watermark image if images are uploaded. Example: watermark="~/Backload/Imaging/watermark.png". [Default: "" (no watermark)].
- background: // Optional background image if images are placed or fit onto a canvas. Example: background="~/Backload/Imaging/background.png". [Default: "" (no background image)].
- watermarkPosition: // Vertical position of a watermark to be placed on an image[Default: "center"]
- top // Top position
- center // Center position
- bottom // Bottom position
+
+
+
+ images, thumbnails: // Image and thumbnail settings
+ width // Width or max width (depends on resizeMode) of the resulting image [images range: 1-100000, Default: "1024"; thumbnails range: 1-1000, Default: "80"]
+ height // Height or max height (depends on resizeMode) of the resulting image [images range: 1-100000, Default: "768"; thumbnails range: 1-1000, Default: "60"]
+ dpi // Resolution of the resulting image (dots per inch) [Range: 1-2400, Default: "96"]
+ canvasColor // Background color of the canvas. Only used when resize mode is fit and the image ratio of the source and target image differ. You can also use argb (rgb with alpha channel, e.g. background: #00ffffff (transparent), #80ffffff (white, 50% transparency), #ffffffff (white, opaque)) [Default: #ffffff]
+ maxFileSize // Images only: Max file size (bytes) of an image to be processed by the image processing sub pipeline. If the file size is bigger, the image is stored directly bypassing image processing [Default: "0" (unlimited)].
+ forceImageType: // Images only: By default the image type of the original image is used. Set this attribute to always output a different type (e.g. image/png or image/jpeg [Defailt: none])
+ none // Use the original image type
+ image/png // Files with .png (protable network graphics) extension
+ image/jpeg // Files with .jpeg or .jpg extension
+ image/tiff // Files with .tif or .tiff extension
+ image/gif // Files with .gif extension
+ image/bmp // Microsoft Bitmap format
+ image/vnd.ms-photo // JPEG XR (extended range, formerly MS Photo) format
+ resizeMode: // [Default: "none"]
+ none // Keep original image, no resizing or cropping
+ ratio // No Canvas, preserves ratio, width and height are max sizes, smaller images are upscaled
+ maxratio // Same as ratio, but smaller images are not upscaled.
+ fit // Fit into canvas, preserves ratio, centered on canvas
+ place // If the source image is bigger than the canvas same as fit. If it is smaller than the canvas, it will be placed in the center of the canvas without resizing
+ crop // Placed on canvas, cropped if neccessary with center of the original image
+ watermark // Images only: Optional watermark image if images are uploaded. Example: watermark="~/Backload/Imaging/watermark.png". [Default: "" (no watermark)].
+ background // Images only: Optional background image if images are placed or fit onto a canvas. Example: background="~/Backload/Imaging/background.png". [Default: "" (no background image)].
+ watermarkPosition: // Images only: Vertical position of a watermark to be placed on an image[Default: "center"]
+ top // Top position
+ center // Center position
+ bottom // Bottom position
+ imageType // Thumbnails only: Thumnail images must all have the same image type in order the upload handler can find and return the correct thumbnail path [Default: "image/png"]
+ path // Thumbnails only: Location of the thumbnail subfolder within the folder where the main file is stored. Set to an empty string (path="") to avoid physical storage. [Default: "_thumbs"]<
+ store // Thumbnail only: If set to "true" (default), preview images are stored physically. If this attribute is set to false and you request preview images (e.g. in a plugin ui) thumbnails have to be created on every request. If you usually use preview images it is recommed to set this attribute to "true". [Default: "true"]
+
-
+
-
+
+
+ clientFiles: // If the bundeling feature is used (@Render.Scripts(), @Render.Styles()), set the appropriate files folder. TIP: Don't forgat to register the bundeling feature in the global.asax. See example project.
+ scripts // Scripts folder [Default: "~/Backload/Client"]
+ styles // Styles folder [Default: "~/Backload/Client"]
+
-
+
+
+ cacheManager: // Adds cache headers to the response if enabled, and returns a http status 304 (Not Modified), if no files have been uploaded or deleted sinse the last request. Note: If you manually or by a different application change files, don't use "lastModified=true", because only requests within Backload's pipeline will be recognized.
+ lastModified // If true, includes a Last-Modified header in the response and returns a 304 (Not Modified) if no files where uploaded or deleted since the last request. [Default="false"]
+ etag // If true, a ETag is returned in the response on a single file request. In the next request for this file a 304 is returned, if the file has not been modified. [Default="false"]
+ expires // Adds an Expires header to the response, if the value is not 0 (seconds). Example: useExpires="3600" (adds 1 hour to the Expires header) [Default="0"]
+ location // Adds a Cache-Control header to the response (Please refer to the System.Web.HttpCacheability enumeration for more info) [Default="ServerAndPrivate"]
+ mustRevalidate // Sets "must-revalidate" within the Cache-Control header. Caches (e.g. Browser, Proxy) are forced to validate if the request has changed [Default="true"].
+
-
-
-
+
+
+
+
+ contentTypes: // Adds a new content type definition to the configuration.
+ thumbnailPath // Path to the content type thumbnails. [Default: "~/Backload/ContentTypes"]
+ thumbnailSize // Content type thumbnail size [Default: "64"]
+ useThumbnailCanvas // Places the thumbnail on a canvas, so it has the same size than image thumbnails [Default: "true"]
+
+ contentType: // Defines a new content type or overrides an existing type
+ // New contentType entry (MS Office, OpenOffice, PDF, Textfile are included by default. No need to inlude these anymore):
+ // Use to clear all preexisting entries, use to remove a specific entry (Example: to remove the predefined PDF type).
+ // Predifined type names: _AdobePDFFile, _MSExcel2003, _MSExcel2012, _MSPowerpoint2003, _MSPowerpoint2012, _MSWord2003, _MSWord2012, _OpenOfficeWriter, _TextFile.
+ // Remarks: _MSxxxx2012 includes all file types from 2007 to 2012 office versions. _MSxxxx2003 includes all file types up to the 2003 office version.
+ name // A unique name of the entry
+ extFragment // Complete or fragment of the file extension as RegEx string (e.g. .mp finds .mp3, .mp4, .mpeg, etc). Leave it blank, to skip this test.
+ typeFragment // Complete or fragment of the content-type as RegEx string (e.g. "mpeg" audio/mpeg, video/mpeg, etc). Leave it blank, to skip this test. Content-types matches are preferred over extension matches.
+ thumbnail // Name of the thumbnail image within the content-types thumbnail folder. Special handling of images: Leave it blank, to send a preview of the uploaded image back, or set a thumbnail if you do not want to return a preview.
+ subfolder // Subfolder of the object context folder. Has to be set only if files of this content-type should be stored seperatly from other types (e.g. "movies"). [Default: ""]
+
+ // Deletes all predefined types -->
+ // Removes the type handling for a specific content type. Example: -->
+
-
-
-
-
-
-
-
\ No newline at end of file
+
+ license: // Provided license data for Pro/Enterprise editions only
+ licensee: // Provided licensee value (usually email adress). Obligatory field in the paid editions.
+ licenseKey: // Provided license key. Obligatory field in the paid editions.
+
+
diff --git a/Web/Backload/Controller/BackloadController.cs b/Web/Backload/Controller/BackloadController.cs
index 9fd1d2c..7617b44 100644
--- a/Web/Backload/Controller/BackloadController.cs
+++ b/Web/Backload/Controller/BackloadController.cs
@@ -15,6 +15,7 @@ namespace Backload.Controllers
///
public partial class BackloadController : Controller
{
+
///
/// The Backload file handler.
/// To access it in an Javascript ajax request use: var url = "/{Application}/Backload/FileHandler/";.
@@ -24,6 +25,7 @@ namespace Backload.Controllers
{
try
{
+
// Create and initialize the handler
IFileHandler handler = Backload.FileHandler.Create();
handler.Init(HttpContext.Request);
@@ -35,6 +37,7 @@ namespace Backload.Controllers
// Helper to create an ActionResult object from the IBackloadResult instance
return ResultCreator.Create(result);
+
}
catch
{
diff --git a/Web/Backload/Helper/ResultCreator.cs b/Web/Backload/Helper/ResultCreator.cs
index 6c551b7..747095b 100644
--- a/Web/Backload/Helper/ResultCreator.cs
+++ b/Web/Backload/Helper/ResultCreator.cs
@@ -23,7 +23,7 @@ namespace Backload.Helper
// RequestType.Default: Json output has been requested (default).
// Otherwise a file or a thumbnail (bytes) will be returned.
if (result.RequestType == RequestType.Default)
- return Create((IFileStatusResult)result);
+ return Create((IJsonResult)result);
else if ((result.RequestType == RequestType.File) || (result.RequestType == RequestType.Thumbnail))
return Create((IFileDataResult)result);
}
@@ -39,13 +39,21 @@ namespace Backload.Helper
///
/// A IFileStatusResult object with client plugin specfic data.
/// JsonResult instance or a http HttpStatusCodeResult to send an http status
- public static ActionResult Create(IFileStatusResult result)
+ public static ActionResult Create(IJsonResult result)
{
+ object resultObject = null;
+
+ // Converts to the correct type and gets the result object. Result is usually in ClientStatus
+ if (result.ResultType == ResultType.Status)
+ resultObject = ((IFileStatusResult)result).ClientStatus;
+ else if (result.ResultType == ResultType.Json)
+ resultObject = ((ICoreResult)result).ResultObject;
+
// Create Json result from the returned client plugin specific file metadata.
- if ((result.ClientStatus != null) && (result.Exception == null))
+ if ((resultObject != null) && (result.Exception == null))
return new JsonResult()
{
- Data = result.ClientStatus,
+ Data = resultObject,
ContentType = result.ContentType,
ContentEncoding = System.Text.Encoding.UTF8,
MaxJsonLength = Int32.MaxValue,
diff --git a/Web/Backload/Imaging/readme.txt b/Web/Backload/Imaging/readme.txt
index 5829065..d30aa17 100644
--- a/Web/Backload/Imaging/readme.txt
+++ b/Web/Backload/Imaging/readme.txt
@@ -2,6 +2,8 @@ To add backgrounds and watermarks to uploaded images, set the path in the
background/watermark attribute of the image element in Web.Backload.config
Background images are only used in resize modes with canvas (fit, place)
+The provided background.png and watermark.png are examples only. You can
+create your own images. PNG images can have an opacity value lower than 1.
Note: Background and watermark images are a Pro/Enterprise features,
while background color is a Standard feature
diff --git a/Web/Backload/Release.txt b/Web/Backload/Release.txt
index b8b4f35..3370705 100644
--- a/Web/Backload/Release.txt
+++ b/Web/Backload/Release.txt
@@ -1,24 +1,24 @@
-This release:
+What's new in release 2.2.2.0?
+
+- Non image type thumbnail creation improved
+- Improved url encoding
+
+
+Release 2.2:
+
+- Azure Blob Storage support
+- Native Database support (incl. EF, FileStream, FileTable, FileSystem storage)
+- Support for request based configuration settings
+- Supporting files (like previews) can be stored in a seperate path
Bug fixes:
-- #69 Memory optimizations when processing very large images
-- #68 Set image height programmatically results in unexpected behaviour.
-- #57 Thumbnail not generated on server for non-image type file
-- Cache could not be disabled
-
-
-What's new in release 2.1?
-Improvements:
-- CORS (Cross-Origin Resource Sharing) support for cross domain access (Pro/Enterprise).
-- Improved image processing
-- new resize method (maxratio)
-- Watermark/background image support (experimental)
-- Improved chunked file handling
-- Reduced memory footprint when saving large files
+- GetInclSubfolder setting problem fixed
+==========================================================================================================
+
Important migration notes (from releases < 2.0):
- Event handler: If you attached to events, FileUploadStatus and FileUploadStatusItem have been renamed to:
diff --git a/Web/Global.asax.cs b/Web/Global.asax.cs
index 340ceae..17f9023 100644
--- a/Web/Global.asax.cs
+++ b/Web/Global.asax.cs
@@ -1,4 +1,4 @@
-using System;
+using System.Web.Optimization;using System;
using System.Web.Optimization;
using System.Web.Mvc;
using System.Web.Routing;
diff --git a/Web/NLog.xsd b/Web/NLog.xsd
index 85019de..dc821bc 100644
--- a/Web/NLog.xsd
+++ b/Web/NLog.xsd
@@ -45,6 +45,11 @@
Pass NLog internal exceptions to the application. Default value is: false.
+
+
+ Write internal NLog messages to the the System.Diagnostics.Trace. Default value is: false
+
+
@@ -366,18 +371,20 @@
+
-
-
+
+
+
-
+
-
+
@@ -405,36 +412,41 @@
Indicates whether to append newline at the end of log message.
+
+
+ Action that should be taken if the will be more connections than .
+
+ Action that should be taken if the message is larger than maxMessageSize.
-
-
- Size of the connection cache (number of connections which are kept alive).
-
-
-
-
- Network address.
-
- Indicates whether to keep connection open whenever possible.
+
+
+ Size of the connection cache (number of connections which are kept alive).
+
+
+
+
+ Maximum current connections. 0 = no maximum.
+
+
+
+
+ Network address.
+
+ Maximum queue size.
-
-
- Indicates whether to include NLog-specific extensions to log4j schema.
-
- Indicates whether to include source info (file name and line number) in the information sent over the network.
@@ -445,6 +457,11 @@
NDC item separator.
+
+
+ Indicates whether to include stack contents.
+
+ Indicates whether to include call site (class and method name) in the information sent over the network.
@@ -455,9 +472,9 @@
AppInfo field. By default it's the friendly name of the current AppDomain.
-
+
- Indicates whether to include stack contents.
+ Indicates whether to include NLog-specific extensions to log4j schema.
@@ -468,6 +485,13 @@
+
+
+
+
+
+
+
@@ -592,6 +616,7 @@
+
@@ -615,6 +640,11 @@
Indicates whether to match whole words only.
+
+
+ Compile the ? This can improve the performance, but at the costs of more memory usage. If false, the Regex Cache is used.
+
+ Background color.
@@ -683,6 +713,7 @@
+
@@ -735,6 +766,11 @@
Indicates whether to keep the database connection open between the log events.
+
+
+ Obsolete - value will be ignored! The logging code always runs outside of transaction. Gets or sets a value indicating whether to use database transactions. Some data providers require this.
+
+ Connection string using for installation and uninstallation. If not provided, regular ConnectionString is being used.
@@ -886,7 +922,9 @@
+
+
@@ -923,14 +961,31 @@
Value to be used as the event Source.
+
+
+ Action to take if the message is larger than the option.
+
+ Optional entrytype. When not set, or when not convertable to then determined by
+
+
+ Message length limit to write to the Event Log.
+
+
+
+
+
+
+
+
+
@@ -961,31 +1016,32 @@
-
+
-
-
+
-
-
-
-
-
+
+
+
-
-
+
+
+
+
+
+
@@ -1017,11 +1073,6 @@
Line ending mode.
-
-
- Maximum number of archive files that should be kept.
-
- Way file archives are numbered.
@@ -1039,7 +1090,12 @@
- Size in bytes above which log files will be automatically archived.
+ Size in bytes above which log files will be automatically archived. Warning: combining this with isn't supported. We cannot create multiple archive files, if they should have the same name. Choose:
+
+
+
+
+ Maximum number of archive files that should be kept.
@@ -1049,17 +1105,12 @@
- Gets ors set a value indicating whether a managed file stream is forced, instead of used the native implementation.
+ Gets or set a value indicating whether a managed file stream is forced, instead of used the native implementation.
-
+
- File attributes (Windows only).
-
-
-
-
- Indicates whether to replace file contents on each write instead of appending log message at the end.
+ Cleanup invalid values in a filename, e.g. slashes in a filename. If set to true, this can impact the performance of massive writes. If set to false, nothing gets written when the filename is wrong.
@@ -1069,7 +1120,7 @@
- Value specifying the date format to use when archving files.
+ Value specifying the date format to use when archiving files.
@@ -1082,34 +1133,24 @@
Indicates whether to create directories if they do not exist.
-
-
- Indicates whether to delete old log file on startup.
-
- Indicates whether to enable log file(s) to be deleted.
-
+
- Maximum number of seconds that files are kept open. If this number is negative the files are not automatically closed after a period of inactivity.
+ File attributes (Windows only).
-
+
- Indicates whether concurrent writes to the log file by multiple processes on different network hosts.
+ Indicates whether to delete old log file on startup.
-
+
- Maximum number of log filenames that should be stored as existing.
-
-
-
-
- Indicates whether to keep log file open instead of opening and closing it on each logging event.
+ Indicates whether to replace file contents on each write instead of appending log message at the end.
@@ -1117,19 +1158,19 @@
Indicates whether concurrent writes to the log file by multiple processes on the same host.
-
-
- Number of times the write is appended on the file before NLog discards the log message.
-
- Delay in milliseconds to wait before attempting to write to the file again.
-
+
- Indicates whether to automatically flush the file buffers after each log message.
+ Maximum number of log filenames that should be stored as existing.
+
+
+
+
+ Indicates whether concurrent writes to the log file by multiple processes on different network hosts.
@@ -1137,11 +1178,31 @@
Number of files to be kept open. Setting this to a higher value may improve performance in a situation where a single File target is writing to many files (such as splitting by level or by logger).
+
+
+ Maximum number of seconds that files are kept open. If this number is negative the files are not automatically closed after a period of inactivity.
+
+ Log file buffer size in bytes.
+
+
+ Indicates whether to automatically flush the file buffers after each log message.
+
+
+
+
+ Number of times the write is appended on the file before NLog discards the log message.
+
+
+
+
+ Indicates whether to keep log file open instead of opening and closing it on each logging event.
+
+
@@ -1366,9 +1427,9 @@
-
-
+
+
@@ -1382,6 +1443,8 @@
+
+
@@ -1418,9 +1481,9 @@
Indicates whether to add new lines between log entries.
-
+
- BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
+ CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
@@ -1428,9 +1491,9 @@
Recipients' email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
-
+
- CC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
+ BCC email addresses separated by semicolons (e.g. john@domain.com;jane@domain.com).
@@ -1498,6 +1561,16 @@
Indicates whether the default Settings from System.Net.MailSettings should be used.
+
+
+ Folder where applications save mail messages to be processed by the local SMTP server.
+
+
+
+
+ Specifies how outgoing email messages will be handled.
+
+
@@ -1508,6 +1581,13 @@
+
+
+
+
+
+
+
@@ -1611,7 +1691,7 @@
- Method name. The method must be public and static.
+ Method name. The method must be public and static. Use the AssemblyQualifiedName , https://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname(v=vs.110).aspx e.g.
@@ -1626,10 +1706,12 @@
+
+
@@ -1657,6 +1739,11 @@
Indicates whether to append newline at the end of log message.
+
+
+ Action that should be taken if the will be more connections than .
+
+ Action that should be taken if the message is larger than maxMessageSize.
@@ -1677,6 +1764,11 @@
Indicates whether to keep connection open whenever possible.
+
+
+ Maximum current connections. 0 = no maximum.
+
+ Maximum queue size.
@@ -1694,18 +1786,20 @@
+
-
-
+
+
+
-
+
-
+
@@ -1733,36 +1827,41 @@
Indicates whether to append newline at the end of log message.
+
+
+ Action that should be taken if the will be more connections than .
+
+ Action that should be taken if the message is larger than maxMessageSize.
-
-
- Size of the connection cache (number of connections which are kept alive).
-
-
-
-
- Network address.
-
- Indicates whether to keep connection open whenever possible.
+
+
+ Size of the connection cache (number of connections which are kept alive).
+
+
+
+
+ Maximum current connections. 0 = no maximum.
+
+
+
+
+ Network address.
+
+ Maximum queue size.
-
-
- Indicates whether to include NLog-specific extensions to log4j schema.
-
- Indicates whether to include source info (file name and line number) in the information sent over the network.
@@ -1773,6 +1872,11 @@
NDC item separator.
+
+
+ Indicates whether to include stack contents.
+
+ Indicates whether to include call site (class and method name) in the information sent over the network.
@@ -1783,9 +1887,9 @@
AppInfo field. By default it's the friendly name of the current AppDomain.
-
+
- Indicates whether to include stack contents.
+ Indicates whether to include NLog-specific extensions to log4j schema.
@@ -1852,6 +1956,7 @@
+
@@ -1884,6 +1989,11 @@
Performance counter type.
+
+
+ The value by which to increment the counter.
+
+ Performance counter instance name.
@@ -2224,15 +2334,27 @@
+
+
+
+ Option to suppress the extra spaces in the output json
+
+
+
+
+
+ Determines wether or not this attribute will be Json encoded.
+
+ Layout that will be rendered as the attribute's value.
diff --git a/Web/Scripts/angular-mocks.js b/Web/Scripts/angular-mocks.js
index febfd0d..598b1c2 100644
--- a/Web/Scripts/angular-mocks.js
+++ b/Web/Scripts/angular-mocks.js
@@ -1,9 +1,9 @@
/**
- * @license AngularJS v1.4.7
- * (c) 2010-2015 Google, Inc. http://angularjs.org
+ * @license AngularJS v1.5.5
+ * (c) 2010-2016 Google, Inc. http://angularjs.org
* License: MIT
*/
-(function(window, angular, undefined) {
+(function(window, angular) {
'use strict';
@@ -134,12 +134,12 @@ angular.mock.$Browser = function() {
};
angular.mock.$Browser.prototype = {
-/**
- * @name $browser#poll
- *
- * @description
- * run all fns in pollFns
- */
+ /**
+ * @name $browser#poll
+ *
+ * @description
+ * run all fns in pollFns
+ */
poll: function poll() {
angular.forEach(this.pollFns, function(pollFn) {
pollFn();
@@ -552,7 +552,7 @@ angular.mock.$IntervalProvider = function() {
* This directive should go inside the anonymous function but a bug in JSHint means that it would
* not be enacted early enough to prevent the warning.
*/
-var R_ISO8061_STR = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/;
+var R_ISO8061_STR = /^(-?\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?:\:?(\d\d)(?:\:?(\d\d)(?:\.(\d{3}))?)?)?(Z|([+-])(\d\d):?(\d\d)))?$/;
function jsonStringToDate(string) {
var match;
@@ -578,7 +578,7 @@ function toInt(str) {
return parseInt(str, 10);
}
-function padNumber(num, digits, trim) {
+function padNumberInMock(num, digits, trim) {
var neg = '';
if (num < 0) {
neg = '-';
@@ -727,13 +727,13 @@ angular.mock.TzDate = function(offset, timestamp) {
// provide this method only on browsers that already have it
if (self.toISOString) {
self.toISOString = function() {
- return padNumber(self.origDate.getUTCFullYear(), 4) + '-' +
- padNumber(self.origDate.getUTCMonth() + 1, 2) + '-' +
- padNumber(self.origDate.getUTCDate(), 2) + 'T' +
- padNumber(self.origDate.getUTCHours(), 2) + ':' +
- padNumber(self.origDate.getUTCMinutes(), 2) + ':' +
- padNumber(self.origDate.getUTCSeconds(), 2) + '.' +
- padNumber(self.origDate.getUTCMilliseconds(), 3) + 'Z';
+ return padNumberInMock(self.origDate.getUTCFullYear(), 4) + '-' +
+ padNumberInMock(self.origDate.getUTCMonth() + 1, 2) + '-' +
+ padNumberInMock(self.origDate.getUTCDate(), 2) + 'T' +
+ padNumberInMock(self.origDate.getUTCHours(), 2) + ':' +
+ padNumberInMock(self.origDate.getUTCMinutes(), 2) + ':' +
+ padNumberInMock(self.origDate.getUTCSeconds(), 2) + '.' +
+ padNumberInMock(self.origDate.getUTCMilliseconds(), 3) + 'Z';
};
}
@@ -758,6 +758,15 @@ angular.mock.TzDate = function(offset, timestamp) {
angular.mock.TzDate.prototype = Date.prototype;
/* jshint +W101 */
+
+/**
+ * @ngdoc service
+ * @name $animate
+ *
+ * @description
+ * Mock implementation of the {@link ng.$animate `$animate`} service. Exposes two additional methods
+ * for testing animations.
+ */
angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
.config(['$provide', function($provide) {
@@ -790,9 +799,50 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
return queueFn;
});
- $provide.decorator('$animate', ['$delegate', '$timeout', '$browser', '$$rAF',
+ $provide.decorator('$$animateJs', ['$delegate', function($delegate) {
+ var runners = [];
+
+ var animateJsConstructor = function() {
+ var animator = $delegate.apply($delegate, arguments);
+ // If no javascript animation is found, animator is undefined
+ if (animator) {
+ runners.push(animator);
+ }
+ return animator;
+ };
+
+ animateJsConstructor.$closeAndFlush = function() {
+ runners.forEach(function(runner) {
+ runner.end();
+ });
+ runners = [];
+ };
+
+ return animateJsConstructor;
+ }]);
+
+ $provide.decorator('$animateCss', ['$delegate', function($delegate) {
+ var runners = [];
+
+ var animateCssConstructor = function(element, options) {
+ var animator = $delegate(element, options);
+ runners.push(animator);
+ return animator;
+ };
+
+ animateCssConstructor.$closeAndFlush = function() {
+ runners.forEach(function(runner) {
+ runner.end();
+ });
+ runners = [];
+ };
+
+ return animateCssConstructor;
+ }]);
+
+ $provide.decorator('$animate', ['$delegate', '$timeout', '$browser', '$$rAF', '$animateCss', '$$animateJs',
'$$forceReflow', '$$animateAsyncRun', '$rootScope',
- function($delegate, $timeout, $browser, $$rAF,
+ function($delegate, $timeout, $browser, $$rAF, $animateCss, $$animateJs,
$$forceReflow, $$animateAsyncRun, $rootScope) {
var animate = {
queue: [],
@@ -804,7 +854,35 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
return $$forceReflow.totalReflows;
},
enabled: $delegate.enabled,
- flush: function() {
+ /**
+ * @ngdoc method
+ * @name $animate#closeAndFlush
+ * @description
+ *
+ * This method will close all pending animations (both {@link ngAnimate#javascript-based-animations Javascript}
+ * and {@link ngAnimate.$animateCss CSS}) and it will also flush any remaining animation frames and/or callbacks.
+ */
+ closeAndFlush: function() {
+ // we allow the flush command to swallow the errors
+ // because depending on whether CSS or JS animations are
+ // used, there may not be a RAF flush. The primary flush
+ // at the end of this function must throw an exception
+ // because it will track if there were pending animations
+ this.flush(true);
+ $animateCss.$closeAndFlush();
+ $$animateJs.$closeAndFlush();
+ this.flush();
+ },
+ /**
+ * @ngdoc method
+ * @name $animate#flush
+ * @description
+ *
+ * This method is used to flush the pending callbacks and animation frames to either start
+ * an animation or conclude an animation. Note that this will not actually close an
+ * actively running animation (see {@link ngMock.$animate#closeAndFlush `closeAndFlush()`} for that).
+ */
+ flush: function(hideErrors) {
$rootScope.$digest();
var doNextRun, somethingFlushed = false;
@@ -821,7 +899,7 @@ angular.mock.animate = angular.module('ngAnimateMock', ['ng'])
}
} while (doNextRun);
- if (!somethingFlushed) {
+ if (!somethingFlushed && !hideErrors) {
throw new Error('No pending animations ready to be closed or flushed');
}
@@ -950,7 +1028,7 @@ angular.mock.dump = function(object) {
* - `$httpBackend.when` - specifies a backend definition
*
*
- * # Request Expectations vs Backend Definitions
+ * ## Request Expectations vs Backend Definitions
*
* Request expectations provide a way to make assertions about requests made by the application and
* to define responses for those requests. The test will fail if the expected requests are not made
@@ -1006,7 +1084,7 @@ angular.mock.dump = function(object) {
* the request. The response from the first matched definition is returned.
*
*
- * # Flushing HTTP requests
+ * ## Flushing HTTP requests
*
* The $httpBackend used in production always responds to requests asynchronously. If we preserved
* this behavior in unit testing, we'd have to create async unit tests, which are hard to write,
@@ -1016,7 +1094,7 @@ angular.mock.dump = function(object) {
* the async api of the backend, while allowing the test to execute synchronously.
*
*
- * # Unit testing with mock $httpBackend
+ * ## Unit testing with mock $httpBackend
* The following code shows how to setup and use the mock backend when unit testing a controller.
* First we create the controller under test:
*
@@ -1030,18 +1108,18 @@ angular.mock.dump = function(object) {
function MyController($scope, $http) {
var authToken;
- $http.get('/auth.py').success(function(data, status, headers) {
- authToken = headers('A-Token');
- $scope.user = data;
+ $http.get('/auth.py').then(function(response) {
+ authToken = response.headers('A-Token');
+ $scope.user = response.data;
});
$scope.saveMessage = function(message) {
var headers = { 'Authorization': authToken };
$scope.status = 'Saving...';
- $http.post('/add-msg.py', message, { headers: headers } ).success(function(response) {
+ $http.post('/add-msg.py', message, { headers: headers } ).then(function(response) {
$scope.status = '';
- }).error(function() {
+ }).catch(function() {
$scope.status = 'Failed...';
});
};
@@ -1132,7 +1210,87 @@ angular.mock.dump = function(object) {
$httpBackend.flush();
});
});
- ```
+ ```
+ *
+ * ## Dynamic responses
+ *
+ * You define a response to a request by chaining a call to `respond()` onto a definition or expectation.
+ * If you provide a **callback** as the first parameter to `respond(callback)` then you can dynamically generate
+ * a response based on the properties of the request.
+ *
+ * The `callback` function should be of the form `function(method, url, data, headers, params)`.
+ *
+ * ### Query parameters
+ *
+ * By default, query parameters on request URLs are parsed into the `params` object. So a request URL
+ * of `/list?q=searchstr&orderby=-name` would set `params` to be `{q: 'searchstr', orderby: '-name'}`.
+ *
+ * ### Regex parameter matching
+ *
+ * If an expectation or definition uses a **regex** to match the URL, you can provide an array of **keys** via a
+ * `params` argument. The index of each **key** in the array will match the index of a **group** in the
+ * **regex**.
+ *
+ * The `params` object in the **callback** will now have properties with these keys, which hold the value of the
+ * corresponding **group** in the **regex**.
+ *
+ * This also applies to the `when` and `expect` shortcut methods.
+ *
+ *
+ * ```js
+ * $httpBackend.expect('GET', /\/user\/(.+)/, undefined, undefined, ['id'])
+ * .respond(function(method, url, data, headers, params) {
+ * // for requested url of '/user/1234' params is {id: '1234'}
+ * });
+ *
+ * $httpBackend.whenPATCH(/\/user\/(.+)\/article\/(.+)/, undefined, undefined, ['user', 'article'])
+ * .respond(function(method, url, data, headers, params) {
+ * // for url of '/user/1234/article/567' params is {user: '1234', article: '567'}
+ * });
+ * ```
+ *
+ * ## Matching route requests
+ *
+ * For extra convenience, `whenRoute` and `expectRoute` shortcuts are available. These methods offer colon
+ * delimited matching of the url path, ignoring the query string. This allows declarations
+ * similar to how application routes are configured with `$routeProvider`. Because these methods convert
+ * the definition url to regex, declaration order is important. Combined with query parameter parsing,
+ * the following is possible:
+ *
+ ```js
+ $httpBackend.whenRoute('GET', '/users/:id')
+ .respond(function(method, url, data, headers, params) {
+ return [200, MockUserList[Number(params.id)]];
+ });
+
+ $httpBackend.whenRoute('GET', '/users')
+ .respond(function(method, url, data, headers, params) {
+ var userList = angular.copy(MockUserList),
+ defaultSort = 'lastName',
+ count, pages, isPrevious, isNext;
+
+ // paged api response '/v1/users?page=2'
+ params.page = Number(params.page) || 1;
+
+ // query for last names '/v1/users?q=Archer'
+ if (params.q) {
+ userList = $filter('filter')({lastName: params.q});
+ }
+
+ pages = Math.ceil(userList.length / pagingLength);
+ isPrevious = params.page > 1;
+ isNext = params.page < pages;
+
+ return [200, {
+ count: userList.length,
+ previous: isPrevious,
+ next: isNext,
+ // sort field -> '/v1/users?sortBy=firstName'
+ results: $filter('orderBy')(userList, params.sortBy || defaultSort)
+ .splice((params.page - 1) * pagingLength, pagingLength)
+ }];
+ });
+ ```
*/
angular.mock.$HttpBackendProvider = function() {
this.$get = ['$rootScope', '$timeout', createHttpBackendMock];
@@ -1170,11 +1328,15 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
}
// TODO(vojta): change params to: method, url, data, headers, callback
- function $httpBackend(method, url, data, callback, headers, timeout, withCredentials) {
+ function $httpBackend(method, url, data, callback, headers, timeout, withCredentials, responseType, eventHandlers, uploadEventHandlers) {
+
var xhr = new MockXhr(),
expectation = expectations[0],
wasExpected = false;
+ xhr.$$events = eventHandlers;
+ xhr.upload.$$events = uploadEventHandlers;
+
function prettyPrint(data) {
return (angular.isString(data) || angular.isFunction(data) || data instanceof RegExp)
? data
@@ -1189,7 +1351,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
return handleResponse;
function handleResponse() {
- var response = wrapped.response(method, url, data, headers);
+ var response = wrapped.response(method, url, data, headers, wrapped.params(url));
xhr.$$respHeaders = response[2];
callback(copy(response[0]), copy(response[1]), xhr.getAllResponseHeaders(),
copy(response[3] || ''));
@@ -1234,7 +1396,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
// if $browser specified, we do auto flush all requests
($browser ? $browser.defer : responsesPush)(wrapResponse(definition));
} else if (definition.passThrough) {
- $delegate(method, url, data, callback, headers, timeout, withCredentials);
+ $delegate(method, url, data, callback, headers, timeout, withCredentials, responseType);
} else throw new Error('No response defined !');
return;
}
@@ -1258,20 +1420,23 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* data string and returns true if the data is as expected.
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
* object and returns true if the headers match the current definition.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*
* - respond –
- * `{function([status,] data[, headers, statusText])
- * | function(function(method, url, data, headers)}`
+ * ```js
+ * {function([status,] data[, headers, statusText])
+ * | function(function(method, url, data, headers, params)}
+ * ```
* – The respond method takes a set of static data to be returned or a function that can
- * return an array containing response status (number), response data (string), response
- * headers (Object), and the text for the status (string). The respond method returns the
- * `requestHandler` object for possible overrides.
+ * return an array containing response status (number), response data (Array|Object|string),
+ * response headers (Object), and the text for the status (string). The respond method returns
+ * the `requestHandler` object for possible overrides.
*/
- $httpBackend.when = function(method, url, data, headers) {
- var definition = new MockHttpExpectation(method, url, data, headers),
+ $httpBackend.when = function(method, url, data, headers, keys) {
+ var definition = new MockHttpExpectation(method, url, data, headers, keys),
chain = {
respond: function(status, data, headers, statusText) {
definition.passThrough = undefined;
@@ -1301,6 +1466,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives a url
* and returns true if the url matches the current definition.
* @param {(Object|function(Object))=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
@@ -1315,6 +1481,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives a url
* and returns true if the url matches the current definition.
* @param {(Object|function(Object))=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
@@ -1329,6 +1496,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives a url
* and returns true if the url matches the current definition.
* @param {(Object|function(Object))=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
@@ -1345,6 +1513,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
* data string and returns true if the data is as expected.
* @param {(Object|function(Object))=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
@@ -1361,6 +1530,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* @param {(string|RegExp|function(string))=} data HTTP request body or function that receives
* data string and returns true if the data is as expected.
* @param {(Object|function(Object))=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
@@ -1374,12 +1544,59 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
*
* @param {string|RegExp|function(string)} url HTTP url or function that receives a url
* and returns true if the url matches the current definition.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
createShortMethods('when');
+ /**
+ * @ngdoc method
+ * @name $httpBackend#whenRoute
+ * @description
+ * Creates a new backend definition that compares only with the requested route.
+ *
+ * @param {string} method HTTP method.
+ * @param {string} url HTTP url string that supports colon param matching.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled. See #when for more info.
+ */
+ $httpBackend.whenRoute = function(method, url) {
+ var pathObj = parseRoute(url);
+ return $httpBackend.when(method, pathObj.regexp, undefined, undefined, pathObj.keys);
+ };
+
+ function parseRoute(url) {
+ var ret = {
+ regexp: url
+ },
+ keys = ret.keys = [];
+
+ if (!url || !angular.isString(url)) return ret;
+
+ url = url
+ .replace(/([().])/g, '\\$1')
+ .replace(/(\/)?:(\w+)([\?\*])?/g, function(_, slash, key, option) {
+ var optional = option === '?' ? option : null;
+ var star = option === '*' ? option : null;
+ keys.push({ name: key, optional: !!optional });
+ slash = slash || '';
+ return ''
+ + (optional ? '' : slash)
+ + '(?:'
+ + (optional ? slash : '')
+ + (star && '(.+?)' || '([^/]+)')
+ + (optional || '')
+ + ')'
+ + (optional || '');
+ })
+ .replace(/([\/$\*])/g, '\\$1');
+
+ ret.regexp = new RegExp('^' + url, 'i');
+ return ret;
+ }
/**
* @ngdoc method
@@ -1395,20 +1612,23 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* is in JSON format.
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
* object and returns true if the headers match the current expectation.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*
* - respond –
- * `{function([status,] data[, headers, statusText])
- * | function(function(method, url, data, headers)}`
+ * ```
+ * { function([status,] data[, headers, statusText])
+ * | function(function(method, url, data, headers, params)}
+ * ```
* – The respond method takes a set of static data to be returned or a function that can
- * return an array containing response status (number), response data (string), response
- * headers (Object), and the text for the status (string). The respond method returns the
- * `requestHandler` object for possible overrides.
+ * return an array containing response status (number), response data (Array|Object|string),
+ * response headers (Object), and the text for the status (string). The respond method returns
+ * the `requestHandler` object for possible overrides.
*/
- $httpBackend.expect = function(method, url, data, headers) {
- var expectation = new MockHttpExpectation(method, url, data, headers),
+ $httpBackend.expect = function(method, url, data, headers, keys) {
+ var expectation = new MockHttpExpectation(method, url, data, headers, keys),
chain = {
respond: function(status, data, headers, statusText) {
expectation.response = createResponse(status, data, headers, statusText);
@@ -1420,7 +1640,6 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
return chain;
};
-
/**
* @ngdoc method
* @name $httpBackend#expectGET
@@ -1430,6 +1649,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives a url
* and returns true if the url matches the current definition.
* @param {Object=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled. See #expect for more info.
@@ -1444,6 +1664,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives a url
* and returns true if the url matches the current definition.
* @param {Object=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
@@ -1458,6 +1679,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives a url
* and returns true if the url matches the current definition.
* @param {Object=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
@@ -1475,6 +1697,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* receives data string and returns true if the data is as expected, or Object if request body
* is in JSON format.
* @param {Object=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
@@ -1492,6 +1715,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* receives data string and returns true if the data is as expected, or Object if request body
* is in JSON format.
* @param {Object=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
@@ -1509,6 +1733,7 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
* receives data string and returns true if the data is as expected, or Object if request body
* is in JSON format.
* @param {Object=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
@@ -1522,12 +1747,30 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
*
* @param {string|RegExp|function(string)} url HTTP url or function that receives an url
* and returns true if the url matches the current definition.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described above.
* @returns {requestHandler} Returns an object with `respond` method that controls how a matched
* request is handled. You can save this object for later use and invoke `respond` again in
* order to change how a matched request is handled.
*/
createShortMethods('expect');
+ /**
+ * @ngdoc method
+ * @name $httpBackend#expectRoute
+ * @description
+ * Creates a new request expectation that compares only with the requested route.
+ *
+ * @param {string} method HTTP method.
+ * @param {string} url HTTP url string that supports colon param matching.
+ * @returns {requestHandler} Returns an object with `respond` method that controls how a matched
+ * request is handled. You can save this object for later use and invoke `respond` again in
+ * order to change how a matched request is handled. See #expect for more info.
+ */
+ $httpBackend.expectRoute = function(method, url) {
+ var pathObj = parseRoute(url);
+ return $httpBackend.expect(method, pathObj.regexp, undefined, undefined, pathObj.keys);
+ };
+
/**
* @ngdoc method
@@ -1617,20 +1860,20 @@ function createHttpBackendMock($rootScope, $timeout, $delegate, $browser) {
function createShortMethods(prefix) {
angular.forEach(['GET', 'DELETE', 'JSONP', 'HEAD'], function(method) {
- $httpBackend[prefix + method] = function(url, headers) {
- return $httpBackend[prefix](method, url, undefined, headers);
+ $httpBackend[prefix + method] = function(url, headers, keys) {
+ return $httpBackend[prefix](method, url, undefined, headers, keys);
};
});
angular.forEach(['PUT', 'POST', 'PATCH'], function(method) {
- $httpBackend[prefix + method] = function(url, data, headers) {
- return $httpBackend[prefix](method, url, data, headers);
+ $httpBackend[prefix + method] = function(url, data, headers, keys) {
+ return $httpBackend[prefix](method, url, data, headers, keys);
};
});
}
}
-function MockHttpExpectation(method, url, data, headers) {
+function MockHttpExpectation(method, url, data, headers, keys) {
this.data = data;
this.headers = headers;
@@ -1669,6 +1912,59 @@ function MockHttpExpectation(method, url, data, headers) {
this.toString = function() {
return method + ' ' + url;
};
+
+ this.params = function(u) {
+ return angular.extend(parseQuery(), pathParams());
+
+ function pathParams() {
+ var keyObj = {};
+ if (!url || !angular.isFunction(url.test) || !keys || keys.length === 0) return keyObj;
+
+ var m = url.exec(u);
+ if (!m) return keyObj;
+ for (var i = 1, len = m.length; i < len; ++i) {
+ var key = keys[i - 1];
+ var val = m[i];
+ if (key && val) {
+ keyObj[key.name || key] = val;
+ }
+ }
+
+ return keyObj;
+ }
+
+ function parseQuery() {
+ var obj = {}, key_value, key,
+ queryStr = u.indexOf('?') > -1
+ ? u.substring(u.indexOf('?') + 1)
+ : "";
+
+ angular.forEach(queryStr.split('&'), function(keyValue) {
+ if (keyValue) {
+ key_value = keyValue.replace(/\+/g,'%20').split('=');
+ key = tryDecodeURIComponent(key_value[0]);
+ if (angular.isDefined(key)) {
+ var val = angular.isDefined(key_value[1]) ? tryDecodeURIComponent(key_value[1]) : true;
+ if (!hasOwnProperty.call(obj, key)) {
+ obj[key] = val;
+ } else if (angular.isArray(obj[key])) {
+ obj[key].push(val);
+ } else {
+ obj[key] = [obj[key],val];
+ }
+ }
+ }
+ });
+ return obj;
+ }
+ function tryDecodeURIComponent(value) {
+ try {
+ return decodeURIComponent(value);
+ } catch (e) {
+ // Ignore any invalid uri component
+ }
+ }
+ };
}
function createMockXhr() {
@@ -1723,6 +2019,20 @@ function MockXhr() {
};
this.abort = angular.noop;
+
+ // This section simulates the events on a real XHR object (and the upload object)
+ // When we are testing $httpBackend (inside the angular project) we make partial use of this
+ // but store the events directly ourselves on `$$events`, instead of going through the `addEventListener`
+ this.$$events = {};
+ this.addEventListener = function(name, listener) {
+ if (angular.isUndefined(this.$$events[name])) this.$$events[name] = [];
+ this.$$events[name].push(listener);
+ };
+
+ this.upload = {
+ $$events: {},
+ addEventListener: this.addEventListener
+ };
}
@@ -1807,10 +2117,12 @@ angular.mock.$RAFDecorator = ['$delegate', function($delegate) {
/**
*
*/
+var originalRootElement;
angular.mock.$RootElementProvider = function() {
- this.$get = function() {
- return angular.element('');
- };
+ this.$get = ['$injector', function($injector) {
+ originalRootElement = angular.element('').data('$injector', $injector);
+ return originalRootElement;
+ }];
};
/**
@@ -1837,9 +2149,9 @@ angular.mock.$RootElementProvider = function() {
*
* // Controller definition ...
*
- * myMod.controller('MyDirectiveController', ['log', function($log) {
+ * myMod.controller('MyDirectiveController', ['$log', function($log) {
* $log.info(this.name);
- * })];
+ * }]);
*
*
* // In a test ...
@@ -1849,7 +2161,7 @@ angular.mock.$RootElementProvider = function() {
* var ctrl = $controller('MyDirectiveController', { /* no locals */ }, { name: 'Clark Kent' });
* expect(ctrl.name).toEqual('Clark Kent');
* expect($log.info.logs).toEqual(['Clark Kent']);
- * });
+ * }));
* });
*
* ```
@@ -1883,6 +2195,50 @@ angular.mock.$ControllerDecorator = ['$delegate', function($delegate) {
};
}];
+/**
+ * @ngdoc service
+ * @name $componentController
+ * @description
+ * A service that can be used to create instances of component controllers.
+ *
+ * Be aware that the controller will be instantiated and attached to the scope as specified in
+ * the component definition object. If you do not provide a `$scope` object in the `locals` param
+ * then the helper will create a new isolated scope as a child of `$rootScope`.
+ *
+ * @param {string} componentName the name of the component whose controller we want to instantiate
+ * @param {Object} locals Injection locals for Controller.
+ * @param {Object=} bindings Properties to add to the controller before invoking the constructor. This is used
+ * to simulate the `bindToController` feature and simplify certain kinds of tests.
+ * @param {string=} ident Override the property name to use when attaching the controller to the scope.
+ * @return {Object} Instance of requested controller.
+ */
+angular.mock.$ComponentControllerProvider = ['$compileProvider', function($compileProvider) {
+ this.$get = ['$controller','$injector', '$rootScope', function($controller, $injector, $rootScope) {
+ return function $componentController(componentName, locals, bindings, ident) {
+ // get all directives associated to the component name
+ var directives = $injector.get(componentName + 'Directive');
+ // look for those directives that are components
+ var candidateDirectives = directives.filter(function(directiveInfo) {
+ // components have controller, controllerAs and restrict:'E'
+ return directiveInfo.controller && directiveInfo.controllerAs && directiveInfo.restrict === 'E';
+ });
+ // check if valid directives found
+ if (candidateDirectives.length === 0) {
+ throw new Error('No component found');
+ }
+ if (candidateDirectives.length > 1) {
+ throw new Error('Too many components found');
+ }
+ // get the info of the component
+ var directiveInfo = candidateDirectives[0];
+ // create a scope if needed
+ locals = locals || {};
+ locals.$scope = locals.$scope || $rootScope.$new(true);
+ return $controller(directiveInfo.controller, locals, bindings, ident || directiveInfo.controllerAs);
+ };
+ }];
+}];
+
/**
* @ngdoc module
@@ -1906,7 +2262,8 @@ angular.module('ngMock', ['ng']).provider({
$log: angular.mock.$LogProvider,
$interval: angular.mock.$IntervalProvider,
$httpBackend: angular.mock.$HttpBackendProvider,
- $rootElement: angular.mock.$RootElementProvider
+ $rootElement: angular.mock.$RootElementProvider,
+ $componentController: angular.mock.$ComponentControllerProvider
}).config(['$provide', function($provide) {
$provide.decorator('$timeout', angular.mock.$TimeoutDecorator);
$provide.decorator('$$rAF', angular.mock.$RAFDecorator);
@@ -1993,16 +2350,20 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* @param {(string|RegExp)=} data HTTP request body.
* @param {(Object|function(Object))=} headers HTTP headers or function that receives http header
* object and returns true if the headers match the current definition.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on
+ * {@link ngMock.$httpBackend $httpBackend mock}.
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
* control how a matched request is handled. You can save this object for later use and invoke
* `respond` or `passThrough` again in order to change how a matched request is handled.
*
* - respond –
- * `{function([status,] data[, headers, statusText])
- * | function(function(method, url, data, headers)}`
+ * ```
+ * { function([status,] data[, headers, statusText])
+ * | function(function(method, url, data, headers, params)}
+ * ```
* – The respond method takes a set of static data to be returned or a function that can return
- * an array containing response status (number), response data (string), response headers
- * (Object), and the text for the status (string).
+ * an array containing response status (number), response data (Array|Object|string), response
+ * headers (Object), and the text for the status (string).
* - passThrough – `{function()}` – Any request matching a backend definition with
* `passThrough` handler will be passed through to the real backend (an XHR request will be made
* to the server.)
@@ -2019,6 +2380,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives a url
* and returns true if the url matches the current definition.
* @param {(Object|function(Object))=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on
+ * {@link ngMock.$httpBackend $httpBackend mock}.
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
* control how a matched request is handled. You can save this object for later use and invoke
* `respond` or `passThrough` again in order to change how a matched request is handled.
@@ -2034,6 +2397,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives a url
* and returns true if the url matches the current definition.
* @param {(Object|function(Object))=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on
+ * {@link ngMock.$httpBackend $httpBackend mock}.
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
* control how a matched request is handled. You can save this object for later use and invoke
* `respond` or `passThrough` again in order to change how a matched request is handled.
@@ -2049,6 +2414,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* @param {string|RegExp|function(string)} url HTTP url or function that receives a url
* and returns true if the url matches the current definition.
* @param {(Object|function(Object))=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on
+ * {@link ngMock.$httpBackend $httpBackend mock}.
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
* control how a matched request is handled. You can save this object for later use and invoke
* `respond` or `passThrough` again in order to change how a matched request is handled.
@@ -2065,6 +2432,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* and returns true if the url matches the current definition.
* @param {(string|RegExp)=} data HTTP request body.
* @param {(Object|function(Object))=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on
+ * {@link ngMock.$httpBackend $httpBackend mock}.
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
* control how a matched request is handled. You can save this object for later use and invoke
* `respond` or `passThrough` again in order to change how a matched request is handled.
@@ -2081,6 +2450,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* and returns true if the url matches the current definition.
* @param {(string|RegExp)=} data HTTP request body.
* @param {(Object|function(Object))=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on
+ * {@link ngMock.$httpBackend $httpBackend mock}.
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
* control how a matched request is handled. You can save this object for later use and invoke
* `respond` or `passThrough` again in order to change how a matched request is handled.
@@ -2097,6 +2468,8 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
* and returns true if the url matches the current definition.
* @param {(string|RegExp)=} data HTTP request body.
* @param {(Object|function(Object))=} headers HTTP headers.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on
+ * {@link ngMock.$httpBackend $httpBackend mock}.
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
* control how a matched request is handled. You can save this object for later use and invoke
* `respond` or `passThrough` again in order to change how a matched request is handled.
@@ -2111,6 +2484,21 @@ angular.module('ngMockE2E', ['ng']).config(['$provide', function($provide) {
*
* @param {string|RegExp|function(string)} url HTTP url or function that receives a url
* and returns true if the url matches the current definition.
+ * @param {(Array)=} keys Array of keys to assign to regex matches in request url described on
+ * {@link ngMock.$httpBackend $httpBackend mock}.
+ * @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
+ * control how a matched request is handled. You can save this object for later use and invoke
+ * `respond` or `passThrough` again in order to change how a matched request is handled.
+ */
+/**
+ * @ngdoc method
+ * @name $httpBackend#whenRoute
+ * @module ngMockE2E
+ * @description
+ * Creates a new backend definition that compares only with the requested route.
+ *
+ * @param {string} method HTTP method.
+ * @param {string} url HTTP url string that supports colon param matching.
* @returns {requestHandler} Returns an object with `respond` and `passThrough` methods that
* control how a matched request is handled. You can save this object for later use and invoke
* `respond` or `passThrough` again in order to change how a matched request is handled.
@@ -2206,11 +2594,16 @@ angular.mock.$RootScopeDecorator = ['$delegate', function($delegate) {
}];
-if (window.jasmine || window.mocha) {
+!(function(jasmineOrMocha) {
+
+ if (!jasmineOrMocha) {
+ return;
+ }
var currentSpec = null,
+ injectorState = new InjectorState(),
annotatedFunctions = [],
- isSpecRunning = function() {
+ wasInjectorCreated = function() {
return !!currentSpec;
};
@@ -2222,46 +2615,6 @@ if (window.jasmine || window.mocha) {
return angular.mock.$$annotate.apply(this, arguments);
};
-
- (window.beforeEach || window.setup)(function() {
- annotatedFunctions = [];
- currentSpec = this;
- });
-
- (window.afterEach || window.teardown)(function() {
- var injector = currentSpec.$injector;
-
- annotatedFunctions.forEach(function(fn) {
- delete fn.$inject;
- });
-
- angular.forEach(currentSpec.$modules, function(module) {
- if (module && module.$$hashKey) {
- module.$$hashKey = undefined;
- }
- });
-
- currentSpec.$injector = null;
- currentSpec.$modules = null;
- currentSpec = null;
-
- if (injector) {
- injector.get('$rootElement').off();
- }
-
- // clean up jquery's fragment cache
- angular.forEach(angular.element.fragments, function(val, key) {
- delete angular.element.fragments[key];
- });
-
- MockXhr.$$lastInstance = null;
-
- angular.forEach(angular.callbacks, function(val, key) {
- delete angular.callbacks[key];
- });
- angular.callbacks.counter = 0;
- });
-
/**
* @ngdoc function
* @name angular.mock.module
@@ -2278,33 +2631,198 @@ if (window.jasmine || window.mocha) {
* @param {...(string|Function|Object)} fns any number of modules which are represented as string
* aliases or as anonymous module initialization functions. The modules are used to
* configure the injector. The 'ng' and 'ngMock' modules are automatically loaded. If an
- * object literal is passed they will be registered as values in the module, the key being
- * the module name and the value being what is returned.
+ * object literal is passed each key-value pair will be registered on the module via
+ * {@link auto.$provide $provide}.value, the key being the string name (or token) to associate
+ * with the value on the injector.
*/
- window.module = angular.mock.module = function() {
+ var module = window.module = angular.mock.module = function() {
var moduleFns = Array.prototype.slice.call(arguments, 0);
- return isSpecRunning() ? workFn() : workFn;
+ return wasInjectorCreated() ? workFn() : workFn;
/////////////////////
function workFn() {
if (currentSpec.$injector) {
throw new Error('Injector already created, can not register a module!');
} else {
- var modules = currentSpec.$modules || (currentSpec.$modules = []);
+ var fn, modules = currentSpec.$modules || (currentSpec.$modules = []);
angular.forEach(moduleFns, function(module) {
if (angular.isObject(module) && !angular.isArray(module)) {
- modules.push(function($provide) {
+ fn = ['$provide', function($provide) {
angular.forEach(module, function(value, key) {
$provide.value(key, value);
});
- });
+ }];
} else {
- modules.push(module);
+ fn = module;
+ }
+ if (currentSpec.$providerInjector) {
+ currentSpec.$providerInjector.invoke(fn);
+ } else {
+ modules.push(fn);
}
});
}
}
};
+ module.$$beforeAllHook = (window.before || window.beforeAll);
+ module.$$afterAllHook = (window.after || window.afterAll);
+
+ // purely for testing ngMock itself
+ module.$$currentSpec = function(to) {
+ if (arguments.length === 0) return to;
+ currentSpec = to;
+ };
+
+ /**
+ * @ngdoc function
+ * @name angular.mock.module.sharedInjector
+ * @description
+ *
+ * *NOTE*: This function is declared ONLY WHEN running tests with jasmine or mocha
+ *
+ * This function ensures a single injector will be used for all tests in a given describe context.
+ * This contrasts with the default behaviour where a new injector is created per test case.
+ *
+ * Use sharedInjector when you want to take advantage of Jasmine's `beforeAll()`, or mocha's
+ * `before()` methods. Call `module.sharedInjector()` before you setup any other hooks that
+ * will create (i.e call `module()`) or use (i.e call `inject()`) the injector.
+ *
+ * You cannot call `sharedInjector()` from within a context already using `sharedInjector()`.
+ *
+ * ## Example
+ *
+ * Typically beforeAll is used to make many assertions about a single operation. This can
+ * cut down test run-time as the test setup doesn't need to be re-run, and enabling focussed
+ * tests each with a single assertion.
+ *
+ * ```js
+ * describe("Deep Thought", function() {
+ *
+ * module.sharedInjector();
+ *
+ * beforeAll(module("UltimateQuestion"));
+ *
+ * beforeAll(inject(function(DeepThought) {
+ * expect(DeepThought.answer).toBeUndefined();
+ * DeepThought.generateAnswer();
+ * }));
+ *
+ * it("has calculated the answer correctly", inject(function(DeepThought) {
+ * // Because of sharedInjector, we have access to the instance of the DeepThought service
+ * // that was provided to the beforeAll() hook. Therefore we can test the generated answer
+ * expect(DeepThought.answer).toBe(42);
+ * }));
+ *
+ * it("has calculated the answer within the expected time", inject(function(DeepThought) {
+ * expect(DeepThought.runTimeMillennia).toBeLessThan(8000);
+ * }));
+ *
+ * it("has double checked the answer", inject(function(DeepThought) {
+ * expect(DeepThought.absolutelySureItIsTheRightAnswer).toBe(true);
+ * }));
+ *
+ * });
+ *
+ * ```
+ */
+ module.sharedInjector = function() {
+ if (!(module.$$beforeAllHook && module.$$afterAllHook)) {
+ throw Error("sharedInjector() cannot be used unless your test runner defines beforeAll/afterAll");
+ }
+
+ var initialized = false;
+
+ module.$$beforeAllHook(function() {
+ if (injectorState.shared) {
+ injectorState.sharedError = Error("sharedInjector() cannot be called inside a context that has already called sharedInjector()");
+ throw injectorState.sharedError;
+ }
+ initialized = true;
+ currentSpec = this;
+ injectorState.shared = true;
+ });
+
+ module.$$afterAllHook(function() {
+ if (initialized) {
+ injectorState = new InjectorState();
+ module.$$cleanup();
+ } else {
+ injectorState.sharedError = null;
+ }
+ });
+ };
+
+ module.$$beforeEach = function() {
+ if (injectorState.shared && currentSpec && currentSpec != this) {
+ var state = currentSpec;
+ currentSpec = this;
+ angular.forEach(["$injector","$modules","$providerInjector", "$injectorStrict"], function(k) {
+ currentSpec[k] = state[k];
+ state[k] = null;
+ });
+ } else {
+ currentSpec = this;
+ originalRootElement = null;
+ annotatedFunctions = [];
+ }
+ };
+
+ module.$$afterEach = function() {
+ if (injectorState.cleanupAfterEach()) {
+ module.$$cleanup();
+ }
+ };
+
+ module.$$cleanup = function() {
+ var injector = currentSpec.$injector;
+
+ annotatedFunctions.forEach(function(fn) {
+ delete fn.$inject;
+ });
+
+ angular.forEach(currentSpec.$modules, function(module) {
+ if (module && module.$$hashKey) {
+ module.$$hashKey = undefined;
+ }
+ });
+
+ currentSpec.$injector = null;
+ currentSpec.$modules = null;
+ currentSpec.$providerInjector = null;
+ currentSpec = null;
+
+ if (injector) {
+ // Ensure `$rootElement` is instantiated, before checking `originalRootElement`
+ var $rootElement = injector.get('$rootElement');
+ var rootNode = $rootElement && $rootElement[0];
+ var cleanUpNodes = !originalRootElement ? [] : [originalRootElement[0]];
+ if (rootNode && (!originalRootElement || rootNode !== originalRootElement[0])) {
+ cleanUpNodes.push(rootNode);
+ }
+ angular.element.cleanData(cleanUpNodes);
+
+ // Ensure `$destroy()` is available, before calling it
+ // (a mocked `$rootScope` might not implement it (or not even be an object at all))
+ var $rootScope = injector.get('$rootScope');
+ if ($rootScope && $rootScope.$destroy) $rootScope.$destroy();
+ }
+
+ // clean up jquery's fragment cache
+ angular.forEach(angular.element.fragments, function(val, key) {
+ delete angular.element.fragments[key];
+ });
+
+ MockXhr.$$lastInstance = null;
+
+ angular.forEach(angular.callbacks, function(val, key) {
+ delete angular.callbacks[key];
+ });
+ angular.callbacks.counter = 0;
+ };
+
+ (window.beforeEach || window.setup)(module.$$beforeEach);
+ (window.afterEach || window.teardown)(module.$$afterEach);
+
/**
* @ngdoc function
* @name angular.mock.inject
@@ -2407,11 +2925,20 @@ if (window.jasmine || window.mocha) {
window.inject = angular.mock.inject = function() {
var blockFns = Array.prototype.slice.call(arguments, 0);
var errorForStack = new Error('Declaration Location');
- return isSpecRunning() ? workFn.call(currentSpec) : workFn;
+ // IE10+ and PhanthomJS do not set stack trace information, until the error is thrown
+ if (!errorForStack.stack) {
+ try {
+ throw errorForStack;
+ } catch (e) {}
+ }
+ return wasInjectorCreated() ? workFn.call(currentSpec) : workFn;
/////////////////////
function workFn() {
var modules = currentSpec.$modules || [];
var strictDi = !!currentSpec.$injectorStrict;
+ modules.unshift(['$injector', function($injector) {
+ currentSpec.$providerInjector = $injector;
+ }]);
modules.unshift('ngMock');
modules.unshift('ng');
var injector = currentSpec.$injector;
@@ -2452,7 +2979,7 @@ if (window.jasmine || window.mocha) {
angular.mock.inject.strictDi = function(value) {
value = arguments.length ? !!value : true;
- return isSpecRunning() ? workFn() : workFn;
+ return wasInjectorCreated() ? workFn() : workFn;
function workFn() {
if (value !== currentSpec.$injectorStrict) {
@@ -2464,7 +2991,16 @@ if (window.jasmine || window.mocha) {
}
}
};
-}
+
+ function InjectorState() {
+ this.shared = false;
+ this.sharedError = null;
+
+ this.cleanupAfterEach = function() {
+ return !this.shared || this.sharedError;
+ };
+ }
+})(window.jasmine || window.mocha);
})(window, window.angular);
diff --git a/Web/Scripts/angular.js b/Web/Scripts/angular.js
index 3c64efb..05ebff5 100644
--- a/Web/Scripts/angular.js
+++ b/Web/Scripts/angular.js
@@ -1,9 +1,9 @@
-/**
- * @license AngularJS v1.4.7
- * (c) 2010-2015 Google, Inc. http://angularjs.org
+/**
+ * @license AngularJS v1.5.5
+ * (c) 2010-2016 Google, Inc. http://angularjs.org
* License: MIT
*/
-(function(window, document, undefined) {'use strict';
+(function(window) {'use strict';
/**
* @description
@@ -57,7 +57,7 @@ function minErr(module, ErrorConstructor) {
return match;
});
- message += '\nhttp://errors.angularjs.org/1.4.7/' +
+ message += '\nhttp://errors.angularjs.org/1.5.5/' +
(module ? module + '/' : '') + code;
for (i = SKIP_INDEXES, paramPrefix = '?'; i < templateArgs.length; i++, paramPrefix = '&') {
@@ -171,6 +171,7 @@ function minErr(module, ErrorConstructor) {
* @ngdoc module
* @name ng
* @module ng
+ * @installation
* @description
*
* # ng (core module)
@@ -188,29 +189,9 @@ var REGEX_STRING_REGEXP = /^\/(.+)\/([a-z]*)$/;
// This is used so that it's possible for internal tests to create mock ValidityStates.
var VALIDITY_STATE_PROPERTY = 'validity';
-/**
- * @ngdoc function
- * @name angular.lowercase
- * @module ng
- * @kind function
- *
- * @description Converts the specified string to lowercase.
- * @param {string} string String to be converted to lowercase.
- * @returns {string} Lowercased string.
- */
-var lowercase = function(string) {return isString(string) ? string.toLowerCase() : string;};
var hasOwnProperty = Object.prototype.hasOwnProperty;
-/**
- * @ngdoc function
- * @name angular.uppercase
- * @module ng
- * @kind function
- *
- * @description Converts the specified string to uppercase.
- * @param {string} string String to be converted to uppercase.
- * @returns {string} Uppercased string.
- */
+var lowercase = function(string) {return isString(string) ? string.toLowerCase() : string;};
var uppercase = function(string) {return isString(string) ? string.toUpperCase() : string;};
@@ -230,7 +211,7 @@ var manualUppercase = function(s) {
// String#toLowerCase and String#toUpperCase don't produce correct results in browsers with Turkish
// locale, for this reason we need to detect this case and redefine lowercase/uppercase methods
-// with correct but slower alternatives.
+// with correct but slower alternatives. See https://github.com/angular/angular.js/issues/11387
if ('i' !== 'I'.toLowerCase()) {
lowercase = manualLowercase;
uppercase = manualUppercase;
@@ -257,7 +238,7 @@ var
* documentMode is an IE-only property
* http://msdn.microsoft.com/en-us/library/ie/cc196988(v=vs.85).aspx
*/
-msie = document.documentMode;
+msie = window.document.documentMode;
/**
@@ -267,20 +248,25 @@ msie = document.documentMode;
* String ...)
*/
function isArrayLike(obj) {
- if (obj == null || isWindow(obj)) {
- return false;
- }
+
+ // `null`, `undefined` and `window` are not array-like
+ if (obj == null || isWindow(obj)) return false;
+
+ // arrays, strings and jQuery/jqLite objects are array like
+ // * jqLite is either the jQuery or jqLite constructor function
+ // * we have to check the existence of jqLite first as this method is called
+ // via the forEach method when constructing the jqLite object in the first place
+ if (isArray(obj) || isString(obj) || (jqLite && obj instanceof jqLite)) return true;
// Support: iOS 8.2 (not reproducible in simulator)
// "length" in obj used to prevent JIT error (gh-11508)
var length = "length" in Object(obj) && obj.length;
- if (obj.nodeType === NODE_TYPE_ELEMENT && length) {
- return true;
- }
+ // NodeList objects (with `item` method) and
+ // other objects with suitable length characteristics are array-like
+ return isNumber(length) &&
+ (length >= 0 && ((length - 1) in obj || obj instanceof Array) || typeof obj.item == 'function');
- return isString(obj) || isArray(obj) || length === 0 ||
- typeof length === 'number' && length > 0 && (length - 1) in obj;
}
/**
@@ -300,7 +286,7 @@ function isArrayLike(obj) {
*
* Unlike ES262's
* [Array.prototype.forEach](http://www.ecma-international.org/ecma-262/5.1/#sec-15.4.4.18),
- * Providing 'undefined' or 'null' values for `obj` will not throw a TypeError, but rather just
+ * providing 'undefined' or 'null' values for `obj` will not throw a TypeError, but rather just
* return the value provided.
*
```js
@@ -377,7 +363,7 @@ function forEachSorted(obj, iterator, context) {
* @returns {function(*, string)}
*/
function reverseParams(iteratorFn) {
- return function(value, key) { iteratorFn(key, value); };
+ return function(value, key) {iteratorFn(key, value);};
}
/**
@@ -425,6 +411,10 @@ function baseExtend(dst, objs, deep) {
dst[key] = new Date(src.valueOf());
} else if (isRegExp(src)) {
dst[key] = new RegExp(src);
+ } else if (src.nodeName) {
+ dst[key] = src.cloneNode(true);
+ } else if (isElement(src)) {
+ dst[key] = src.clone();
} else {
if (!isObject(dst[key])) dst[key] = isArray(src) ? [] : {};
baseExtend(dst[key], [src], true);
@@ -537,10 +527,10 @@ function identity($) {return $;}
identity.$inject = [];
-function valueFn(value) {return function() {return value;};}
+function valueFn(value) {return function valueRef() {return value;};}
function hasCustomToString(obj) {
- return isFunction(obj.toString) && obj.toString !== Object.prototype.toString;
+ return isFunction(obj.toString) && obj.toString !== toString;
}
@@ -739,9 +729,13 @@ function isPromiseLike(obj) {
}
-var TYPED_ARRAY_REGEXP = /^\[object (Uint8(Clamped)?)|(Uint16)|(Uint32)|(Int8)|(Int16)|(Int32)|(Float(32)|(64))Array\]$/;
+var TYPED_ARRAY_REGEXP = /^\[object (?:Uint8|Uint8Clamped|Uint16|Uint32|Int8|Int16|Int32|Float32|Float64)Array\]$/;
function isTypedArray(value) {
- return TYPED_ARRAY_REGEXP.test(toString.call(value));
+ return value && isNumber(value.length) && TYPED_ARRAY_REGEXP.test(toString.call(value));
+}
+
+function isArrayBuffer(obj) {
+ return toString.call(obj) === '[object ArrayBuffer]';
}
@@ -781,7 +775,7 @@ function isElement(node) {
* @returns {object} in the form of {key1:true, key2:true, ...}
*/
function makeMap(str) {
- var obj = {}, items = str.split(","), i;
+ var obj = {}, items = str.split(','), i;
for (i = 0; i < items.length; i++) {
obj[items[i]] = true;
}
@@ -863,100 +857,141 @@ function arrayRemove(array, value) {
*/
-function copy(source, destination, stackSource, stackDest) {
- if (isWindow(source) || isScope(source)) {
- throw ngMinErr('cpws',
- "Can't copy! Making copies of Window or Scope instances is not supported.");
- }
- if (isTypedArray(destination)) {
- throw ngMinErr('cpta',
- "Can't copy! TypedArray destination cannot be mutated.");
- }
+function copy(source, destination) {
+ var stackSource = [];
+ var stackDest = [];
- if (!destination) {
- destination = source;
- if (isObject(source)) {
- var index;
- if (stackSource && (index = stackSource.indexOf(source)) !== -1) {
- return stackDest[index];
- }
-
- // TypedArray, Date and RegExp have specific copy functionality and must be
- // pushed onto the stack before returning.
- // Array and other objects create the base object and recurse to copy child
- // objects. The array/object will be pushed onto the stack when recursed.
- if (isArray(source)) {
- return copy(source, [], stackSource, stackDest);
- } else if (isTypedArray(source)) {
- destination = new source.constructor(source);
- } else if (isDate(source)) {
- destination = new Date(source.getTime());
- } else if (isRegExp(source)) {
- destination = new RegExp(source.source, source.toString().match(/[^\/]*$/)[0]);
- destination.lastIndex = source.lastIndex;
- } else if (isFunction(source.cloneNode)) {
- destination = source.cloneNode(true);
- } else {
- var emptyObject = Object.create(getPrototypeOf(source));
- return copy(source, emptyObject, stackSource, stackDest);
- }
-
- if (stackDest) {
- stackSource.push(source);
- stackDest.push(destination);
- }
+ if (destination) {
+ if (isTypedArray(destination) || isArrayBuffer(destination)) {
+ throw ngMinErr('cpta', "Can't copy! TypedArray destination cannot be mutated.");
}
- } else {
- if (source === destination) throw ngMinErr('cpi',
- "Can't copy! Source and destination are identical.");
-
- stackSource = stackSource || [];
- stackDest = stackDest || [];
-
- if (isObject(source)) {
- stackSource.push(source);
- stackDest.push(destination);
+ if (source === destination) {
+ throw ngMinErr('cpi', "Can't copy! Source and destination are identical.");
}
- var result, key;
- if (isArray(source)) {
+ // Empty the destination object
+ if (isArray(destination)) {
destination.length = 0;
- for (var i = 0; i < source.length; i++) {
- destination.push(copy(source[i], null, stackSource, stackDest));
+ } else {
+ forEach(destination, function(value, key) {
+ if (key !== '$$hashKey') {
+ delete destination[key];
+ }
+ });
+ }
+
+ stackSource.push(source);
+ stackDest.push(destination);
+ return copyRecurse(source, destination);
+ }
+
+ return copyElement(source);
+
+ function copyRecurse(source, destination) {
+ var h = destination.$$hashKey;
+ var key;
+ if (isArray(source)) {
+ for (var i = 0, ii = source.length; i < ii; i++) {
+ destination.push(copyElement(source[i]));
+ }
+ } else if (isBlankObject(source)) {
+ // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty
+ for (key in source) {
+ destination[key] = copyElement(source[key]);
+ }
+ } else if (source && typeof source.hasOwnProperty === 'function') {
+ // Slow path, which must rely on hasOwnProperty
+ for (key in source) {
+ if (source.hasOwnProperty(key)) {
+ destination[key] = copyElement(source[key]);
+ }
}
} else {
- var h = destination.$$hashKey;
- if (isArray(destination)) {
- destination.length = 0;
- } else {
- forEach(destination, function(value, key) {
- delete destination[key];
- });
- }
- if (isBlankObject(source)) {
- // createMap() fast path --- Safe to avoid hasOwnProperty check because prototype chain is empty
- for (key in source) {
- destination[key] = copy(source[key], null, stackSource, stackDest);
- }
- } else if (source && typeof source.hasOwnProperty === 'function') {
- // Slow path, which must rely on hasOwnProperty
- for (key in source) {
- if (source.hasOwnProperty(key)) {
- destination[key] = copy(source[key], null, stackSource, stackDest);
- }
- }
- } else {
- // Slowest path --- hasOwnProperty can't be called as a method
- for (key in source) {
- if (hasOwnProperty.call(source, key)) {
- destination[key] = copy(source[key], null, stackSource, stackDest);
- }
+ // Slowest path --- hasOwnProperty can't be called as a method
+ for (key in source) {
+ if (hasOwnProperty.call(source, key)) {
+ destination[key] = copyElement(source[key]);
}
}
- setHashKey(destination,h);
+ }
+ setHashKey(destination, h);
+ return destination;
+ }
+
+ function copyElement(source) {
+ // Simple values
+ if (!isObject(source)) {
+ return source;
+ }
+
+ // Already copied values
+ var index = stackSource.indexOf(source);
+ if (index !== -1) {
+ return stackDest[index];
+ }
+
+ if (isWindow(source) || isScope(source)) {
+ throw ngMinErr('cpws',
+ "Can't copy! Making copies of Window or Scope instances is not supported.");
+ }
+
+ var needsRecurse = false;
+ var destination = copyType(source);
+
+ if (destination === undefined) {
+ destination = isArray(source) ? [] : Object.create(getPrototypeOf(source));
+ needsRecurse = true;
+ }
+
+ stackSource.push(source);
+ stackDest.push(destination);
+
+ return needsRecurse
+ ? copyRecurse(source, destination)
+ : destination;
+ }
+
+ function copyType(source) {
+ switch (toString.call(source)) {
+ case '[object Int8Array]':
+ case '[object Int16Array]':
+ case '[object Int32Array]':
+ case '[object Float32Array]':
+ case '[object Float64Array]':
+ case '[object Uint8Array]':
+ case '[object Uint8ClampedArray]':
+ case '[object Uint16Array]':
+ case '[object Uint32Array]':
+ return new source.constructor(copyElement(source.buffer));
+
+ case '[object ArrayBuffer]':
+ //Support: IE10
+ if (!source.slice) {
+ var copied = new ArrayBuffer(source.byteLength);
+ new Uint8Array(copied).set(new Uint8Array(source));
+ return copied;
+ }
+ return source.slice(0);
+
+ case '[object Boolean]':
+ case '[object Number]':
+ case '[object String]':
+ case '[object Date]':
+ return new source.constructor(source.valueOf());
+
+ case '[object RegExp]':
+ var re = new RegExp(source.source, source.toString().match(/[^\/]*$/)[0]);
+ re.lastIndex = source.lastIndex;
+ return re;
+
+ case '[object Blob]':
+ return new source.constructor([source], {type: source.type});
+ }
+
+ if (isFunction(source.cloneNode)) {
+ return source.cloneNode(true);
}
}
- return destination;
}
/**
@@ -1013,44 +1048,78 @@ function shallowCopy(src, dst) {
* @param {*} o1 Object or value to compare.
* @param {*} o2 Object or value to compare.
* @returns {boolean} True if arguments are equal.
+ *
+ * @example
+
+
+
+
+
+
+
+ angular.module('equalsExample', []).controller('ExampleController', ['$scope', function($scope) {
+ $scope.user1 = {};
+ $scope.user2 = {};
+ $scope.result;
+ $scope.compare = function() {
+ $scope.result = angular.equals($scope.user1, $scope.user2);
+ };
+ }]);
+
+
*/
function equals(o1, o2) {
if (o1 === o2) return true;
if (o1 === null || o2 === null) return false;
if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN
var t1 = typeof o1, t2 = typeof o2, length, key, keySet;
- if (t1 == t2) {
- if (t1 == 'object') {
- if (isArray(o1)) {
- if (!isArray(o2)) return false;
- if ((length = o1.length) == o2.length) {
- for (key = 0; key < length; key++) {
- if (!equals(o1[key], o2[key])) return false;
- }
- return true;
- }
- } else if (isDate(o1)) {
- if (!isDate(o2)) return false;
- return equals(o1.getTime(), o2.getTime());
- } else if (isRegExp(o1)) {
- return isRegExp(o2) ? o1.toString() == o2.toString() : false;
- } else {
- if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2) ||
- isArray(o2) || isDate(o2) || isRegExp(o2)) return false;
- keySet = createMap();
- for (key in o1) {
- if (key.charAt(0) === '$' || isFunction(o1[key])) continue;
+ if (t1 == t2 && t1 == 'object') {
+ if (isArray(o1)) {
+ if (!isArray(o2)) return false;
+ if ((length = o1.length) == o2.length) {
+ for (key = 0; key < length; key++) {
if (!equals(o1[key], o2[key])) return false;
- keySet[key] = true;
- }
- for (key in o2) {
- if (!(key in keySet) &&
- key.charAt(0) !== '$' &&
- isDefined(o2[key]) &&
- !isFunction(o2[key])) return false;
}
return true;
}
+ } else if (isDate(o1)) {
+ if (!isDate(o2)) return false;
+ return equals(o1.getTime(), o2.getTime());
+ } else if (isRegExp(o1)) {
+ if (!isRegExp(o2)) return false;
+ return o1.toString() == o2.toString();
+ } else {
+ if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2) ||
+ isArray(o2) || isDate(o2) || isRegExp(o2)) return false;
+ keySet = createMap();
+ for (key in o1) {
+ if (key.charAt(0) === '$' || isFunction(o1[key])) continue;
+ if (!equals(o1[key], o2[key])) return false;
+ keySet[key] = true;
+ }
+ for (key in o2) {
+ if (!(key in keySet) &&
+ key.charAt(0) !== '$' &&
+ isDefined(o2[key]) &&
+ !isFunction(o2[key])) return false;
+ }
+ return true;
}
}
return false;
@@ -1060,8 +1129,8 @@ var csp = function() {
if (!isDefined(csp.rules)) {
- var ngCspElement = (document.querySelector('[ng-csp]') ||
- document.querySelector('[data-ng-csp]'));
+ var ngCspElement = (window.document.querySelector('[ng-csp]') ||
+ window.document.querySelector('[data-ng-csp]'));
if (ngCspElement) {
var ngCspAttribute = ngCspElement.getAttribute('ng-csp') ||
@@ -1136,7 +1205,7 @@ var jq = function() {
var i, ii = ngAttrPrefixes.length, prefix, name;
for (i = 0; i < ii; ++i) {
prefix = ngAttrPrefixes[i];
- if (el = document.querySelector('[' + prefix.replace(':', '\\:') + 'jq]')) {
+ if (el = window.document.querySelector('[' + prefix.replace(':', '\\:') + 'jq]')) {
name = el.getAttribute(prefix + 'jq');
break;
}
@@ -1201,7 +1270,7 @@ function toJsonReplacer(key, value) {
val = undefined;
} else if (isWindow(value)) {
val = '$WINDOW';
- } else if (value && document === value) {
+ } else if (value && window.document === value) {
val = '$DOCUMENT';
} else if (isScope(value)) {
val = '$SCOPE';
@@ -1227,7 +1296,7 @@ function toJsonReplacer(key, value) {
* @returns {string|undefined} JSON-ified string representing `obj`.
*/
function toJson(obj, pretty) {
- if (typeof obj === 'undefined') return undefined;
+ if (isUndefined(obj)) return undefined;
if (!isNumber(pretty)) {
pretty = pretty ? 2 : null;
}
@@ -1254,7 +1323,10 @@ function fromJson(json) {
}
+var ALL_COLONS = /:/g;
function timezoneToOffset(timezone, fallback) {
+ // IE/Edge do not "understand" colon (`:`) in timezone
+ timezone = timezone.replace(ALL_COLONS, '');
var requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;
return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset;
}
@@ -1269,8 +1341,9 @@ function addDateMinutes(date, minutes) {
function convertTimezoneToLocal(date, timezone, reverse) {
reverse = reverse ? -1 : 1;
- var timezoneOffset = timezoneToOffset(timezone, date.getTimezoneOffset());
- return addDateMinutes(date, reverse * (timezoneOffset - date.getTimezoneOffset()));
+ var dateTimezoneOffset = date.getTimezoneOffset();
+ var timezoneOffset = timezoneToOffset(timezone, dateTimezoneOffset);
+ return addDateMinutes(date, reverse * (timezoneOffset - dateTimezoneOffset));
}
@@ -1289,7 +1362,7 @@ function startingTag(element) {
return element[0].nodeType === NODE_TYPE_TEXT ? lowercase(elemHtml) :
elemHtml.
match(/^(<[^>]+>)/)[1].
- replace(/^<([\w\-]+)/, function(match, nodeName) { return '<' + lowercase(nodeName); });
+ replace(/^<([\w\-]+)/, function(match, nodeName) {return '<' + lowercase(nodeName);});
} catch (e) {
return lowercase(elemHtml);
}
@@ -1437,10 +1510,17 @@ function getNgAttribute(element, ngAttr) {
* designates the **root element** of the application and is typically placed near the root element
* of the page - e.g. on the `` or `` tags.
*
- * Only one AngularJS application can be auto-bootstrapped per HTML document. The first `ngApp`
- * found in the document will be used to define the root element to auto-bootstrap as an
- * application. To run multiple applications in an HTML document you must manually bootstrap them using
- * {@link angular.bootstrap} instead. AngularJS applications cannot be nested within each other.
+ * There are a few things to keep in mind when using `ngApp`:
+ * - only one AngularJS application can be auto-bootstrapped per HTML document. The first `ngApp`
+ * found in the document will be used to define the root element to auto-bootstrap as an
+ * application. To run multiple applications in an HTML document you must manually bootstrap them using
+ * {@link angular.bootstrap} instead.
+ * - AngularJS applications cannot be nested within each other.
+ * - Do not use a directive that uses {@link ng.$compile#transclusion transclusion} on the same element as `ngApp`.
+ * This includes directives such as {@link ng.ngIf `ngIf`}, {@link ng.ngInclude `ngInclude`} and
+ * {@link ngRoute.ngView `ngView`}.
+ * Doing this misplaces the app {@link ng.$rootElement `$rootElement`} and the app's {@link auto.$injector injector},
+ * causing animations to stop working and making the injector inaccessible from outside the app.
*
* You can specify an **AngularJS module** to be used as the root module for the application. This
* module will be loaded into the {@link auto.$injector} when the application is bootstrapped. It
@@ -1580,16 +1660,25 @@ function angularInit(element, bootstrap) {
* @description
* Use this function to manually start up angular application.
*
- * See: {@link guide/bootstrap Bootstrap}
- *
- * Note that Protractor based end-to-end tests cannot use this function to bootstrap manually.
- * They must use {@link ng.directive:ngApp ngApp}.
+ * For more information, see the {@link guide/bootstrap Bootstrap guide}.
*
* Angular will detect if it has been loaded into the browser more than once and only allow the
* first loaded script to be bootstrapped and will report a warning to the browser console for
* each of the subsequent scripts. This prevents strange results in applications, where otherwise
* multiple instances of Angular try to work on the DOM.
*
+ *
+ * **Note:** Protractor based end-to-end tests cannot use this function to bootstrap manually.
+ * They must use {@link ng.directive:ngApp ngApp}.
+ *
+ *
+ *
+ * **Note:** Do not bootstrap the app on an element with a directive that uses {@link ng.$compile#transclusion transclusion},
+ * such as {@link ng.ngIf `ngIf`}, {@link ng.ngInclude `ngInclude`} and {@link ngRoute.ngView `ngView`}.
+ * Doing this misplaces the app {@link ng.$rootElement `$rootElement`} and the app's {@link auto.$injector injector},
+ * causing animations to stop working and making the injector inaccessible from outside the app.
+ *
+ *
* ```html
*
*
@@ -1633,11 +1722,11 @@ function bootstrap(element, modules, config) {
element = jqLite(element);
if (element.injector()) {
- var tag = (element[0] === document) ? 'document' : startingTag(element);
+ var tag = (element[0] === window.document) ? 'document' : startingTag(element);
//Encode angle brackets to prevent input from being sanitized to empty string #8683
throw ngMinErr(
'btstrpd',
- "App Already Bootstrapped with this Element '{0}'",
+ "App already bootstrapped with this element '{0}'",
tag.replace(/,'<').replace(/>/,'>'));
}
@@ -1732,7 +1821,6 @@ function snake_case(name, separator) {
}
var bindJQueryFired = false;
-var skipDestroyOnNextJQueryCleanData;
function bindJQuery() {
var originalCleanData;
@@ -1766,15 +1854,11 @@ function bindJQuery() {
originalCleanData = jQuery.cleanData;
jQuery.cleanData = function(elems) {
var events;
- if (!skipDestroyOnNextJQueryCleanData) {
- for (var i = 0, elem; (elem = elems[i]) != null; i++) {
- events = jQuery._data(elem, "events");
- if (events && events.$destroy) {
- jQuery(elem).triggerHandler('$destroy');
- }
+ for (var i = 0, elem; (elem = elems[i]) != null; i++) {
+ events = jQuery._data(elem, "events");
+ if (events && events.$destroy) {
+ jQuery(elem).triggerHandler('$destroy');
}
- } else {
- skipDestroyOnNextJQueryCleanData = false;
}
originalCleanData(elems);
};
@@ -1968,7 +2052,7 @@ function setupModuleLoader(window) {
* unspecified then the module is being retrieved for further configuration.
* @param {Function=} configFn Optional configuration function for the module. Same as
* {@link angular.Module#config Module#config()}.
- * @returns {module} new module with the {@link angular.Module} api.
+ * @returns {angular.Module} new module with the {@link angular.Module} api.
*/
return function module(name, requires, configFn) {
var assertNotHasOwnProperty = function(name, context) {
@@ -2080,7 +2164,7 @@ function setupModuleLoader(window) {
* @param {string} name constant name
* @param {*} object Constant value.
* @description
- * Because the constant are fixed, they get applied before other provide methods.
+ * Because the constants are fixed, they get applied before other provide methods.
* See {@link auto.$provide#constant $provide.constant()}.
*/
constant: invokeLater('$provide', 'constant', 'unshift'),
@@ -2089,9 +2173,9 @@ function setupModuleLoader(window) {
* @ngdoc method
* @name angular.Module#decorator
* @module ng
- * @param {string} The name of the service to decorate.
- * @param {Function} This function will be invoked when the service needs to be
- * instantiated and should return the decorated service instance.
+ * @param {string} name The name of the service to decorate.
+ * @param {Function} decorFn This function will be invoked when the service needs to be
+ * instantiated and should return the decorated service instance.
* @description
* See {@link auto.$provide#decorator $provide.decorator()}.
*/
@@ -2174,6 +2258,19 @@ function setupModuleLoader(window) {
*/
directive: invokeLaterAndSetModuleName('$compileProvider', 'directive'),
+ /**
+ * @ngdoc method
+ * @name angular.Module#component
+ * @module ng
+ * @param {string} name Name of the component in camel-case (i.e. myComp which will match as my-comp)
+ * @param {Object} options Component definition object (a simplified
+ * {@link ng.$compile#directive-definition-object directive definition object})
+ *
+ * @description
+ * See {@link ng.$compileProvider#component $compileProvider.component()}.
+ */
+ component: invokeLaterAndSetModuleName('$compileProvider', 'component'),
+
/**
* @ngdoc method
* @name angular.Module#config
@@ -2325,11 +2422,14 @@ function toDebugString(obj) {
$AnchorScrollProvider,
$AnimateProvider,
$CoreAnimateCssProvider,
+ $$CoreAnimateJsProvider,
$$CoreAnimateQueueProvider,
- $$CoreAnimateRunnerProvider,
+ $$AnimateRunnerFactoryProvider,
+ $$AnimateAsyncRunFactoryProvider,
$BrowserProvider,
$CacheFactoryProvider,
$ControllerProvider,
+ $DateProvider,
$DocumentProvider,
$ExceptionHandlerProvider,
$FilterProvider,
@@ -2379,11 +2479,11 @@ function toDebugString(obj) {
* - `codeName` – `{string}` – Code name of the release, such as "jiggling-armfat".
*/
var version = {
- full: '1.4.7', // all of these placeholder strings will be replaced by grunt's
+ full: '1.5.5', // all of these placeholder strings will be replaced by grunt's
major: 1, // package task
- minor: 4,
- dot: 7,
- codeName: 'dark-luminescence'
+ minor: 5,
+ dot: 5,
+ codeName: 'material-conspiration'
};
@@ -2485,8 +2585,10 @@ function publishExternalAPI(angular) {
$anchorScroll: $AnchorScrollProvider,
$animate: $AnimateProvider,
$animateCss: $CoreAnimateCssProvider,
+ $$animateJs: $$CoreAnimateJsProvider,
$$animateQueue: $$CoreAnimateQueueProvider,
- $$AnimateRunner: $$CoreAnimateRunnerProvider,
+ $$AnimateRunner: $$AnimateRunnerFactoryProvider,
+ $$animateAsyncRun: $$AnimateAsyncRunFactoryProvider,
$browser: $BrowserProvider,
$cacheFactory: $CacheFactoryProvider,
$controller: $ControllerProvider,
@@ -2557,16 +2659,22 @@ function publishExternalAPI(angular) {
*
* If jQuery is available, `angular.element` is an alias for the
* [jQuery](http://api.jquery.com/jQuery/) function. If jQuery is not available, `angular.element`
- * delegates to Angular's built-in subset of jQuery, called "jQuery lite" or "jqLite."
+ * delegates to Angular's built-in subset of jQuery, called "jQuery lite" or **jqLite**.
*
- *
jqLite is a tiny, API-compatible subset of jQuery that allows
- * Angular to manipulate the DOM in a cross-browser compatible way. **jqLite** implements only the most
- * commonly needed functionality with the goal of having a very small footprint.
+ * jqLite is a tiny, API-compatible subset of jQuery that allows
+ * Angular to manipulate the DOM in a cross-browser compatible way. jqLite implements only the most
+ * commonly needed functionality with the goal of having a very small footprint.
*
- * To use `jQuery`, simply ensure it is loaded before the `angular.js` file.
+ * To use `jQuery`, simply ensure it is loaded before the `angular.js` file. You can also use the
+ * {@link ngJq `ngJq`} directive to specify that jqlite should be used over jQuery, or to use a
+ * specific version of jQuery if multiple versions exist on the page.
*
- *
**Note:** all element references in Angular are always wrapped with jQuery or
- * jqLite; they are never raw DOM references.
+ *
**Note:** All element references in Angular are always wrapped with jQuery or
+ * jqLite (such as the element argument in a directive's compile / link function). They are never raw DOM references.
+ *
+ *
**Note:** Keep in mind that this function will not find elements
+ * by tag name / CSS selector. For lookups by tag name, try instead `angular.element(document).find(...)`
+ * or `$document.find()`, or use the standard DOM APIs, e.g. `document.querySelectorAll()`.
*
* ## Angular's jqLite
* jqLite provides only the following jQuery methods:
@@ -2579,7 +2687,8 @@ function publishExternalAPI(angular) {
* - [`children()`](http://api.jquery.com/children/) - Does not support selectors
* - [`clone()`](http://api.jquery.com/clone/)
* - [`contents()`](http://api.jquery.com/contents/)
- * - [`css()`](http://api.jquery.com/css/) - Only retrieves inline-styles, does not call `getComputedStyle()`. As a setter, does not convert numbers to strings or append 'px'.
+ * - [`css()`](http://api.jquery.com/css/) - Only retrieves inline-styles, does not call `getComputedStyle()`.
+ * As a setter, does not convert numbers to strings or append 'px', and also does not have automatic property prefixing.
* - [`data()`](http://api.jquery.com/data/)
* - [`detach()`](http://api.jquery.com/detach/)
* - [`empty()`](http://api.jquery.com/empty/)
@@ -2631,6 +2740,9 @@ function publishExternalAPI(angular) {
* - `inheritedData()` - same as `data()`, but walks up the DOM until a value is found or the top
* parent element is reached.
*
+ * @knownIssue You cannot spy on `angular.element` if you are using Jasmine version 1.x. See
+ * https://github.com/angular/angular.js/issues/14251 for more information.
+ *
* @param {string|DOMElement} element HTML string or DOMElement to be wrapped into jQuery.
* @returns {Object} jQuery object.
*/
@@ -2713,6 +2825,12 @@ function jqLiteHasData(node) {
return false;
}
+function jqLiteCleanData(nodes) {
+ for (var i = 0, ii = nodes.length; i < ii; i++) {
+ jqLiteRemoveData(nodes[i]);
+ }
+}
+
function jqLiteBuildFragment(html, context) {
var tmp, tag, wrap,
fragment = context.createDocumentFragment(),
@@ -2751,7 +2869,7 @@ function jqLiteBuildFragment(html, context) {
}
function jqLiteParseHTML(html, context) {
- context = context || document;
+ context = context || window.document;
var parsed;
if ((parsed = SINGLE_TAG_REGEXP.exec(html))) {
@@ -2765,6 +2883,24 @@ function jqLiteParseHTML(html, context) {
return [];
}
+function jqLiteWrapNode(node, wrapper) {
+ var parent = node.parentNode;
+
+ if (parent) {
+ parent.replaceChild(wrapper, node);
+ }
+
+ wrapper.appendChild(node);
+}
+
+
+// IE9-11 has no method "contains" in SVG element and in Node.prototype. Bug #10259.
+var jqLiteContains = window.Node.prototype.contains || function(arg) {
+ // jshint bitwise: false
+ return !!(this.compareDocumentPosition(arg) & 16);
+ // jshint bitwise: true
+};
+
/////////////////////////////////////////////
function JQLite(element) {
if (element instanceof JQLite) {
@@ -2823,17 +2959,23 @@ function jqLiteOff(element, type, fn, unsupported) {
delete events[type];
}
} else {
- forEach(type.split(' '), function(type) {
- if (isDefined(fn)) {
- var listenerFns = events[type];
- arrayRemove(listenerFns || [], fn);
- if (listenerFns && listenerFns.length > 0) {
- return;
- }
- }
- removeEventListenerFn(element, type, handle);
- delete events[type];
+ var removeHandler = function(type) {
+ var listenerFns = events[type];
+ if (isDefined(fn)) {
+ arrayRemove(listenerFns || [], fn);
+ }
+ if (!(isDefined(fn) && listenerFns && listenerFns.length > 0)) {
+ removeEventListenerFn(element, type, handle);
+ delete events[type];
+ }
+ };
+
+ forEach(type.split(' '), function(type) {
+ removeHandler(type);
+ if (MOUSE_EVENT_MAP[type]) {
+ removeHandler(MOUSE_EVENT_MAP[type]);
+ }
});
}
}
@@ -3001,7 +3143,7 @@ function jqLiteRemove(element, keepData) {
function jqLiteDocumentLoaded(action, win) {
win = win || window;
if (win.document.readyState === 'complete') {
- // Force the action to be run async for consistent behaviour
+ // Force the action to be run async for consistent behavior
// from the action's point of view
// i.e. it will definitely not be in a $apply
win.setTimeout(action);
@@ -3025,8 +3167,8 @@ var JQLitePrototype = JQLite.prototype = {
}
// check if document is already loaded
- if (document.readyState === 'complete') {
- setTimeout(trigger);
+ if (window.document.readyState === 'complete') {
+ window.setTimeout(trigger);
} else {
this.on('DOMContentLoaded', trigger); // works for modern browsers and IE9
// we can not use jqLite since we are not done loading and jQuery could be loaded later.
@@ -3087,7 +3229,8 @@ function getAliasedAttrName(name) {
forEach({
data: jqLiteData,
removeData: jqLiteRemoveData,
- hasData: jqLiteHasData
+ hasData: jqLiteHasData,
+ cleanData: jqLiteCleanData
}, function(fn, name) {
JQLite[name] = fn;
});
@@ -3288,6 +3431,9 @@ function createEventHandler(element, events) {
return event.immediatePropagationStopped === true;
};
+ // Some events have special handlers that wrap the real handler
+ var handlerWrapper = eventFns.specialHandlerWrapper || defaultHandlerWrapper;
+
// Copy event handlers in case event handlers array is modified during execution.
if ((eventFnsLength > 1)) {
eventFns = shallowCopy(eventFns);
@@ -3295,7 +3441,7 @@ function createEventHandler(element, events) {
for (var i = 0; i < eventFnsLength; i++) {
if (!event.isImmediatePropagationStopped()) {
- eventFns[i].call(element, event);
+ handlerWrapper(element, event, eventFns[i]);
}
}
};
@@ -3306,6 +3452,22 @@ function createEventHandler(element, events) {
return eventHandler;
}
+function defaultHandlerWrapper(element, event, handler) {
+ handler.call(element, event);
+}
+
+function specialMouseHandlerWrapper(target, event, handler) {
+ // Refer to jQuery's implementation of mouseenter & mouseleave
+ // Read about mouseenter and mouseleave:
+ // http://www.quirksmode.org/js/events_mouse.html#link8
+ var related = event.relatedTarget;
+ // For mousenter/leave call the handler if related is outside the target.
+ // NB: No relatedTarget if the mouse left/entered the browser window
+ if (!related || (related !== target && !jqLiteContains.call(target, related))) {
+ handler.call(target, event);
+ }
+}
+
//////////////////////////////////////////
// Functions iterating traversal.
// These functions chain results into a single
@@ -3334,35 +3496,28 @@ forEach({
var types = type.indexOf(' ') >= 0 ? type.split(' ') : [type];
var i = types.length;
- while (i--) {
- type = types[i];
+ var addHandler = function(type, specialHandlerWrapper, noEventListener) {
var eventFns = events[type];
if (!eventFns) {
- events[type] = [];
-
- if (type === 'mouseenter' || type === 'mouseleave') {
- // Refer to jQuery's implementation of mouseenter & mouseleave
- // Read about mouseenter and mouseleave:
- // http://www.quirksmode.org/js/events_mouse.html#link8
-
- jqLiteOn(element, MOUSE_EVENT_MAP[type], function(event) {
- var target = this, related = event.relatedTarget;
- // For mousenter/leave call the handler if related is outside the target.
- // NB: No relatedTarget if the mouse left/entered the browser window
- if (!related || (related !== target && !target.contains(related))) {
- handle(event, type);
- }
- });
-
- } else {
- if (type !== '$destroy') {
- addEventListenerFn(element, type, handle);
- }
+ eventFns = events[type] = [];
+ eventFns.specialHandlerWrapper = specialHandlerWrapper;
+ if (type !== '$destroy' && !noEventListener) {
+ addEventListenerFn(element, type, handle);
}
- eventFns = events[type];
}
+
eventFns.push(fn);
+ };
+
+ while (i--) {
+ type = types[i];
+ if (MOUSE_EVENT_MAP[type]) {
+ addHandler(MOUSE_EVENT_MAP[type], specialMouseHandlerWrapper);
+ addHandler(type, undefined, true);
+ } else {
+ addHandler(type);
+ }
}
},
@@ -3430,12 +3585,7 @@ forEach({
},
wrap: function(element, wrapNode) {
- wrapNode = jqLite(wrapNode).eq(0).clone()[0];
- var parent = element.parentNode;
- if (parent) {
- parent.replaceChild(wrapNode, element);
- }
- wrapNode.appendChild(element);
+ jqLiteWrapNode(element, jqLite(wrapNode).eq(0).clone()[0]);
},
remove: jqLiteRemove,
@@ -3708,22 +3858,29 @@ var $$HashMapProvider = [function() {
/**
* @ngdoc module
* @name auto
+ * @installation
* @description
*
* Implicit module which gets automatically added to each {@link auto.$injector $injector}.
*/
+var ARROW_ARG = /^([^\(]+?)=>/;
var FN_ARGS = /^[^\(]*\(\s*([^\)]*)\)/m;
var FN_ARG_SPLIT = /,/;
var FN_ARG = /^\s*(_?)(\S+?)\1\s*$/;
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;
var $injectorMinErr = minErr('$injector');
+function extractArgs(fn) {
+ var fnText = Function.prototype.toString.call(fn).replace(STRIP_COMMENTS, ''),
+ args = fnText.match(ARROW_ARG) || fnText.match(FN_ARGS);
+ return args;
+}
+
function anonFn(fn) {
// For anonymous functions, showing at the very least the function signature can help in
// debugging.
- var fnText = fn.toString().replace(STRIP_COMMENTS, ''),
- args = fnText.match(FN_ARGS);
+ var args = extractArgs(fn);
if (args) {
return 'function(' + (args[1] || '').replace(/[\s\r\n]+/, ' ') + ')';
}
@@ -3732,7 +3889,6 @@ function anonFn(fn) {
function annotate(fn, strictDi, name) {
var $inject,
- fnText,
argDecl,
last;
@@ -3747,8 +3903,7 @@ function annotate(fn, strictDi, name) {
throw $injectorMinErr('strictdi',
'{0} is not using explicit annotation and cannot be invoked in strict mode', name);
}
- fnText = fn.toString().replace(STRIP_COMMENTS, '');
- argDecl = fnText.match(FN_ARGS);
+ argDecl = extractArgs(fn);
forEach(argDecl[1].split(FN_ARG_SPLIT), function(arg) {
arg.replace(FN_ARG, function(all, underscore, name) {
$inject.push(name);
@@ -4138,8 +4293,20 @@ function annotate(fn, strictDi, name) {
*
* Register a **service constructor**, which will be invoked with `new` to create the service
* instance.
- * This is short for registering a service where its provider's `$get` property is the service
- * constructor function that will be used to instantiate the service instance.
+ * This is short for registering a service where its provider's `$get` property is a factory
+ * function that returns an instance instantiated by the injector from the service constructor
+ * function.
+ *
+ * Internally it looks a bit like this:
+ *
+ * ```
+ * {
+ * $get: function() {
+ * return $injector.instantiate(constructor);
+ * }
+ * }
+ * ```
+ *
*
* You should use {@link auto.$provide#service $provide.service(class)} if you define your service
* as a type/class.
@@ -4179,14 +4346,13 @@ function annotate(fn, strictDi, name) {
* @description
*
* Register a **value service** with the {@link auto.$injector $injector}, such as a string, a
- * number, an array, an object or a function. This is short for registering a service where its
+ * number, an array, an object or a function. This is short for registering a service where its
* provider's `$get` property is a factory function that takes no arguments and returns the **value
- * service**.
+ * service**. That also means it is not possible to inject other services into a value service.
*
* Value services are similar to constant services, except that they cannot be injected into a
* module configuration function (see {@link angular.Module#config}) but they can be overridden by
- * an Angular
- * {@link auto.$provide#decorator decorator}.
+ * an Angular {@link auto.$provide#decorator decorator}.
*
* @param {string} name The name of the instance.
* @param {*} value The value.
@@ -4211,8 +4377,11 @@ function annotate(fn, strictDi, name) {
* @name $provide#constant
* @description
*
- * Register a **constant service**, such as a string, a number, an array, an object or a function,
- * with the {@link auto.$injector $injector}. Unlike {@link auto.$provide#value value} it can be
+ * Register a **constant service** with the {@link auto.$injector $injector}, such as a string,
+ * a number, an array, an object or a function. Like the {@link auto.$provide#value value}, it is not
+ * possible to inject other services into a constant.
+ *
+ * But unlike {@link auto.$provide#value value}, a constant can be
* injected into a module configuration function (see {@link angular.Module#config}) and it cannot
* be overridden by an Angular {@link auto.$provide#decorator decorator}.
*
@@ -4240,7 +4409,7 @@ function annotate(fn, strictDi, name) {
* @description
*
* Register a **service decorator** with the {@link auto.$injector $injector}. A service decorator
- * intercepts the creation of a service, allowing it to override or modify the behaviour of the
+ * intercepts the creation of a service, allowing it to override or modify the behavior of the
* service. The object returned by the decorator may be the original service, or a new service
* object which replaces or wraps and delegates to the original service.
*
@@ -4289,14 +4458,19 @@ function createInjector(modulesToLoad, strictDi) {
throw $injectorMinErr('unpr', "Unknown provider: {0}", path.join(' <- '));
})),
instanceCache = {},
- instanceInjector = (instanceCache.$injector =
+ protoInstanceInjector =
createInternalInjector(instanceCache, function(serviceName, caller) {
var provider = providerInjector.get(serviceName + providerSuffix, caller);
- return instanceInjector.invoke(provider.$get, provider, undefined, serviceName);
- }));
+ return instanceInjector.invoke(
+ provider.$get, provider, undefined, serviceName);
+ }),
+ instanceInjector = protoInstanceInjector;
-
- forEach(loadModules(modulesToLoad), function(fn) { if (fn) instanceInjector.invoke(fn); });
+ providerCache['$injector' + providerSuffix] = { $get: valueFn(protoInstanceInjector) };
+ var runBlocks = loadModules(modulesToLoad);
+ instanceInjector = protoInstanceInjector.get('$injector');
+ instanceInjector.strictDi = strictDi;
+ forEach(runBlocks, function(fn) { if (fn) instanceInjector.invoke(fn); });
return instanceInjector;
@@ -4446,48 +4620,67 @@ function createInjector(modulesToLoad, strictDi) {
}
}
+
+ function injectionArgs(fn, locals, serviceName) {
+ var args = [],
+ $inject = createInjector.$$annotate(fn, strictDi, serviceName);
+
+ for (var i = 0, length = $inject.length; i < length; i++) {
+ var key = $inject[i];
+ if (typeof key !== 'string') {
+ throw $injectorMinErr('itkn',
+ 'Incorrect injection token! Expected service name as string, got {0}', key);
+ }
+ args.push(locals && locals.hasOwnProperty(key) ? locals[key] :
+ getService(key, serviceName));
+ }
+ return args;
+ }
+
+ function isClass(func) {
+ // IE 9-11 do not support classes and IE9 leaks with the code below.
+ if (msie <= 11) {
+ return false;
+ }
+ // Workaround for MS Edge.
+ // Check https://connect.microsoft.com/IE/Feedback/Details/2211653
+ return typeof func === 'function'
+ && /^(?:class\s|constructor\()/.test(Function.prototype.toString.call(func));
+ }
+
function invoke(fn, self, locals, serviceName) {
if (typeof locals === 'string') {
serviceName = locals;
locals = null;
}
- var args = [],
- $inject = createInjector.$$annotate(fn, strictDi, serviceName),
- length, i,
- key;
-
- for (i = 0, length = $inject.length; i < length; i++) {
- key = $inject[i];
- if (typeof key !== 'string') {
- throw $injectorMinErr('itkn',
- 'Incorrect injection token! Expected service name as string, got {0}', key);
- }
- args.push(
- locals && locals.hasOwnProperty(key)
- ? locals[key]
- : getService(key, serviceName)
- );
- }
+ var args = injectionArgs(fn, locals, serviceName);
if (isArray(fn)) {
- fn = fn[length];
+ fn = fn[fn.length - 1];
}
- // http://jsperf.com/angularjs-invoke-apply-vs-switch
- // #5388
- return fn.apply(self, args);
+ if (!isClass(fn)) {
+ // http://jsperf.com/angularjs-invoke-apply-vs-switch
+ // #5388
+ return fn.apply(self, args);
+ } else {
+ args.unshift(null);
+ return new (Function.prototype.bind.apply(fn, args))();
+ }
}
+
function instantiate(Type, locals, serviceName) {
// Check if Type is annotated and use just the given function at n-1 as parameter
// e.g. someModule.factory('greeter', ['$window', function(renamed$window) {}]);
- // Object creation: http://jsperf.com/create-constructor/2
- var instance = Object.create((isArray(Type) ? Type[Type.length - 1] : Type).prototype || null);
- var returnedValue = invoke(Type, instance, locals, serviceName);
-
- return isObject(returnedValue) || isFunction(returnedValue) ? returnedValue : instance;
+ var ctor = (isArray(Type) ? Type[Type.length - 1] : Type);
+ var args = injectionArgs(Type, locals, serviceName);
+ // Empty object at position 0 is ignored for invocation with `new`, but required.
+ args.unshift(null);
+ return new (Function.prototype.bind.apply(ctor, args))();
}
+
return {
invoke: invoke,
instantiate: instantiate,
@@ -4543,7 +4736,7 @@ function $AnchorScrollProvider() {
* When called, it scrolls to the element related to the specified `hash` or (if omitted) to the
* current value of {@link ng.$location#hash $location.hash()}, according to the rules specified
* in the
- * [HTML5 spec](http://dev.w3.org/html5/spec/Overview.html#the-indicated-part-of-the-document).
+ * [HTML5 spec](http://www.w3.org/html/wg/drafts/html/master/browsers.html#the-indicated-part-of-the-document).
*
* It also watches the {@link ng.$location#hash $location.hash()} and automatically scrolls to
* match any anchor whenever it changes. This can be disabled by calling
@@ -4826,27 +5019,8 @@ function prepareAnimateOptions(options) {
: {};
}
-var $$CoreAnimateRunnerProvider = function() {
- this.$get = ['$q', '$$rAF', function($q, $$rAF) {
- function AnimateRunner() {}
- AnimateRunner.all = noop;
- AnimateRunner.chain = noop;
- AnimateRunner.prototype = {
- end: noop,
- cancel: noop,
- resume: noop,
- pause: noop,
- complete: noop,
- then: function(pass, fail) {
- return $q(function(resolve) {
- $$rAF(function() {
- resolve();
- });
- }).then(pass, fail);
- }
- };
- return AnimateRunner;
- }];
+var $$CoreAnimateJsProvider = function() {
+ this.$get = noop;
};
// this is prefixed with Core since it conflicts with
@@ -4874,7 +5048,12 @@ var $$CoreAnimateQueueProvider = function() {
addRemoveClassesPostDigest(element, options.addClass, options.removeClass);
}
- return new $$AnimateRunner(); // jshint ignore:line
+ var runner = new $$AnimateRunner(); // jshint ignore:line
+
+ // since there are no animations to run the runner needs to be
+ // notified that the animation call is complete.
+ runner.complete();
+ return runner;
}
};
@@ -5058,7 +5237,7 @@ var $AnimateProvider = ['$provide', function($provide) {
* when an animation is detected (and animations are enabled), $animate will do the heavy lifting
* to ensure that animation runs with the triggered DOM operation.
*
- * By default $animate doesn't trigger an animations. This is because the `ngAnimate` module isn't
+ * By default $animate doesn't trigger any animations. This is because the `ngAnimate` module isn't
* included and only when it is active then the animation hooks that `$animate` triggers will be
* functional. Once active then all structural `ng-` directives will trigger animations as they perform
* their DOM-related operations (enter, leave and move). Other directives such as `ngClass`,
@@ -5113,15 +5292,20 @@ var $AnimateProvider = ['$provide', function($provide) {
* // remove all the animation event listeners listening for `enter`
* $animate.off('enter');
*
+ * // remove listeners for all animation events from the container element
+ * $animate.off(container);
+ *
* // remove all the animation event listeners listening for `enter` on the given element and its children
* $animate.off('enter', container);
*
- * // remove the event listener function provided by `listenerFn` that is set
- * // to listen for `enter` on the given `element` as well as its children
+ * // remove the event listener function provided by `callback` that is set
+ * // to listen for `enter` on the given `container` as well as its children
* $animate.off('enter', container, callback);
* ```
*
- * @param {string} event the animation event (e.g. enter, leave, move, addClass, removeClass, etc...)
+ * @param {string|DOMElement} event|container the animation event (e.g. enter, leave, move,
+ * addClass, removeClass, etc...), or the container element. If it is the element, all other
+ * arguments are ignored.
* @param {DOMElement=} container the container element the event listener was placed on
* @param {Function=} callback the callback function that was registered as the listener
*/
@@ -5339,17 +5523,30 @@ var $AnimateProvider = ['$provide', function($provide) {
* @kind function
*
* @description Performs an inline animation on the element which applies the provided to and from CSS styles to the element.
- * If any detected CSS transition, keyframe or JavaScript matches the provided className value then the animation will take
- * on the provided styles. For example, if a transition animation is set for the given className then the provided from and
- * to styles will be applied alongside the given transition. If a JavaScript animation is detected then the provided styles
- * will be given in as function paramters into the `animate` method (or as apart of the `options` parameter).
+ * If any detected CSS transition, keyframe or JavaScript matches the provided className value, then the animation will take
+ * on the provided styles. For example, if a transition animation is set for the given classNamem, then the provided `from` and
+ * `to` styles will be applied alongside the given transition. If the CSS style provided in `from` does not have a corresponding
+ * style in `to`, the style in `from` is applied immediately, and no animation is run.
+ * If a JavaScript animation is detected then the provided styles will be given in as function parameters into the `animate`
+ * method (or as part of the `options` parameter):
+ *
+ * ```js
+ * ngModule.animation('.my-inline-animation', function() {
+ * return {
+ * animate : function(element, from, to, done, options) {
+ * //animation
+ * done();
+ * }
+ * }
+ * });
+ * ```
*
* @param {DOMElement} element the element which the CSS styles will be applied to
* @param {object} from the from (starting) CSS styles that will be applied to the element and across the animation.
* @param {object} to the to (destination) CSS styles that will be applied to the element and across the animation.
* @param {string=} className an optional CSS class that will be applied to the element for the duration of the animation. If
* this value is left as empty then a CSS class of `ng-inline-animate` will be applied to the element.
- * (Note that if no animation is detected then this value will not be appplied to the element.)
+ * (Note that if no animation is detected then this value will not be applied to the element.)
* @param {object=} options an optional collection of options/styles that will be applied to the element
*
* @return {Promise} the animation callback promise
@@ -5367,6 +5564,190 @@ var $AnimateProvider = ['$provide', function($provide) {
}];
}];
+var $$AnimateAsyncRunFactoryProvider = function() {
+ this.$get = ['$$rAF', function($$rAF) {
+ var waitQueue = [];
+
+ function waitForTick(fn) {
+ waitQueue.push(fn);
+ if (waitQueue.length > 1) return;
+ $$rAF(function() {
+ for (var i = 0; i < waitQueue.length; i++) {
+ waitQueue[i]();
+ }
+ waitQueue = [];
+ });
+ }
+
+ return function() {
+ var passed = false;
+ waitForTick(function() {
+ passed = true;
+ });
+ return function(callback) {
+ passed ? callback() : waitForTick(callback);
+ };
+ };
+ }];
+};
+
+var $$AnimateRunnerFactoryProvider = function() {
+ this.$get = ['$q', '$sniffer', '$$animateAsyncRun', '$document', '$timeout',
+ function($q, $sniffer, $$animateAsyncRun, $document, $timeout) {
+
+ var INITIAL_STATE = 0;
+ var DONE_PENDING_STATE = 1;
+ var DONE_COMPLETE_STATE = 2;
+
+ AnimateRunner.chain = function(chain, callback) {
+ var index = 0;
+
+ next();
+ function next() {
+ if (index === chain.length) {
+ callback(true);
+ return;
+ }
+
+ chain[index](function(response) {
+ if (response === false) {
+ callback(false);
+ return;
+ }
+ index++;
+ next();
+ });
+ }
+ };
+
+ AnimateRunner.all = function(runners, callback) {
+ var count = 0;
+ var status = true;
+ forEach(runners, function(runner) {
+ runner.done(onProgress);
+ });
+
+ function onProgress(response) {
+ status = status && response;
+ if (++count === runners.length) {
+ callback(status);
+ }
+ }
+ };
+
+ function AnimateRunner(host) {
+ this.setHost(host);
+
+ var rafTick = $$animateAsyncRun();
+ var timeoutTick = function(fn) {
+ $timeout(fn, 0, false);
+ };
+
+ this._doneCallbacks = [];
+ this._tick = function(fn) {
+ var doc = $document[0];
+
+ // the document may not be ready or attached
+ // to the module for some internal tests
+ if (doc && doc.hidden) {
+ timeoutTick(fn);
+ } else {
+ rafTick(fn);
+ }
+ };
+ this._state = 0;
+ }
+
+ AnimateRunner.prototype = {
+ setHost: function(host) {
+ this.host = host || {};
+ },
+
+ done: function(fn) {
+ if (this._state === DONE_COMPLETE_STATE) {
+ fn();
+ } else {
+ this._doneCallbacks.push(fn);
+ }
+ },
+
+ progress: noop,
+
+ getPromise: function() {
+ if (!this.promise) {
+ var self = this;
+ this.promise = $q(function(resolve, reject) {
+ self.done(function(status) {
+ status === false ? reject() : resolve();
+ });
+ });
+ }
+ return this.promise;
+ },
+
+ then: function(resolveHandler, rejectHandler) {
+ return this.getPromise().then(resolveHandler, rejectHandler);
+ },
+
+ 'catch': function(handler) {
+ return this.getPromise()['catch'](handler);
+ },
+
+ 'finally': function(handler) {
+ return this.getPromise()['finally'](handler);
+ },
+
+ pause: function() {
+ if (this.host.pause) {
+ this.host.pause();
+ }
+ },
+
+ resume: function() {
+ if (this.host.resume) {
+ this.host.resume();
+ }
+ },
+
+ end: function() {
+ if (this.host.end) {
+ this.host.end();
+ }
+ this._resolve(true);
+ },
+
+ cancel: function() {
+ if (this.host.cancel) {
+ this.host.cancel();
+ }
+ this._resolve(false);
+ },
+
+ complete: function(response) {
+ var self = this;
+ if (self._state === INITIAL_STATE) {
+ self._state = DONE_PENDING_STATE;
+ self._tick(function() {
+ self._resolve(response);
+ });
+ }
+ },
+
+ _resolve: function(response) {
+ if (this._state !== DONE_COMPLETE_STATE) {
+ forEach(this._doneCallbacks, function(fn) {
+ fn(response);
+ });
+ this._doneCallbacks.length = 0;
+ this._state = DONE_COMPLETE_STATE;
+ }
+ }
+ };
+
+ return AnimateRunner;
+ }];
+};
+
/**
* @ngdoc service
* @name $animateCss
@@ -5379,37 +5760,18 @@ var $AnimateProvider = ['$provide', function($provide) {
* Click here {@link ngAnimate.$animateCss to read the documentation for $animateCss}.
*/
var $CoreAnimateCssProvider = function() {
- this.$get = ['$$rAF', '$q', function($$rAF, $q) {
+ this.$get = ['$$rAF', '$q', '$$AnimateRunner', function($$rAF, $q, $$AnimateRunner) {
- var RAFPromise = function() {};
- RAFPromise.prototype = {
- done: function(cancel) {
- this.defer && this.defer[cancel === true ? 'reject' : 'resolve']();
- },
- end: function() {
- this.done();
- },
- cancel: function() {
- this.done(true);
- },
- getPromise: function() {
- if (!this.defer) {
- this.defer = $q.defer();
- }
- return this.defer.promise;
- },
- then: function(f1,f2) {
- return this.getPromise().then(f1,f2);
- },
- 'catch': function(f1) {
- return this.getPromise()['catch'](f1);
- },
- 'finally': function(f1) {
- return this.getPromise()['finally'](f1);
+ return function(element, initialOptions) {
+ // all of the animation functions should create
+ // a copy of the options data, however, if a
+ // parent service has already created a copy then
+ // we should stick to using that
+ var options = initialOptions || {};
+ if (!options.$$prepared) {
+ options = copy(options);
}
- };
- return function(element, options) {
// there is no point in applying the styles since
// there is no animation that goes on at all in
// this version of $animateCss.
@@ -5422,7 +5784,8 @@ var $CoreAnimateCssProvider = function() {
options.from = null;
}
- var closed, runner = new RAFPromise();
+ /* jshint newcap: false */
+ var closed, runner = new $$AnimateRunner();
return {
start: run,
end: run
@@ -5430,16 +5793,16 @@ var $CoreAnimateCssProvider = function() {
function run() {
$$rAF(function() {
- close();
+ applyAnimationContents();
if (!closed) {
- runner.done();
+ runner.complete();
}
closed = true;
});
return runner;
}
- function close() {
+ function applyAnimationContents() {
if (options.addClass) {
element.addClass(options.addClass);
options.addClass = null;
@@ -5482,7 +5845,6 @@ var $CoreAnimateCssProvider = function() {
*/
function Browser(window, document, $log, $sniffer) {
var self = this,
- rawDocument = document[0],
location = window.location,
history = window.history,
setTimeout = window.setTimeout,
@@ -5545,7 +5907,14 @@ function Browser(window, document, $log, $sniffer) {
var cachedState, lastHistoryState,
lastBrowserUrl = location.href,
baseElement = document.find('base'),
- pendingLocation = null;
+ pendingLocation = null,
+ getCurrentState = !$sniffer.history ? noop : function getCurrentState() {
+ try {
+ return history.state;
+ } catch (e) {
+ // MSIE can reportedly throw when there is no state (UNCONFIRMED).
+ }
+ };
cacheState();
lastHistoryState = cachedState;
@@ -5653,14 +6022,6 @@ function Browser(window, document, $log, $sniffer) {
fireUrlChange();
}
- function getCurrentState() {
- try {
- return history.state;
- } catch (e) {
- // MSIE can reportedly throw when there is no state (UNCONFIRMED).
- }
- }
-
// This variable should be used *only* inside the cacheState function.
var lastCachedState = null;
function cacheState() {
@@ -5910,9 +6271,9 @@ function $CacheFactoryProvider() {
var size = 0,
stats = extend({}, options, {id: cacheId}),
- data = {},
+ data = createMap(),
capacity = (options && options.capacity) || Number.MAX_VALUE,
- lruHash = {},
+ lruHash = createMap(),
freshEnd = null,
staleEnd = null;
@@ -6040,6 +6401,8 @@ function $CacheFactoryProvider() {
delete lruHash[key];
}
+ if (!(key in data)) return;
+
delete data[key];
size--;
},
@@ -6054,9 +6417,9 @@ function $CacheFactoryProvider() {
* Clears the cache object of any entries.
*/
removeAll: function() {
- data = {};
+ data = createMap();
size = 0;
- lruHash = {};
+ lruHash = createMap();
freshEnd = staleEnd = null;
},
@@ -6345,7 +6708,7 @@ function $TemplateCacheProvider() {
* When this property is set to true, the HTML compiler will collect DOM nodes between
* nodes with the attributes `directive-name-start` and `directive-name-end`, and group them
* together as the directive elements. It is recommended that this feature be used on directives
- * which are not strictly behavioural (such as {@link ngClick}), and which
+ * which are not strictly behavioral (such as {@link ngClick}), and which
* do not manipulate or replace child nodes (such as {@link ngInclude}).
*
* #### `priority`
@@ -6383,35 +6746,62 @@ function $TemplateCacheProvider() {
* is bound to the parent scope, via matching attributes on the directive's element:
*
* * `@` or `@attr` - bind a local scope property to the value of DOM attribute. The result is
- * always a string since DOM attributes are strings. If no `attr` name is specified then the
- * attribute name is assumed to be the same as the local name.
- * Given `` and widget definition
- * of `scope: { localName:'@myAttr' }`, then widget scope property `localName` will reflect
- * the interpolated value of `hello {{name}}`. As the `name` attribute changes so will the
- * `localName` property on the widget scope. The `name` is read from the parent scope (not
- * component scope).
+ * always a string since DOM attributes are strings. If no `attr` name is specified then the
+ * attribute name is assumed to be the same as the local name. Given `` and the isolate scope definition `scope: { localName:'@myAttr' }`,
+ * the directive's scope property `localName` will reflect the interpolated value of `hello
+ * {{name}}`. As the `name` attribute changes so will the `localName` property on the directive's
+ * scope. The `name` is read from the parent scope (not the directive's scope).
*
- * * `=` or `=attr` - set up bi-directional binding between a local scope property and the
- * parent scope property of name defined via the value of the `attr` attribute. If no `attr`
- * name is specified then the attribute name is assumed to be the same as the local name.
- * Given `` and widget definition of
- * `scope: { localModel:'=myAttr' }`, then widget scope property `localModel` will reflect the
+ * * `=` or `=attr` - set up a bidirectional binding between a local scope property and an expression
+ * passed via the attribute `attr`. The expression is evaluated in the context of the parent scope.
+ * If no `attr` name is specified then the attribute name is assumed to be the same as the local
+ * name. Given `` and the isolate scope definition `scope: {
+ * localModel: '=myAttr' }`, the property `localModel` on the directive's scope will reflect the
+ * value of `parentModel` on the parent scope. Changes to `parentModel` will be reflected in
+ * `localModel` and vice versa. Optional attributes should be marked as such with a question mark:
+ * `=?` or `=?attr`. If the binding expression is non-assignable, or if the attribute isn't
+ * optional and doesn't exist, an exception ({@link error/$compile/nonassign `$compile:nonassign`})
+ * will be thrown upon discovering changes to the local value, since it will be impossible to sync
+ * them back to the parent scope. By default, the {@link ng.$rootScope.Scope#$watch `$watch`}
+ * method is used for tracking changes, and the equality check is based on object identity.
+ * However, if an object literal or an array literal is passed as the binding expression, the
+ * equality check is done by value (using the {@link angular.equals} function). It's also possible
+ * to watch the evaluated value shallowly with {@link ng.$rootScope.Scope#$watchCollection
+ * `$watchCollection`}: use `=*` or `=*attr` (`=*?` or `=*?attr` if the attribute is optional).
+ *
+ * * `<` or `` and directive definition of
+ * `scope: { localModel:'` and widget definition of
- * `scope: { localFn:'&myAttr' }`, then isolate scope property `localFn` will point to
- * a function wrapper for the `count = count + value` expression. Often it's desirable to
- * pass data from the isolated scope via an expression to the parent scope, this can be
- * done by passing a map of local variable names and values into the expression wrapper fn.
- * For example, if the expression is `increment(amount)` then we can specify the amount value
- * by calling the `localFn` as `localFn({amount: 22})`.
+ * One-way binding is useful if you do not plan to propagate changes to your isolated scope bindings
+ * back to the parent. However, it does not make this completely impossible.
+ *
+ * * `&` or `&attr` - provides a way to execute an expression in the context of the parent scope. If
+ * no `attr` name is specified then the attribute name is assumed to be the same as the local name.
+ * Given `` and the isolate scope definition `scope: {
+ * localFn:'&myAttr' }`, the isolate scope property `localFn` will point to a function wrapper for
+ * the `count = count + value` expression. Often it's desirable to pass data from the isolated scope
+ * via an expression to the parent scope. This can be done by passing a map of local variable names
+ * and values into the expression wrapper fn. For example, if the expression is `increment(amount)`
+ * then we can specify the amount value by calling the `localFn` as `localFn({amount: 22})`.
*
* In general it's possible to apply more than one directive to one element, but there might be limitations
* depending on the type of scope required by the directives. The following points will help explain these limitations.
@@ -6429,9 +6819,32 @@ function $TemplateCacheProvider() {
*
*
* #### `bindToController`
- * When an isolate scope is used for a component (see above), and `controllerAs` is used, `bindToController: true` will
- * allow a component to have its properties bound to the controller, rather than to scope. When the controller
- * is instantiated, the initial values of the isolate scope bindings are already available.
+ * This property is used to bind scope properties directly to the controller. It can be either
+ * `true` or an object hash with the same format as the `scope` property. Additionally, a controller
+ * alias must be set, either by using `controllerAs: 'myAlias'` or by specifying the alias in the controller
+ * definition: `controller: 'myCtrl as myAlias'`.
+ *
+ * When an isolate scope is used for a directive (see above), `bindToController: true` will
+ * allow a component to have its properties bound to the controller, rather than to scope.
+ *
+ * After the controller is instantiated, the initial values of the isolate scope bindings will be bound to the controller
+ * properties. You can access these bindings once they have been initialized by providing a controller method called
+ * `$onInit`, which is called after all the controllers on an element have been constructed and had their bindings
+ * initialized.
+ *
+ *
+ * **Deprecation warning:** although bindings for non-ES6 class controllers are currently
+ * bound to `this` before the controller constructor is called, this use is now deprecated. Please place initialization
+ * code that relies upon bindings inside a `$onInit` method on the controller, instead.
+ *
+ *
+ * It is also possible to set `bindToController` to an object hash with the same format as the `scope` property.
+ * This will set up the scope bindings to the controller directly. Note that `scope` can still be used
+ * to define which kind of scope is created. By default, no scope is created. Use `scope: {}` to create an isolate
+ * scope (useful for component directives).
+ *
+ * If both `bindToController` and `scope` are defined and have object hashes, `bindToController` overrides `scope`.
+ *
*
* #### `controller`
* Controller constructor function. The controller is instantiated before the
@@ -6443,10 +6856,10 @@ function $TemplateCacheProvider() {
* * `$element` - Current element
* * `$attrs` - Current attributes object for the element
* * `$transclude` - A transclude linking function pre-bound to the correct transclusion scope:
- * `function([scope], cloneLinkingFn, futureParentElement)`.
- * * `scope`: optional argument to override the scope.
- * * `cloneLinkingFn`: optional argument to create clones of the original transcluded content.
- * * `futureParentElement`:
+ * `function([scope], cloneLinkingFn, futureParentElement, slotName)`:
+ * * `scope`: (optional) override the scope.
+ * * `cloneLinkingFn`: (optional) argument to create clones of the original transcluded content.
+ * * `futureParentElement` (optional):
* * defines the parent to which the `cloneLinkingFn` will add the cloned elements.
* * default: `$element.parent()` resp. `$element` for `transclude:'element'` resp. `transclude:true`.
* * only needed for transcludes that are allowed to contain non html elements (e.g. SVG elements)
@@ -6454,14 +6867,48 @@ function $TemplateCacheProvider() {
* as those elements need to created and cloned in a special way when they are defined outside their
* usual containers (e.g. like `