Set a cookie for hiding a modal window and selecting the language - cookies

I have created a modal window that shows up upon loading any page in my site. I am using this modal window for language selection. I would like the users to be able to hide (1 month) the language selection modal window by clicking a hide this window button.
I have the modal window opening and loading the content in an external file as:
jQuery(document).ready(function(){
//name, value, additional -- expire cookie in 30 days
jQuery.colorbox({href:'/language.php', iframe:true, open:true, width:860, height:450})
});
And this is the external file with the language selection menu:
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<title></title>
<meta name="description" content="" />
<meta name="keywords" content="" />
<meta name="robots" content="" />
<style>
#lang-container {width: 100%}
.halfregion {display: block; float: left; width: 50%;}
.langblock {float: left; width: 40%; background: #ebebf1; margin: .5em; padding: 0.5em; height: 230px; text-align: center;}
</style>
</head>
<body>
<div id="lang-container">
<div class="halfregion">
<h2>Choose your region</h2>
<div class="langblock">
<p style="text-align: center"><img src="/sites/all/themes/podsystem/images/en-us.png" width=80 alt="US region" /></p>
<p>This site includes content and products for US, please select this region if you are in United States.</p>
<p>US English</p>
</div>
<div class="langblock">
<p style="text-align: center"><img src="/sites/all/themes/podsystem/images/en.png" width=80 alt="International English region" /></p>
<p>Select this region if you are outside US.</p>
<p>English</p>
</div>
<p><a class="hidthis" href="#">Click here to stop showing this message</a></p>
</div>
<div class="halfregion">
<h2>Elige tu región</h2>
<div class="langblock">
<p style="text-align: center"><img src="/sites/all/themes/podsystem/images/es.png" width=80 alt="US region" /></p>
<p>Selecciona esta region si hablas español.</p>
<p>Español</p>
</div>
<div class="langblock">
<p>We are working to improve your experience using our sites. Would you like to see other languages? Drop us a comment.</p>
<p>Contact us</p>
</div>
<p><a class="hidthis" href="#">Pincha aquí para dejar de mostrar este mensaje.</a></p>
</div>
</div>
</body>
</html>
I am really stuck now, how do I do to get the modal window to close when the users click on the links with the .hidthis class?
Thanks in advance.

The documentation at http://www.jacklmoore.com/colorbox/ suggests that you could attach $.colorbox.close() to the links to "initiate the close sequence."
If you don't have any more use for the plugin's functionality $.colorbox.remove() is also available to disable the functionality, with the provision that you no longer need it during the life of the page.

Related

Play audio from remote Url in Ionic(Hybrid app Development using cordova)

I am new to both Ionic and Cordova. I'm creating a basic app where I'll have some URLs of audio files that I want users to be able to play.
These URLs are fetching from web service. Please help me with this query. Thanks.
Edited after trying your answer:
following is the web service response. There is multiple event.Each event has two different audio that I want to play in one section.
{
"message":"success",
"title":"Panchkavani",
"error_msg":"",
"result":[
{"events_id":null,
"image":"",
"title":"test pachkavani",
"stanak":"https://ionic-audio.s3.amazonaws.com/Message%20in%20a%20bottle.mp3",
"mandir":"https://ionic-audio.s3.amazonaws.com/Roxane.mp3","date_added":"Saturday, 13-May-2017","date_time":"01:49 AM"}]}
here is a sample . dont forget to install cordova plugin add org.apache.cordova.media for more https://www.thepolyglotdeveloper.com/2014/11/playing-audio-android-ios-ionicframework-app/.this sample slso works only if you add media plugin
angular.module('ionicApp', ['ionic', 'ionic-audio'])
.controller('MyCtrl', function($scope) {
$scope.tracks = [
{
url: 'https://ionic-audio.s3.amazonaws.com/Message%20in%20a%20bottle.mp3',
artist: 'The Police',
title: 'Message in a bottle',
art: 'https://ionic-audio.s3.amazonaws.com/The_Police_Greatest_Hits.jpg'
},
{
url: 'https://ionic-audio.s3.amazonaws.com/Roxane.mp3',
artist: 'The Police',
title: 'Roxane',
art: 'https://ionic-audio.s3.amazonaws.com/The_Police_Greatest_Hits.jpg'
}
];
});
<html ng-app="ionicApp">
<head>
<meta charset="utf-8">
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
<title>Ionic Pull to Refresh</title>
<link href="//code.ionicframework.com/nightly/css/ionic.css" rel="stylesheet">
<script src="//code.ionicframework.com/nightly/js/ionic.bundle.js"></script>
<script src="https://rawgit.com/arielfaur/ionic-audio/master/dist/ion-audio.js"></script>
</head>
<body ng-controller="MyCtrl">
<ion-header-bar class="bar-positive">
<h1 class="title">Audio tracks with embedded bar</h1>
</ion-header-bar>
<ion-content>
<div class="list">
<ion-audio-track ng-repeat="track in tracks" track="track">
<div class="card">
<div class="item item-thumbnail-left">
<img src="{{track.art}}">
<h2>{{track.title}}</h2>
<p>{{track.artist}}</p>
<ion-audio-controls>
<a class="button button-icon icon" ion-audio-play></a>
<ion-spinner icon="ios" style="position: relative; top: 8px; left: 4px"></ion-spinner>
</ion-audio-controls>
</div>
<div class="item item-divider">
<ion-audio-progress-bar display-time></ion-audio-progress-bar>
</div>
</div>
</ion-audio-track>
</div>
</ion-content>
</body>
</html>

Zurb Foundation 5.5.2 range slider clicking on bar to advance handle to position does not work

I am using Zurb Foundation 5.5.2 and trying to get the range slider to work like on the Foundation web site documentation page for range sliders. The desired functionality is that you click on any location on the bar, and the handle advances to that location. On the Foundation web site kitchen sink page, clicking on the range slider bar does nothing. On this codepen that I use the most basic range slider code, you also cannot click on the bar and get the handle to advance. How do I get this to work?
Here is the Codepen code:
<div class="range-slider" data-slider>
<span class="range-slider-handle" role="slider" tabindex="0"></span>
<span class="range-slider-active-segment"></span>
<input type="hidden">
</div>
Foundation v5.x serie seems not trigger mousemove event when using slider.
Digging into foudantion issues on github I found this:
slider: add support for changing by clicking on the slider without having started to drag from the handle
It strikes me that this feature is only available for future versions of Foundation library such as v5.5.3 or v5.6 (see milestones).
But you can use that rigth now, just copy and past o raw code from github:
https://github.com/zurb/foundation/blob/master/js/foundation/foundation.js
https://github.com/zurb/foundation/blob/master/js/foundation/foundation.slider.js
Just click on "raw" button and save to the local storage.
So it should be work like this:
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/css/foundation.min.css" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/5.5.2/js/vendor/modernizr.js"></script>
</head>
<body>
<div class="row">
<div class="small-10 medium-11 columns">
<!-- SLIDER START -->
<div class="range-slider" data-slider data-options="display_selector: #sliderOutput3;trigger_input_change: true">
<span class="range-slider-handle" role="slider" tabindex="0"></span>
<span class="range-slider-active-segment"></span>
</div>
<!-- SLIDER END -->
</div>
<div class="small-2 medium-1 columns">
<span id="sliderOutput3"></span>
</div>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<!-- Foundation updated -->
<script src="https://raw.githubusercontent.com/zurb/foundation/master/js/foundation/foundation.js"></script>
<script src="https://raw.githubusercontent.com/zurb/foundation/master/js/foundation/foundation.slider.js"></script>
<script>$(document).foundation();</script>
</body>
</html>

Off-canvas conflict with cover background images

I'm using some background images with background-size: cover;. It was running ok until I added the Foundation's off-canvas-menu. The background images aren't displayed in Chrome.
Any idea of how to fix this?
Thanks!
It's a problem with backface, probably on Chrome side. You can overwrite it with the following css code
.off-canvas-wrap, .inner-wrap {
-webkit-backface-visibility: visible;
}
I'm sorry, I thought that it maybe was a common issue. The problem is only in Chrome and Opera. I didn't try IE. Here is the code:
<!DOCTYPE html>
<html>
<head>
<title>Test canvas</title>
<link rel="stylesheet" href="css/foundation.css" />
<style>
.fondo-imagen-bn{
height:1000px;
background: url(img/foto-fondo-secciones.jpg) no-repeat center center fixed;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size: cover;
}
</style>
</head>
<body>
<div class="off-canvas-wrap" data-offcanvas>
<div class="inner-wrap">
<a class="left-off-canvas-toggle show-for-small-only" href="#" >Off Canvas Menu</a>
<aside class="left-off-canvas-menu">
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
</aside>
<section class="fondo-imagen-bn">
<h1>Example with cover background</h1>
</section>
<footer style="height:300px;">
<h2>footer</h2>
</footer>
<a class="exit-off-canvas"></a>
</div>
</div>
<script src="js/vendor/jquery.js"></script>
<script src="js/foundation.min.js"></script>
<script src="js/foundation/foundation.js"></script>
<script src="js/foundation/foundation.offcanvas.js"></script>
<script src="js/scripts.js"></script>
<script>
$(document).foundation();
</script>

how to reload a list WinJS

I want to create a list which dinamically grows after an event (take a shoot) I mean adding each picture on real time to the list, this is my method...
//Invoke the camera capture UI for snapping a photo
function imageCapture() {
...
//Creates the array, datalist and the namespace for making this data public
if (dataArray == null) { dataArray = new Array(); }
dataArray[captureCount] = { title: capturedItem.name, id: "img" + captureCount, picture: photoBlobUrl };
var dataList = new WinJS.Binding.List(dataArray);
var publicMembers = { itemList: dataList };
WinJS.Namespace.define("DataExample", publicMembers);
}
And this is the HTML page which loads the content
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta charset="utf-8" />
<title>eCamera</title>
<!-- Referencias de WinJS -->
<link href="//Microsoft.WinJS.1.0/css/ui-dark.css" rel="stylesheet" />
<script src="//Microsoft.WinJS.1.0/js/base.js"></script>
<script src="//Microsoft.WinJS.1.0/js/ui.js"></script>
<!-- Referencias de eCamera2 -->
<link href="/css/default.css" rel="stylesheet" />
<script src="/js/default.js"></script>
</head>
<body >
<div id="content">
<div id="mediumListIconTextTemplate" data-win-control="WinJS.Binding.Template">
<div style="width: 150px; height: 100px;">
<!-- Displays the "picture" field. -->
<img src="#" style="width: 60px; height: 60px;" data-win-bind="alt: title; src: picture" />
<div>
<!-- Displays the "title" field. -->
<h4 data-win-bind="innerText: title"></h4>
<!-- Displays the "id" field. -->
<h6 data-win-bind="innerText: id"></h6>
</div>
</div>
</div>
<div id="basicListView"
data-win-control="WinJS.UI.ListView"
data-win-options="{ itemDataSource : DataExample.itemList.dataSource,
itemTemplate: select('#mediumListIconTextTemplate'),
itemsDraggable: true,
itemsReorderable: true }"></div>
</div>
</body>
</html>
If I load all the content in a fixed dataArray at first it works perfect, but dinamically adding elements and setting it all each time I take a picture so far doesn't work, how to make it work???
thanks in advance for the support
The app should not create new list each time. Use the WinJS.Binding.List.push method to append or splice can be used to insert. Since the list is observable, UI will autoupdate on changes (delete/add) to the list.

