How can I automate this code for a slideshow? - slideshow

I recently did this tutorial: http://fearlessflyer.com/2010/08/how-to-create-your-own-jquery-content-slider/ and I was wondering if anyone knows how I can use the code in this tutorial but change it to automatically scroll through the images instead of scrolling through when clicking on the text.
the code that scrolls the images after checking the mouse "click" event is:
$(theImage).each(
function(intIndex){
$(this).nextAll('a')
.bind("click", function(){
if($(this).is(".next")) {
$(this).parent('li').parent('ul').animate({
"margin-left": (-(intIndex + 1) * theWidth)
}, 1000)
} else if($(this).is(".previous")){
$(this).parent('li').parent('ul').animate({
"margin-left": (-(intIndex - 1) * theWidth)
}, 1000)
} else if($(this).is(".startover")){
$(this).parent('li').parent('ul').animate({
"margin-left": (0)
}, 1000)
}
});//close .bind()
});//close .each()
the statement:
.bind("click", function(){...
checks for a mouse "click" event and then executes the if statement. I would like to instead just run the if statement without first having to click. Any help would be greatly appreciated, thanks.

<script language="JavaScript" type="text/javascript">
var images = new Array('morning.jpg','afternoon.jpg','night.jpg','lightbulb_on.jpg')
var count = -1
function slideShow(){
if (count <=2){
count ++;
}
document.getElementById("show").innerHTML = "<img src="images/"+images[count]+"">"
setTimeout("slideShow()", 3000)
}
</script>
<div id="show">
<script>slideShow()</script>
</div>
That one works with the click event, so you have to change the way it works, setting timers.
I usually do it with this code. Hope it helps.
I dont put the comment because I cant (low reputation) sorry

Related

(Ember-cli-g-maps) - Changing markers properties dinamically

This is my first question here, so I hope do it in the right way.
I'm trying to use ember-cli-g-maps in my project. The tool is great, but I'm having great dificulties in making one of my requirements work.
The chalange is: I create a set of markers setting the "draggable" property to false.
Template
{{g-maps name="map" lat=lat lng=lng zoom=zoom markers=markers idle="onMapIdle" click="onMapClick"}}
Controller
for (let i=0; i< data.stops.length; i++)
{
let stop = data.stops[i];
markers.pushObject(
{
id: stop.id, // Recommended
lat: stop.coordinate[0],
lng: stop.coordinate[1],
draggable: false,
icon:
});
}
The markers are added correctly in the map.
But I want to make all markers draggable when the user press a button .
This is how I trying to do it.
enableMarkersDrag()
{
for (var i=0; i<this.get('markers').length; i++)
{
this.get('markers')[i].draggable = true;
}
},
This doesn't work immediatelly, but it does when I make some change in the "markers" array, adding or removing an item. It is a MuttableArray.
I understand why. This is because the observer is observing the array, not the properties inside the array.
But I believe that 'add' and 'remove' an item just to trigger the observer is not the right way to do it. Do you guys know the clean way of doing this?
Thanks in advance;

#ember-power-select Trigger focus from an action

I've been stuck on this issue for about a week now, and I am not exactly sure how to solve it.
What I am trying to do is set the focus of ember-power-select from triggering an
I am currently able to set focus to the power select via tabbing or clicking, however I can't seem to gain its focus from another action.
(Like the hacky way I can think of is to call handleFocus directly and pass a select object)
In Component.hbs:
{{#power-select
class='ls-search-box'
options=searchList
selected=selected
onfocus=(action "handleFocus") as |item|
}}
In Component.js:
actions: {
handleFocus(select, e){
select.actions.open()
},
focusSearch(){
//console.log('focus Search');
var input = Ember.$(".ls-search-box");
if(input) {
input.focus();
}
}
}
Any know what I should do?
You need to change focusSearch like :
focusSearch(){
//console.log('focus Search');
var input = Ember.$(".ls-search-box > .ember-power-select-trigger");
if(input) {
input.focus();
}
}
You used a wrong css selector

KO Grid Scrollbars not visible & Display issues

I am having two problems with KOgrid.
1) I could not get scroll bars in the kogrid .It is very difficult to do data entry without scroll bars.
2) I also could not get kogrid to working wihout specifying hard coded height and width.In my application I can not have a fixed height and width.
Did anybody else had the same issue ?
I tried a workaround suggestion from this thread ( using jQuery fix as last line in my viewmodel).
KO Grid Display Isseues, On resize Gird shows one row. Images also included
that just increased that size of the grid but it did not display any data . However, when I resize the page data shows up.
Below are my HTML and kogrid options ( I tried with and without paging options, Ideally I do not want to use paging )
<div data-bind="koGrid: gridOptions"
style="height: 800px; background-color: none;width: 1850px;">
</div>
self.gridOptions = {
data: self.mydatarray,
footerVisible: true,
displaySelectionCheckbox: true,
afterSelectionChange: self.RowSelectionChange,
rowHeight: 50,
selectWithCheckboxOnly: true,
enableSorting: false,
multiSelect: true,
selectedItems: self.SelectedRows,
enableColumnResize: true,
showFilter: false,
canSelectRows: true,
enablePaging: true,
pagingOptions: {
currentPage: ko.observable(1),
pageSize: ko.observable(3),
pageSizes: ko.observableArray([3, 6, 9])
},
rowTemplate: errrowtmpl,
columnDefs: [
{ field: 'Customer', displayName: 'Customer', cellTemplate: Customersddedittmpl, headerCellTemplate: headercelltmpl },
...
...
{ field: 'GenNotes', displayName: 'GenNotes', cellTemplate: simpleedittmpl, headerCellTemplate: headercelltmpl }
]
}
Please let me know if you need any more information
Thanks
Kenner Dev
I found a solution to the problems I am facing.
1) I used Jquery to add scroll bar. I added code line below as last line of my data loading function. I am not sure id this breaks any other KOGrid functionality.In my application I did some basic testing and it seems to be working fine.
$("div.kgViewport").css("overflow", "scroll");
2) I still dont know how to solve this problem 100%. It still does not work unless fixed width and height are mentioned in style. In my app I used vw and vh as opposed fixed width and height to solve the problem of making it work on all screen sizes.
<div data-bind="koGrid: gridOptions"
style="height: 73vh;overflow:scroll;width: 96vw;"></div>

