Skip to content

Commit

Permalink
Merge pull request #11 from hiteshaggarwal/master
Browse files Browse the repository at this point in the history
V1.2 Updates
  • Loading branch information
hiteshaggarwal committed Aug 14, 2018
2 parents 3c15893 + c5962e7 commit 4d466fa
Show file tree
Hide file tree
Showing 64 changed files with 2,660 additions and 3,068 deletions.
355 changes: 236 additions & 119 deletions README.md

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions astroid/astroid-framework/assets/css/admin.css
Expand Up @@ -182,7 +182,24 @@

.unit-picker li{
cursor: pointer;
line-height: 26px;
line-height: 30px;
}

.unit-picker li label{
cursor: pointer;
line-height: 30px;
}

.unit-picker li label input[type="radio"]{
opacity: 0;
width: 0;
height: 0;
}

.unit-picker li label input[type="radio"]:checked ~ span{
color: #000;
font-weight: bold;
border-bottom: 1px dashed;
}

.unit-picker li.active{
Expand All @@ -199,7 +216,7 @@
border: none;
line-height: 24px;
background: none;
width: 40px;
width: 50px;
text-align: center;
border: none !important;
border-bottom: 1px dashed !important;
Expand All @@ -209,7 +226,7 @@
}

.margin-left-50px{
margin-left: 50px;
margin-left: 55px;
}

[range-slider].d-none{
Expand Down
4 changes: 2 additions & 2 deletions astroid/astroid-framework/assets/css/astroid-framework.css

Large diffs are not rendered by default.

58 changes: 18 additions & 40 deletions astroid/astroid-framework/assets/js/astroid-framework.js
Expand Up @@ -210,6 +210,21 @@ astroidFramework.directive('astroidsocialprofiles', ['$http', function ($http) {
});
$scope.profiles = _profiles;
};

$scope.addCustomProfile = function () {
var _profile = {
color: '#495057',
enabled: false,
icon: '',
icons: [],
id: "custom",
link: "#",
title: "Custom social profile"
};
var _profiles = $scope.profiles;
_profiles.push(angular.copy(_profile));
$scope.profiles = _profiles;
};
}
};
}
Expand Down Expand Up @@ -267,12 +282,12 @@ astroidFramework.directive('rangeSlider', function () {
setTimeout(function () {
ngModel.$setViewValue(parseFloat($(element).data('slider-value')));
scope.$apply();
}, 10);
}, 50);


setTimeout(function () {
$(element).slider(rangeConfig);
$(element).slider('setValue', parseFloat($(element).data('slider-value')));
//$(element).slider('setValue', parseFloat($(element).data('slider-value')));
}, 100);


Expand All @@ -295,43 +310,6 @@ astroidFramework.directive('rangeSlider', function () {
};
});

astroidFramework.directive('unitPicker', function () {
return {
restrict: 'A',
scope: true,
require: 'ngModel',
link: function ($scope, element, attrs, ngModel) {
if (typeof $ == 'undefined') {
var $ = jQuery;
}
setTimeout(function () {
$(element).wrap('<div class="d-inline-block margin-left-50px" />');
$(element).after('<ul class="list-inline unit-picker"><li class="list-inline-item" data-value="px">px</li><li class="list-inline-item" data-value="em">em</li><li class="list-inline-item" data-value="rem">rem</li><li class="list-inline-item" data-value="pt">pt</li><li class="list-inline-item" data-value="%">%</li></ul>');
$(element).parent('div').find('.unit-picker').children('li').bind('click', function () {
$(this).siblings().removeClass('active');
$(this).addClass('active');
$(element).val($(this).data('value'));
ngModel.$setViewValue($(this).data('value'));
$scope.$apply();
});

if (ngModel.$modelValue != '') {
$(element).parent('div').find('.unit-picker').children('li[data-value="' + ngModel.$modelValue + '"]').addClass('active');
}

var setUnit = function () {
var _slider = $('[data-slider-id="' + $(element).data('unit-slider-id') + '"]');
$(_slider).attr('data-unit', ngModel.$modelValue);
$(_slider).trigger('change');
};

$scope.$watch(attrs['ngModel'], setUnit);

}, 100);
},
};
});

