mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-27 09:36:19 -05:00
Remove Discourse.Mobile
constants
This commit is contained in:
parent
ef75f87c8b
commit
849c99f83d
31 changed files with 205 additions and 185 deletions
|
@ -12,8 +12,8 @@ export default Ember.Component.extend({
|
|||
return !c.get('parentCategory');
|
||||
}),
|
||||
|
||||
hidden: function(){
|
||||
return Discourse.Mobile.mobileView && !this.get('category');
|
||||
hidden: function() {
|
||||
return this.site.mobileView && !this.get('category');
|
||||
}.property('category'),
|
||||
|
||||
firstCategory: function() {
|
||||
|
|
|
@ -18,7 +18,7 @@ export default Ember.Component.extend({
|
|||
|
||||
@on('init')
|
||||
_setupPreview() {
|
||||
const val = (Discourse.Mobile.mobileView ? false : (this.keyValueStore.get('composer.showPreview') || 'true'));
|
||||
const val = (this.site.mobileView ? false : (this.keyValueStore.get('composer.showPreview') || 'true'));
|
||||
this.set('showPreview', val === 'true');
|
||||
},
|
||||
|
||||
|
@ -218,7 +218,7 @@ export default Ember.Component.extend({
|
|||
}
|
||||
});
|
||||
|
||||
if (Discourse.Mobile.mobileView) {
|
||||
if (this.site.mobileView) {
|
||||
this.$(".mobile-file-upload").on("click.uploader", function () {
|
||||
// redirect the click on the hidden file input
|
||||
$("#mobile-uploader").click();
|
||||
|
|
|
@ -25,153 +25,156 @@ const OP = {
|
|||
|
||||
const _createCallbacks = [];
|
||||
|
||||
function Toolbar() {
|
||||
this.shortcuts = {};
|
||||
class Toolbar {
|
||||
|
||||
this.groups = [
|
||||
{group: 'fontStyles', buttons: []},
|
||||
{group: 'insertions', buttons: []},
|
||||
{group: 'extras', buttons: []}
|
||||
];
|
||||
constructor(site) {
|
||||
this.shortcuts = {};
|
||||
|
||||
this.addButton({
|
||||
id: 'bold',
|
||||
group: 'fontStyles',
|
||||
shortcut: 'B',
|
||||
perform: e => e.applySurround('**', '**', 'bold_text')
|
||||
});
|
||||
|
||||
this.addButton({
|
||||
id: 'italic',
|
||||
group: 'fontStyles',
|
||||
shortcut: 'I',
|
||||
perform: e => e.applySurround('_', '_', 'italic_text')
|
||||
});
|
||||
|
||||
this.addButton({id: 'link', group: 'insertions', shortcut: 'K', action: 'showLinkModal'});
|
||||
|
||||
this.addButton({
|
||||
id: 'quote',
|
||||
group: 'insertions',
|
||||
icon: 'quote-right',
|
||||
shortcut: 'Shift+9',
|
||||
perform: e => e.applySurround('> ', '', 'code_text')
|
||||
});
|
||||
|
||||
this.addButton({
|
||||
id: 'code',
|
||||
group: 'insertions',
|
||||
shortcut: 'Shift+C',
|
||||
perform(e) {
|
||||
if (e.selected.value.indexOf("\n") !== -1) {
|
||||
e.applySurround(' ', '', 'code_text');
|
||||
} else {
|
||||
e.applySurround('`', '`', 'code_text');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
this.addButton({
|
||||
id: 'bullet',
|
||||
group: 'extras',
|
||||
icon: 'list-ul',
|
||||
shortcut: 'Shift+8',
|
||||
title: 'composer.ulist_title',
|
||||
perform: e => e.applyList('* ', 'list_item')
|
||||
});
|
||||
|
||||
this.addButton({
|
||||
id: 'list',
|
||||
group: 'extras',
|
||||
icon: 'list-ol',
|
||||
shortcut: 'Shift+7',
|
||||
title: 'composer.olist_title',
|
||||
perform: e => e.applyList(i => !i ? "1. " : `${parseInt(i) + 1}. `, 'list_item')
|
||||
});
|
||||
|
||||
this.addButton({
|
||||
id: 'heading',
|
||||
group: 'extras',
|
||||
icon: 'font',
|
||||
shortcut: 'Alt+1',
|
||||
perform: e => e.applyList('## ', 'heading_text')
|
||||
});
|
||||
|
||||
this.addButton({
|
||||
id: 'rule',
|
||||
group: 'extras',
|
||||
icon: 'minus',
|
||||
shortcut: 'Alt+R',
|
||||
title: 'composer.hr_title',
|
||||
perform: e => e.addText("\n\n----------\n")
|
||||
});
|
||||
|
||||
if (Discourse.Mobile.mobileView) {
|
||||
this.groups.push({group: 'mobileExtras', buttons: []});
|
||||
this.groups = [
|
||||
{group: 'fontStyles', buttons: []},
|
||||
{group: 'insertions', buttons: []},
|
||||
{group: 'extras', buttons: []}
|
||||
];
|
||||
|
||||
this.addButton({
|
||||
id: 'preview',
|
||||
group: 'mobileExtras',
|
||||
icon: 'television',
|
||||
title: 'composer.hr_preview',
|
||||
perform: e => e.preview()
|
||||
id: 'bold',
|
||||
group: 'fontStyles',
|
||||
shortcut: 'B',
|
||||
perform: e => e.applySurround('**', '**', 'bold_text')
|
||||
});
|
||||
}
|
||||
|
||||
this.groups[this.groups.length-1].lastGroup = true;
|
||||
};
|
||||
this.addButton({
|
||||
id: 'italic',
|
||||
group: 'fontStyles',
|
||||
shortcut: 'I',
|
||||
perform: e => e.applySurround('_', '_', 'italic_text')
|
||||
});
|
||||
|
||||
Toolbar.prototype.addButton = function(button) {
|
||||
const g = this.groups.findProperty('group', button.group);
|
||||
if (!g) {
|
||||
throw `Couldn't find toolbar group ${button.group}`;
|
||||
}
|
||||
this.addButton({id: 'link', group: 'insertions', shortcut: 'K', action: 'showLinkModal'});
|
||||
|
||||
const createdButton = {
|
||||
id: button.id,
|
||||
className: button.className || button.id,
|
||||
icon: button.icon || button.id,
|
||||
action: button.action || 'toolbarButton',
|
||||
perform: button.perform || Ember.K
|
||||
};
|
||||
this.addButton({
|
||||
id: 'quote',
|
||||
group: 'insertions',
|
||||
icon: 'quote-right',
|
||||
shortcut: 'Shift+9',
|
||||
perform: e => e.applySurround('> ', '', 'code_text')
|
||||
});
|
||||
|
||||
if (button.sendAction) {
|
||||
createdButton.sendAction = button.sendAction;
|
||||
}
|
||||
this.addButton({
|
||||
id: 'code',
|
||||
group: 'insertions',
|
||||
shortcut: 'Shift+C',
|
||||
perform(e) {
|
||||
if (e.selected.value.indexOf("\n") !== -1) {
|
||||
e.applySurround(' ', '', 'code_text');
|
||||
} else {
|
||||
e.applySurround('`', '`', 'code_text');
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const title = I18n.t(button.title || `composer.${button.id}_title`);
|
||||
if (button.shortcut) {
|
||||
const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
||||
const mod = mac ? 'Meta' : 'Ctrl';
|
||||
var shortcutTitle = `${mod}+${button.shortcut}`;
|
||||
this.addButton({
|
||||
id: 'bullet',
|
||||
group: 'extras',
|
||||
icon: 'list-ul',
|
||||
shortcut: 'Shift+8',
|
||||
title: 'composer.ulist_title',
|
||||
perform: e => e.applyList('* ', 'list_item')
|
||||
});
|
||||
|
||||
// Mac users are used to glyphs for shortcut keys
|
||||
if (mac) {
|
||||
shortcutTitle = shortcutTitle
|
||||
.replace('Shift', "\u21E7")
|
||||
.replace('Meta', "\u2318")
|
||||
.replace('Alt', "\u2325")
|
||||
.replace(/\+/g, '');
|
||||
} else {
|
||||
shortcutTitle = shortcutTitle
|
||||
.replace('Shift', I18n.t('shortcut_modifier_key.shift'))
|
||||
.replace('Ctrl', I18n.t('shortcut_modifier_key.ctrl'))
|
||||
.replace('Alt', I18n.t('shortcut_modifier_key.alt'));
|
||||
this.addButton({
|
||||
id: 'list',
|
||||
group: 'extras',
|
||||
icon: 'list-ol',
|
||||
shortcut: 'Shift+7',
|
||||
title: 'composer.olist_title',
|
||||
perform: e => e.applyList(i => !i ? "1. " : `${parseInt(i) + 1}. `, 'list_item')
|
||||
});
|
||||
|
||||
this.addButton({
|
||||
id: 'heading',
|
||||
group: 'extras',
|
||||
icon: 'font',
|
||||
shortcut: 'Alt+1',
|
||||
perform: e => e.applyList('## ', 'heading_text')
|
||||
});
|
||||
|
||||
this.addButton({
|
||||
id: 'rule',
|
||||
group: 'extras',
|
||||
icon: 'minus',
|
||||
shortcut: 'Alt+R',
|
||||
title: 'composer.hr_title',
|
||||
perform: e => e.addText("\n\n----------\n")
|
||||
});
|
||||
|
||||
if (site.mobileView) {
|
||||
this.groups.push({group: 'mobileExtras', buttons: []});
|
||||
|
||||
this.addButton({
|
||||
id: 'preview',
|
||||
group: 'mobileExtras',
|
||||
icon: 'television',
|
||||
title: 'composer.hr_preview',
|
||||
perform: e => e.preview()
|
||||
});
|
||||
}
|
||||
|
||||
createdButton.title = `${title} (${shortcutTitle})`;
|
||||
|
||||
this.shortcuts[`${mod}+${button.shortcut}`.toLowerCase()] = createdButton;
|
||||
} else {
|
||||
createdButton.title = title;
|
||||
this.groups[this.groups.length-1].lastGroup = true;
|
||||
}
|
||||
|
||||
if (button.unshift) {
|
||||
g.buttons.unshift(createdButton);
|
||||
} else {
|
||||
g.buttons.push(createdButton);
|
||||
addButton(button) {
|
||||
const g = this.groups.findProperty('group', button.group);
|
||||
if (!g) {
|
||||
throw `Couldn't find toolbar group ${button.group}`;
|
||||
}
|
||||
|
||||
const createdButton = {
|
||||
id: button.id,
|
||||
className: button.className || button.id,
|
||||
icon: button.icon || button.id,
|
||||
action: button.action || 'toolbarButton',
|
||||
perform: button.perform || Ember.K
|
||||
};
|
||||
|
||||
if (button.sendAction) {
|
||||
createdButton.sendAction = button.sendAction;
|
||||
}
|
||||
|
||||
const title = I18n.t(button.title || `composer.${button.id}_title`);
|
||||
if (button.shortcut) {
|
||||
const mac = /Mac|iPod|iPhone|iPad/.test(navigator.platform);
|
||||
const mod = mac ? 'Meta' : 'Ctrl';
|
||||
var shortcutTitle = `${mod}+${button.shortcut}`;
|
||||
|
||||
// Mac users are used to glyphs for shortcut keys
|
||||
if (mac) {
|
||||
shortcutTitle = shortcutTitle
|
||||
.replace('Shift', "\u21E7")
|
||||
.replace('Meta', "\u2318")
|
||||
.replace('Alt', "\u2325")
|
||||
.replace(/\+/g, '');
|
||||
} else {
|
||||
shortcutTitle = shortcutTitle
|
||||
.replace('Shift', I18n.t('shortcut_modifier_key.shift'))
|
||||
.replace('Ctrl', I18n.t('shortcut_modifier_key.ctrl'))
|
||||
.replace('Alt', I18n.t('shortcut_modifier_key.alt'));
|
||||
}
|
||||
|
||||
createdButton.title = `${title} (${shortcutTitle})`;
|
||||
|
||||
this.shortcuts[`${mod}+${button.shortcut}`.toLowerCase()] = createdButton;
|
||||
} else {
|
||||
createdButton.title = title;
|
||||
}
|
||||
|
||||
if (button.unshift) {
|
||||
g.buttons.unshift(createdButton);
|
||||
} else {
|
||||
g.buttons.push(createdButton);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export function onToolbarCreate(func) {
|
||||
_createCallbacks.push(func);
|
||||
|
@ -237,7 +240,7 @@ export default Ember.Component.extend({
|
|||
|
||||
@computed
|
||||
toolbar() {
|
||||
const toolbar = new Toolbar();
|
||||
const toolbar = new Toolbar(this.site);
|
||||
_createCallbacks.forEach(cb => cb(toolbar));
|
||||
this.sendAction('extraButtons', toolbar);
|
||||
return toolbar;
|
||||
|
|
|
@ -10,17 +10,17 @@ export default Ember.Component.extend({
|
|||
|
||||
@computed()
|
||||
showKeyboardShortcuts() {
|
||||
return !Discourse.Mobile.mobileView && !this.capabilities.touch;
|
||||
return !this.site.mobileView && !this.capabilities.touch;
|
||||
},
|
||||
|
||||
@computed()
|
||||
showMobileToggle() {
|
||||
return Discourse.Mobile.mobileView || (this.siteSettings.enable_mobile_theme && this.capabilities.touch);
|
||||
return this.site.mobileView || (this.siteSettings.enable_mobile_theme && this.capabilities.touch);
|
||||
},
|
||||
|
||||
@computed()
|
||||
mobileViewLinkTextKey() {
|
||||
return Discourse.Mobile.mobileView ? "desktop_view" : "mobile_view";
|
||||
return this.site.mobileView ? "desktop_view" : "mobile_view";
|
||||
},
|
||||
|
||||
@computed()
|
||||
|
@ -68,7 +68,7 @@ export default Ember.Component.extend({
|
|||
this.sendAction('showKeyboardAction');
|
||||
},
|
||||
toggleMobileView() {
|
||||
Discourse.Mobile.toggleMobileView();
|
||||
this.site.toggleMobileView();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -17,7 +17,7 @@ export default Ember.Component.extend({
|
|||
if (this.siteSettings.login_required && !this.currentUser) {
|
||||
this.sendAction('loginAction');
|
||||
} else {
|
||||
if (Discourse.Mobile.mobileView && this.get('mobileAction')) {
|
||||
if (this.site.mobileView && this.get('mobileAction')) {
|
||||
this.sendAction('mobileAction');
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -14,11 +14,11 @@ export default Ember.Component.extend({
|
|||
}.property('targetUrl'),
|
||||
|
||||
showSmallLogo: function() {
|
||||
return !Discourse.Mobile.mobileView && this.get("minimized");
|
||||
return !this.site.mobileView && this.get("minimized");
|
||||
}.property("minimized"),
|
||||
|
||||
showMobileLogo: function() {
|
||||
return Discourse.Mobile.mobileView && !Ember.isBlank(this.get('mobileBigLogoUrl'));
|
||||
return this.site.mobileView && !Ember.isBlank(this.get('mobileBigLogoUrl'));
|
||||
}.property(),
|
||||
|
||||
smallLogoUrl: setting('logo_small_url'),
|
||||
|
|
|
@ -120,17 +120,17 @@ export default Ember.Component.extend({
|
|||
|
||||
@computed()
|
||||
showKeyboardShortcuts() {
|
||||
return !Discourse.Mobile.mobileView && !this.capabilities.touch;
|
||||
return !this.site.mobileView && !this.capabilities.touch;
|
||||
},
|
||||
|
||||
@computed()
|
||||
showMobileToggle() {
|
||||
return Discourse.Mobile.mobileView || (this.siteSettings.enable_mobile_theme && this.capabilities.touch);
|
||||
return this.site.mobileView || (this.siteSettings.enable_mobile_theme && this.capabilities.touch);
|
||||
},
|
||||
|
||||
@computed()
|
||||
mobileViewLinkTextKey() {
|
||||
return Discourse.Mobile.mobileView ? "desktop_view" : "mobile_view";
|
||||
return this.site.mobileView ? "desktop_view" : "mobile_view";
|
||||
},
|
||||
|
||||
@computed()
|
||||
|
|
|
@ -19,7 +19,7 @@ export default Ember.Component.extend({
|
|||
}.property(),
|
||||
|
||||
skipHeader: function() {
|
||||
return Discourse.Mobile.mobileView;
|
||||
return this.site.mobileView;
|
||||
}.property(),
|
||||
|
||||
showLikes: function(){
|
||||
|
|
|
@ -10,7 +10,7 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||
revisionsTextKey: "post.revisions.controls.comparing_previous_to_current_out_of_total",
|
||||
|
||||
_changeViewModeOnMobile: function() {
|
||||
if (Discourse.Mobile.mobileView) { this.set("viewMode", "inline"); }
|
||||
if (this.site.mobileView) { this.set("viewMode", "inline"); }
|
||||
}.on("init"),
|
||||
|
||||
refresh(postId, postVersion) {
|
||||
|
|
|
@ -61,8 +61,10 @@ export default Ember.Controller.extend({
|
|||
// containing a single invisible character
|
||||
markerElement.appendChild(document.createTextNode("\ufeff"));
|
||||
|
||||
const isMobileDevice = this.site.isMobileDevice;
|
||||
|
||||
// collapse the range at the beginning/end of the selection
|
||||
range.collapse(!Discourse.Mobile.isMobileDevice);
|
||||
range.collapse(!isMobileDevice);
|
||||
// and insert it at the start of our selection range
|
||||
range.insertNode(markerElement);
|
||||
|
||||
|
@ -83,7 +85,7 @@ export default Ember.Controller.extend({
|
|||
let topOff = markerOffset.top;
|
||||
let leftOff = markerOffset.left;
|
||||
|
||||
if (Discourse.Mobile.isMobileDevice) {
|
||||
if (isMobileDevice) {
|
||||
topOff = topOff + 20;
|
||||
leftOff = Math.min(leftOff + 10, $(window).width() - $quoteButton.outerWidth());
|
||||
} else {
|
||||
|
|
|
@ -45,7 +45,7 @@ export default Ember.Controller.extend({
|
|||
}
|
||||
|
||||
// Don't show on mobile
|
||||
if (Discourse.Mobile.mobileView) {
|
||||
if (this.site.mobileView) {
|
||||
const url = "/users/" + username;
|
||||
DiscourseURL.routeTo(url);
|
||||
return;
|
||||
|
|
|
@ -12,7 +12,7 @@ export default Ember.Controller.extend({
|
|||
bulkSelectEnabled: Em.computed.alias('controllers.user-topics-list.bulkSelectEnabled'),
|
||||
|
||||
mobileView: function() {
|
||||
return Discourse.Mobile.mobileView;
|
||||
return this.site.mobileView;
|
||||
}.property(),
|
||||
|
||||
showNewPM: function(){
|
||||
|
|
|
@ -141,7 +141,7 @@ export default Ember.DefaultResolver.extend({
|
|||
},
|
||||
|
||||
findMobileTemplate(parsedName) {
|
||||
if (Discourse.Mobile.mobileView) {
|
||||
if (this.mobileView) {
|
||||
var mobileParsedName = this.parseName(parsedName.fullName.replace("template:", "template:mobile/"));
|
||||
return this.findTemplate(mobileParsedName);
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
export default {
|
||||
name: 'ensure-image-dimensions',
|
||||
after: 'mobile',
|
||||
initialize: function() {
|
||||
initialize(container) {
|
||||
if (!window) { return; }
|
||||
|
||||
// This enforces maximum dimensions of images based on site settings
|
||||
|
@ -11,7 +11,8 @@ export default {
|
|||
var width = Discourse.SiteSettings.max_image_width;
|
||||
var height = Discourse.SiteSettings.max_image_height;
|
||||
|
||||
if (Discourse.Mobile.mobileView) {
|
||||
const site = container.lookup('site:main');
|
||||
if (site.mobileView) {
|
||||
width = $(window).width() - 20;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,14 +1,19 @@
|
|||
/**
|
||||
Initializes the `Discourse.Mobile` helper object.
|
||||
**/
|
||||
import Mobile from 'discourse/lib/mobile';
|
||||
|
||||
// Initializes the `Mobile` helper object.
|
||||
export default {
|
||||
name: 'mobile',
|
||||
after: 'inject-objects',
|
||||
|
||||
initialize: function(container) {
|
||||
Discourse.Mobile.init();
|
||||
var site = container.lookup('site:main');
|
||||
site.set('mobileView', Discourse.Mobile.mobileView);
|
||||
initialize(container, app) {
|
||||
Mobile.init();
|
||||
const site = container.lookup('site:main');
|
||||
|
||||
site.set('mobileView', Mobile.mobileView);
|
||||
site.set('isMobileDevice', Mobile.isMobileDevice);
|
||||
|
||||
// This is a bit weird but you can't seem to inject into the resolver?
|
||||
app.registry.resolver.__resolver__.mobileView = Mobile.mobileView;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ export default {
|
|||
});
|
||||
|
||||
if (!Ember.testing) {
|
||||
if (!Discourse.Mobile.mobileView) {
|
||||
if (!site.mobileView) {
|
||||
bus.subscribe("/notification-alert/" + user.get('id'), function(data){
|
||||
onNotification(data, user);
|
||||
});
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
@module $.fn.autocomplete
|
||||
**/
|
||||
|
||||
export var CANCELLED_STATUS = "__CANCELLED";
|
||||
|
||||
const allowedLettersRegex = /[\s\t\[\{\(\/]/;
|
||||
|
@ -226,7 +225,7 @@ export default function(options) {
|
|||
vOffset = div.height();
|
||||
}
|
||||
|
||||
if (Discourse.Mobile.mobileView && !isInput) {
|
||||
if (Discourse.Site.currentProp('mobileView') && !isInput) {
|
||||
div.css('width', 'auto');
|
||||
|
||||
if ((me.height() / 2) >= pos.top) { vOffset = -23; }
|
||||
|
|
|
@ -161,7 +161,7 @@ function showSelector(options) {
|
|||
options.appendTo.append('<div class="emoji-modal-wrapper"></div>');
|
||||
$('.emoji-modal-wrapper').click(() => closeSelector());
|
||||
|
||||
if (Discourse.Mobile.mobileView) PER_ROW = 9;
|
||||
if (Discourse.Site.currentProp('mobileView')) { PER_ROW = 9; }
|
||||
const page = keyValueStore.getInt("emojiPage", 0);
|
||||
const offset = keyValueStore.getInt("emojiOffset", 0);
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
// An object that is responsible for logic related to mobile devices.
|
||||
Discourse.Mobile = {
|
||||
const Mobile = {
|
||||
isMobileDevice: false,
|
||||
mobileView: false,
|
||||
|
||||
init: function() {
|
||||
var $html = $('html');
|
||||
init() {
|
||||
const $html = $('html');
|
||||
this.isMobileDevice = $html.hasClass('mobile-device');
|
||||
this.mobileView = $html.hasClass('mobile-view');
|
||||
|
||||
|
@ -42,3 +42,13 @@ Discourse.Mobile = {
|
|||
window.location.assign(window.location.pathname + '?mobile_view=' + (mobile ? '1' : '0'));
|
||||
}
|
||||
};
|
||||
|
||||
// Backwards compatibiltity, deprecated
|
||||
Object.defineProperty(Discourse, 'Mobile', {
|
||||
get: function() {
|
||||
Ember.warn("DEPRECATION: `Discourse.Mobile` is deprecated, use `this.site.mobileView` instead");
|
||||
return Mobile;
|
||||
}
|
||||
});
|
||||
|
||||
export default Mobile;
|
|
@ -154,7 +154,7 @@ const Composer = RestModel.extend({
|
|||
usernameLink
|
||||
});
|
||||
|
||||
if (!Discourse.Mobile.mobileView) {
|
||||
if (!this.site.mobileView) {
|
||||
const replyUsername = post.get('reply_to_user.username');
|
||||
const replyAvatarTemplate = post.get('reply_to_user.avatar_template');
|
||||
if (replyUsername && replyAvatarTemplate && this.get('action') === EDIT) {
|
||||
|
|
|
@ -7,7 +7,7 @@ const NavItem = Discourse.Model.extend({
|
|||
name = this.get('name'),
|
||||
count = this.get('count') || 0;
|
||||
|
||||
if (name === 'latest' && !Discourse.Mobile.mobileView) {
|
||||
if (name === 'latest' && !Discourse.Site.currentProp('mobileView')) {
|
||||
count = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@ export default Discourse.Route.extend({
|
|||
// HACK: Something with the way the user card intercepts clicks seems to break how the
|
||||
// transition into a user's activity works. This makes the back button work on mobile
|
||||
// where there is no user card as well as desktop where there is.
|
||||
if (Discourse.Mobile.mobileView) {
|
||||
if (this.site.mobileView) {
|
||||
this.replaceWith('userActivity');
|
||||
} else {
|
||||
this.transitionTo('userActivity');
|
||||
|
|
|
@ -9,7 +9,7 @@ export default Ember.View.extend({
|
|||
$('#discourse-modal').modal('show');
|
||||
|
||||
// Focus on first element
|
||||
if (!Discourse.Mobile.mobileView && this.get('focusInput')) {
|
||||
if (!this.site.mobileView && this.get('focusInput')) {
|
||||
Em.run.schedule('afterRender', () => this.$('input:first').focus());
|
||||
}
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ export default Ember.View.extend({
|
|||
|
||||
$shareLink.css({top: "" + y + "px"});
|
||||
|
||||
if (!Discourse.Mobile.mobileView) {
|
||||
if (!this.site.mobileView) {
|
||||
$shareLink.css({left: "" + x + "px"});
|
||||
}
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ export default ContainerView.extend({
|
|||
|
||||
@on('init')
|
||||
createButtons() {
|
||||
const mobileView = Discourse.Mobile.mobileView;
|
||||
const mobileView = this.site.mobileView;
|
||||
|
||||
if (!mobileView && this.currentUser.get('staff')) {
|
||||
const viewArgs = {action: 'showTopicAdminMenu', title: 'topic_admin_menu', icon: 'wrench', position: 'absolute'};
|
||||
|
|
|
@ -76,7 +76,7 @@ export default Ember.View.extend({
|
|||
_focusWhenOpened: function() {
|
||||
|
||||
// Don't focus on mobile or touch
|
||||
if (Discourse.Mobile.mobileView || this.capabilities.isIOS) {
|
||||
if (this.site.mobileView || this.capabilities.isIOS) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ export default class PostCooked {
|
|||
// deferring work only for posts with images
|
||||
// we got to use screen here, cause nothing is rendered yet.
|
||||
// long term we may want to allow for weird margins that are enforced, instead of hardcoding at 70/20
|
||||
maxWindowWidth = maxWindowWidth || $(window).width() - (Discourse.Mobile.mobileView ? 20 : 70);
|
||||
maxWindowWidth = maxWindowWidth || $(window).width() - (this.attrs.mobileView ? 20 : 70);
|
||||
if (maxImageWidth < maxWindowWidth) {
|
||||
maxWindowWidth = maxImageWidth;
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ registerButton('reply', attrs => {
|
|||
|
||||
if (!attrs.canCreatePost) { return; }
|
||||
|
||||
if (!Discourse.Mobile.mobileView) {
|
||||
if (!attrs.mobileView) {
|
||||
args.label = 'topic.reply.title';
|
||||
}
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ export default createWidget('post-stream', {
|
|||
let prevPost;
|
||||
let prevDate;
|
||||
|
||||
const mobileView = this.site.mobileView;
|
||||
for (let i=0; i<postArray.length; i++) {
|
||||
const post = postArray[i];
|
||||
|
||||
|
@ -31,6 +32,7 @@ export default createWidget('post-stream', {
|
|||
|
||||
const transformed = transformPost(this.currentUser, this.site, post, prevPost, nextPost);
|
||||
transformed.canCreatePost = attrs.canCreatePost;
|
||||
transformed.mobileView = mobileView;
|
||||
|
||||
if (transformed.canManage) {
|
||||
transformed.multiSelect = attrs.multiSelect;
|
||||
|
|
|
@ -331,7 +331,7 @@ createWidget('post-article', {
|
|||
const replyPostNumber = this.attrs.reply_to_post_number;
|
||||
|
||||
// jump directly on mobile
|
||||
if (Discourse.Mobile.mobileView) {
|
||||
if (this.attrs.mobileView) {
|
||||
DiscourseURL.jumpToPost(replyPostNumber);
|
||||
return Ember.RSVP.Promise.resolve();
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import DiscourseResolver from 'discourse/ember/resolver';
|
||||
|
||||
var originalTemplates, originalMobileViewFlag;
|
||||
var resolver = DiscourseResolver.create();
|
||||
let originalTemplates;
|
||||
let resolver;
|
||||
|
||||
function lookupTemplate(name, expectedTemplate, message) {
|
||||
var parseName = resolver.parseName(name);
|
||||
|
@ -20,13 +20,11 @@ module("lib:resolver", {
|
|||
originalTemplates = Ember.TEMPLATES;
|
||||
Ember.TEMPLATES = {};
|
||||
|
||||
originalMobileViewFlag = Discourse.Mobile.mobileView;
|
||||
Discourse.Mobile.mobileView = false;
|
||||
resolver = DiscourseResolver.create();
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
Ember.TEMPLATES = originalTemplates;
|
||||
Discourse.Mobile.mobileView = originalMobileViewFlag;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -92,7 +90,7 @@ test("resolves mobile templates to 'mobile/' namespace", function() {
|
|||
"baz"
|
||||
]);
|
||||
|
||||
Discourse.Mobile.mobileView = true;
|
||||
resolver.mobileView = true;
|
||||
|
||||
lookupTemplate("template:foo", "mobile/foo", "finding mobile version even if normal one is not present");
|
||||
lookupTemplate("template:bar", "mobile/bar", "preferring mobile version when both mobile and normal versions are present");
|
||||
|
|
Loading…
Reference in a new issue