1
0
Fork 0
forked from 0x2620/oxjs

ExamplePanel/ExamplePage: add mode/selected option ('source' or 'live')

This commit is contained in:
rolux 2012-07-05 21:38:02 +02:00
commit 01717f3727
2 changed files with 47 additions and 30 deletions

View file

@ -5,6 +5,8 @@ Ox.ExamplePage <f> Example Page
options <o> Options
self <o> Shared private variable
([options[, self]]) -> <o:Ox.SplitPanel> Example Page
change <!> Change event
close <!> Close event
@*/
Ox.ExamplePage = function(options, self) {
@ -20,7 +22,12 @@ Ox.ExamplePage = function(options, self) {
selected: 'source',
title: ''
})
.options(options || {});
.options(options || {})
.update({
selected: function() {
self.$tabs.options({value: self.options.selected});
}
});
self.$toolbar = Ox.Bar({size: 24});
@ -116,37 +123,21 @@ Ox.ExamplePage = function(options, self) {
self.$reloadButton.options({disabled: disabled});
self.$openButton.options({disabled: disabled});
self.$content.animate({
marginLeft: data.value == 'source'
marginLeft: self.options.selected == 'source'
? 0 : -self.options.width + 'px'
}, 250, function() {
if (data.value == 'live' && !self.$frame.attr('src')) {
if (
self.options.selected == 'live'
&& !self.$frame.attr('src')
) {
self.$frame.attr({src: self.options.html});
}
});
that.triggerEvent('change', data);
}
})
.appendTo(self.$toolbar);
/*
self.$referencesMenu = Ox.MenuButton({
items: self.options.references.map(function(reference) {
return {id: reference, title: reference};
}),
//title: 'Documentation',
//width: 128
title: 'select',
tooltip: 'References',
type: 'image'
})
.css({float: 'right', margin: '4px 2px 4px 2px'})
.bindEvent({
click: function(data) {
that.triggerEvent('doc', {id: data.id});
}
})
.appendTo(self.$toolbar);
*/
self.$viewer = Ox.SourceViewer({
file: self.options.js,
replaceCode: self.options.replaceCode,
@ -173,7 +164,9 @@ Ox.ExamplePage = function(options, self) {
self.$content = Ox.Element()
.css({
position: 'absolute',
width: self.options.width * 2 + 'px'
width: self.options.width * 2 + 'px',
marginLeft: self.options.selected == 'source'
? 0 : -self.options.width + 'px'
})
.append(self.$viewer)
.append(self.$frame);
@ -202,7 +195,12 @@ Ox.ExamplePage = function(options, self) {
}
});
setTimeout(setSize, 100);
setTimeout(function() {
setSize();
if (self.options.selected == 'live') {
self.$frame.attr({src: self.options.html});
}
}, 100);
function setSize() {
self.options.width = that.width();