How can I share working Famo.us code snippets with others on SO? - famo.us

AFAIK, no sites like jsfiddle or codepen currently support Famo.us. Are there other methods for sharing working code examples of Famo.us that are permanent enough to warrant using on Stack Overflow?

Starting on May 16th, Famo.us will begin testing a minified CDN version of famous.js that can be used in much the same way as one would use the minified CDN for JQuery and JQuery plugins. Once the CDN is in place, developers can fiddle with famo.us core, famo.us discrete examples, famo.us widgets and famo.us templates within famo.us university, jsfiddle and codepen.
In addition, we will also be testing a new BUILD MIN service to super minify your code. Send a .zip file to the BUILD MIN service of famo.us and get back a custom min'd and CDN'd famous.js that only uses the components needed for our app.
hope this helps.

I compiled famo.us so that it can be used in a jsfiddle.
Here is the jsfiddle http://jsfiddle.net/jperl/7wEWU.
Here is the compiled repo https://github.com/jperl/famous-compiled.

http://jsfiddle.net/7beq5/2
<html>
<script src='http://code.famo.us/lib/require.js'></script>
<script src='http://code.famo.us/famous/0.2/famous.min.js'></script>
<script> // (this could be another file)
require(['famous/core/Engine',
'famous/core/Surface',
'famous/core/Modifier'
], function(Engine, Surface, Modifier){
// --------------- use famo.us here ------------------ //
});
</script>
<html>

** EDIT **
Check out jonperls answer. He has compiled a working version of famo.us for use in JSFiddle. Simply use the External Links feature of JSFiddle to link to the compiled source.
** ORIGINAL **
I have not heard of any way to share snippets in line with working examples.. But you could always just host the code here.. then link to the working example.
The quickest and easiest way I found to share Famo.us demos has been to host the examples on amazon's S3 as a static webpage.
It is super easy to create a bucket and enable it to act as a static hosted site.
Worrying about DNS is optional. When you enable a bucket as a static host you get an endpoint. eg.
http://higherorderhuman.com.s3-website-us-east-1.amazonaws.com
It is up to you if you want to deal with setting up DNS and making that point to a more attractive URL. For me, both..
http://higherorderhuman.com.s3-website-us-east-1.amazonaws.com/examples/lens.html
and
http://higherorderhuman.com/examples/lens.html
Go to the same place.
By using folders on s3 and creating separate html files, I am able to host all examples from this single endpoind. eg. another example at..
http://higherorderhuman.com/examples/scrollbars.html
Just make sure all files that get uploaded are made public with.. 'Make Public'
Still looking forward for JSFiddle support.. But at least this does it for me for now!

The codefamo.us site launched today (May 19). It displays famo.us code stored as a GitHub Gist if saved with the name main.js.
To view the working example of the code, simply tack the gist identifier onto the end of the "gist.codefamo.us" uri:
For example:
http://gist.codefamo.us/74ca030bafdca1635e47
The code displays in a collapsible panel and runs in a preview panel. You can make changes to the code and see them reflected in the preview, similar to Famo.us University.
Disclosure: I'm one of the two people behind this site.

Use http://famousco.de/ and then post the link here!
p.s. i am the webmaster of famousco.de :)

Related

Replace Javascript with Bootstrap responsive slideshow

I'm trying to find a nice looking bootstrap slideshow that looks similar to this one: https://www.jssor.com/demos/simple-fade-slideshow.slider
I would use the one in the link but it's got way to much Javascript and doesn't respond properly when I change the size of my window. Any ideas how I could create this using Bootstrap, HTML and CSS only? So it still needs to be automatic as well.
Thank you
It’s the carousel you’re after, without knowing which version of bootstrap you’re on I cannot provide an example but you can find full examples for what you need in the bootstrap docs: https://getbootstrap.com/docs/4.1/components/carousel/

Branding Issues - JS Injections

In our attempt to transform our code from FTC to CAM we are facing some minor difficulties from the branding perspective. I’ll briefly elaborate about our scenario below:
In our current FTC implementation we are using both CSS and JS to render the desired UI. References for both the assets are present in the master page and hence get rendered with the HTML
Since it is recommended not to modify the master page when moving to vNext, we decided to go via the custom actions route.
We added custom actions for both CSS and JS to a test site. On browsing to our test site, we found out that the UI was appearing as desired but only with a noticeable lag.
As it appeared, what was happening was that the corev4.css was getting applied and then after around 2 seconds our custom CSS would be applied leading to an unpleasant flickering effect.
I went through a project named Branding.CustomCSS present in the PnP samples which did a similar thing of applying the CSS by rendering link tag via a custom action. In the documentation for that project, it was mentioned that this wasn’t a recommended approach for applying CSS if we are on Office 365 or April 2014 CU on-prem. Instead, the AlternateCSS approach was recommended.
I modified the code to use the AlternateCSS approach for rendering the CSS reference while keeping the custom action for rendering JS reference as it is. That certainly improved the experience.
We still had the JS file though which was manipulating the DOM to achieve the desired look and feel and that was still loading with a delay. We suspect that this is happening because in case of Custom Actions the code to insert JS references runs after the page is loaded. While the JS loads and executes, the UI that is shown meanwhile is without the DOM manipulations and is not what is desired. So the flickering of some components in the page, that the JS is responsible to beautify, is still present. This was not the case in our FTC where there was no noticeable lag.
I required some suggestions as to what approach we should follow so that we can do away with the delay in loading such asset files?
Also, is there an approach that would render JS references along with the HTML and not after page load like it does in case of custom actions?
I too are experiencing this issue. It is a really ordinary user experience. As you said, you can limit it by updating the logo and applying the alternate CSS in the provisioning process, but you still get that noticeable flicker. I have been experimenting with adding ms-hidden to the body tag at the start of the process, then removing it at the end, but it hasn't helped much. I might see about hiding the body from the get-go via the alternate css, then in the injector.js file override that style. Any suggestions from others would be greatly appreciated though. The PnP only has a basic injector scenario where it puts a message in the status area, but that isn't really a realistic scenario.

