2013-05-13 21:45:59 +04:00
|
|
|
/*globals document, location, jQuery */
|
2013-05-11 20:44:25 +04:00
|
|
|
(function ($) {
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var changePage = function (e) {
|
|
|
|
var newPage = $(this).children('a').attr('href');
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
$('.settings-menu .active').removeClass('active');
|
2013-05-13 21:45:59 +04:00
|
|
|
location.hash = $(this).attr('class'); // Placed here so never gets given the active attribute.
|
2013-05-11 20:44:25 +04:00
|
|
|
$(this).addClass('active');
|
|
|
|
|
|
|
|
$('.settings-content').fadeOut().delay(250);
|
|
|
|
$(newPage).fadeIn();
|
|
|
|
|
2013-05-23 17:57:37 +04:00
|
|
|
},
|
|
|
|
|
2013-05-23 18:00:45 +04:00
|
|
|
defaultSettings = {
|
|
|
|
title: 'My Blog',
|
|
|
|
description: ''
|
|
|
|
},
|
|
|
|
|
|
|
|
getSettings = function () {
|
|
|
|
return $.extend(defaultSettings, {
|
|
|
|
title : $('#blog-title').val(),
|
|
|
|
description : $('#blog-description').val()
|
|
|
|
});
|
|
|
|
};
|
2013-05-11 20:44:25 +04:00
|
|
|
|
2013-05-13 21:45:59 +04:00
|
|
|
$(document).ready(function () {
|
|
|
|
if (location.hash) {
|
|
|
|
var page = $(".settings-menu li." + location.hash.replace('#', '')),
|
|
|
|
newPage = page.children('a').attr('href');
|
|
|
|
$('.settings-menu .active').removeClass('active');
|
|
|
|
page.addClass('active');
|
|
|
|
|
|
|
|
$('.settings-content').hide().delay(250);
|
|
|
|
$(newPage).show();
|
|
|
|
}
|
2013-05-11 20:44:25 +04:00
|
|
|
$('.settings-menu li').on('click', changePage);
|
2013-05-13 21:25:16 +04:00
|
|
|
|
|
|
|
$('input').iCheck({
|
|
|
|
checkboxClass: 'icheckbox_square-grey'
|
|
|
|
});
|
2013-05-20 01:52:12 +04:00
|
|
|
|
2013-05-23 17:57:37 +04:00
|
|
|
$('.button-save').click(function (e) {
|
2013-05-20 01:52:12 +04:00
|
|
|
e.preventDefault();
|
2013-05-23 17:57:37 +04:00
|
|
|
var data = getSettings();
|
|
|
|
$.ajax({
|
|
|
|
method: 'PUT',
|
2013-05-24 16:17:46 +04:00
|
|
|
url: '/api/v0.1/settings',
|
2013-05-23 17:57:37 +04:00
|
|
|
data: data,
|
|
|
|
success: function (res, xhr, c) {
|
|
|
|
console.log(xhr, c);
|
|
|
|
}
|
|
|
|
});
|
2013-05-20 01:52:12 +04:00
|
|
|
});
|
2013-05-23 17:57:37 +04:00
|
|
|
});
|
2013-05-20 01:52:12 +04:00
|
|
|
|
2013-05-11 20:44:25 +04:00
|
|
|
}(jQuery));
|