|
|
|
@ -106,4 +106,228 @@ menu.runScript = function(_id){
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
menu.events = {}
|
|
|
|
|
menu.events._dialog = function (_item,_context){
|
|
|
|
|
// var url = _args['url']
|
|
|
|
|
_item.type = (_item.type == null)? 'redirect' :_item.type
|
|
|
|
|
var http = HttpClient.instance()
|
|
|
|
|
http.setHeader('uri',_item.uri)
|
|
|
|
|
http.setHeader('dom',(_item.title)?_item.title:'dialog')
|
|
|
|
|
// http.setHeader('dom',_args.text)
|
|
|
|
|
http.get(_context+'/dialog',function(x){
|
|
|
|
|
|
|
|
|
|
jx.modal.show({html:x.responseText,id:'dialog'})
|
|
|
|
|
// menu.events.finalize ('.jxmodal')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
menu.events._open = function (id,uri,_context){
|
|
|
|
|
id = id.replace(/ /g,'-')
|
|
|
|
|
|
|
|
|
|
var pid = '#content'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('.content').children().slideUp()
|
|
|
|
|
$('#'+id).remove()
|
|
|
|
|
var httpclient = HttpClient.instance()
|
|
|
|
|
_context = (_context == null)?'':_context;
|
|
|
|
|
httpclient.setHeader('uri',uri)
|
|
|
|
|
httpclient.setHeader('dom',id)
|
|
|
|
|
httpclient.post(_context+'/page',function(x){
|
|
|
|
|
var _html = x.responseText
|
|
|
|
|
var _dom = $(_html)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(jx.dom.exists(pid) && jx.dom.exists(id)){
|
|
|
|
|
jx.dom.remove(id)
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
$(pid).append(_dom)
|
|
|
|
|
|
|
|
|
|
// jx.dom.append(pid,_dom)
|
|
|
|
|
// $('#'+id).show('fast',function(){
|
|
|
|
|
// $('#'+pid).slideUp()
|
|
|
|
|
// })
|
|
|
|
|
var ref = pid + ' #'+id
|
|
|
|
|
$(pid).children().slideUp('fast', function(){
|
|
|
|
|
$(ref ).slideDown('fast',function(){
|
|
|
|
|
|
|
|
|
|
$(pid).slideDown('fast',function(){
|
|
|
|
|
var input = $(pid).find('input')
|
|
|
|
|
if (input.length > 0 ){
|
|
|
|
|
$(input[0]).focus()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
menu.events.finalize (ref)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// $('.content').append(_dom)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
menu.utils = {}
|
|
|
|
|
menu.utils.format = function(text){
|
|
|
|
|
return text.replace(/(-|_)/g,' ').trim()
|
|
|
|
|
}
|
|
|
|
|
menu.events.finalize = function (ref) {
|
|
|
|
|
var scripts = $(ref+' script')
|
|
|
|
|
jx.utils.patterns.visitor(scripts,function(_item){
|
|
|
|
|
if(_item.text.trim().length > 0){
|
|
|
|
|
|
|
|
|
|
var _code = eval(_item.text)
|
|
|
|
|
var id = ref
|
|
|
|
|
if (_item.parentNode != null){
|
|
|
|
|
var id = _item.parentNode.id == null?_item.parentNode.className : _item.parentNode.id
|
|
|
|
|
}
|
|
|
|
|
id = (id != null)?id : ref
|
|
|
|
|
|
|
|
|
|
// _delegate.scripts[id] = _code
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Let's build the tab handling here ...
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
var QCMSBasic= function(_layout,_context,_clickEvent) {
|
|
|
|
|
this._layout = _layout
|
|
|
|
|
this._context= _context
|
|
|
|
|
this._make = function (_items){
|
|
|
|
|
var _panes = []
|
|
|
|
|
var _context = this._context ;
|
|
|
|
|
_items.forEach(_item=>{
|
|
|
|
|
var _div = jx.dom.get .instance('DIV')
|
|
|
|
|
|
|
|
|
|
_div.innerHTML = menu.utils.format(_item.text)
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// We need to check for the override text and see if it goes here
|
|
|
|
|
_div.className = 'active'
|
|
|
|
|
_div.data = _item
|
|
|
|
|
_panes.push(_div)
|
|
|
|
|
$(_div).on('click', function (){
|
|
|
|
|
//
|
|
|
|
|
// how do we process this ...
|
|
|
|
|
|
|
|
|
|
if(this.data.uri) {
|
|
|
|
|
|
|
|
|
|
if (this.data.type == 'dialog') {
|
|
|
|
|
menu.events._dialog(this.data,_context)
|
|
|
|
|
}else{
|
|
|
|
|
menu.events._open(menu.utils.format(this.data.text),this.data.uri,_context)
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
window.open(this.data.url,menu.utils.format(this.data.text))
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
return _panes ;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
this.init = function (){
|
|
|
|
|
var _make = this._make
|
|
|
|
|
var _layout = this._layout
|
|
|
|
|
Object.keys(this._layout.menu).forEach(function(_name){
|
|
|
|
|
var _div = _make(_layout.menu[_name]) ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var _sub = jx.dom.get.instance('DIV')
|
|
|
|
|
var _menuItem = jx.dom.get.instance('DIV')
|
|
|
|
|
_menuItem.innerHTML = menu.utils.format (_name)
|
|
|
|
|
_sub.className = 'sub-menu border-round border '
|
|
|
|
|
_menuItem.className = 'item'
|
|
|
|
|
_div.forEach(_item=>{$(_sub).append(_item) })
|
|
|
|
|
$(_sub).append(_div)
|
|
|
|
|
_menuItem.appendChild(_sub)
|
|
|
|
|
|
|
|
|
|
$('.main .menu').append(_menuItem)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var QCMSTabs = function(_layout,_context,_clickEvent){
|
|
|
|
|
//
|
|
|
|
|
// This object will make tabs in the area of the menu
|
|
|
|
|
// @TODO: we can parameterize where the menu is made to improve flexibility
|
|
|
|
|
//
|
|
|
|
|
this.tabs = jx.dom.get.instance('DIV')
|
|
|
|
|
this.tabs.className = 'tabs'
|
|
|
|
|
this._context = _context
|
|
|
|
|
this._make = function (text,_item,_event){
|
|
|
|
|
var text = text.trim().replace(/(_|-)/ig,' ').trim()
|
|
|
|
|
var _context = this._context;
|
|
|
|
|
if (text.match(/\//)){
|
|
|
|
|
text = text.split(/\//g).slice(-1)[0]
|
|
|
|
|
}
|
|
|
|
|
var _button = jx.dom.get.instance('INPUT')
|
|
|
|
|
var _label = jx.dom.get.instance('LABEL')
|
|
|
|
|
_button.type= 'radio'
|
|
|
|
|
_button.id = text+'tab'
|
|
|
|
|
_button.name = 'menu-tabs'
|
|
|
|
|
_label.innerHTML = text.toLowerCase()
|
|
|
|
|
_label._uri = _item[0].uri
|
|
|
|
|
_label.htmlFor = _button.id
|
|
|
|
|
$(_label).on('click',function (){
|
|
|
|
|
|
|
|
|
|
menu.events._open(this.innerHTML,this._uri,_context)
|
|
|
|
|
})
|
|
|
|
|
// $(this.tabs).append( [_button,_label])
|
|
|
|
|
return [_button,_label]
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._layout = _layout
|
|
|
|
|
this.init = function (){
|
|
|
|
|
var _make = this._make
|
|
|
|
|
var tabs = this.tabs
|
|
|
|
|
Object.keys(_layout.menu).forEach(function(_key){
|
|
|
|
|
_item = _layout.menu[_key]
|
|
|
|
|
// console.log([_item])
|
|
|
|
|
_tabItem = _make(_key,_item)
|
|
|
|
|
$(tabs).append(_tabItem)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
this.tabs.className = 'tabs'
|
|
|
|
|
$('.main .menu').append(this.tabs)
|
|
|
|
|
$('.main .menu').css({'border':'1px solid transparent'})
|
|
|
|
|
}
|
|
|
|
|
//
|
|
|
|
|
// We need to load the pages here ...
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
menu.tabs = { }
|
|
|
|
|
// menu.tabs.make = function(text,_clickEvent){
|
|
|
|
|
// var _id = text.trim()
|
|
|
|
|
// if (text.match(/\//)){
|
|
|
|
|
// _id = text.split(/\//g).slice(-1)[0]
|
|
|
|
|
// }
|
|
|
|
|
// var _button = jx.dom.get.instance('div')
|
|
|
|
|
// var _label = jx.dom.get.instance('LABEL')
|
|
|
|
|
// _button.type= 'radio'
|
|
|
|
|
// _button.id = _id
|
|
|
|
|
|
|
|
|
|
// _label.innerHTML = _id.toLowerCase()
|
|
|
|
|
// $(_label).on('click',_clickEvent)
|
|
|
|
|
// return [_button,_label]
|
|
|
|
|
// }
|
|
|
|
|
menu.tabs.init =function (_layout){
|
|
|
|
|
// console.log(_layout)
|
|
|
|
|
// var _tabs = new QCMSTabs (_layout)
|
|
|
|
|
var _tabs = new QCMSBasic (_layout)
|
|
|
|
|
_tabs.init()
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|