Opencart different .TPL for the Home Page

I have a doubt and not really sure about how is the best approach, I have a client with a website based on opencart with really bad practices on it, for example, all products are manually placed in the home page instead to be using the CMS capabilities of OC, right now the way it works is, if you are using a computer, full browser, the site displays the full version of the site, but if you are using an ipad or iphone/android device then loads the "small" version, both versions are placed manually in the same home.tpl document and they appear/disappear by some CSS. The question is, the client doesn't want to change the way the home page is designed, so instead to be loading that enormity of code is there a way to have a different tpl for the small version? for example a home.tpl version with the code for the full version and home-mobile.tpl for the small one? how this should work? How the system should determine the screen size and point to a TPL or other TPL?
I know it's a weird request but the client is "happy" with how the site looks like and don't want to change the manual code used on the home page.
CSS is the correct way to handle the resizing and restructuring of the same content on different screens. If you want a vastly different homepage for mobile users, with different content, there are a couple of ways to do it:
Detect the browser using JS and redirect to a mobile-only page. This would probably involve copying your current home controller (and template etc.) to a new file, or using a GET variable to switch templates further down the code.
Detect the browser using PHP, and serve the correct template directly in the code. For this you could use a library like this one (untested, just an example) in your home controller, and change the template path as needed at the bottom of the script.
But first I would really try harder to emphasise to your client that he is doing it wrong.

Custom viewpager tabs with custom view, multiple fragment and layouts

I want to make a viewpager which is just like latest facebook application.
and the problem is with tabs.
however i tried to make it, but i need icons with text in tabs and multiple fragments and layouts associated with it.
two issue occurred when i tried to develop.
1. I compromised with my UI, and tried putting static icons in it, but they don't change on selection and they don't even have badge like in facebook application.
2. when i put that code in my application which i have developed in demo app, it shows error and after researching i found that my application don't have an actionbar. so it was giving error after calling getActionBar.
please someone can provide any example or link to that which can help me.
You can refer to the official solution: http://developer.android.com/training/implementing-navigation/lateral.html
Or try this awsome lib: https://github.com/astuetz/PagerSlidingTabStrip

Webview Swipe issue - Appcelerator Titanium

Right now I am using one webview to show data from my aplicationDatadirectory, here everything is working fine, I get content when user click next back respectively. Now what I am doing is in onload of webview I register "touchevent" and "touchmove" in webview's html like this :-
$.webview.evalJS('document.getElementsByTagName("body")[0].addEventListener("touchstart", function mytouch(){Ti.App.fireEvent("touch", {X:event.touches[0].pageX,Y:event.touches[0].pageY,length:event.touches.length});}, false);');
$.webview.evalJS('document.getElementsByTagName("body")[0].addEventListener("touchmove", function mymove(){Ti.App.fireEvent("move", {X:event.touches[0].pageX,Y:event.touches[0].pageY,length:event.touches.length});}, false);');
on the basis of this I find swipe event. I get correct html in webview(I can see images). But I am unable to get touchstart and move call. I dont know what is the problem here. I set data in webview using url here.
Now when I set data in webview using html(I used data of my html file(given below) in one var) now I am unable to see images it just shows me one black border(empty) but here my touchstart and touchmove events are firing also my swipe is also working as expected. I am checking this functionality in iPhone.
Can any one find the issue what is going wrong here? Thanks.
I think that this depends on the time when you apply
$.webview.evalJS('document.getElementsByTagName("body")[0].addEventListener("touchstart", function mytouch(){Ti.App.fireEvent("touch", {X:event.touches[0].pageX,Y:event.touches[0].pageY,length:event.touches.length});}, false);');
$.webview.evalJS('document.getElementsByTagName("body")[0].addEventListener("touchmove", function mymove(){Ti.App.fireEvent("move", {X:event.touches[0].pageX,Y:event.touches[0].pageY,length:event.touches.length});}, false);');
If you use the html property data is loaded immediately and you can use the code exactly after setting html content. If you use the url (even if it is located locally, which might be difficult for android) then you need to wait a short time until the page is loaded. There is also an event listener for that (web view-event load) but i can't say if that works for local resources but i don't think so.
In this case you should apply your javascript snippet into your html resources (if they are locally) instead of manually adding it using evalJS.
Please note that there is an issue on android that you can't use local images (resources folder) in your webview when you provide the content via html property.
I made it swipe working in iOS(in android it was working).
I did not expect this thing to be a reason but I do not know logic behind it. I was accessing .xhtml files from application data directory and it was working without any issue in android but in iOS it was not.
I just change(rename in my code) .xhtml file to .html and now it is working. :)
Hope this can help someone who is looking for the same.(or just for his interest)
Thanks.