|
|
|
@ -104,6 +104,7 @@ |
|
|
|
|
|
|
|
|
|
var editor = ace.edit("input"); |
|
|
|
|
var sessions = {}; |
|
|
|
|
|
|
|
|
|
var Range = ace.require('ace/range').Range; |
|
|
|
|
var errMarkerId = null; |
|
|
|
|
|
|
|
|
@ -120,6 +121,7 @@ |
|
|
|
|
|
|
|
|
|
SOL_CACHE_FILE = getFiles()[0]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var files = getFiles(); |
|
|
|
|
for (var x in files) |
|
|
|
|
sessions[files[x]] = newEditorSession(files[x]) |
|
|
|
@ -127,13 +129,11 @@ |
|
|
|
|
editor.setSession( sessions[SOL_CACHE_FILE] ); |
|
|
|
|
editor.resize(true); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function newEditorSession(filename) { |
|
|
|
|
var s = new ace.EditSession(window.localStorage[filename]) |
|
|
|
|
s.setMode("ace/mode/javascript"); |
|
|
|
|
function newEditorSession(filekey) { |
|
|
|
|
var s = new ace.EditSession(window.localStorage[filekey], "ace/mode/javascript") |
|
|
|
|
s.setTabSize(4); |
|
|
|
|
s.setUseSoftTabs(true); |
|
|
|
|
aces[filekey] = s; |
|
|
|
|
return s; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -143,7 +143,9 @@ |
|
|
|
|
|
|
|
|
|
$('#options li').click(function(ev){ |
|
|
|
|
var $el = $(this); |
|
|
|
|
var cls = /[a-z]+View/.exec( $el.get(0).className )[0]; |
|
|
|
|
var match = /[a-z]+View/.exec( $el.get(0).className ); |
|
|
|
|
if (!match) return; |
|
|
|
|
var cls = match[0]; |
|
|
|
|
if (!$el.hasClass('active')) { |
|
|
|
|
$el.parent().find('li').removeClass('active'); |
|
|
|
|
$('#optionViews').attr('class', '').addClass(cls); |
|
|
|
@ -225,6 +227,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ----------------- file selector-------------
|
|
|
|
|
|
|
|
|
|
var $filesEl = $('#files'); |
|
|
|
|
$filesEl.on('click','.newFile', function() { |
|
|
|
|
while (window.localStorage[SOL_CACHE_UNTITLED + untitledCount]) |
|
|
|
@ -313,11 +316,12 @@ |
|
|
|
|
} |
|
|
|
|
$('#input').toggle( !!SOL_CACHE_FILE ); |
|
|
|
|
$('#output').toggle( !!SOL_CACHE_FILE ); |
|
|
|
|
reAdjust(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function fileTabTemplate(key) { |
|
|
|
|
var name = fileNameFromKey(key); |
|
|
|
|
return $('<span class="file"><span class="name">'+name+'</span><span class="remove"><i class="fa fa-close"></i></span></span>'); |
|
|
|
|
return $('<li class="file"><span class="name">'+name+'</span><span class="remove"><i class="fa fa-close"></i></span></li>'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function fileKey( name ) { |
|
|
|
@ -341,6 +345,68 @@ |
|
|
|
|
|
|
|
|
|
updateFiles(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var hidWidth; |
|
|
|
|
|
|
|
|
|
function widthOfList (){ |
|
|
|
|
var itemsWidth = 0; |
|
|
|
|
$('.file').each(function(){ |
|
|
|
|
var itemWidth = $(this).outerWidth(); |
|
|
|
|
itemsWidth += itemWidth; |
|
|
|
|
}); |
|
|
|
|
return itemsWidth; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function widthOfHidden(){ |
|
|
|
|
return (($('.files-wrapper').outerWidth()) - widthOfList() - getLeftPosi()); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function widthOfVisible(){ |
|
|
|
|
return $('.files-wrapper').outerWidth(); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function getLeftPosi(){ |
|
|
|
|
return $('#files').position().left; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
function reAdjust (){ |
|
|
|
|
|
|
|
|
|
console.log("left start: ", getLeftPosi()) |
|
|
|
|
console.log("outer width: ", widthOfVisible(), "content width: ", widthOfList(), " left+vis: ", getLeftPosi() + widthOfVisible()) |
|
|
|
|
if (widthOfList() + getLeftPosi() > + widthOfVisible()) { |
|
|
|
|
console.log( "show right scroll") |
|
|
|
|
$('.scroller-right').fadeIn('fast'); |
|
|
|
|
} else { |
|
|
|
|
console.log( "hide right scroll") |
|
|
|
|
$('.scroller-right').fadeOut('fast'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (getLeftPosi()<0) { |
|
|
|
|
console.log( "show left scroll") |
|
|
|
|
$('.scroller-left').fadeIn('fast'); |
|
|
|
|
} else { |
|
|
|
|
console.log( "hide left scroll") |
|
|
|
|
$('.scroller-left').fadeOut('fast'); |
|
|
|
|
$('#files').animate({left: getLeftPosi() + "px"},'slow'); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$('.scroller-right').click(function() { |
|
|
|
|
var delta = (getLeftPosi() - 200) |
|
|
|
|
console.log(delta) |
|
|
|
|
$('#files').animate({left: delta + "px"},'slow',function(){ |
|
|
|
|
reAdjust(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
$('.scroller-left').click(function() { |
|
|
|
|
var delta = Math.min( (getLeftPosi() + 200), 0 ) |
|
|
|
|
console.log(delta) |
|
|
|
|
$('#files').animate({left: delta + "px"},'slow',function(){ |
|
|
|
|
reAdjust(); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
// ----------------- version selector-------------
|
|
|
|
|
|
|
|
|
|
// var soljsonSources is provided by bin/list.js
|
|
|
|
@ -395,6 +461,7 @@ |
|
|
|
|
dragging = false; |
|
|
|
|
setEditorSize(delta); |
|
|
|
|
window.localStorage.setItem(EDITOR_SIZE_CACHE_KEY, delta); |
|
|
|
|
reAdjust(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -410,7 +477,8 @@ |
|
|
|
|
$('.toggleRHP').click(function(){ |
|
|
|
|
hidingRHP = !hidingRHP; |
|
|
|
|
setEditorSize( hidingRHP ? 0 : window.localStorage[EDITOR_SIZE_CACHE_KEY] ); |
|
|
|
|
$('.toggleRHP').toggleClass('hiding', hidingRHP); |
|
|
|
|
$('.toggleRHP i').toggleClass('fa-angle-double-right', !hidingRHP); |
|
|
|
|
$('.toggleRHP i').toggleClass('fa-angle-double-left', hidingRHP); |
|
|
|
|
if (!hidingRHP) compile(); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -429,6 +497,7 @@ |
|
|
|
|
session.setWrapLimit(parseInt(contentWidth / characterWidth, 10)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
reAdjust(); |
|
|
|
|
} |
|
|
|
|
window.onresize = onResize; |
|
|
|
|
onResize(); |
|
|
|
@ -770,7 +839,7 @@ |
|
|
|
|
$('.col2 input,textarea').click(function() { this.select(); }); |
|
|
|
|
}; |
|
|
|
|
var tableRowItems = function(first, second, cls) { |
|
|
|
|
return $('<div class="row"/>') |
|
|
|
|
return $('<div class="crow"/>') |
|
|
|
|
.addClass(cls) |
|
|
|
|
.append($('<div class="col1">').append(first)) |
|
|
|
|
.append($('<div class="col2">').append(second)); |
|
|
|
|