Durandal Mobile Views - mobile

Does anyone have a solution that will allow you to create a desktop and mobile view for a single viewmodel in Durandal?
Ideally I would like to take a page from MVC4 and have a view.html and view.mobile.html for each viewmodel and just direct the browser to the relevant one based on userAgent string.
Edit 1
Looks like I can override the View Locator's convertModuleIdToViewId function, solution to follow.

Related

AngularJS: Triangular three way binding -- Project Structure

I am currently working out an admin interface with a Live Preview and I am still not 100% on how to structure it properly.
My page basically consists out of two parts. The Admin Interface and the Live Preview. Obviously, the Admin Interface fills some variables with data and the Live Preview displays this.
Therefore, the Admin Interface needs to bind variables, that the Live Preview will bind for reading.
Furthermore, the Live Preview in the end (if possible) should be re-used as the final product that displays a set of information. All it does is display a single JSON file that is received from the server (when in product mode) and in case of the Live Preview it will need to update the data Live as its edited.
One more note: Both, the Live Preview and the Admin Interface consist of elements like directives again and parts of the Admin Interface need to be loaded dynamically by having a user add a page with a certain type of content.
After researching how modules are handled I came up with the following:
Live Preview is a Module
Admin Interface is a Module
My page includes both modules
Both of them should be connected to something central that provides the ability of editing the data (bound variables?) and reading the data so its updated live.
Ideally, this would be a service, so later on when loading the "Live Preview" as an actual product, can just use the same kind of service which in this case provides the information from our Database instead of a variable in its scope.
Is this a good approach? Is there a way to have a service that on the one hand side can be edited lively like in a two way binding so that my live preview can also pick it up? Is there something I can use instead of the services, like a controller? How should I go on about this?
You are doing everything right. I don't think that it is relevant as to whether the preview and admin panel are their own modules or contained within one. You will find people using module seperation in a wide variety of ways within their Angular apps.
What I think you said that is important and correct is to connect the preview and admin panel via a Service. Other methods of connecting these two (i.e. $rootScope) are costly and bad practice.
If you will be re-using live preview in many locations of your application I would wrap it in a directive.
You should feel confident in your approach, it's a good one.

How to serve separate page (Orchard template) for phones

Using Orchard 1.8.1 I have written a simple image gallery that displays thumbnails and a lightbox. It is just a template that is driven by an Orchard Projection, using a Shape Layout. Works just fine. However, for phone users there is no point displaying thumbnails and it's better to just display the lightbox (with touch support). So I have also implemented that in a separate template. But how can I get Orchard to switch templates depending on the UserAgent string?
I have tried implementing Theme switching (http://weblogs.asp.net/bleroy/dynamically-switching-the-theme-in-orchard), but it's a really ugly solution when I really want to just replace one view, and still enable implementers to switch themes. This is NOT an issue of styling; it's an issue of changing the content based on the device.
I tried implementing DisplayModeProvider as described here: http://www.campusmvp.net/blog/displaymodes-in-mvc-4. But although the filter was called, it had no effect on view names.
Are Projections problematic here because the shape name is set? Is there a better way to go about this?
Create an alternate when you see a mobile browser, preferably from a shape table provider.

How to have a Splitview in a tab bar with storyboard?

I have seen IPad apps like the new Amazon app that have a split view as a tab in a tab bar. I have tried to make one like that by starting with a master-detail template and adding a tab bar and/or a tab bar controller to it, then I tried a Tabbed template and added a split view and/or a split view controller to it, I even tried one from scratch and still no luck. I know it can be done and approved by apple because I'm starting to see more of them on the app store.
Can any one help find a way to make a app like this with storyboards preferably?
this is a screenshot of what I would like to do
The problem is your using templates from apple and they have setup in app delegate file for what the root view controller should be. In both situations you present you change this. Using a master detail template you will have this in your app delegate
UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
MasterViewController *controller = (MasterViewController *)navigationController.topViewController;
controller.managedObjectContext = self.managedObjectContext;
and then you try to make the root view a tab bar controller and that's where you are getting errors. I just did a test and pretty much cleared everything in app delegate and changed masterviewcontroller in storybuilder to a regular tableviewcontroller class and everything loaded up. If it's not exactly what you need for a small application you are better off starting with a empty application for learning purposes and because it's better to know where everything is because you are the one that created it.

Is it possible to reference a masterpage in an MVC ASCX control

I have an ASCX control that has to render Silverlight dynamically. The dynamic code works in a non-MVC environment, however when I try to load the silverlight into an MVC ASCX, I get a ScriptManager error. However, my main aspx page does reference the masterpage, which has a script manager. I just need the control to realize that there will be a scriptmanager once it is plugged into the main page. I am trying to use a ScriptManagerProxy, but it is still looking for the ScriptManager. So, I think my biggest problem is getting the control to recognize the masterpage from the main page. Hopefully this explains my problem properly. If you need any code snippets, I can provide them
I don't think you should be using ScriptManager with MVC. ScriptManager is for Web Forms. There is a 3rd party one for MVC http://mvcscriptmanager.codeplex.com/.
I don't know that I quite understand what you are trying to accomplish. But you can use an IFrame (yuck) in your MVC page to display an aspx page.

Navigation application - Forces a page at startup

I have a silverlight navigation application where I load and initialize a lot of things in the MainPage.aspx loading.
All the Pages (views) are dependent on the loading of that data.
But really often my users add an internet shortcut on their desktop for my application. but the link often points to a specific page like that :
http://myServer/MyApp/default.aspx#/TheView
I want to force the users to go to the "Default" view (and ignore the #/view parameter) when the application Starts up.
Whats the best way I can do that?
I don't think it's a good idea to 'avoid' links. You should construct the application in a way when it's not a problem.
For example you can send a message from your main logic when everything loaded, and until that message you can disable the appropriate UI (while waiting for data). Messenger (or EventAggregator in Prism) is a publisher-subscriber pattern to achive communication between components without reference to each other. If you don't know it yet, take a look at MVVMLight Messenger or Prism EventAggregator
But if the first option is not okay for you, you can play with the Frame control's JournalOwnership property:
http://msdn.microsoft.com/en-us/library/system.windows.controls.frame.journalownership(v=vs.95).aspx
http://msdn.microsoft.com/en-us/library/system.windows.navigation.journalownership(v=vs.95).aspx
OwnsJournal is your value, because it does not integrate with the browser journal and the url stays the original so your users can't bookmark a 'sub page'.
You can also implement your own journal mechanism.
Another :), but pretty ugly option would be if you track the first page load (in OnNavigatedTo Page events for example), and at the very first request you manually navigate to the main page. Or in the App.xaml.cs, when application starts up you forward the page request.
But I recommend the first one.

Resources