-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmpl.js
91 lines (77 loc) · 2.55 KB
/
tmpl.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
function loadJS(src, cbFn){
var headEl = document.getElementsByTagName("head")[0];
var newScript = document.createElement('script');
newScript.type = "text/javascript";
if(typeof cbFn == 'function'){
newScript.onload = cbFn;
}
newScript.src = src;
headEl.appendChild(newScript);
}
function loadCSS(src, cbFn){
var headEl = document.getElementsByTagName("head")[0];
var newScript = document.createElement('link');
if(typeof cbFn == 'function'){
newScript.onload = cbFn;
}
newScript.rel = "stylesheet";
newScript.href = src;
newScript.type = "text/css";
headEl.appendChild(newScript);
}
loadCSS("style.css");
loadJS("https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js", function(){
loadJS("http://ajax.microsoft.com/ajax/jquery.templates/beta1/jquery.tmpl.min.js", function(){
loadJS("lib/jquery.observehashchange.min.js", function(){
loadJS("lib/jquery.url.js", function(){
loadJS("templates.js", function(){
start();
});
});
});
})
});
function runEvent(anchor){
if (anchor=="#/collages"){
$('#dre_content').html("");
$.tmpl( templates['collages'], { "catalog" : "1" }).appendTo($('#dre_content'));
$('#dre_menu li').removeClass("active");
$("#menu_collages").addClass("active");
}
if (anchor=="#/catalog"){
$('#dre_content').html("");
$.tmpl( templates['catalog'], { "catalog" : "1" }).appendTo($('#dre_content'));
$('#dre_menu li').removeClass("active");
$("#menu_catalog").addClass("active");
}
}
function openCollages(){
}
function openCatalog(){
}
function start(){
script = $('#editor_script');
base = $("<div/>").insertAfter(script);
base.attr("id", "editor_base");
$.tmpl( templates['main'], { "Name" : "John Doe" }).appendTo(base);
$.tmpl( templates['menu'], { "catalog" : "1" }).appendTo($('#dre_menu'));
$.tmpl( templates['footer'], { "text" : "Dressed LLC" }).appendTo($('#dre_footer'));
jQuery.observeHashChange({interval:100});
jQuery(window).hashchange(function(e, data) {
runEvent(data.after);
});
$('#dre_editor_wrapper a').each(function(id, el){
//$(el).attr("href", "#" + $(el).attr("href"));
$(el).bind("click", function(){
base_href = document.location.href;
if (bh_a = document.location.href.match(/(.*)\#/))
base_href = bh_a[1];
document.location.href = base_href + "#" + $(el).attr("href");
return false;
//alert('a');
})
})
//document.write(jQuery.fn.jquery);
}
//
//https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js