How change the event in [XTK]

Hello,
I wonder how do I change my mouse event
because I would like to X.Caption activates only when I right-clicked on it.
thank you very much
If I'm correct ( other contributors, don't be afraid to correct me ), you might have to edit the internals of XTK for your needs. XTK has the "controls" defined in X.event.js for it's event such as HoverEvent and PanEvent which are acquired from the Google Closure Library. You can look into the Google Closure Library more as I haven't completely reviewed it, but X.caption is mostly derived from Goog.ui.Tooltip which can be used with the events from Goog.ui.Popup, Goog.ui.PopupBase, and Goog.events. You can try to include Goog.events into your Javascript and define your own click event or something related to that and look through the Google Closure Library some more.
If what I just wrote in the small paragraph above is not completely correct or anything like that, there are of course basic Javascript DOM Events for clicking. I'm not quite sure how those would work with XTK because XTK uses WebGL for rendering. You can review the basic events at http://www.w3schools.com/jsref/dom_obj_event.asp. If you find any solution for yourself, you are more than welcome to contribute it to XTK.
I think there are too ways no ? Change the xtk source code and compile your own version or something like this :
window.onload = function() {
myrenderer.config.HOVERING_ENABLED = false; // disabling show caption on mousehover
var mouse_x, mouse_y;
myrenderer.interactor.onMouseMove = function(event) {
mouse_x = event.offsetX;
mouse_y = event.offsetY;
}
myrenderer.interactor.onMouseDown = function(left,middle, right) {
if (right) {
var picked_id = myrenderer.pick(mouse_x, mouse_y);
if (picked_id==-1) throw new Error("No object");
var picked_object = myrenderer.get(picked_id);
var mycontainer = myrenderer.container;
var caption = new X.caption(mycontainer,mycontainer.offsetLeft + mouse_x + 10, mycontainer.offsetTop + mouse_y + 10,myrenderer.interactor);
caption.setHtml(picked_object.caption);
// use settimeout or something else to destroy the caption
}
}
}
The following JSFiddle shows how to do that. To actually display a tooltip etc. you can use any JS Library like jQuery UI.
http://jsfiddle.net/haehn/ZpX34/

Flexigrid + IE9 height:auto

The problem is very elemental.
If you go to http://flexigrid.info/ with IE9, and explore the 'example 2' section, and the columns resize over the visible place, that it will activate the horizontal scrollbar. And you hover the rows, you experience growing up the Flexigrid size. I don't experience IE7 and IE8, only IE9. This problem has by height: auto configurate. I didn't find solution yet. Please help me!
Actually, the solution that #Szenti posted will only work for 1 flexigrid on the page, if there are multiple, it will only takes the height value of the 1st bDiv it founds and apply the fix to all.
My revised version I think will apply to situations where there are many flexigrids on the page at one time.
ie9Fix: function() {
var bDivH = $(this.bDiv).height();
var bDivTH = $('table', this.bDiv).height();
if(bDivH != bDivTH && p.height=='auto') {
$(".bDiv").css({height: bDivTH + 18});
}
},
I had this same issue. Thanks #Szenti for the Answer, however, once this was in place I then had flexigrid resize issue when the results in the table where regenerated via AJAX. This occured in latest Chrome, Firefox and IE7/8.
So I added a (some would say dirty) browser sniff into the mix.
Global var:
var ie9 = false;
if ($.browser.msie && parseInt($.browser.version, 10) == 9) {
ie9 = true;
}
Then where #Szanti's method is called I just wrap it in:
if (ie9) {
this.ie9Fix();
}
Now works a treat in all browsers.
The solution:
You have to edit the flexigrid js. Append the g object with this:
ie9Fix: function() {
if($(".bDiv").height() != $(".bDiv table").height() && p.height=='auto') {
$(".bDiv").css({height: $(".bDiv table").height() + 18});
}
},
You have to call ie9Fix function in 2 places
In the g.dragEnd() function last row (this.ie9Fix();)
In the g.addRowProp() you have to write a new event:
.mouseleave(function(){
g.ie9Fix();
})
That's it!