How to wrap <noscript> tag to hide content when javascript disable

Let's say, I have HTML code like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
This is content.
</body>
</html>
And I want to add a <noscript> tag there. Which means, if the JavaScript disabled, it will show as a blank page.
And only when JavaScript is disabled, it will show "This is content text".
Please give me some examples to achieve. Thanks.
An alternative to a JS approach as suggested by rahul is to display a div in the <noscript> element, covering the entire page:
<noscript>
<div style="position: fixed; top: 0px; left: 0px; z-index: 30000000;
height: 100%; width: 100%; background-color: #FFFFFF">
<p style="margin-left: 10px">JavaScript is not enabled.</p>
</div>
</noscript>
Wrap all you contents inside a main div with display none and in the onload function change the display to block.
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<div id="divMain" style="display: none">
This is content.
</div>
<noscript>
JS not enabled
</noscript>
<script>
document.getElementById("divMain").style.display = "block";
</script>
</body>
</html>
The noscript tag works the other way around. To make the content visible when script is enabled, put it in an element that is hidden, and show it using script:
<div id="hasScript" style="display:none">
This is content
</div>
<script>document.getElementById('hasScript').style.display='';</script>
It's a little odd.
You don't even need a 'noscript' for this. You can just have a blank first page, who's only content is a javascript of the form:
document.location = '/realpage.htm';
And then call that OnLoad, with jQuery, or whatever. This will mean if the client doesn't have scripting, they don't go anywhere, hence the page remains blank.
Edit:
Example, as requested:
<html>
<body onload="document.location = 'realpage.html';">
</body>
</html>
This SHOULD really work!
hide a content when javascript is not enabled
Note: you can replace <noscript> with <noembed> or <noframes>, too.
<!-- Normal page content should be here: -->
Content
<!-- Normal page content should be here: -->
<noscript>
<div style="position: absolute; right: 0; bottom: 0;
display: none; visibility: hidden">
</noscript>
<-- Content that should hide begin -->
**Don't Show! Content**
<-- Content that should hide begin -->
<noscript>
</div>
</noscript>
<!-- Normal page content should be here: -->
Content
<!-- Normal page content should be here: -->
Both the style tag and the meta refresh DO work inside noscript:
<noscript>
<style>body { display:none; }</style>
<meta http-equiv="refresh" content="0; url=blankpage.html">
</noscript>
The first line will display the current page but empty.
The Second line will redirect to blankpage.html
I had a very problem:
I wanted to show the full site when javascript was enabled. However, if javascript were disabled, not only did I want to show a "this site requires javascript..." message, but I still wanted to display the header & footer (which reside in header.inc and footer.inc, called by each content page) of my site (to look nice). In other words, I only wanted to replace the main content area of my site. Here's my html/css solution:
Header.inc file (location not important):
<noscript>
<style>
.hideNoJavascript {
display: none;
}
#noJavascriptWarning {
display: block !important;
}
</style>
</noscript>
Header file (bottom):
<div id="noJavascriptWarning">The Ignite site requires Javascript to be enabled!</div>
<div class="container-fluid hideNoJavascript">
<!-- regular .php content here -->
CSS file:
#noJavascriptWarning {
color: #ed1c24;
font-size: 3em;
display: none; /* this attribute will be overridden as necessary in header.inc */
text-align: center;
max-width: 70%;
margin: 100px auto;
}
In summary, my "javascript required" message is hidden per my default CSS rule. However, when the browser parses the tag, it overrides the default rule, resulting in main content being hidden and (everything except header/footer) and the javascript message being displayed. Works perfectly...for my needs! Hopefully someone else finds this useful :-)
Here are two screenshots with javascript enabled/disabled:
You could do something like
<body id="thebody">
this is content.
<script>
document.getElementById('thebody').innerHTML = "<p>content when JS is enabled!</p>";
</script>
</body>
I know this is an old inquire, but somehow none of this things worked in one of the PHP page I created. Below is what worked, the important thing was the comment tag between the noscript tag:
<noscript>
<center><div style="font-size:300%;position: absolute;top: 40%;left: 50%;margin-right: -50%;transform: translate(-50%, -50%)">
Scripts are Required...
<meta http-equiv='refresh' content="1;url=http://flstate.us/NoScript"/>
</div> </center>
<!--
</noscript>
<html>
<body>
Page HERE...
</body>
</html>
<noscript> --> </noscript>