astroidFramework.directive('colorPicker', function ($parse) {
return {
restrict: 'A',
Expand All @@ -342,7 +320,7 @@ astroidFramework.directive('colorPicker', function ($parse) {
}
var _value = $(element).val();
if ($(element).hasClass('color-picker-lg')) {
var spectrumConfigExtend = spectrumConfig;
var spectrumConfigExtend = angular.copy(spectrumConfig);
spectrumConfigExtend.replacerClassName = 'color-picker-lg';
$(element).spectrum(spectrumConfigExtend);
} else {
Expand Down
103 changes: 99 additions & 4 deletions astroid/astroid-framework/assets/js/astroid.js
Expand Up @@ -183,14 +183,27 @@ class AstroidAdmin {
this.initSidebar = function () {
var _class = this;
$('.sidebar-nav > li > a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
$('body').removeClass('show-options');
if ($('body').hasClass('astroid-live-preview')) {
_class.refreshPreviewScrolls();
}

if ($(e.target).attr('data-target') == '#astroid-tab-astroid_layout') {
$('body').addClass('astroid-layout-tab-selected');
} else {
$('body').removeClass('astroid-layout-tab-selected');
}

$.cookie("astroid-default-tab", $(e.target).attr('data-target'));
$('.sidebar-submenu').slideUp(500);
$(e.target).siblings('.sidebar-submenu').slideDown(500);
setTimeout(function () {
$('body, html').animate({
scrollTop: 0
}, 0);
_class.refreshScroll();
if (!$('body').hasClass('astroid-live-preview')) {
_class.refreshScroll();
}
}, 510);
$('body, html').animate({
scrollTop: 2
Expand Down Expand Up @@ -256,6 +269,63 @@ class AstroidAdmin {
}, 300);
};

this.livePreview = function () {
$('body').addClass('astroid-live-preview');
$('body').addClass('show-options');
setTimeout(function () {
Admin.livePreviewScrolls();
//Admin.refreshScroll();
}, 220);
Admin.hideAllTabs();
};

this.reloadPreview = function () {
if ($('body').hasClass('astroid-live-preview')) {
var iframe = document.getElementById('live-preview');
iframe.src = iframe.src + '?ts=' + generateID();
}
};

this.hideAllTabs = function () {
$('#astroid-menu li a').removeClass('active');
$('#astroid-menu li a').removeClass('show');
$('#astroid-menu li a').prop('aria-selected', false);
};

this.closeLivePreview = function () {
$('body').removeClass('astroid-live-preview');
$('body').removeClass('show-options');
setTimeout(function () {
$('#astroid-content-wrapper').getNiceScroll().remove();
Admin.refreshScroll();
}, 220);
};

this.livePreviewScrolls = function () {
$('#astroid-content-wrapper').niceScroll({autohidemode: 'leave', cursoropacitymin: 0.4, background: 'rgba(243,243,243,1)', cursorcolor: '#4A5768', cursorwidth: '7px', cursorborderradius: 0, cursorborder: 'none'});
Admin.refreshPreviewScrolls();
};

this.setPreviewViewport = function (_class, _obj) {
$('#live-preview-viewport').removeClass().addClass(_class);
$('.viewport-options').find('a').removeClass('active');
$(_obj).addClass('active');
};

this.refreshPreviewScrolls = function () {
setTimeout(function () {
$('#astroid-content-wrapper').getNiceScroll().resize();
$("#astroid-sidebar-wrapper").getNiceScroll().resize();
}, 50);
};

this.showOptions = function () {
$('body').addClass('show-options');
$('body').removeClass('astroid-layout-tab-selected');
Admin.refreshPreviewScrolls();
Admin.hideAllTabs();
}

// form functions
this.initForm = function () {
$('#astroid-form').parsley({
Expand Down Expand Up @@ -302,6 +372,7 @@ class AstroidAdmin {
return false;
}
Admin.saved = true;
Admin.reloadPreview();
if (!_export) {
Admin.notify('Template Saved.', 'success');
} else {
Expand Down Expand Up @@ -373,6 +444,7 @@ class AstroidAdmin {
Admin.notify(response.message, 'error');
} else {
Admin.saved = true;
Admin.reloadPreview();
Admin.notify('Settings Imported.', 'success');
}
setTimeout(function () {
Expand Down Expand Up @@ -514,6 +586,14 @@ class AstroidAdmin {
var _this = this;

var _defaultTab = $.cookie("astroid-default-tab");


if (_defaultTab == '#astroid-tab-astroid_layout') {
$('body').addClass('astroid-layout-tab-selected');
} else {
$('body').removeClass('astroid-layout-tab-selected');
}

if (typeof _defaultTab == 'undefined') {
$('#astroid-menu li:first-child a').tab('show');
} else {
Expand All @@ -523,10 +603,14 @@ class AstroidAdmin {
$('#astroid-menu li a[data-target="' + _defaultTab + '"]').tab('show');
}
}

//Admin.livePreview();
setTimeout(function () {
_this.loading(false);
Admin.saved = true;
}, 150);
setTimeout(function () {
_this.loading(false);
}, 500);
}, 300);
this.initCodeArea();
};

Expand All @@ -552,7 +636,6 @@ var Admin = new AstroidAdmin();
Admin.init();
getGoogleFonts();
initAstroidUploader();
initAstroidTypographyField();
$('.astroid-code-editor-exit-fs').click(function () {
$(this).parent('.head').parent('.astroid-code-editor').removeClass('full-screen');
});
Expand All @@ -574,6 +657,7 @@ var Admin = new AstroidAdmin();
$(this).parent('div').parent('.body').parent('.astroid-preloaders-selector').parent('.astroid-preloader-field').children('.select-preloader').html($(this).html());
$(this).parent('div').parent('.body').parent('.astroid-preloaders-selector').removeClass('open');
});
initAstroidUnitPicker();
};

var initAstroidTypographyField = function () {
Expand Down Expand Up @@ -648,6 +732,9 @@ var Admin = new AstroidAdmin();
_preview.css(_property, _value + _unit);
_field.change(function () {
var _u = $(this).attr('data-unit');
if (typeof _u == 'undefined') {
_u = '';
}
var _value = _field.val();
_preview.css(_property, _value + _u);
});
Expand Down Expand Up @@ -771,7 +858,15 @@ var Admin = new AstroidAdmin();
Dropzone.autoDiscover = false;
};

var initAstroidUnitPicker = function () {
$('.unit-picker').children('li').children('label').children('input[type=radio]').change(function () {
var _sliderid = $(this).data('sid');
$('[data-slider-id="' + _sliderid + '"]').attr('data-unit', $(this).val()).trigger('change');
});
};

var winLoad = function () {
initAstroidTypographyField();
Admin.load();
};

Expand Down

0 comments on commit 4d466fa

Please sign in to comment.