How to develop for tablet using Worklight? - ibm-mobilefirst

I have develop my UI under common folder, then I create a skin for my tablet and name it as android.tablet. But when I run it on my tablet simulator, it looks like this:
I use below code in skinLoader.js:
var userAgent = navigator.userAgent;
var skinName = "default";
//android tablet
if(userAgent.toLowerCase().indexOf("android") != -1 &&
userAgent.toLowerCase().indexOf("mobile") == -1){
skinName = "android.tablet";
alert("tablet!");
}
//android phone
else if(userAgent.toLowerCase().indexOf("android") != -1 &&
userAgent.toLowerCase().indexOf("mobile") != -1){
skinName = "default";
alert("default!");
}
HTML:
<div data-role="page" id="homePage" class="fullWidth">
<div data-role="header" data-tap-toggle="false">
<div class="ui-title">...</div>
</div>
<div data-role="content" style="text-align: center">
Login
</div>
</div>
CSS:
.fullWidth{
width: 100% !important;
}
Why it can't be full screen? Any code I lack?

Have you made sure to read the Worklight Skins training module?
The basic premise for Worklight Skins is this:
Create a new Worklight project, application
Add a skins-supported environment (Android, BlackBerry 6/7/10, iPhone, iPad)
For the sake of simplicity, update skinLoader.js to point to the skin's folder ("android.skin" for example)
Create a CSS and JS files in the respective folders of the skin
Copy the HTML file from common to the skin folder
Do whatever you want in the CSS, JS and HTML in the skin folder, like changing color and adding an alart
Build all & Deploy
Verify the color and alert are displayed, ensuring it is the skin and not default that was loaded.
To preview the skin's web resources:
Right-click on the android environment folder
Choose Run As >> Preview...
Select the skin from the Skin dropdown
Click the Run button
You should now see the skin (previewing only displays web resources, not native parts if you have any).
If this fails, you can try altering the URL as follows.
This essentially strips away the MBS container and displays only the web resources.
From:
http://localhost:8080/_MobileBrowserSimulator/index.html?webpage=http://localhost:8080/apps/services/preview/your-app-name/android/1.0/your-skin-name-here/your-html-filename-here.html&devicesFilePath=devices.json&platform=android&ips=169.254.236.125,9.148.205.249,10.0.0.2
To:
http://localhost:8080/apps/services/preview/your-app-name/android/1.0/your-skin-folder-name/your-html-filename-here.html
This process will hopefully get more streamlined in a future release...
As for it being full screen or not, that's completely in the hands of the developer (your CSS, etc), and not Worklight's.
I see you're using jQuery Mobile, look at these:
http://jquerymobile.com/demos/1.2.1/docs/toolbars/bars-fullscreen.html
How to set header to full screen mode in jQuery Mobile?

If you want to develop for Android tablet make sure that element in AndroidManifest.xml (inside of Android project) declared that. By default only normalScreens support is set to true.
You might need to adjust CSS. By default it has fixed width of 320px and dynamic height, which pretty much is what you have on a screenshot.

Related

Can't use Bootstrap Icon in ASP.NET Core 6

I have installed Bootstrap icon like this link: https://icons.getbootstrap.com/#install
This is how I import the link and create the CSS file for Bootstrap Icon:
But then it still doesn't work. I still can't use the icon:
Did I do something wrong? Hope someone can explain this to me clearly because I am new to ASP.NET Core 6 and am still learning.
Thank you very much.
Here is a working demo:
Try to add the css into Views/Shared/_Layout.cshtml,or you can add it into the view you want to use the icons:
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons#1.9.1/font/bootstrap-icons.css">
And then use the icons like this:
<i class="bi bi-train-front-fill"></i>
Then the result will be:
If you want a local Bootstrap Icon installation. Are the SVG files also available locally?
The Bootstrap icons are based on SVG files see link
https://getbootstrap.com/docs/5.2/extend/icons/#bootstrap-icons
"...While most icon sets include multiple file formats, we prefer SVG implementations for their improved accessibility and vector support..."
Therefore, the SVG files (over 1900) must be in the appropriate directory.
These can be downloaded via the ZIP file link
https://github.com/twbs/icons/releases/tag/v1.10.2

fomantics-ui change theme settings

I have fomantic-ui 2.8.8 installed on express 4.161. I'm pretty sure fomantics is working, since in header.hbs I changed the line:
<div class="ui mini borderless main bottom attached stackable menu ">
to
<div class="ui inverted mini borderless main bottom attached stackable menu ">
and the results was a header that was all black with white text.
But I can't seem to change the default theme settings. Absolutely everything I change in
semantic/src/site or semantic/src/theme has no effect.
That makes zero sense to me. The settings have to be coming from these files.
For instance I changed the file "semantic/src/themes/default/globals/site.variables" from:
#emSize : 14px;
#inputBackground : #white;
to:
#emSize : 34px;
#inputBackground : #red;
and this had no effect on my web page. I made plenty of other changes of all sorts of variations, but nothing had any effect.
Any ideas anyone?
SOLVED
fomantic-ui was installed using gulp.
Inside the semantic folder is a gulp.js file, a src folder, and a dist folder.
Changing the files in src does nothing until you run "gulp watch" while changing the src files.
Then gulp creates updated "dist/semantic.css" etc. files.
Now, in your .hbs or .html you can reference the new "dist/semantic.css"
(I was missing the "gulp watch" step.)

Background banners (skins) in responsive layout, how to implement them?

