fix persisting the minimized sidebar status

This commit is contained in:
Sven Fuchs 2012-09-23 02:22:13 +02:00
parent 1eb33161a7
commit ef9b34b235
7 changed files with 18 additions and 93 deletions

View File

@ -20,7 +20,6 @@ input 'assets/javascripts' do
vendor/ansiparse.js
vendor/i18n.js
vendor/pusher.js
vendor/jquery.cookie.js
vendor/jquery.timeago.js
vendor/sc-routes.js
)

View File

@ -67,13 +67,3 @@ Travis.reopen
controller: @controller
view.appendTo(@get('rootElement') || 'body')
toggleSidebar: ->
$('body').toggleClass('maximized')
# TODO gotta force redraws here :/
element = $('<span></span>')
$('#top .profile').append(element)
Em.run.later (-> element.remove()), 10
element = $('<span></span>')
$('#repository').append(element)
Em.run.later (-> element.remove()), 10

View File

@ -4,12 +4,28 @@ Travis.reopen
@tickables = []
Travis.Ticker.create(target: this, interval: Travis.INTERVALS.sponsors)
@toggle() if localStorage?.getItem('travis.maximized')
@connectWorkers(Travis.Worker.find())
@connectQueues(Travis.QUEUES)
@connectSponsors('decks', Travis.Sponsor.decks(), 1)
@connectSponsors('links', Travis.Sponsor.links(), 6)
persist: ->
localStorage?.setItem('travis.maximized', @isMinimized())
isMinimized: ->
return $('body').hasClass('maximized');
toggle: ->
$('body').toggleClass('maximized')
@persist()
# TODO gotta force redraws here :/
element = $('<span></span>')
$('#top .profile').append(element)
Em.run.later (-> element.remove()), 10
connectSponsors: (name, sponsors, perPage) ->
controller = Travis.SponsorsController.create(perPage: perPage, content: sponsors)
viewClass = Em.View.extend(templateName: "sponsors/#{name}")

View File

@ -2,7 +2,7 @@
{{t layouts.application.fork_me}}
</a>
<div id="slider" {{action toggleSidebar target="Travis.app"}}>
<div id="slider" {{action toggle target="controller"}}>
<div class='icon'></div>&nbsp;
</div>

View File

@ -1,40 +0,0 @@
/**
* jQuery Cookie plugin
*
* Copyright (c) 2010 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
jQuery.cookie = function (key, value, options) {
// key and at least value given, set cookie...
if (arguments.length > 1 && String(value) !== "[object Object]") {
options = jQuery.extend({}, options);
if (value === null || value === undefined) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
value = String(value);
return (document.cookie = [
encodeURIComponent(key), '=',
options.raw ? value : encodeURIComponent(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// key and possibly options given, get cookie...
options = value || {};
var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};

File diff suppressed because one or more lines are too long

View File

@ -27564,46 +27564,6 @@ var _require=function(){var a;a=document.addEventListener?function(b,c){b.addEve
for(var h=0,i=b.length,g=0;g<i;g++)d(b[g],c)}}();(function(){var a=[],b=function(){Pusher.ready()};window.JSON==undefined&&a.push("http://js.pusherapp.com/1.6.4/json2");if(window.WebSocket==undefined){window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION=true;a.push("http://js.pusherapp.com/1.6.4/flashfallback");b=function(){FABridge.addInitializationCallback("webSocket",function(){Pusher.ready()});WebSocket.__initialize()}}a.length>0?_require(a,b):b()})();
/**
* jQuery Cookie plugin
*
* Copyright (c) 2010 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
jQuery.cookie = function (key, value, options) {
// key and at least value given, set cookie...
if (arguments.length > 1 && String(value) !== "[object Object]") {
options = jQuery.extend({}, options);
if (value === null || value === undefined) {
options.expires = -1;
}
if (typeof options.expires === 'number') {
var days = options.expires, t = options.expires = new Date();
t.setDate(t.getDate() + days);
}
value = String(value);
return (document.cookie = [
encodeURIComponent(key), '=',
options.raw ? value : encodeURIComponent(value),
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path : '',
options.domain ? '; domain=' + options.domain : '',
options.secure ? '; secure' : ''
].join(''));
}
// key and possibly options given, get cookie...
options = value || {};
var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};
/*
* timeago: a jQuery plugin, version: 0.9.2 (2010-09-14)
* @requires jQuery v1.2.3 or later