I need to close WMP (Window Media Player) automatically display on flash. The code follows.
Main page for a WMP displayed by this code:
<script type="text/javascript">
$(document).ready(function(){
var flashvars = {
shelfXmlData : "/eLibNida/shelf/categoryInClientListXML/${clientId}",
coverXmlData : "/eLibNida/shelf/coverBookInCategoryXML",
saverXmlData : "/eLibNida/shelf/screensaverInClientXML/?clientId=${clientId}",
secureURL:"http://elibrary4.nida.ac.th/Media/crossdomain.xml"
};
var params = {
menu: "false",
allowDomain : "always",
allowscriptaccess: "always",
allowFullScreen: "true",
wmode:"opaque"
};
var attribute = {};
$.post("/eLibNida/shelf/themeInClient/${clientId}",function(theme){
swfobject.embedSWF("${createLinkTo(dir:'swf',file:'digitalBookShelf"+theme+".swf')}","flash","1920","1080","9.0.0","${createLinkTo(dir:'swf',file:'expressInstall.swf')}",
flashvars, params, attribute);
})
});
Display WMP by this code:
<div id="media" style="margin-left:auto;margin-right:auto"></div>
<script type="text/javascript">
$(document).ready(function(){
var thisType = "${contentType}";
var opacLink = "${opcLink}";
if(thisType == "WindowClip"){
wmv = '<OBJECT ID="MediaPlayer" WIDTH="1280" HEIGHT="960"
CLASSID="CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95"
STANDBY="Loading Windows Media Player components..."
TYPE="application/x-oleobject">';
wmv += '<PARAM NAME="FileName" VALUE="${value}">';
wmv += '<PARAM name="autostart" VALUE="true">';
wmv += '<PARAM name="ShowControls" VALUE="true">';
wmv += '<PARAM name="ShowStatusBar" value="false">';
wmv += '<PARAM name="ShowDisplay" VALUE="false">';
wmv += '<PARAM name="stretchtofit" VALUE="true">';
wmv += '<PARAM name="loop" VALUE="true">';
wmv += '<EMBED TYPE="application/x-ms-wmp" SRC="${value}"
NAME="MediaPlayer"WIDTH="1280" HEIGHT="960" ShowControls="true"
ShowStatusBar="false"ShowDisplay="false" autostart="true"
stretchtofit="true" loop="true"</EMBED>';
wmv += '</OBJECT>';
$("#media").prepend(wmv).width(1280).height(960).css({"margin-top":"50px"});
How do I close it?
Related
In my Django app I have a leaflet map with two layers "active_event_layer" and "inactive_event_layer". I can select which layer I want to see in the top right menu. But when the page is loaded no layer is selected by default, so in order to see a layer I must selected it first. What I want to do is to set a layer by default, so, when the page is loaded the "Active events" layer is selected by default.
Here is my code:
var active_event_collection = {{ active_events|geojsonfeature:"name"|safe }};
var inactive_event_collection = {{ inactive_events|geojsonfeature:"name"|safe }};
function onEachFeature(feature, layer) {
layer.bindPopup(feature.properties.name);
}
function map_init(map, options) {
var active_event_layer= L.geoJson(active_event_collection, {onEachFeature: onEachFeature})
var inactive_event_layer = L.geoJson(inactive_event_collection, {onEachFeature: onEachFeature})
var basemaps = {
"Gray scale": L.tileLayer('http://{s}.tiles.wmflabs.org/bw-mapnik/{z}/{x}/{y}.png', {
maxZoom: 18,
attribution: '© OpenStreetMap'
}),
Streets: L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
maxZoom: 19,
attribution: '© OpenStreetMap'
})
};
var overlayMaps = {
"Active events": active_event_layer,
"Inactive events": inactive_event_layer,
};
var features = L.control.layers(basemaps, overlayMaps).addTo(map);
map.fitBounds(active_event_layer.getBounds());
}
I have a knockout page where I am formatting the input with regex. It makes the input field to a MM/dd/yyyy format. So if a user inputs "1111" it will change the input vbox to show "01/01/2011" or for "01111" it will show "01/01/2011".
The problem I am facing is that my observable only returning the keystroke entered by user and not the fully formatted item. For example , if user is entering "1111" I get back "1111" instead of the "01/01/2011"
Here is the Html segment
<input id="inpEventDt" placeholder="MM/DD/YYYY" class="input-small" data-date-blur="true" data-regex="^((\d{0,2})|(\d{1,2}/?\d{0,2})|(\d{1,2}/?\d{1,2}/?\d{0,4}))$"
type="text" data-bind="textInput: dateofevent"/>
And this is how I have the knockout binding
var ViewModel = function (eventdt ) {
var self = this;
self.dateofevent = ko.observable(eventdt);
}
viewModel = new ViewModel("");
ko.applyBindings(viewModel);
Trying to figure out what I am doing wrong.
I would not try to format the text input while the user is typing, because it makes a hard to understand user interface and non intuitive typing experience.
In addition, it's more complicated, because while typing, the input is likely invalid.
Try instead to format your input on some event (blur for example), while validating it on keystroke:
var viewModel = function() {
var self = this;
var regex = /^(\d{1,2})\/(\d{1,2})\/(\d{4})$/;
this.isValid = ko.observable(false);
this.date = ko.observable("");
this.format = function() {
self.validate(self.date());
// TODO: something else
}
this.validate = function(newVal) {
var matches = newVal.match(regex);
if (!matches || matches.length != 4) {
self.isValid(false);
} else {
self.isValid(true);
}
};
this.date.subscribe(function(newVal) {
self.validate(newVal);
});
this.style = ko.computed(function() {
return self.isValid() ? "valid" : "invalid";
}, this);
};
var vm = new viewModel();
ko.applyBindings(vm);
.invalid {
border: 1px solid red;
}
.valid {
border: 1px solid green;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js"></script>
<input id="inpEventDt" placeholder="MM/DD/YYYY" class="input-small" data-date-blur="true" type="text" data-bind="textInput: date, event: { blur: format }, css: style" />
<div data-bind="visible: isValid">OK</div>
You should try using a read/write computed for this. Check out the example 3 in the knockout documentation for computed observables.
Also, here is a jsfiddle using moment.js to help with date formatting.
var ViewModel = function (eventdt ) {
var self = this;
self.dateofevent = ko.observable(eventdt);
self.formattedDate = ko.pureComputed({
read: function () {
return moment(self.dateofevent()).format("MM/DD/YYYY");
},
write: function (value) {
self.dateofevent(moment(value).toDate()); // Write to underlying storage
}
});
}
viewModel = new ViewModel(new Date("03/25/2015"));
ko.applyBindings(viewModel);
I have created a new chart type:
Chart.types.Line.extend({
name: "LineWithRectangle",
draw: function () {
Chart.types.Line.prototype.draw.apply(this, arguments);
var startPoint = this.datasets[0].points[this.options.startIndex]
var endPoint = this.datasets[0].points[this.options.endIndex]
var scale = this.scale
this.chart.ctx.fillStyle = "#808080";
ctx.globalAlpha = 0.2;
this.chart.ctx.fillRect(startPoint.x,
scale.startPoint,
endPoint.x - startPoint.x,
scale.endPoint - scale.startPoint);
ctx.stroke();
ctx.globalAlpha = 1;
this.chart.ctx.textAlign = 'center';
this.chart.ctx.fillText("EVENT DAY",
startPoint.x + (endPoint.x - startPoint.x) / 2,
scale.startPoint + 20);
}
});
I placed this code in another file and referenced in the page :
<script src="~/lib/charts-js/Chart.js" type="text/javascript"></script>
<script src="~/lib/charts-js/ChartExtensions.js" type="text/javascript"></script>
But when I try to use it I'm not getting a chart object in the debugger:
new Chart(ctx.children[0].getContext("2d")).LineWithRectangle(data, { pointHitDetectionRadius: 0.05, animation: false, startIndex: start, endIndex: end })
Chrome is not reporting a ChartType object like it does for built in chart types but says "not available".
What am I doing wrong here?
Your code expects different values for ctx in the main code vs. your extension. In your main code it seems like a DOM node and in your extension you are using it as a context.
Just add
var ctx = this.chart.ctx;
after Chart.types.Line.prototype.draw.apply(this, arguments); and it should work. If not, check if your main code variables are all defined with correct values (start, end and ctx)
I am just starting with Qt Quick and QML.
I wrote a login page which loads a users id after username and password input. After the successful authentication, I need to pass this ID to the new window that is being created.
How can I do that?
login.qml snippet
BSButton {
id: btnOK
anchors.top:senhaInput.bottom
anchors.left: senhaInput.left
anchors.topMargin: 10
width: (senhaInput.width * 0.60) - 5
text: "Entrar"
isDefault: true
onClicked: {
lblMsgErro.text = ""
lblMsgErro.visible = false;
controller.autenticar(); // returns user id to pass to main.qml
}
}
QLoginController {
id: controller
login: loginInput.text
senha: senhaInput.text
onAuthenticated: {
if (success) {
var component = Qt.createComponent("main.qml");
var win = component.createObject();
win.showFullScreen();
close();
} else {
senhaInput.text = "";
console.log("Falha na autenticação: Usuário e/ou senha inválidos.");
lblMsgErro.text = "Usuário e/ou senha inválidos.";
lblMsgErro.visible = true;
loginInput.focus = true;
}
}
}
The database stuff is working, I just don't know how to send the userid to the main.qml
Thank you in advance.
var win = component.createObject();
win.userid = login;
and your main.qml should have the property userid.
or,
var win = component.createObject(controller, {'userid':login});
it will make a property userid for win.
When I expand the Sitecore content tree and when the vertical scroll bar appears for the content tree, and if I scroll down and select an item in the bottom of the tree, it scroll to top.
This only happens in Firefox, IE10, IE9, Chrome it works fine.
I did the Sitecore upgrade very recently. Has anyone encountered similar issue? Please help!
Sitecore.NET 6.6.0 (rev. 130404)
Firefox versions - 21,22
I have had a similar issue and contacted Sitecore support about it. They provided me with the following solution that works for us:
- open \sitecore\shell\Controls\Gecko.js
- replace at line 668
scBrowser.prototype.resizeFixsizeElements = function() {
var form = $$("form")[0];
this.fixsizeElements.each(function(element) {
var height = form.getHeight() - element.scHeightAdjustment + "px";
element.setStyle({ height: height });
});
/* trigger re-layouting to fix the firefox bug: table is not shrinking itself down on resize */
scGeckoRelayout();
}
by:
scBrowser.prototype.resizeFixsizeElements = function() {
var form = $$("form")[0];
if (!form) {
return;
}
this.fixsizeElements.each(function (element) {
if (!element.hasClassName('scFixSizeNested')) {
element.setStyle({ height: '100%' });
}
});
var maxHeight = 0;
var formChilds = form.childNodes;
for (var i = 0; i != formChilds.length; i++) {
var elementHeight = formChilds[i].offsetHeight;
if (elementHeight > maxHeight) {
maxHeight = elementHeight;
}
}
var formHeight = form.offsetHeight;
this.fixsizeElements.each(function (element) {
var height = element.hasClassName('scFixSizeNested')
? (form.getHeight() - element.scHeightAdjustment) + 'px'
: (element.offsetHeight - (maxHeight - formHeight)) + 'px';
element.setStyle({ height: height });
});
/* trigger re-layouting to fix the firefox bug: table is not shrinking itself down on resize */
scGeckoRelayout();
}
Thanks to Sitecore support, found the issue,
The issue occures due to Fixefox refreshes html controls as soon as some property was changed. Upon selecting an item, a content tree panels width is changed and as a result it is redrawn. Developed workaround forbids changing of the controls size for static controls for Firefox (like content tree). An aftermath might be incorrect window resizing (changing height of the browser window) in Firefox. To implement the workaround please replace an exicting one under the path 'Website\sitecore\shell\Controls\Gecko.js' with attached one and clear browser cache. Please notify us with the results.
scBrowser.prototype.resizeFixsizeElements = function() {
var form = $$("form")[0];
if (!form) {
return;
}
if (!this.isFirefox)
{
this.fixsizeElements.each(function (element) {
if (!element.hasClassName('scFixSizeNested')) {
element.setStyle({ height: '100%' });
}
});
var maxHeight = 0;
var formChilds = form.childNodes;
for (var i = 0; i != formChilds.length; i++) {
var elementHeight = formChilds[i].offsetHeight;
if (elementHeight > maxHeight) {
maxHeight = elementHeight;
}
}
var formHeight = form.offsetHeight;
this.fixsizeElements.each(function (element) {
var height = element.hasClassName('scFixSizeNested')
? (form.getHeight() - element.scHeightAdjustment) + 'px'
: (element.offsetHeight - (maxHeight - formHeight)) + 'px';
element.setStyle({ height: height });
});
}
/* trigger re-layouting to fix the firefox bug: table is not shrinking itself down on resize */
scGeckoRelayout();
}