The Situation:
My Script creates a weekplanner with the masterpage as template.
What's happening in the script is:
Create Page
Apply Masterpage
Override each item
Change content of each item
do this for the whole dates-array length
The Problem:
The position of the masterPageItems after overriding gets messed up.
I've made two screenshots as demonstration.
Now the real weirdness about this is, that it gets messed up on a "custom-size" document, but it doesn't get messed up on A4-Format...
I've already tried to restore the geometricBounds of each item after overriding it, but this doesnt seem to work either...
Do you have any idea what could be causing this behaviour?
The masterpage: http://i.imgur.com/T0ApzZj.png?1
Messed up after overriding: http://i.imgur.com/Lx6rZup.png?1
EDIT:
As proof that restoring the geometricBounds doesn't work, I did the following:
function OverrideMasterItems(currPage) {
var allItems = currPage.masterPageItems;
var itemPos;
for(var i=0;i<allItems.length;i++){
try{
itemPos = allItems[i].geometricBounds;
allItems[i].override(currPage);
allItems[i].geometricBounds = itemPos;
$.writeln("Original itemPos: " + itemPos);
$.writeln("New itemPos: " + allItems[i].geometricBounds);
if(itemPos == allItems[i].geometricBounds) {
$.writeln("same position");
}
}
catch(e){}
}
}
As you see I assign the items original geometric bounds again and in the console it says that it's the same value - but it looks like in the screenshots. Also it doesn't write "same position" - which means the if-statement isn't true...
I solved it! For future reference:
It wasn't a programming bug, but some awkward InDesign "Bug(?!)" that lead to this weird behaviour:
I copied the elements of the Masterpage from a different document, that had different dimensions, and I just resized the textfields to fit the new format.
That's what caused the behaviour - it seems like the textfields still have some information from the other document I got it from and that this information wasn't removable/editable.
Because even deleting the paragraph styles etc. didn't change the weird behaviour...
As I'm pretty new to InDesign scripting I don't know if this a common thing you guys know about, but this gave me headaches... ;)
EDIT 1: I didn't solve it! Still not working sometimes!
Okay, it's still happening, and I just don't understand why... As the script executes the "override" on an item, the item gets repositioned to a completely wrong position...
Related
I included a layer tree according to http://www.acuriousanimal.com/thebookofopenlayers3/chapter02_03_layer_groups.html and http://jsfiddle.net/joshuadickerson92/mtwbs2dg/ (JSFiddle - cannot post more than 2 links due to insufficient reputation) in my Openlayers 3 map.
I cannot get the opacity slider to work. Moving it from right to left and vice versa has no effect on the opacity of the layers at all, regardless of these parameters: data-slider-min='0' data-slider-max='1' data-slider-step='0.1'
This bit
$('input.opacity').slider().on('slide', function (ev) {
var layername = $(this).closest('li').data('layerid');
var layer = findBy(map.getLayerGroup(), 'name', layername);
layer.setOpacity(ev.value);
});
seems to be skipped over when checking the page in Firefox's debugger tool.
I've been searching for solutions for days now, but still couldn't find anything. Any help appreciated!
JSFiddle here: http://jsfiddle.net/kidalex/j34xzaa3/5/
Update: I added this chunk of JS code, and now it works! Updated fiddle here: http://jsfiddle.net/kidalex/j34xzaa3/5/
Now I'm going to investigate which ones of those 8914 lines of (tidied up) code are the cause for that.
Try publishing your whole code so we can help better.
More probably your issue is related to javascript than to OL3, because of this I can't give you a concrete solution.
Ensure your $('input.opacity').slider().on('slide', function (ev) {... function returns a good ev.value when you move the slider.
Check too your findBy function works fine a the layername variable is getting the right value.
Use your browser debugger or simply the console to check all that.
Cheers.
I've been doing some web stuff with jQuery and css, and came across a problem, which I'm unable to find a solution to. I've written a code, where using jQuery, I get data from server and according to that data I add new elements. The elements have a lot of absolute positioning in them, and it messes up whenever I add them via jQuery.
My code is here:
function output(progress, data) {
$("#lookup .bar").css('width', (100/3*progress) + '%');
if (progress === 3) {
$("#lookup div.container").html(data);
$('#lookup').css("text-align", "left");
}
}
Basicly, I just remove the progress bar, and set my text-align to left, because of otherwise even more messed up aligning, this is the only workaround I found... The problem I'm having looks like this:
Although normally, it should look like this:
The strange thing is that the problem fixes itself whenever I refresh styling, for example with firebug, I would just delete some padding, then restore it, and the problem is gone... I feel that it has to do something with jQuery part. I'm pretty sure styling is fine, but if you need me to paste a code here, just ask, and I'll update the post.
UPDATE: Live preview on jsbin: http://jsbin.com/awomen/5/
I know the code is ugly ;)
(Okay, I know the questions probably sounds rancid bad, so someone edit if they they know how to reformulate it).
So, basically I have this: jsFiddle
And as you can probably see, I'm trying to re-create a basic windows 7 aero effect (curiosity, fun, learning, etc nothing big), but I stumbled into a few problems.
(I will explain only vaguely, since you can see it on the fiddle and otherwise it would be a textathon)
The text is stuck on top of the parent's(div) parent(div) element.
The text somehow leaks out of the duplicate element(div), even thought it doesn't from the original.
I know this all sounds odd, but you'll probably best see it on the fiddle.
Thank you.
I think the problem you're having is stemming from this:
$(container).find('*').each(function() {
var e_clone = $(this).clone(false).appendTo(processor);
// etc etc
});
By using the * selector then running .each you are cloning more markup into #processor than I think you might have intended to. You get two copies of span.lol in there because first it clones #box (including all its children) and then on the next iteration through the each it copies over span.lol on it own.
As for the "leaking" of text out of the parent, it does happen in the original... at least that's what I see in Chrome if I comment out the call to glass('#container', '#processor').
So, I have this pretty complex ajax thing going.
It loads new html (including div tags and all) to show up on the page.
I included a 'more' link to load additional data.
This more link links to my javascript function. The 'more' link is located in a div, which I gave a unique id. The next time the load function is called, I use document.getElementById(the id).style.display="none"; to "remove" this div from the look of the page.
I set error traps for this, the div with that id is found without problems, but javascript fails to change my style property.
I tested alert(document.getElementById(the id).innerHTML); and that worked without problems - hence the title of the question.
So, does anyone have any ideas/do I need to offer more information? The main problem is that it doesn't throw any errors anywhere, yet it fails to complete the task I asked...
Here's a bit of code to go with it -
try
{
var myidthing = "morelink" + ContentStart.toString(); //the id is correct
var div = document.getElementById(myidthing);
if (!div)
{
}
else
{
div.style.display="none"; //this doesn't work, but doesn't raise an error
alert(div.innerHTML); //this works without problem
}
}
catch(theerr)
{
alert(theerr);
}
------------------------->EDIT<-------------------------
I'm incredibly sorry if I upset any people.
I'm also angry at myself, for it was a stupid thing in my code. Basically, I had a variable that stored the contents of a parent div. Then I (succesfully) removed the div using the removeChild() method. Then my code pasted the contents of that vaiable (including the div I wanted gone) back into the parent div.
I switched around the order and it works fine now.
Again, excuse me for this.
Throwing out a few ideas of things to look for:
You said the div is generated by javascript. Is it possible the div you are targeting is not the one you think you are? It could be you are targeting another div, which is already hidden, or obstructed... or maybe the innerHTML you are displaying goes with a different element than the one you intend to target. Put an alert or script breakpoint in the if(!div) case, also, and see if it's going down that path.
If the above code is only a stripped-down version of your actual code, check your actual code for typos (for example: style.display = "none;";)
Using the FireBug plugin for FireFox, inspect the target element after the operation completes, and make sure that the display: none appears in the style information. If not, use FireBug's debugger to walk through your javascript, and see if you can figure out why.
Use FireBug to break on all script errors, in case there is another error causing this behavior.
Try empty quotes instead of 'none' and see if that works?:
document.getElementById('element_id').style.display="";
Failing that, don't change the style, just add a class which hides the element.
This is the gallery I've been asked to implement
http://sandbox.leigeber.com/slideshow/
I've chopped and changed it ever so slightly so it'd fit into the new site's templating system a bit easier.
Whenever I run it, this line causes an error
ta=document.getElementById(thumbid);
Saying that ta is null. I know the thumbid var's value does exist as an Id of the unordered list.
I've tried to figure what's been going on for at least half an hour now, and can't seem to nail it!
Can someone please tell me what I'm doing wrong?
Yeah the code looks fine, and running the same lines from Firebug console work OK, so it makes me wonder if the thumbs element actually exists at the time of running? Is it in a document.ready-style handler? If it's being called before the element exists on that page, then ta will be null, which would create that error.
It looks like the slideshow function is called for initialization too early. This will be called before the DOM tree is ready:
var slideshow = function() {
...
} ();
try removing that () at the end.
Good news! jQuery is written in vanilla Javascript! You should be able to copy out their method for getting elements by ID and use that.
It's a little unclear what value thumbid should have, but it looks to me like your problem is that the li items in your unordered list don't have ids, they have values.
Calling document.getElementById('thumbs') works fine to get the ul element of the list itself.
In Safari 4 line 19 was throwing me a type error regarding ta which was null.
This is due to the line you pointed out where ta was assigned.
I like how you encapsulate the functions in a closure, but I think the window.onload can be changed to be more jQuery like; the same can be said of actually selecting the elements you're looking for, something like t=$('ul#thumbs li') should do the trick. I don't know if throwing a var in front of ta is going to fix anything, but it's worth a shot.