|
@@ -4,6 +4,7 @@
|
|
|
Old = {},
|
|
|
Key = null,
|
|
|
flags = [],
|
|
|
+ actions = [],
|
|
|
templates = [],
|
|
|
flag = window.flag = function(name,value){
|
|
|
if(exists(value)){
|
|
@@ -49,6 +50,11 @@
|
|
|
}
|
|
|
return false;
|
|
|
},
|
|
|
+ action = window.action = function(name){
|
|
|
+ if(exists(actions[name])){
|
|
|
+ loadState(actions[name]);
|
|
|
+ }
|
|
|
+ },
|
|
|
template = window.template = function(type,name,template,hash){
|
|
|
var id = (function(type,name){
|
|
|
for(var i in templates){
|
|
@@ -250,7 +256,16 @@
|
|
|
console.log('Context detected console.logout');
|
|
|
setKey(null);
|
|
|
}
|
|
|
- render.topbar(template('topbars',d.topbar.template),d.topbar.context);
|
|
|
+ actions = [];
|
|
|
+ if(exists(d.topbar)){
|
|
|
+ render.topbar(template('topbars',d.topbar.template),d.topbar.context);
|
|
|
+ if(exists(d.topbar.context.actions)){
|
|
|
+ actions = d.topbar.context.actions;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(exists(d.sidebar)){
|
|
|
+ render.sidebar(template('sidebars',d.sidebar.template),d.sidebar.context);
|
|
|
+ }
|
|
|
if(exists(d.template)){
|
|
|
console.log('Using template: '+d.template.type+':'+d.template.name);
|
|
|
d.template = template(d.template.type,d.template.name);
|
|
@@ -310,6 +325,7 @@
|
|
|
$('#topbar .icon-back').click(function(){
|
|
|
back();
|
|
|
});
|
|
|
+ $('#topbar h1').text($('#topbar h1').text().capitalize());
|
|
|
$('#topbar .icon-menu').click(function(){
|
|
|
if($('#drawer').hasClass('open')){
|
|
|
$('#drawer').removeClass('open').css('transform','');
|
|
@@ -317,10 +333,22 @@
|
|
|
$('#drawer').addClass('open').css('transform','translateX(80%)');
|
|
|
}
|
|
|
});
|
|
|
- $('#topbar .icon-new').click(function(){
|
|
|
+ $('#topbar .icon-add').click(function(){
|
|
|
action('new');
|
|
|
});
|
|
|
- //render.refresh('#topbar');
|
|
|
+ render.links('#topbar');
|
|
|
+ },
|
|
|
+ sidebar: function(t,c){
|
|
|
+ $('#sidebar').html(Handlebars.compile(t)(c));
|
|
|
+ $('#toolbar-done').click(function(){
|
|
|
+ $('#drawer').removeClass('open').css('transform','');
|
|
|
+ });
|
|
|
+ render.links('#sidebar');
|
|
|
+ $('#sidebar').find('a').click(function(e){
|
|
|
+ $('#drawer').removeClass('open').css('transform','');
|
|
|
+ e.preventDefault();
|
|
|
+ return false;
|
|
|
+ });
|
|
|
},
|
|
|
content: function(t,c){
|
|
|
$(document).unbind('ready');
|
|
@@ -483,38 +511,38 @@
|
|
|
render.inputs(selector);
|
|
|
},
|
|
|
inputs: function(selector){
|
|
|
- // $(selector).find('input[type=text],input[type=password]').each(function(){
|
|
|
- // var input = $(this),
|
|
|
- // height = input.height()>=17?17:input.height();
|
|
|
- // input.siblings('.input-clear').remove();
|
|
|
- // input.off('focus').off('blur').after(
|
|
|
- // $('<div>').css({
|
|
|
- // position: 'absolute',
|
|
|
- // right: $(window).width() - (input.outerWidth() + input.position().left)+2,
|
|
|
- // top: input.position().top+2,
|
|
|
- // 'background-image': 'url(img/headers/icons/clear.png)',
|
|
|
- // 'background-position': 'center',
|
|
|
- // 'background-size': height+'px '+height+'px',
|
|
|
- // 'background-repeat': 'no-repeat',
|
|
|
- // width: input.height(),
|
|
|
- // height: input.height(),
|
|
|
- // cursor: 'pointer'
|
|
|
- // }).hide().addClass('input-clear').mousedown(function(){
|
|
|
- // input.val('');
|
|
|
- // })
|
|
|
- // );
|
|
|
- // input.focus(function(){
|
|
|
- // input.next().show();
|
|
|
- // }).blur(function(e){
|
|
|
- // input.next().hide();
|
|
|
- // });
|
|
|
- // });
|
|
|
- // $(selector).find('input[type=text],input[type=password],textarea').each(function(){
|
|
|
- // var input = $(this);
|
|
|
- // if(input.hasClass('fill-width')){
|
|
|
- // input.css('width','calc(100% - '+(input.outerWidth()-input.width())+'px)');
|
|
|
- // }
|
|
|
- // });
|
|
|
+ /*$(selector).find('input[type=text],input[type=password]').each(function(){
|
|
|
+ var input = $(this),
|
|
|
+ height = input.height()>=17?17:input.height();
|
|
|
+ input.siblings('.input-clear').remove();
|
|
|
+ input.off('focus').off('blur').after(
|
|
|
+ $('<div>').css({
|
|
|
+ position: 'absolute',
|
|
|
+ right: $(window).width() - (input.outerWidth() + input.position().left)+2,
|
|
|
+ top: input.position().top+2,
|
|
|
+ 'background-image': 'url(img/headers/icons/clear.png)',
|
|
|
+ 'background-position': 'center',
|
|
|
+ 'background-size': height+'px '+height+'px',
|
|
|
+ 'background-repeat': 'no-repeat',
|
|
|
+ width: input.height(),
|
|
|
+ height: input.height(),
|
|
|
+ cursor: 'pointer'
|
|
|
+ }).hide().addClass('input-clear').mousedown(function(){
|
|
|
+ input.val('');
|
|
|
+ })
|
|
|
+ );
|
|
|
+ input.focus(function(){
|
|
|
+ input.next().show();
|
|
|
+ }).blur(function(e){
|
|
|
+ input.next().hide();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ $(selector).find('input[type=text],input[type=password],textarea').each(function(){
|
|
|
+ var input = $(this);
|
|
|
+ if(input.hasClass('fill-width')){
|
|
|
+ input.css('width','calc(100% - '+(input.outerWidth()-input.width())+'px)');
|
|
|
+ }
|
|
|
+ });*/
|
|
|
},
|
|
|
dialog: function(selector,title){
|
|
|
$(selector).dialog({
|
|
@@ -547,17 +575,7 @@
|
|
|
href = href.substr(href.indexOf('#')+1);
|
|
|
$(this).click(function(e){
|
|
|
try{
|
|
|
- if(($(this).hasClass('topbar-home') || $(this).hasClass('topbar-back'))&&$(window).width()<767){
|
|
|
- $('#topbar').children('div.topbar-right,div.topbar-left').toggle();
|
|
|
- $('#topbar').toggleClass('overflow-hide');
|
|
|
- $(window).resize();
|
|
|
- }else if($(this).hasClass('topbar-history')){
|
|
|
- back();
|
|
|
- }else if($(this).hasClass('topbar-current')){
|
|
|
- replaceState(href);
|
|
|
- }else{
|
|
|
- loadState(href);
|
|
|
- }
|
|
|
+ loadState(href);
|
|
|
}catch(error){
|
|
|
console.error(error);
|
|
|
}
|
|
@@ -739,8 +757,10 @@
|
|
|
},'json');
|
|
|
};
|
|
|
fn('topbars',function(){
|
|
|
- fn('pages',function(){
|
|
|
- callback();
|
|
|
+ fn('sidebars',function(){
|
|
|
+ fn('pages',function(){
|
|
|
+ callback();
|
|
|
+ });
|
|
|
});
|
|
|
});
|
|
|
};
|