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
Xiaowu Zhang
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
Hide 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 @@
...
@@ -32,10 +32,9 @@
// Returns the list of gadget prototype
// Returns the list of gadget prototype
RenderJSGadget
.
prototype
.
getInterfaceList
=
function
()
{
RenderJSGadget
.
prototype
.
getInterfaceList
=
function
()
{
var
dfr
=
$
.
Deferred
(),
var
dfr
=
$
.
Deferred
(),
gadget
=
this
,
gadget
=
this
;
context
=
$
(
this
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
dfr
.
resolve
With
(
context
,
[
gadget
.
interface_list
]
);
dfr
.
resolve
(
gadget
.
interface_list
);
});
});
return
dfr
.
promise
();
return
dfr
.
promise
();
};
};
...
@@ -43,10 +42,9 @@
...
@@ -43,10 +42,9 @@
// Returns a list of CSS required by the gadget
// Returns a list of CSS required by the gadget
RenderJSGadget
.
prototype
.
getRequiredCSSList
=
function
()
{
RenderJSGadget
.
prototype
.
getRequiredCSSList
=
function
()
{
var
dfr
=
$
.
Deferred
(),
var
dfr
=
$
.
Deferred
(),
gadget
=
this
,
gadget
=
this
;
context
=
$
(
this
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
dfr
.
resolve
With
(
context
,
[
gadget
.
required_css_list
]
);
dfr
.
resolve
(
gadget
.
required_css_list
);
});
});
return
dfr
.
promise
();
return
dfr
.
promise
();
};
};
...
@@ -54,10 +52,9 @@
...
@@ -54,10 +52,9 @@
// Returns a list of JS required by the gadget
// Returns a list of JS required by the gadget
RenderJSGadget
.
prototype
.
getRequiredJSList
=
function
()
{
RenderJSGadget
.
prototype
.
getRequiredJSList
=
function
()
{
var
dfr
=
$
.
Deferred
(),
var
dfr
=
$
.
Deferred
(),
gadget
=
this
,
gadget
=
this
;
context
=
$
(
this
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
dfr
.
resolve
With
(
context
,
[
gadget
.
required_js_list
]
);
dfr
.
resolve
(
gadget
.
required_js_list
);
});
});
return
dfr
.
promise
();
return
dfr
.
promise
();
};
};
...
@@ -65,10 +62,9 @@
...
@@ -65,10 +62,9 @@
// Returns the path of the code of a gadget
// Returns the path of the code of a gadget
RenderJSGadget
.
prototype
.
getPath
=
function
()
{
RenderJSGadget
.
prototype
.
getPath
=
function
()
{
var
dfr
=
$
.
Deferred
(),
var
dfr
=
$
.
Deferred
(),
gadget
=
this
,
gadget
=
this
;
context
=
$
(
this
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
dfr
.
resolve
With
(
context
,
[
gadget
.
path
]
);
dfr
.
resolve
(
gadget
.
path
);
});
});
return
dfr
.
promise
();
return
dfr
.
promise
();
};
};
...
@@ -76,10 +72,9 @@
...
@@ -76,10 +72,9 @@
// Returns the title of a gadget
// Returns the title of a gadget
RenderJSGadget
.
prototype
.
getTitle
=
function
()
{
RenderJSGadget
.
prototype
.
getTitle
=
function
()
{
var
dfr
=
$
.
Deferred
(),
var
dfr
=
$
.
Deferred
(),
gadget
=
this
,
gadget
=
this
;
context
=
$
(
this
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
dfr
.
resolve
With
(
context
,
[
gadget
.
title
]
);
dfr
.
resolve
(
gadget
.
title
);
});
});
return
dfr
.
promise
();
return
dfr
.
promise
();
};
};
...
@@ -87,10 +82,9 @@
...
@@ -87,10 +82,9 @@
// Returns the HTML of a gadget
// Returns the HTML of a gadget
RenderJSGadget
.
prototype
.
getHTML
=
function
()
{
RenderJSGadget
.
prototype
.
getHTML
=
function
()
{
var
dfr
=
$
.
Deferred
(),
var
dfr
=
$
.
Deferred
(),
gadget
=
this
,
gadget
=
this
;
context
=
$
(
this
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
dfr
.
resolve
With
(
context
,
[
gadget
.
html
]
);
dfr
.
resolve
(
gadget
.
html
);
});
});
return
dfr
.
promise
();
return
dfr
.
promise
();
};
};
...
@@ -243,13 +237,7 @@
...
@@ -243,13 +237,7 @@
// });
// });
renderJS
=
function
(
selector
)
{
renderJS
=
function
(
selector
)
{
var
result
;
throw
new
Error
(
"
Unknown selector '
"
+
selector
+
"
'
"
);
if
(
typeof
selector
===
"
string
"
)
{
result
=
gadget_scope_dict
[
selector
];
}
else
{
result
=
root_gadget
;
}
return
result
;
};
};
renderJS
.
declareJS
=
function
(
url
)
{
renderJS
.
declareJS
=
function
(
url
)
{
...
@@ -268,7 +256,7 @@
...
@@ -268,7 +256,7 @@
if
(
javascript_registration_dict
.
hasOwnProperty
(
url
))
{
if
(
javascript_registration_dict
.
hasOwnProperty
(
url
))
{
origin_dfr
=
$
.
Deferred
();
origin_dfr
=
$
.
Deferred
();
setTimeout
(
function
()
{
setTimeout
(
function
()
{
origin_dfr
.
resolve
With
(
$
(
this
),
[]
);
origin_dfr
.
resolve
(
);
});
});
dfr
=
origin_dfr
.
promise
();
dfr
=
origin_dfr
.
promise
();
}
else
{
}
else
{
...
@@ -290,7 +278,7 @@
...
@@ -290,7 +278,7 @@
link
;
link
;
if
(
stylesheet_registration_dict
.
hasOwnProperty
(
url
))
{
if
(
stylesheet_registration_dict
.
hasOwnProperty
(
url
))
{
setTimeout
(
function
()
{
setTimeout
(
function
()
{
origin_dfr
.
resolve
With
(
$
(
this
),
[]
);
origin_dfr
.
resolve
(
);
});
});
}
else
{
}
else
{
head
=
document
.
getElementsByTagName
(
'
head
'
)[
0
];
head
=
document
.
getElementsByTagName
(
'
head
'
)[
0
];
...
@@ -307,7 +295,7 @@
...
@@ -307,7 +295,7 @@
head
.
appendChild
(
link
);
head
.
appendChild
(
link
);
setTimeout
(
function
()
{
setTimeout
(
function
()
{
origin_dfr
.
resolve
With
(
$
(
this
),
[]
);
origin_dfr
.
resolve
(
);
});
});
}
}
...
@@ -318,7 +306,7 @@
...
@@ -318,7 +306,7 @@
var
dfr
=
$
.
Deferred
(),
var
dfr
=
$
.
Deferred
(),
parsed_html
;
parsed_html
;
if
(
gadget_model_dict
.
hasOwnProperty
(
url
))
{
if
(
gadget_model_dict
.
hasOwnProperty
(
url
))
{
dfr
.
resolve
With
(
$
(
this
),
[
gadget_model_dict
[
url
]
]);
dfr
.
resolve
(
gadget_model_dict
[
url
]);
}
else
{
}
else
{
$
.
ajax
(
url
)
$
.
ajax
(
url
)
.
done
(
function
(
value
,
textStatus
,
jqXHR
)
{
.
done
(
function
(
value
,
textStatus
,
jqXHR
)
{
...
@@ -343,16 +331,16 @@
...
@@ -343,16 +331,16 @@
}
}
gadget_model_dict
[
url
]
=
tmp_constructor
;
gadget_model_dict
[
url
]
=
tmp_constructor
;
}
}
dfr
.
resolve
With
(
$
(
this
),
[
gadget_model_dict
[
url
]
]);
dfr
.
resolve
(
gadget_model_dict
[
url
]);
}
catch
(
e
)
{
}
catch
(
e
)
{
dfr
.
reject
With
(
$
(
this
),
[
jqXHR
,
"
HTML Parsing failed
"
]
);
dfr
.
reject
(
jqXHR
,
"
HTML Parsing failed
"
);
}
}
}
else
{
}
else
{
dfr
.
reject
With
(
$
(
this
),
[
jqXHR
,
"
Unexpected content type
"
]
);
dfr
.
reject
(
jqXHR
,
"
Unexpected content type
"
);
}
}
})
})
.
fail
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
.
fail
(
function
(
jqXHR
,
textStatus
,
errorThrown
)
{
dfr
.
reject
With
(
$
(
this
),
[
jqXHR
,
textStatus
,
errorThrown
]
);
dfr
.
reject
(
jqXHR
,
textStatus
,
errorThrown
);
});
});
}
}
return
dfr
.
promise
();
return
dfr
.
promise
();
...
@@ -416,14 +404,13 @@
...
@@ -416,14 +404,13 @@
// .done(function (value, textStatus, jqXHR) {
// .done(function (value, textStatus, jqXHR) {
// if ((jqXHR.getResponseHeader("Content-Type") || "")
// if ((jqXHR.getResponseHeader("Content-Type") || "")
// === 'text/html') {
// === 'text/html') {
// dfr.resolveWith($(this),
// dfr.resolve($.parseGadgetHTML(value), textStatus, jqXHR);
// [$.parseGadgetHTML(value), textStatus, jqXHR]);
// } else {
// } else {
// dfr.reject
With($(this), [jqXHR, "Unexpected content type"]
);
// dfr.reject
(jqXHR, "Unexpected content type"
);
// }
// }
// })
// })
// .fail(function (jqXHR, textStatus, errorThrown) {
// .fail(function (jqXHR, textStatus, errorThrown) {
// dfr.reject
With($(this), [jqXHR, textStatus, errorThrown]
);
// dfr.reject
(jqXHR, textStatus, errorThrown
);
// });
// });
// console.log("Declaring gadget " + url);
// console.log("Declaring gadget " + url);
// // console.log(settings.context.html());
// // 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