Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
24809d40
Commit
24809d40
authored
Jun 13, 2014
by
Romain Courteaud
Committed by
Jérome Perrin
Aug 11, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Share duplicated functions.
parent
4ca4b874
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
60 additions
and
98 deletions
+60
-98
dream/platform/src2/dream/create_document.html
dream/platform/src2/dream/create_document.html
+1
-0
dream/platform/src2/dream/create_document.js
dream/platform/src2/dream/create_document.js
+3
-41
dream/platform/src2/dream/manage_document.html
dream/platform/src2/dream/manage_document.html
+1
-0
dream/platform/src2/dream/manage_document.js
dream/platform/src2/dream/manage_document.js
+4
-28
dream/platform/src2/dream/mixin_promise.js
dream/platform/src2/dream/mixin_promise.js
+43
-0
dream/platform/src2/dream/run_simulation.html
dream/platform/src2/dream/run_simulation.html
+1
-0
dream/platform/src2/dream/run_simulation.js
dream/platform/src2/dream/run_simulation.js
+7
-29
No files found.
dream/platform/src2/dream/create_document.html
View file @
24809d40
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
<title>
Create Document
</title>
<title>
Create Document
</title>
<script
src=
"../<%= copy.rsvp.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"../<%= copy.rsvp.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"../<%= copy.renderjs.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"../<%= copy.renderjs.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"mixin_promise.js"
type=
"text/javascript"
></script>
<script
src=
"create_document.js"
type=
"text/javascript"
></script>
<script
src=
"create_document.js"
type=
"text/javascript"
></script>
</head>
</head>
<body>
<body>
...
...
dream/platform/src2/dream/create_document.js
View file @
24809d40
/*global console, rJS, RSVP,
FileReader
*/
/*global console, rJS, RSVP,
promiseEventListener, promiseReadAsText
*/
(
function
(
window
,
rJS
,
RSVP
,
FileReader
)
{
(
function
(
window
,
rJS
,
RSVP
,
promiseEventListener
,
promiseReadAsText
)
{
"
use strict
"
;
"
use strict
"
;
function
promiseEventListener
(
target
,
type
,
useCapture
)
{
//////////////////////////
// Resolve the promise as soon as the event is triggered
// eventListener is removed when promise is cancelled/resolved/rejected
//////////////////////////
var
handle_event_callback
;
function
canceller
()
{
target
.
removeEventListener
(
type
,
handle_event_callback
,
useCapture
);
}
function
resolver
(
resolve
)
{
handle_event_callback
=
function
(
evt
)
{
canceller
();
evt
.
stopPropagation
();
evt
.
preventDefault
();
resolve
(
evt
);
return
false
;
};
target
.
addEventListener
(
type
,
handle_event_callback
,
useCapture
);
}
return
new
RSVP
.
Promise
(
resolver
,
canceller
);
}
function
promiseReadAsText
(
file
)
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
evt
)
{
resolve
(
evt
.
target
.
result
);
};
reader
.
onerror
=
function
(
evt
)
{
reject
(
evt
);
};
reader
.
readAsText
(
file
);
});
}
rJS
(
window
)
rJS
(
window
)
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Acquired methods
// Acquired methods
...
@@ -121,4 +83,4 @@
...
@@ -121,4 +83,4 @@
});
});
});
});
}(
window
,
rJS
,
RSVP
,
FileReader
));
}(
window
,
rJS
,
RSVP
,
promiseEventListener
,
promiseReadAsText
));
dream/platform/src2/dream/manage_document.html
View file @
24809d40
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<script
src=
"../<%= curl.jquery.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"../<%= curl.jquery.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"../<%= curl.jquerymobilejs.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"../<%= curl.jquerymobilejs.relative_dest %>"
type=
"text/javascript"
></script>
<script
src=
"mixin_promise.js"
type=
"text/javascript"
></script>
<script
src=
"mixin_document_page.js"
type=
"text/javascript"
></script>
<script
src=
"mixin_document_page.js"
type=
"text/javascript"
></script>
<script
src=
"manage_document.js"
type=
"text/javascript"
></script>
<script
src=
"manage_document.js"
type=
"text/javascript"
></script>
</head>
</head>
...
...
dream/platform/src2/dream/manage_document.js
View file @
24809d40
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery */
/*global console, rJS, RSVP, initDocumentPageMixin, jQuery,
(
function
(
window
,
rJS
,
RSVP
,
initDocumentPageMixin
,
$
)
{
promiseEventListener */
(
function
(
window
,
rJS
,
RSVP
,
initDocumentPageMixin
,
$
,
promiseEventListener
)
{
"
use strict
"
;
"
use strict
"
;
function
datatouri
(
data
,
mime_type
)
{
function
datatouri
(
data
,
mime_type
)
{
...
@@ -10,31 +11,6 @@
...
@@ -10,31 +11,6 @@
return
result
+
"
;base64,
"
+
window
.
btoa
(
data
);
return
result
+
"
;base64,
"
+
window
.
btoa
(
data
);
}
}
function
promiseEventListener
(
target
,
type
,
useCapture
)
{
//////////////////////////
// Resolve the promise as soon as the event is triggered
// eventListener is removed when promise is cancelled/resolved/rejected
//////////////////////////
var
handle_event_callback
;
function
canceller
()
{
target
.
removeEventListener
(
type
,
handle_event_callback
,
useCapture
);
}
function
resolver
(
resolve
)
{
handle_event_callback
=
function
(
evt
)
{
canceller
();
evt
.
stopPropagation
();
evt
.
preventDefault
();
resolve
(
evt
);
return
false
;
};
target
.
addEventListener
(
type
,
handle_event_callback
,
useCapture
);
}
return
new
RSVP
.
Promise
(
resolver
,
canceller
);
}
function
disableAllButtons
(
gadget
)
{
function
disableAllButtons
(
gadget
)
{
// Prevent double click
// Prevent double click
var
i
,
var
i
,
...
@@ -191,4 +167,4 @@
...
@@ -191,4 +167,4 @@
waitForKnowledgeExtraction
(
this
)
waitForKnowledgeExtraction
(
this
)
]);
]);
});
});
}(
window
,
rJS
,
RSVP
,
initDocumentPageMixin
,
jQuery
));
}(
window
,
rJS
,
RSVP
,
initDocumentPageMixin
,
jQuery
,
promiseEventListener
));
dream/platform/src2/dream/mixin_promise.js
0 → 100644
View file @
24809d40
/*global console, RSVP, FileReader */
(
function
(
window
,
RSVP
,
FileReader
)
{
"
use strict
"
;
window
.
promiseEventListener
=
function
(
target
,
type
,
useCapture
)
{
//////////////////////////
// Resolve the promise as soon as the event is triggered
// eventListener is removed when promise is cancelled/resolved/rejected
//////////////////////////
var
handle_event_callback
;
function
canceller
()
{
target
.
removeEventListener
(
type
,
handle_event_callback
,
useCapture
);
}
function
resolver
(
resolve
)
{
handle_event_callback
=
function
(
evt
)
{
canceller
();
evt
.
stopPropagation
();
evt
.
preventDefault
();
resolve
(
evt
);
return
false
;
};
target
.
addEventListener
(
type
,
handle_event_callback
,
useCapture
);
}
return
new
RSVP
.
Promise
(
resolver
,
canceller
);
};
window
.
promiseReadAsText
=
function
(
file
)
{
return
new
RSVP
.
Promise
(
function
(
resolve
,
reject
)
{
var
reader
=
new
FileReader
();
reader
.
onload
=
function
(
evt
)
{
resolve
(
evt
.
target
.
result
);
};
reader
.
onerror
=
function
(
evt
)
{
reject
(
evt
);
};
reader
.
readAsText
(
file
);
});
};
}(
window
,
RSVP
,
FileReader
));
dream/platform/src2/dream/run_simulation.html
View file @
24809d40
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
<
label
>
{{
label
}}
<
/label
>
<
label
>
{{
label
}}
<
/label
>
</script>
</script>
<script
src=
"mixin_promise.js"
type=
"text/javascript"
></script>
<script
src=
"mixin_document_page.js"
type=
"text/javascript"
></script>
<script
src=
"mixin_document_page.js"
type=
"text/javascript"
></script>
<script
src=
"run_simulation.js"
type=
"text/javascript"
></script>
<script
src=
"run_simulation.js"
type=
"text/javascript"
></script>
</head>
</head>
...
...
dream/platform/src2/dream/run_simulation.js
View file @
24809d40
/*global rJS, RSVP, initDocumentPageMixin, jQuery, Handlebars */
/*global rJS, RSVP, initDocumentPageMixin, jQuery, Handlebars,
/*jslint nomen: true, maxlen: 200 */
promiseEventListener */
(
function
(
window
,
rJS
,
RSVP
,
initDocumentPageMixin
,
$
,
Handlebars
)
{
/*jslint nomen: true */
(
function
(
window
,
rJS
,
RSVP
,
initDocumentPageMixin
,
$
,
Handlebars
,
promiseEventListener
)
{
"
use strict
"
;
"
use strict
"
;
function
promiseEventListener
(
target
,
type
,
useCapture
)
{
//////////////////////////
// Resolve the promise as soon as the event is triggered
// eventListener is removed when promise is cancelled/resolved/rejected
//////////////////////////
var
handle_event_callback
;
function
canceller
()
{
target
.
removeEventListener
(
type
,
handle_event_callback
,
useCapture
);
}
function
resolver
(
resolve
)
{
handle_event_callback
=
function
(
evt
)
{
canceller
();
evt
.
stopPropagation
();
evt
.
preventDefault
();
resolve
(
evt
);
return
false
;
};
target
.
addEventListener
(
type
,
handle_event_callback
,
useCapture
);
}
return
new
RSVP
.
Promise
(
resolver
,
canceller
);
}
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
// Handlebars
// Handlebars
/////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////
...
@@ -189,4 +166,5 @@
...
@@ -189,4 +166,5 @@
return
gadget
.
pleaseRedirectMyHash
(
url
);
return
gadget
.
pleaseRedirectMyHash
(
url
);
});
});
});
});
}(
window
,
rJS
,
RSVP
,
initDocumentPageMixin
,
jQuery
,
Handlebars
));
}(
window
,
rJS
,
RSVP
,
initDocumentPageMixin
,
jQuery
,
Handlebars
,
promiseEventListener
));
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment