Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Subtabs stubbed out until completed - stable build

  • Loading branch information...
commit a5d72191be3e5fd1829e8d149e957aa3a504f53e 1 parent 1fe78fb
@matthew-dean authored
View
BIN  Crunch.1.5.3.air
Binary file not shown
View
1  css/skin2.css
@@ -990,6 +990,7 @@ li {
border-radius: 5px;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
margin: 4px 2px 0;
+ cursor: default;
}
.subtabs span.t.active {
background: #a9a39e;
View
117 js/scripts.js
@@ -7,7 +7,7 @@ appUpdater.initialize();
if(air && air.Introspector) {
console = air.Introspector.Console;
- console.log('test');
+ //console.log('test');
}(function($) {
var Crunch = function() {
@@ -184,8 +184,6 @@ if(air && air.Introspector) {
save : function() {
var $activeEl = $("#tabs li.active .subtabs .active");
- console.log($activeEl);
- console.log($activeEl.data('session'));
trySave($activeEl, false);
},
saveAs : function() {
@@ -197,9 +195,10 @@ if(air && air.Introspector) {
crunch : function() {
var $activeEl = $("#tabs li.active");
lastCrunch = crunchFile($activeEl);
- if(!lastCrunch)
+ if(lastCrunch.err != null) {
+ showMessage($activeEl.find('.messages'), lastCrunch.err);
return;
-
+ }
if(!($activeEl.data('session').saved)) {
var answer = confirm('You have to save before crunching. Go ahead and save?');
if(answer) {
@@ -271,24 +270,26 @@ if(air && air.Introspector) {
var $scrollContainer;
var $tabContainer;
var $thisTab;
-
+ var tabSession;
+
if($el.is("a")) {
$scrollContainer = $("#scroller");
$tabContainer = $('#tabs');
$thisTab = $el.parent();
$tabContainer.find('li').removeClass('active');
$thisTab.addClass('active');
+ tabSession = $thisTab.find('span.t.active').data('session');
}
else {
- var $parentTab = $el.parent();
+ var $parentTab = $el.closest('.subtabs');
$scrollContainer = $parentTab.find('.imports');
$tabContainer = $scrollContainer.find('>div');
$thisTab = $el;
- $parentTab.find('.subtabs span.t').removeClass('active');
+ $parentTab.find('span.t').removeClass('active');
$el.addClass('active');
+ tabSession = $el.data('session');
}
- // WHY IS THIS ZERO?? WHERE I AM
if($thisTab.length == 0)
return;
if($thisTab.data('notless') || !$thisTab.data('file-less')) {
@@ -300,8 +301,8 @@ if(air && air.Introspector) {
var tabs = $tabContainer;
if(!($el.hasClass('.main') || $el.hasClass('.crunched'))) {
if(($thisTab.outerWidth() + $thisTab.position().left) > width) {
- tabs.animate({
- 'margin-left' : (tabs[0].scrollWidth - width) * -1
+ $tabContainer.animate({
+ 'margin-left' : ($tabContainer[0].scrollWidth - width) * -1
}, {
duration : 'fast',
complete : function() {
@@ -309,8 +310,8 @@ if(air && air.Introspector) {
}
});
} else if($thisTab.position().left < 0) {
- tabs.animate({
- 'margin-left' : tabs.margin().left - $thisTab.position().left + 25
+ $tabContainer.animate({
+ 'margin-left' : $tabContainer.margin().left - $thisTab.position().left + 25
}, {
duration : 'fast',
complete : function() {
@@ -319,8 +320,15 @@ if(air && air.Introspector) {
});
}
}
- Editor.setSession($thisTab.data('session').session);
- if($thisTab.data('session').saved)
+
+ Editor.setSession(tabSession.session);
+
+ if(tabSession.readonly)
+ Editor.setReadOnly(true);
+ else
+ Editor.setReadOnly(false);
+
+ if(tabSession.saved)
$thisTab.find('.save:first').hide();
else
$thisTab.find('.save:first').show();
@@ -337,6 +345,7 @@ if(air && air.Introspector) {
}
function closeTab(el) {
+
var i = $(el).index('#tabs > li.t');
var wasActive = $(el).hasClass('active');
@@ -424,6 +433,7 @@ if(air && air.Introspector) {
}
$el.data('session', tabSession);
+ $el.find('.subtabs .main').data('session', tabSession);
setActive($el.find('a.tab'));
adjustTabOverflow();
return $el;
@@ -531,28 +541,8 @@ if(air && air.Introspector) {
this.responseText = getTree(settings.data.path);
}
});
-
- // // Less.js tries to do an XMLHttpRequest. Not sure how to circumvent, so we'll just hijack that too.
- // // Yes, the fact that there are two hijackers is stupid, I know. There's a good explanation... well, a reasonable explanation, and I'll fix later.
- // var server = new MockHttpServer();
- // server.handle = function(request) {
- //
- // if(request.url.match(/\.less/i)) {
- // request.url = request.url.replace(/app:\//ig, '');
- // var getFile = Paths.project.resolvePath(request.url);
- // if(!getFile.exists) {
- // request.receive(404, "Not found.");
- // } else {
- // request.setResponseHeader("Last-Modified", getFile.modificationDate);
- // var fileStream = new air.FileStream();
- // fileStream.open(getFile, air.FileMode.READ);
- // request.receive(200, fileStream.readUTFBytes(fileStream.bytesAvailable));
- // fileStream.close();
- // }
- // }
- // };
- // server.start();
-
+
+ // No longer needed as of LESS 1.3
// $(window).bind('crunch.error', function(ev, e, href) {
// air.trace('LESS error')
// var $activeEl = $("#tabs li.active .messages");
@@ -596,7 +586,7 @@ if(air && air.Introspector) {
tabSession = getTabSession(file);
var tabTemplate = '<span class="t"><span class="filename">' + file.name +'</span><span class="save" style="display: none;">*</span></span>';
- var $imports = $crunchEl.find('.subtabs .imports');
+ var $imports = $crunchEl.find('.subtabs .imports > div');
var $subtab = $(tabTemplate);
$subtab.data('file-less',file);
$subtab.data('session',tabSession);
@@ -688,12 +678,26 @@ if(air && air.Introspector) {
else
$el.find('.save:first').show();
+
+ $el.data('file-less', file);
+ $el.find('.subtabs .main').data('file-less', file).data('session', tabSession);
+
if(!file.name.match(/\.less/i)) {
setTabType($el, true);
}
- $el.data('file-less', file);
- $el.find('.subtabs .main').data('file-less', file).data('session', tabSession);
-
+ else {
+ var compiled = crunchFile($el);
+ if(compiled.err == null) {
+ var $compiled = $el.find('.subtabs .crunched');
+ var tabSession = getTabSession();
+ canChangeSave = false;
+ tabSession.session.setValue(compiled.output);
+ canChangeSave = true;
+ tabSession.readonly = true;
+ $compiled.data('session', tabSession);
+ }
+ }
+
setActive($el.find('a.tab'));
addOpenFile(file);
@@ -708,6 +712,7 @@ if(air && air.Introspector) {
function crunchFile($el) {
var output;
+ var errMessage = null;
try {
// TODO: Should be top session
@@ -727,7 +732,7 @@ if(air && air.Introspector) {
hideMessage($el.find('.messages'));
});
} catch(err) {
- var errMessage = err.message;
+ errMessage = err.message;
//if(err.index) {
// errMessage += ' Index: ' + err.index;
//}
@@ -737,11 +742,10 @@ if(air && air.Introspector) {
if(err.filename) {
errMessage += '<br>Filename: ' + err.filename;
}
- showMessage($el.find('.messages'), errMessage);
return false;
}
- return output;
+ return { output: output, err: errMessage };
}
function trySave($el, crunch, closeWindow) {
@@ -774,11 +778,24 @@ if(air && air.Introspector) {
if(crunch) {
fileSelect = $el.data('file-css');
try {
- writeData = lastCrunch;
+ writeData = lastCrunch.output;
} catch(err) {
alert("I failed at saving. My bad. Here's what happened: " + err.message);
return false;
}
+
+ var tabSession;
+ if(!(fileSelect.nativePath in Sessions)) {
+ canChangeSave = false;
+ tabSession = getTabSession(fileSelect);
+ tabSession.session.setValue(writeData);
+ canChangeSave = true;
+ }
+ else
+ tabSession = getTabSession(fileSelect);
+
+ $el.find('.subtabs .crunched').data('session', tabSession);
+
} else {
fileSelect = $el.data('file-less');
writeData = Editor.getSession().getValue();
@@ -813,6 +830,7 @@ if(air && air.Introspector) {
alert("I failed in the saving of your glorious creation. Here's why: " + err.message);
return false;
}
+ // Comment out 2 lines with subtabs enabled
if(crunch)
openFile(fileSelect, true);
$el.data('session').saved = true;
@@ -868,6 +886,7 @@ if(air && air.Introspector) {
var newFile = event.target;
if(crunch) {
$el.data('file-css', newFile);
+ $el.find('.subtabs .crunched .filename').html(newFile.name);
App.paths.css = newFile.parent.nativePath;
updateOpenFile($el.data('file-less'), $el.data('file-css'));
} else {
@@ -1034,7 +1053,7 @@ if(air && air.Introspector) {
var fileData = fileStream.readUTFBytes(fileStream.bytesAvailable);
fileStream.close();
- addSubTab(file, fileData);
+ //addSubTab(file, fileData);
new (less.Parser)({
paths : [file.nativePath.replace(/[\w\.-]+$/, '')].concat(paths),
filename : file.nativePath
@@ -1094,13 +1113,16 @@ if(air && air.Introspector) {
}
});
- $('#tabs > li.t > a').click(function() {
+ $('#tabs').on('click','li.t > a', function() {
if(!pendingClose && $(this).parent().data('file-less')) {
App.activeTab = $(this).parent().data('file-less').nativePath;
updateAppState();
}
setActive($(this));
});
+ $('.subtabs').on('click', '.t', function() {
+ setActive($(this));
+ });
$('.messages .close').click(function() {
hideMessage($(this).closest('.messages'));
});
@@ -1157,6 +1179,7 @@ if(air && air.Introspector) {
$('#tabs a.tab .close').click(function() {
var listItem = $(this).parent().parent();
tryCloseTab(listItem);
+ return false;
});
$("#findbar .close").click(function() {
View
9 less/skin2.less
@@ -36,6 +36,14 @@ ul, li { margin: 0; padding: 0; list-style-type: none;}
-webkit-box-shadow: 0 1px 0 #fff;
height: 100%;
padding: 0 5px;
+ position: relative;
+ .imports {
+ position: absolute;
+ left: 100px;
+ top: 0;
+ height: 100%;
+ right: 0;
+ }
span.t {
font-family: "Lucida Sans", "Lucida Grande", "Lucida Sans Unicode", sans-serif;
font-size: 11px;
@@ -45,6 +53,7 @@ ul, li { margin: 0; padding: 0; list-style-type: none;}
border-radius: 5px;
text-shadow: 0 1px 0 rgba(255,255,255,0.3);
margin: 4px 2px 0;
+ cursor: default;
&.active {
background: #a9a39e;
color: white;
View
4 main.html
@@ -102,8 +102,8 @@
<li class="t">
<a class="tab" href="#"><span class="filename">new.less</span><span class="save" style="display: none;">*</span><span class="close"><img src="img/skin/closeicon.png"></span></a>
<div class="subtabs-outer"><div class="subtabs">
- <span class="active main t">Source<span class="save" style="display: none;">*</span></span>
- <span class="crunched t"><span class="filename">Compiled</span><span class="save" style="display: none;">*</span></span>
+ <span class="active main t" style="visibility: hidden">Source<span class="save" style="display: none;">*</span></span>
+ <span class="crunched t" style="visibility: hidden"><span class="filename">Compiled</span><span class="save" style="display: none;">*</span></span>
<div class="imports"><div>
</div></div>
Please sign in to comment.
Something went wrong with that request. Please try again.