diff --git a/lib/client/files.js b/lib/client/files.js index 1659087e..1a7e7a50 100644 --- a/lib/client/files.js +++ b/lib/client/files.js @@ -13,7 +13,8 @@ var Util, DOM, Promise; var Promises = {}, Files = this, FILES_JSON = 'config|modules|ext', - FILES_HTML = 'config-tmpl|file|path|link|pathLink', + FILES_HTML = 'file|path|link|pathLink|media', + FILES_HTML_ROOT = 'view/media-tmpl|config-tmpl', funcs = [], Data = {}, DIR_HTML = '/html/', @@ -45,7 +46,7 @@ var Util, DOM, Promise; }; this.set = function(name, data, callback) { - var strFiles = FILES_JSON + FILES_HTML, + var strFiles = FILES_JSON + FILES_HTML + FILES_HTML_ROOT, regExp = new RegExp(strFiles), isFile = name.match(regExp); @@ -83,13 +84,15 @@ var Util, DOM, Promise; } function getPath(name, isHTML, isJSON) { - var path; + var path, + regExp = new RegExp(FILES_HTML_ROOT), + isRoot = name.match(regExp); if (isHTML) { - if (name === 'config-tmpl') + if (isRoot) path = DIR_HTML + Util.rmStr(name, '-tmpl'); else - path = DIR_HTML_FS + name; + path = DIR_HTML_FS + name; path += '.html'; } else if (isJSON) { diff --git a/lib/client/view.js b/lib/client/view.js index bfd49f9c..d056e54c 100644 --- a/lib/client/view.js +++ b/lib/client/view.js @@ -231,24 +231,30 @@ var CloudCmd, Util, DOM, CloudFunc, $; } function getMediaElement(src, callback) { - CloudCmd.getTemplate(TemplateAudio, 'view/media', function(template) { + Util.checkArgs(arguments, ['src', 'callback']); + + DOM.Files.get('view/media-tmpl', function(error, template) { var rendered, element, type, is, name = Info.name; - if (!TemplateAudio) - TemplateAudio = template; - - is = isAudio(name); - type = is ? 'audio' : 'video'; - - rendered = Util.render(TemplateAudio, { - src : src, - type: type, - name: Info.name - }); - - element = $(rendered)[0]; - Util.exec(callback, element); + if (error) { + Util.log(error); + } else { + if (!TemplateAudio) + TemplateAudio = template; + + is = isAudio(name); + type = is ? 'audio' : 'video'; + + rendered = Util.render(TemplateAudio, { + src : src, + type: type, + name: Info.name + }); + + element = $(rendered)[0]; + callback(element); + } }); }