I am looking for tutorials, ideas, suggestions on how to implement the "skin-banners" (also called background-banners) in responsive template as the famous twitter bootstrap template.
How to manage the width of the background picture?
Is it possibile to implement a backgroud banner without using javascript complex scripts? Are there any working examples?
Many thanks, Fabio
The solution is to display the correct skin for each viewport.
First of all you needto read the width of the window browser:
<script type='text/javascript'>
var WidthBrowser = $(window).width();
</script>
Then for each viewport you have to call the right skin.
For desktop version for instance:
if (WidthBrowser > 1200){
// code for skin
}
else if ...

show PDF in an Ext.Container SENCHA TOUCH 2

I am trying to show a pdf content in a Ext.Container of Sencha Touch 2. Tried several ways answered on SO but they all didn't work.
Few things tried, include:
Tried converting file content into html and extract the HTML inside the BODY tag and put it into Ext.XTemplate of the Container. This way I can only play cool with it, if HTML is being converted from a .doc file but if it was a .pdf file it messes up design because when I convert a pdf file into HTML then it adds position: absolute inside every DIV and with absolute position the parent element will not have any height and I am stuck with the scrolling issues.
for example:
<div style="position:relative;display:inline-block;;top:994px;left:712px;font-family:'Times New Roman';font-size:10pt;white-space:nowrap;">description</div>
Second try,
2. Tried putting PDF into IFRAME and EMBED tags as a link and put them into the Ext.XTemplate but these tags are also not working in mobile.
for example:
<embed type="application/pdf" width="800px" height="800px" src="example.pdf" />
<iframe style="position:absolute; z-index: 1; left: 0; top: 0;" width="100%" height="2000" src="example.pdf"></iframe>
Please give some idea how to display/open PDF(or its content, with atleast few formatting). Or do we have any plugin to display it. One final solution is showing using google docs but my initial requirement is showing PDF content in sencha touch 2 app not using any third party service(like google docs).
you can use inapp browser plugin for opening file in the iOS:
install inappbrowser cordoav plugin and open file like this:
function openPDF(){
ref = window.open('http://static.googleusercontent.com/media/www.google.com/en/us/webmasters/docs/search-engine-optimization-starter-guide.pdf', '_blank', 'location=no');
ref.addEventListener('exit', function() {
ref.removeEventListener('exit', function(){});
ref.close();
} );
}
It is very useful the PDFObject library, I have added this third-parties library to my project based on Sencha Touch 2 and its working in the browser, my current issue is show the pdf in Ipad.. :-(

Change Global Variable onclick/img source update with javascript variable

First off I am completely new to Javascript but I have some HTML/CSS experience. I've been trying to create an html/javascript image gallery for a website; (It would probably be a lot easier to do in PHP but the web coordinator disabled PHP on our server for security reasons).
Anyway What I have is a page showing an Album-list, Album-browser and Photo-viewer in different a div and 2 iframes respectively. I have it set up so that when someone clicks on an album from the album list, a page is opened up in the album browser section (iframe:"browser-frame" showing thumbnails of all the images in the particular album). I've been trying to set it up so that when someone clicks on an image in the album browser the image will appear in the Photo-viewer section (iframe:"viewer-frame" showing the photo itself).
I didn't want the photo's in the viewer-frame to be larger than the set dimensions for the viewer-frame so I created a page for the viewer-frame that puts the image in a div with a class of set dimensions (defined in a stylesheet) as follows:
...<body>
<div class="photoview">
<img id="viewed_image" class="large" src="images/album1/1.jpg" />
</div>
</body>...
I then created a script that updates the image src to a variable:image_to_be_viewed and called it image-changer.js
// JavaScript Document
{
var image_to_be_viewed="images/album1/1.jpg";
document.getElementById("viewed_image").src=image_to_be_viewed;
}
And added a script to the viewer-frame page so it looks like:
...<body>
<div class="photoview">
<img id="viewed_image" class="large" src="images/album1/1.jpg" />
<script src="image-changer.js"></script>
</div>
</body>...
Now I wanted the gallery to work so that in the page loaded in the browser-frame, whenever one clicked on one of the pictures, the value of the global variable 'image_to_be_viewed' would be changed to the source of the clicked image as follows:
<body>
<div class="photobrowse">
<img class="medium" src="images/album1/1.jpg" onClick="image_to_be_viewed='images/album1/1.jpg'"/>
<img class="medium" src="images/album1/2.jpg" onClick="image_to_be_viewed='images/album1/2.jpg'"/>
<img class="medium" src="images/album1/3.jpg" onClick="image_to_be_viewed='images/album1/3.jpg'"/>
</div>
</body>
It doesn't work....
the gallery i'm working on is on http://ptc.tamu.edu/test/gallery_directory/test_gallery.html
everything up to the loading of the selected picture in the viewer frame works (I'm running the onlick event on the default loaded pictures 1,2,3 in the browser-frame page)(default pic's 4 and 5 simply load the image in the iframe but with no way to adjust the size it is too big and gets cut off and i don't want that)
I've been working on for an entire day and I'm sure I'm doing something wrong here but I can't figure out what exactly it is. I have a feeling it has to do with changing the global variable: image_to_be_viewed from the browser-frame page but I wanted to confirm with experts instead of flopping about like a headless fish. I'm going to continue trying to figure this out but i thought maybe having some expert assistance would speed up the process.
What the onclick triggers should be a javascript function call.
e.g. onclick="changeImg('images/album1/1.jpg')"
And the function itself should looks like this
function changeImg (image_to_be_viewed) {
document.getElementById("viewed_image").src = image_to_be_viewed;
}
btw, you probably should learn javascript a little bit more before work on something real. I recommend this book
thank you I got it to work! I figured that the changeImg function was targeting the wrong document/wrong frame and I fixed it by changing the js script to:
function changeImg (image_to_be_viewed) {
window.parent.viewer_frame.document.getElementById("viewed_image").src = image_to_be_viewed;
}