Skip to content

Commit

Permalink
Making Websites With October CMS - Part 45 - Ajax Image Upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Dorić authored and Ivan Dorić committed Aug 19, 2017
1 parent 0d564a5 commit ecc71b3
Show file tree
Hide file tree
Showing 929 changed files with 35,856 additions and 8,399 deletions.
2 changes: 1 addition & 1 deletion config/cms.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
|
*/

'edgeUpdates' => false,
'edgeUpdates' => true,

/*
|--------------------------------------------------------------------------
Expand Down
20 changes: 10 additions & 10 deletions modules/backend/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use BackendMenu;
use BackendAuth;
use Backend\Classes\WidgetManager;
use System\Models\MailTemplate;
use System\Classes\MailManager;
use System\Classes\CombineAssets;
use System\Classes\SettingsManager;
use October\Rain\Support\ModuleServiceProvider;
Expand Down Expand Up @@ -51,10 +51,10 @@ public function boot()
*/
protected function registerMailer()
{
MailTemplate::registerCallback(function ($template) {
$template->registerMailTemplates([
'backend::mail.invite' => 'Invitation for newly created administrators.',
'backend::mail.restore' => 'Password reset instructions for backend-end administrators.',
MailManager::instance()->registerCallback(function ($manager) {
$manager->registerMailTemplates([
'backend::mail.invite',
'backend::mail.restore',
]);
});
}
Expand All @@ -64,7 +64,7 @@ protected function registerMailer()
*/
protected function registerAssetBundles()
{
CombineAssets::registerCallback(function($combiner) {
CombineAssets::registerCallback(function ($combiner) {
$combiner->registerBundle('~/modules/backend/assets/less/october.less');
$combiner->registerBundle('~/modules/backend/assets/js/october.js');
$combiner->registerBundle('~/modules/backend/widgets/table/assets/js/build.js');
Expand Down Expand Up @@ -95,7 +95,7 @@ protected function registerBackendNavigation()
'iconSvg' => 'modules/backend/assets/images/dashboard-icon.svg',
'url' => Backend::url('backend'),
'permissions' => ['backend.access_dashboard'],
'order' => 1
'order' => 10
]
]);
});
Expand All @@ -107,7 +107,7 @@ protected function registerBackendNavigation()
protected function registerBackendReportWidgets()
{
WidgetManager::instance()->registerReportWidgets(function ($manager) {
$manager->registerReportWidget('Backend\ReportWidgets\Welcome', [
$manager->registerReportWidget(\Backend\ReportWidgets\Welcome::class, [
'label' => 'backend::lang.dashboard.welcome.widget_title_default',
'context' => 'dashboard'
]);
Expand Down Expand Up @@ -198,7 +198,7 @@ protected function registerBackendSettings()
'description' => 'backend::lang.myaccount.menu_description',
'category' => SettingsManager::CATEGORY_MYSETTINGS,
'icon' => 'icon-user',
'url' => Backend::URL('backend/users/myaccount'),
'url' => Backend::url('backend/users/myaccount'),
'order' => 500,
'context' => 'mysettings',
'keywords' => 'backend::lang.myaccount.menu_keywords'
Expand All @@ -208,7 +208,7 @@ protected function registerBackendSettings()
'description' => 'backend::lang.backend_preferences.menu_description',
'category' => SettingsManager::CATEGORY_MYSETTINGS,
'icon' => 'icon-laptop',
'url' => Backend::URL('backend/preferences'),
'url' => Backend::url('backend/preferences'),
'permissions' => ['backend.manage_preferences'],
'order' => 510,
'context' => 'mysettings'
Expand Down
185 changes: 102 additions & 83 deletions modules/backend/assets/css/october.css

Large diffs are not rendered by default.

Binary file modified modules/backend/assets/images/treeview-submenu-tabs.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 28 additions & 0 deletions modules/backend/assets/js/backend.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,3 +208,31 @@ $.fn.extend({
}
})
*/

/*
* Browser Fixes
* - If another fix using JS is necessary, move this logic to backend.fixes.js
*/

/*
* Internet Explorer v11
* - IE11 will not honor height 100% when overflow is used on the Y axis.
*/
if (!!window.MSInputMethodContext && !!document.documentMode) {
$(window).on('resize', function() {
fixMediaManager()
fixSidebar()
})

function fixMediaManager() {
var $el = $('div[data-control="media-manager"] .control-scrollpad')
$el.height($el.parent().height())
}

function fixSidebar() {
$('#layout-sidenav').height(Math.max(
$('#layout-body').innerHeight(),
$(window).height() - $('#layout-mainmenu').height()
))
}
}
156 changes: 31 additions & 125 deletions modules/backend/assets/js/october-min.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion modules/backend/assets/js/october.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
=require october.sidepaneltab.js
=require october.simplelist.js
=require october.treelist.js
=require october.autocomplete.js
=require october.sidenav-tree.js
=require october.datetime.js
Expand Down
6 changes: 3 additions & 3 deletions modules/backend/assets/js/october.layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@
OctoberLayout.prototype.updateLayout = function(title) {
var $children, $el, fixedWidth, margin

// The entire 'width-fix' class can probably be removed if year >= 2017
// After checking that it isn't being used anywhere -sg
$('.layout-cell.width-fix, [data-calculate-width]').each(function(){
$('[data-calculate-width]').each(function(){
$children = $(this).children()

if ($children.length > 0) {
Expand Down Expand Up @@ -46,6 +44,8 @@
$parent = $(el).parent(),
$menu = $el.next()

$el.tooltip('hide')

if ($menu.hasClass('active')) {
self.$accountMenuOverlay.remove()
$parent.removeClass('highlight')
Expand Down
6 changes: 5 additions & 1 deletion modules/backend/assets/js/october.navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
var
navbar = $(this),
nav = $('ul.nav', navbar),
collapseMode = navbar.hasClass('navbar-mode-collapse')
collapseMode = navbar.hasClass('navbar-mode-collapse'),
isMobile = $('html').hasClass('mobile')

nav.verticalMenu($('a.menu-toggle', navbar), {
breakpoint: collapseMode ? Infinity : 769
Expand All @@ -26,6 +27,9 @@
placement: 'bottom',
template: '<div class="tooltip mainmenu-tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
})
.on('show.bs.tooltip', function (e) {
if (isMobile) e.preventDefault()
})

$('[data-calculate-width]', navbar).one('oc.widthFixed', function() {
var dragScroll = $('[data-control=toolbar]', navbar).data('oc.dragScroll')
Expand Down
11 changes: 9 additions & 2 deletions modules/backend/assets/js/october.scrollbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
self = this,
options = this.options = options || {},
sizeName = this.sizeName = options.vertical ? 'height' : 'width',
isNative = $('html').hasClass('mobile'),
isTouch = this.isTouch = Modernizr.touch,
isScrollable = this.isScrollable = false,
isLocked = this.isLocked = false,
Expand All @@ -38,6 +39,13 @@

this.$el.one('dispose-control', this.proxy(this.dispose))

/*
* Native (mobile) environments use overflow auto in CSS
*/
if (isNative) {
return
}

/*
* Create Scrollbar
*/
Expand All @@ -53,7 +61,6 @@
/*
* Bind events
*/

if (isTouch) {
this.$el.on('touchstart', function (event){
var touchEvent = event.originalEvent;
Expand Down Expand Up @@ -116,7 +123,7 @@
moveDrag(event)
return false
})

$(window).on('mouseup.scrollbar', function(){
stopDrag()
return false
Expand Down
78 changes: 45 additions & 33 deletions modules/backend/assets/js/october.sidenav-tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
this.options = options
this.$el = $(element)

this.init();
this.init()
}

SidenavTree.DEFAULTS = {
Expand All @@ -32,16 +32,15 @@
var self = this

$(document.body).addClass('has-sidenav-tree')

this.statusCookieName = this.options.treeName + 'groupStatus'
this.searchCookieName = this.options.treeName + 'search'
this.$searchInput = $(this.options.searchInput)

this.$el.on('click', 'li > div.group', function() {
self.toggleGroup($(this).closest('li'))

return false;
});
return false
})

this.$searchInput.on('keyup', function(){
self.handleSearchChange()
Expand All @@ -56,46 +55,52 @@
var scrollbar = $('[data-control=scrollbar]', this.$el).data('oc.scrollbar'),
active = $('li.active', this.$el)

if (active.length > 0)
if (active.length > 0) {
scrollbar.gotoElement(active)
}
}

SidenavTree.prototype.toggleGroup = function(group) {
var $group = $(group),
status = $group.attr('data-status')

status === undefined || status == 'expanded' ?
this.collapseGroup($group) :
this.expandGroup($group)
status === undefined || status == 'expanded'
? this.collapseGroup($group)
: this.expandGroup($group)
}

SidenavTree.prototype.collapseGroup = function(group) {
var
var
$list = $('> ul', group),
self = this;
self = this

$list.css('overflow', 'hidden')
$list.animate({'height': 0}, { duration: 100, queue: false, complete: function() {
$list.css({
'overflow': 'visible',
'display': 'none'
})
$(group).attr('data-status', 'collapsed')
$(window).trigger('oc.updateUi')
self.saveGroupStatus($(group).data('group-code'), true)
} })
$list.animate({ 'height': 0 }, {
duration: 100,
queue: false,
complete: function() {
$list.css({
'overflow': 'visible',
'display': 'none'
})

$(group).attr('data-status', 'collapsed')
$(window).trigger('oc.updateUi')
self.saveGroupStatus($(group).data('group-code'), true)
}
})
}

SidenavTree.prototype.expandGroup = function(group, duration) {
var
var
$list = $('> ul', group),
self = this

duration = duration === undefined ? 100 : duration

$list.css({
'overflow': 'hidden',
'display': 'block',
'display': '',
'height': 0
})
$list.animate({'height': $list[0].scrollHeight}, { duration: duration, queue: false, complete: function() {
Expand All @@ -113,31 +118,35 @@
var collapsedGroups = $.cookie(this.statusCookieName),
updatedGroups = []

if (collapsedGroups === undefined)
if (collapsedGroups === undefined) {
collapsedGroups = ''
}

collapsedGroups = collapsedGroups.split('|')
$.each(collapsedGroups, function() {
if (groupCode != this)
updatedGroups.push(this)
})

if (collapsed)
if (collapsed) {
updatedGroups.push(groupCode)
}

$.cookie(this.statusCookieName, updatedGroups.join('|'), { expires: 30, path: '/' })
}

SidenavTree.prototype.handleSearchChange = function() {
var lastValue = this.$searchInput.data('oc.lastvalue');

if (lastValue !== undefined && lastValue == this.$searchInput.val())
if (lastValue !== undefined && lastValue == this.$searchInput.val()) {
return
}

this.$searchInput.data('oc.lastvalue', this.$searchInput.val())

if (this.dataTrackInputTimer !== undefined)
window.clearTimeout(this.dataTrackInputTimer);
if (this.dataTrackInputTimer !== undefined) {
window.clearTimeout(this.dataTrackInputTimer)
}

var self = this
this.dataTrackInputTimer = window.setTimeout(function(){
Expand All @@ -160,8 +169,9 @@
return
}

// Find visible groups and items
//
/*
* Find visible groups and items
*/
$('ul.top-level > li', this.$el).each(function() {
var $li = $(this)

Expand All @@ -171,7 +181,8 @@
$('ul li', $li).each(function(){
visibleItems.push(this)
})
} else {
}
else {
$('ul li', $li).each(function(){
if (self.textContainsWords($(this).text(), words) || self.textContainsWords($(this).data('keywords'), words)) {
visibleGroups.push($li.get(0))
Expand All @@ -181,8 +192,9 @@
}
})

// Hide invisible groups and items
//
/*
* Hide invisible groups and items
*/
$('ul.top-level > li', this.$el).each(function() {
var $li = $(this),
groupIsVisible = $.inArray(this, visibleGroups) !== -1
Expand Down Expand Up @@ -253,4 +265,4 @@
$('[data-control=sidenav-tree]').sidenavTree()
})

}(window.jQuery);
}(window.jQuery);
Loading

0 comments on commit ecc71b3

Please sign in to comment.