Commit 441320d8 authored by Tristan Cavelier's avatar Tristan Cavelier

davstorage.js amd compatible now

parent f2df0cdd
/*
* Copyright 2013, Nexedi SA
* Released under the LGPL license.
* http://www.gnu.org/licenses/lgpl.html
*/
* Copyright 2013, Nexedi SA
* Released under the LGPL license.
* http://www.gnu.org/licenses/lgpl.html
*/
/*jslint indent: 2, maxlen: 80, nomen: true */
/*global jIO: true, $: true, btoa: true */
/*global define, jIO, jQuery, btoa */
// JIO Dav Storage Description :
// {
......@@ -57,8 +57,16 @@
// ('%', '%25')
// The file will be saved as http:%2F%2F100%25_.json
jIO.addStorageType("dav", function (spec, my) {
// define([module_name], [dependencies], module);
(function (dependencies, module) {
"use strict";
if (typeof define === 'function' && define.amd) {
return define(dependencies, module);
}
module(jIO, jQuery);
}(['jio', 'jquery'], function (jIO, $) {
"use strict";
jIO.addStorageType("dav", function (spec, my) {
var priv = {}, that = my.basicStorage(spec, my), dav = {};
// ATTRIBUTES //
......@@ -95,7 +103,8 @@ jIO.addStorageType("dav", function (spec, my) {
// OVERRIDES //
that.specToStore = function () {
// TODO: secured password
// The encoded_login can be seen by anyone, we must find a way to secure it!
// The encoded_login can be seen by anyone,
// we must find a way to secure it!
// secured_login = encrypt(encoded_login)
// encoded_login = decrypt(secured_login)
return {
......@@ -274,7 +283,8 @@ jIO.addStorageType("dav", function (spec, my) {
ajax_object.url = priv.url + "/" + priv.secureName(file_name) +
"?_=" + Date.now();
ajax_object.async = ajax_object.async === false ? false : true;
ajax_object.crossdomain = ajax_object.crossdomain === false ? false : true;
ajax_object.crossdomain =
ajax_object.crossdomain === false ? false : true;
ajax_object.headers = ajax_object.headers || {};
ajax_object.headers.Authorization = ajax_object.headers.Authorization ||
priv.encoded_login;
......@@ -872,7 +882,11 @@ jIO.addStorageType("dav", function (spec, my) {
doc_id,
attachment_id
).always(function (err, response) {
that.success({"ok": true, "id": doc_id, "attachment": attachment_id});
that.success({
"ok": true,
"id": doc_id,
"attachment": attachment_id
});
});
});
});
......@@ -924,4 +938,6 @@ jIO.addStorageType("dav", function (spec, my) {
priv.__init__(spec);
return that;
});
});
}));
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment