some more refactoring, preparing to move the editor to editor.js...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2013-03-04 16:59:12 +04:00
parent 8519c14c71
commit 84f84f9c4f

View File

@ -208,43 +208,49 @@
// XXX need better separation between full screen and ribbon modes...
function setupEditor(){
var indicator = $('<div class="current-page-indicator"/>')
.appendTo($('.magazine'))
function setupEditorToolbars(){
var indicator = $('<div class="current-page-indicator"/>')
.appendTo($('.magazine'))
// the toolbars...
var left_bar = $('<div class="left-toolbar"/>')
.appendTo(indicator)
var right_bar = $('<div class="right-toolbar"/>')
// the toolbars...
var left_bar = $('<div class="left-toolbar"/>')
.appendTo(indicator)
var right_bar = $('<div class="right-toolbar"/>')
.appendTo(indicator)
$('<button class="button remove">&times;</button>')
.appendTo(indicator)
.click(function(){
setTransitionDuration($('.magazine'), 0)
removePage()
})
$('<button class="button remove">&times;</button>')
.appendTo(indicator)
.click(function(){
setTransitionDuration($('.magazine'), 0)
removePage()
})
$('<button class="button shift">&gt;</button>')
.appendTo(right_bar)
.click(function(){
shiftPageRight()
})
$('<button class="button add">+</button>')
.appendTo(right_bar)
.click(function(){
})
$('<button class="button shift">&gt;</button>')
.appendTo(right_bar)
.click(function(){
shiftPageRight()
})
$('<button class="button add">+</button>')
.appendTo(right_bar)
.click(function(){
})
$('<button class="button shift">&lt;</button>')
.appendTo(left_bar)
.click(function(){
shiftPageLeft()
})
$('<button class="button add">+</button>')
.appendTo(left_bar)
.click(function(){
})
$('<button class="button shift">&lt;</button>')
.appendTo(left_bar)
.click(function(){
shiftPageLeft()
})
$('<button class="button add">+</button>')
.appendTo(left_bar)
.click(function(){
})
}
function clearEdiorToolbars(){
var indicator = $('.current-page-indicator').remove()
}
// general editor mode...
window.toggleEditor = createCSSClassToggler(
'.chrome',
'editor',
@ -262,10 +268,16 @@ function setupEditor(){
}
setCurrentPage($('.current.page'))
})
var toggleInlineEditor = createCSSClassToggler(
// inline editor switcher...
window.toggleInlineEditor = createCSSClassToggler(
'.chrome',
'inline-edior',
function(action){
// prevent switching on while not in editor mode...
if(toggleEditor('?') == 'off' && action == 'on'){
return false
}
},
function(action){
if(action == 'on'){
MagazineScroller.stop()
@ -278,6 +290,7 @@ function setupEditor(){
}
})
// editable focus...
$('[contenteditable]')
.on('focus', function(){
if(toggleInlineEditor('?') == 'off'){
@ -290,9 +303,9 @@ function setupEditor(){
toggleInlineEditorMode('off')
})
// move the page indicator...
// NOTE: this is to be used for page-specific toolbars etc.
$('.viewer')
// move the page indicator...
// NOTE: this is to be used for page-specific toolbars etc.
.on('pageChanged', function(){
var cur = $('.current.page')
var indicator = $('.current-page-indicator')
@ -307,7 +320,7 @@ function setupEditor(){
top: 0,
})
})
// switch between editor modes...
.on('fullScreenMode', function(){
$(':focus').blur()
if(toggleEditor('?') == 'on'){
@ -320,6 +333,8 @@ function setupEditor(){
toggleInlineEditor('off')
}
})
setupEditorToolbars()
}