Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
2c2668ca
Commit
2c2668ca
authored
Sep 06, 2013
by
David Baumgold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed template loader JS library
parent
1b4f9c66
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
0 additions
and
79 deletions
+0
-79
cms/static/js/template_loader.js
+0
-79
No files found.
cms/static/js/template_loader.js
deleted
100644 → 0
View file @
1b4f9c66
// <!-- from https://github.com/Gazler/Underscore-Template-Loader/blob/master/index.html -->
// TODO Figure out how to initialize w/ static views from server (don't call .load but instead inject in django as strings)
// so this only loads the lazily loaded ones.
(
function
()
{
if
(
typeof
window
.
templateLoader
==
'function'
)
return
;
var
templateLoader
=
{
templateVersion
:
"0.0.15"
,
templates
:
{},
// Control whether template caching in local memory occurs. Caching screws up development but may
// be a good optimization in production (it works fairly well).
cacheTemplates
:
false
,
loadRemoteTemplate
:
function
(
templateName
,
filename
,
callback
)
{
if
(
!
this
.
templates
[
templateName
])
{
var
self
=
this
;
jQuery
.
ajax
({
url
:
filename
,
success
:
function
(
data
)
{
self
.
addTemplate
(
templateName
,
data
);
self
.
saveLocalTemplates
();
callback
(
data
);
},
error
:
function
(
xhdr
,
textStatus
,
errorThrown
)
{
console
.
log
(
textStatus
);
},
dataType
:
"html"
})
}
else
{
callback
(
this
.
templates
[
templateName
]);
}
},
addTemplate
:
function
(
templateName
,
data
)
{
// is there a reason this doesn't go ahead and compile the template? _.template(data)
// I suppose localstorage use would still req raw string rather than compiled version, but that sd work
// if it maintains a separate cache of uncompiled ones
this
.
templates
[
templateName
]
=
data
;
},
localStorageAvailable
:
function
()
{
try
{
return
this
.
cacheTemplates
&&
'localStorage'
in
window
&&
window
[
'localStorage'
]
!==
null
;
}
catch
(
e
)
{
return
false
;
}
},
saveLocalTemplates
:
function
()
{
if
(
this
.
localStorageAvailable
())
{
localStorage
.
setItem
(
"templates"
,
JSON
.
stringify
(
this
.
templates
));
localStorage
.
setItem
(
"templateVersion"
,
this
.
templateVersion
);
}
},
loadLocalTemplates
:
function
()
{
if
(
this
.
localStorageAvailable
())
{
var
templateVersion
=
localStorage
.
getItem
(
"templateVersion"
);
if
(
templateVersion
&&
templateVersion
==
this
.
templateVersion
)
{
var
templates
=
localStorage
.
getItem
(
"templates"
);
if
(
templates
)
{
templates
=
JSON
.
parse
(
templates
);
for
(
var
x
in
templates
)
{
if
(
!
this
.
templates
[
x
])
{
this
.
addTemplate
(
x
,
templates
[
x
]);
}
}
}
}
else
{
localStorage
.
removeItem
(
"templates"
);
localStorage
.
removeItem
(
"templateVersion"
);
}
}
}
};
templateLoader
.
loadLocalTemplates
();
window
.
templateLoader
=
templateLoader
;
})();
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