using localStorageService + applied further documentation
This commit is contained in:
@@ -10,32 +10,17 @@
|
||||
* The service has a set way for defining a data-set by a entryType and alias, which later will be used to retrive the posible entries for a paste scenario.
|
||||
*
|
||||
*/
|
||||
function clipboardService(notificationsService, eventsService) {
|
||||
function clipboardService(notificationsService, eventsService, localStorageService) {
|
||||
|
||||
|
||||
var STORAGE_KEY = "umbClipboardService";
|
||||
|
||||
var supportsLocalStorage = function () {
|
||||
var test = "test";
|
||||
|
||||
try {
|
||||
window.localStorage.setItem(test, test);
|
||||
window.localStorage.removeItem(test);
|
||||
return true;
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
var retriveStorage = function() {
|
||||
if (supportsLocalStorage === false) {
|
||||
if (localStorageService.isSupported === false) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var dataJSON;
|
||||
var dataString = window.localStorage.getItem(STORAGE_KEY);
|
||||
var dataString = localStorageService.get(STORAGE_KEY);
|
||||
if (dataString != null) {
|
||||
dataJSON = JSON.parse(dataString);
|
||||
}
|
||||
@@ -52,11 +37,11 @@ function clipboardService(notificationsService, eventsService) {
|
||||
}
|
||||
|
||||
var saveStorage = function(storage) {
|
||||
var storageString = JSON.stringify(storage)
|
||||
var storageString = JSON.stringify(storage);
|
||||
|
||||
try {
|
||||
var storageJSON = JSON.parse(storageString);
|
||||
window.localStorage.setItem(STORAGE_KEY, storageString);
|
||||
localStorageService.set(STORAGE_KEY, storageString);
|
||||
|
||||
eventsService.emit("clipboardService.storageUpdate");
|
||||
|
||||
@@ -76,6 +61,10 @@ function clipboardService(notificationsService, eventsService) {
|
||||
* @name umbraco.services.clipboardService#copy
|
||||
* @methodOf umbraco.services.clipboardService
|
||||
*
|
||||
* @param type {string} umbraco A string defining the type of data to storing, example: 'elementType', 'contentNode'
|
||||
* @param alias {string} umbraco A string defining the alias of the data to store, example: 'product'
|
||||
* @param data {object} umbraco A object containing the properties to be saved.
|
||||
*
|
||||
* @description
|
||||
* Saves a single JS-object with a type and alias to the clipboard.
|
||||
*/
|
||||
@@ -116,13 +105,18 @@ function clipboardService(notificationsService, eventsService) {
|
||||
* @description
|
||||
* Determins wether the current browser is able to performe its actions.
|
||||
*/
|
||||
service.isSupported = supportsLocalStorage;
|
||||
service.isSupported = function() {
|
||||
return localStorageService.isSupported;
|
||||
};
|
||||
|
||||
/**
|
||||
* @ngdoc method
|
||||
* @name umbraco.services.supportsCopy#hasEntriesOfType
|
||||
* @methodOf umbraco.services.clipboardService
|
||||
*
|
||||
* @param type {string} umbraco A string defining the type of data test for.
|
||||
* @param aliases {string} umbraco A array of strings providing the alias of the data you want to test for.
|
||||
*
|
||||
* @description
|
||||
* Determins wether the current clipboard has entries that matches given type and a one of the aliases.
|
||||
*/
|
||||
@@ -140,6 +134,9 @@ function clipboardService(notificationsService, eventsService) {
|
||||
* @name umbraco.services.supportsCopy#retriveEntriesOfType
|
||||
* @methodOf umbraco.services.clipboardService
|
||||
*
|
||||
* @param type {string} umbraco A string defining the type of data to recive.
|
||||
* @param aliases {string} umbraco A array of strings providing the alias of the data you want to recive.
|
||||
*
|
||||
* @description
|
||||
* Returns an array of entries matching the given type and one of the provided aliases.
|
||||
*/
|
||||
@@ -162,6 +159,9 @@ function clipboardService(notificationsService, eventsService) {
|
||||
* @name umbraco.services.supportsCopy#retriveEntriesOfType
|
||||
* @methodOf umbraco.services.clipboardService
|
||||
*
|
||||
* @param type {string} umbraco A string defining the type of data to recive.
|
||||
* @param aliases {string} umbraco A array of strings providing the alias of the data you want to recive.
|
||||
*
|
||||
* @description
|
||||
* Returns an array of data of entries matching the given type and one of the provided aliases.
|
||||
*/
|
||||
@@ -174,6 +174,9 @@ function clipboardService(notificationsService, eventsService) {
|
||||
* @name umbraco.services.supportsCopy#retriveEntriesOfType
|
||||
* @methodOf umbraco.services.clipboardService
|
||||
*
|
||||
* @param type {string} umbraco A string defining the type of data to remove.
|
||||
* @param aliases {string} umbraco A array of strings providing the alias of the data you want to remove.
|
||||
*
|
||||
* @description
|
||||
* Removes entries matching the given type and one of the provided aliases.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user