Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
renderjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Romain Courteaud
renderjs
Commits
3c7624d6
Commit
3c7624d6
authored
Jul 08, 2013
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Do not keep meaningless callback context.
parent
28a6dc1e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
37 deletions
+24
-37
renderjs.js
renderjs.js
+24
-37
No files found.
renderjs.js
View file @
3c7624d6
...
...
@@ -32,10 +32,9 @@
// Returns the list of gadget prototype
RenderJSGadget
.
prototype
.
getInterfaceList
=
function
()
{
var
dfr
=
$
.
Deferred
(),
gadget
=
this
,
context
=
$
(
this
);
gadget
=
this
;
setTimeout
(
function
()
{
dfr
.
resolve
With
(
context
,
[
gadget
.
interface_list
]
);
dfr
.
resolve
(
gadget
.
interface_list
);
});
return
dfr
.
promise
();
};
...
...
@@ -43,10 +42,9 @@
// Returns a list of CSS required by the gadget
RenderJSGadget
.
prototype
.
getRequiredCSSList
=
function
()
{
var
dfr
=
$
.
Deferred
(),
gadget
=
this
,
context
=
$
(
this
);
gadget
=
this
;
setTimeout
(
function
()
{
dfr
.
resolve
With
(
context
,
[
gadget
.
required_css_list
]
);
dfr
.
resolve
(
gadget
.
required_css_list
);
});
return
dfr
.
promise
();
};
...
...
@@ -54,10 +52,9 @@
// Returns a list of JS required by the gadget
RenderJSGadget
.
prototype
.
getRequiredJSList
=
function
()
{
var
dfr
=
$
.
Deferred
(),
gadget
=
this
,
context
=
$
(
this
);
gadget
=
this
;
setTimeout
(
function
()
{
dfr
.
resolve
With
(
context
,
[
gadget
.
required_js_list
]
);
dfr
.
resolve
(
gadget
.
required_js_list
);
});
return
dfr
.
promise
();
};
...
...
@@ -65,10 +62,9 @@
// Returns the path of the code of a gadget
RenderJSGadget
.
prototype
.
getPath
=
function
()
{
var
dfr
=
$
.
Deferred
(),
gadget
=
this
,
context
=
$
(
this
);
gadget
=
this
;
setTimeout
(
function
()
{
dfr
.
resolve
With
(
context
,
[
gadget
.
path
]
);
dfr
.
resolve
(
gadget
.
path
);
});
return
dfr
.
promise
();
};
...
...
@@ -76,10 +72,9 @@
// Returns the title of a gadget
RenderJSGadget
.
prototype
.
getTitle
=
function
()
{
var
dfr
=
$
.
Deferred
(),
gadget
=
this
,
context
=
$
(
this
);
gadget
=
this
;
setTimeout
(
function
()
{
dfr
.
resolve
With
(
context
,
[
gadget
.
title
]
);
dfr
.
resolve
(
gadget
.
title
);
});
return
dfr
.
promise
();
};
...
...
@@ -87,10 +82,9 @@
// Returns the HTML of a gadget
RenderJSGadget
.
prototype
.
getHTML
=
function
()
{
var
dfr
=
$
.
Deferred
(),
gadget
=
this
,
context
=
$
(
this
);
gadget
=
this
;
setTimeout
(
function
()
{
dfr
.
resolve
With
(
context
,
[
gadget
.
html
]
);
dfr
.
resolve
(
gadget
.
html
);
});
return
dfr
.
promise
();
};
...
...
@@ -243,13 +237,7 @@
// });
renderJS
=
function
(
selector
)
{
var
result
;
if
(
typeof
selector
===
"
string
"
)
{
result
=
gadget_scope_dict
[
selector
];
}
else
{
result
=
root_gadget
;
}
return
result
;
throw
new
Error
(
"
Unknown selector '
"
+
selector
+
"
'
"
);
};
renderJS
.
declareJS
=
function
(
url
)
{
...
...
@@ -268,7 +256,7 @@
if
(
javascript_registration_dict
.
hasOwnProperty
(
url
))
{
origin_dfr
=
$
.
Deferred
();
setTimeout
(
function
()
{
origin_dfr
.
resolve
With
(
$
(
this
),
[]
);
origin_dfr
.
resolve
(
);
});
dfr
=
origin_dfr
.
promise
();
}
else
{
...
...
@@ -290,7 +278,7 @@
link
;
if
(
stylesheet_registration_dict
.
hasOwnProperty
(
url
))
{
setTimeout
(
function
()
{
origin_dfr
.
resolve
With
(
$
(
this
),
[]
);
origin_dfr
.
resolve
(
);
});
}
else
{
head
=
document
.
getElementsByTagName
(
'
head
'
)[
0
];
...
...
@@ -307,7 +295,7 @@
head
.
appendChild
(
link
);
setTimeout
(
function
()
{
origin_dfr
.
resolve
With
(
$
(
this
),
[]
);
origin_dfr
.
resolve
(
);
});
}
...
...
@@ -318,7 +306,7 @@
var
dfr
=
$
.
Deferred
(),
parsed_html
;
if
(
gadget_model_dict
.
hasOwnProperty
(
url
))
{
dfr
.
resolve
With
(
$
(
this
),
[
gadget_model_dict
[
url
]
]);
dfr
.
resolve
(
gadget_model_dict
[
url
]);
}
else
{
$
.
ajax
(
url
)
.
done
(
function
(
value
,
textStatus
,
jqXHR
)
{
...
...
@@ -343,16 +331,16 @@
}
gadget_model_dict
[
url
]
=
tmp_constructor
;
}
dfr
.
resolve
With
(
$
(
this
),
[
gadget_model_dict
[
url
]
]);
dfr
.
resolve
(
gadget_model_dict
[
url
]);
}
catch
(
e
)
{
dfr
.
reject
With
(
$
(
this
),
[
jqXHR
,
"
HTML Parsing failed
"
]
);
dfr
.
reject
(
jqXHR
,
"
HTML Parsing failed
"
);
}
}
else
{
dfr
.
reject
With
(
$
(
this
),
[
jqXHR
,
"
Unexpected content type
"
]
);
dfr
.
reject
(
jqXHR
,
"
Unexpected content type
"
);
}
})
.
fail
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
dfr
.
reject
With
(
$
(
this
),
[
jqXHR
,
textStatus
,
errorThrown
]
);
dfr
.
reject
(
jqXHR
,
textStatus
,
errorThrown
);
});
}
return
dfr
.
promise
();
...
...
@@ -416,14 +404,13 @@
// .done(function (value, textStatus, jqXHR) {
// if ((jqXHR.getResponseHeader("Content-Type") || "")
// === 'text/html') {
// dfr.resolveWith($(this),
// [$.parseGadgetHTML(value), textStatus, jqXHR]);
// dfr.resolve($.parseGadgetHTML(value), textStatus, jqXHR);
// } else {
// dfr.reject
With($(this), [jqXHR, "Unexpected content type"]
);
// dfr.reject
(jqXHR, "Unexpected content type"
);
// }
// })
// .fail(function (jqXHR, textStatus, errorThrown) {
// dfr.reject
With($(this), [jqXHR, textStatus, errorThrown]
);
// dfr.reject
(jqXHR, textStatus, errorThrown
);
// });
// console.log("Declaring gadget " + url);
// // console.log(settings.context.html());
...
...
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