Opencart Fancybox product title - fancybox

I am using opencart 1.5.6 ,I installed a responsive custom Opencart template but i have an issue with product title in fancybox on product page. If i put only one basic image on my product without any additional images i can't see my product title. But on the other hand if my product has additional images then it works correctly.
Here is code from fancybox for basic image:
<div class="fancybox-skin" style="padding: 15px; width: auto; height: auto;">
<div class="fancybox-outer">
<a class="fancybox-item fancybox-close" href="javascript:;" title="Close"></a>
And this is code when i use additional images:
<div class="fancybox-skin" style="padding: 15px; width: auto; height: auto;">
<div class="fancybox-outer">
<div class="fancybox-title fancybox-title-float-wrap">
<a class="fancybox-item fancybox-close" href="javascript:;" title="Close"></a>
its seems that tittle is enabled only if i have additional images.
My question is how to add this title for basic image as well?
Here is code from fancybox.js(it's one part i couldn't post it all)
scrollOutside : !0,
index : 0,
type : null,
href : null,
content : null,
title : null,
tpl : {
wrap : '<div class="fancybox-wrap" tabIndex="-1"><div class="fancybox-skin"><div class="fancybox-outer"><div class="fancybox-inner"></div></div></div></div>',
image : '<img class="fancybox-image" src="{href}" alt="" />',
iframe : '<iframe id="fancybox-frame{rnd}" name="fancybox-frame{rnd}" class="fancybox-iframe" frameborder="0" vspace="0" hspace="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen' +
(f.browser.msie ? ' allowtransparency="true"' : "") + "></iframe>",
error : '<p class="fancybox-error">The requested content cannot be loaded.<br/>Please try again later.</p>',
closeBtn : '<a title="Close" class="fancybox-item fancybox-close" href="javascript:;"></a>',
next : '<a title="Next" class="fancybox-nav fancybox-next" href="javascript:;"><span></span></a>',
prev : '<a title="Previous" class="fancybox-nav fancybox-prev" href="javascript:;"><span></span></a>'
},
openEffect : "fade",
openSpeed : 250,
openEasing : "swing",
openOpacity : !0,
openMethod : "zoomIn",
closeEffect : "fade",
closeSpeed : 250,
closeEasing : "swing",
closeOpacity : !0,
closeMethod : "zoomOut",
nextEffect : "elastic",
nextSpeed : 250,
nextEasing : "swing",
nextMethod : "changeIn",
prevEffect : "elastic",
prevSpeed : 250,
prevEasing : "swing",
prevMethod : "changeOut",
helpers : {
overlay : !0,
title : !0
},
onCancel : f.noop,
beforeLoad : f.noop,
afterLoad : f.noop,
beforeShow : f.noop,
afterShow : f.noop,
beforeChange : f.noop,
beforeClose : f.noop,
afterClose : f.noop
},
group : {},
opts : {},
previous : null,
coming : null,
current : null,
isActive : !1,
isOpen : !1,
isOpened : !1,
wrap : null,
skin : null,
outer : null,
inner : null,
player : {
timer : null,
isActive : !1
},
ajaxLoad : null,
imgPreload : null,
transitions : {},
helpers : {},
open : function (a, d) {
if (a && (f.isPlainObject(d) || (d = {}), !1 !== b.close(!0)))
return f.isArray(a) || (a = s(a) ? f(a).get() : [a]), f.each(a, function (e, c) {
var j = {},
g,
h,
i,
l,
k;
"object" === f.type(c) && (c.nodeType && (c = f(c)), s(c) ? (j = {
href : c.data("fancybox-href") || c.attr("href"),
title : c.data("fancybox-title") || c.attr("title"),
isDom : !0,
element : c
}, f.metadata && f.extend(!0,
j, c.metadata())) : j = c);
g = d.href || j.href || (p(c) ? c : null);
h = d.title !== q ? d.title : j.title || "";
l = (i = d.content || j.content) ? "html" : d.type || j.type;
!l && j.isDom && (l = c.data("fancybox-type"), l || (l = (l = c.prop("class").match(/fancybox\.(\w+)/)) ? l[1] : null));
p(g) && (l || (b.isImage(g) ? l = "image" : b.isSWF(g) ? l = "swf" : "#" === g.charAt(0) ? l = "inline" : p(c) && (l = "html", i = c)), "ajax" === l && (k = g.split(/\s+/, 2), g = k.shift(), k = k.shift()));
i || ("inline" === l ? g ? i = f(p(g) ? g.replace(/.*(?=#[^\s]+$)/, "") : g) : j.isDom && (i = c) : "html" === l ? i = g : !l && (!g &&
j.isDom) && (l = "inline", i = c));
f.extend(j, {
href : g,
type : l,
content : i,
title : h,
selector : k
});
a[e] = j
}), b.opts = f.extend(!0, {}, b.defaults, d), d.keys !== q && (b.opts.keys = d.keys ? f.extend({}, b.defaults.keys, d.keys) : !1), b.group = a, b._start(b.opts.index)
},
cancel : function () {
var a = b.coming;
a && !1 !== b.trigger("onCancel") && (b.hideLoading(), b.ajaxLoad && b.ajaxLoad.abort(), b.ajaxLoad = null, b.imgPreload && (b.imgPreload.onload = b.imgPreload.onerror = null), a.wrap && a.wrap.stop(!0, !0).trigger("onReset").remove(), b.coming = null, b.current ||
b._afterZoomOut(a))
},
close : function (a) {
b.cancel();
!1 !== b.trigger("beforeClose") && (b.unbindEvents(), b.isActive && (!b.isOpen || !0 === a ? (f(".fancybox-wrap").stop(!0).trigger("onReset").remove(), b._afterZoomOut()) : (b.isOpen = b.isOpened = !1, b.isClosing = !0, f(".fancybox-item, .fancybox-nav").remove(), b.wrap.stop(!0, !0).removeClass("fancybox-opened"), b.transitions[b.current.closeMethod]())))
},
play : function (a) {
var d = function () {
clearTimeout(b.player.timer)
},
e = function () {
d();
b.current && b.player.isActive && (b.player.timer =
setTimeout(b.next, b.current.playSpeed))
},
c = function () {
d();
f("body").unbind(".player");
b.player.isActive = !1;
b.trigger("onPlayEnd")
};
if (!0 === a || !b.player.isActive && !1 !== a) {
if (b.current && (b.current.loop || b.current.index < b.group.length - 1))
b.player.isActive = !0, f("body").bind({
"afterShow.player onUpdate.player" : e,
"onCancel.player beforeClose.player" : c,
"beforeLoad.player" : d
}), e(), b.trigger("onPlayStart")
} else
c()
},
next : function (a) {
var d = b.current;
d && (p(a) || (a = d.direction.next), b.jumpto(d.index + 1, a, "next"))
},
prev : function (a) {
var d = b.current;
d && (p(a) || (a = d.direction.prev), b.jumpto(d.index - 1, a, "prev"))
},
jumpto : function (a, d, e) {
var c = b.current;
c && (a = k(a), b.direction = d || c.direction[a >= c.index ? "next" : "prev"], b.router = e || "jumpto", c.loop && (0 > a && (a = c.group.length + a % c.group.length), a %= c.group.length), c.group[a] !== q && (b.cancel(), b._start(a)))
},
reposition : function (a, d) {
var e = b.current,
c = e ? e.wrap : null,
j;
c && (j = b._getPosition(d), a && "scroll" === a.type ? (delete j.position, c.stop(!0, !0).animate(j, 200)) : (c.css(j), e.pos = f.extend({},
e.dim, j)))
},
update : function (a) {
var d = a && a.type,
e = !d || "orientationchange" === d;
e && (clearTimeout(u), u = null);
b.isOpen && !u && (u = setTimeout(function () {
var c = b.current;
c && !b.isClosing && (b.wrap.removeClass("fancybox-tmp"), (e || "load" === d || "resize" === d && c.autoResize) && b._setDimension(), "scroll" === d && c.canShrink || b.reposition(a), b.trigger("onUpdate"), u = null)
}, e && !n ? 0 : 300))
},
toggle : function (a) {
b.isOpen && (b.current.fitToView = "boolean" === f.type(a) ? a : !b.current.fitToView, n && (b.wrap.removeAttr("style").addClass("fancybox-tmp"),
b.trigger("onUpdate")), b.update())
},
hideLoading : function () {
m.unbind(".loading");
f("#fancybox-loading").remove()
},
showLoading : function () {
var a,
d;
b.hideLoading();
a = f('<div id="fancybox-loading"><div></div></div>').click(b.cancel).appendTo("body");
m.bind("keydown.loading", function (a) {
if (27 === (a.which || a.keyCode))
a.preventDefault(), b.cancel()
});
b.defaults.fixed || (d = b.getViewport(), a.css({
position : "absolute",
top : 0.5 * d.h + d.y,
left : 0.5 * d.w + d.x
}))
},
getViewport : function () {
var a = b.current && b.current.locked ||
!1,
d = {
x : r.scrollLeft(),
y : r.scrollTop()
};
a ? (d.w = a[0].clientWidth, d.h = a[0].clientHeight) : (d.w = n && B.innerWidth ? B.innerWidth : r.width(), d.h = n && B.innerHeight ? B.innerHeight : r.height());
return d
},
unbindEvents : function () {
b.wrap && s(b.wrap) && b.wrap.unbind(".fb");
m.unbind(".fb");
r.unbind(".fb")
},
bindEvents : function () {
var a = b.current,
d;
a && (r.bind("orientationchange.fb" + (n ? "" : " resize.fb") + (a.autoCenter && !a.locked ? " scroll.fb" : ""), b.update), (d = a.keys) && m.bind("keydown.fb", function (e) {
var c = e.which || e.keyCode,
j =
e.target || e.srcElement;
if (27 === c && b.coming)
return !1;
!e.ctrlKey && (!e.altKey && !e.shiftKey && !e.metaKey && (!j || !j.type && !f(j).is("[contenteditable]"))) && f.each(d, function (d, j) {
if (1 < a.group.length && j[c] !== q)
return b[d](j[c]), e.preventDefault(), !1;
if (-1 < f.inArray(c, j))
return b[d](), e.preventDefault(), !1
})
}), f.fn.mousewheel && a.mouseWheel && b.wrap.bind("mousewheel.fb", function (d, c, j, g) {
for (var h = f(d.target || null), i = !1; h.length && !i && !h.is(".fancybox-skin") && !h.is(".fancybox-wrap"); )
i = h[0] && !(h[0].style.overflow &&
"hidden" === h[0].style.overflow) && (h[0].clientWidth && h[0].scrollWidth > h[0].clientWidth || h[0].clientHeight && h[0].scrollHeight > h[0].clientHeight), h = f(h).parent();
if (0 !== c && !i && 1 < b.group.length && !a.canShrink) {
if (0 < g || 0 < j)
b.prev(0 < g ? "down" : "left");
else if (0 > g || 0 > j)
b.next(0 > g ? "up" : "right");
d.preventDefault()
}
}))
},
trigger : function (a, d) {
var e,
c = d || b.coming || b.current;
if (c) {
f.isFunction(c[a]) && (e = c[a].apply(c, Array.prototype.slice.call(arguments, 1)));
if (!1 === e)
return !1;
c.helpers && f.each(c.helpers, function (d,
e) {
e && (b.helpers[d] && f.isFunction(b.helpers[d][a])) && (e = f.extend(!0, {}, b.helpers[d].defaults, e), b.helpers[d][a](e, c))
});
f.event.trigger(a + ".fb")
}
},
isImage : function (a) {
return p(a) && a.match(/(^data:image\/.*,)|(\.(jp(e|g|eg)|gif|png|bmp|webp)((\?|#).*)?$)/i)
},
isSWF : function (a) {
return p(a) && a.match(/\.(swf)((\?|#).*)?$/i)
},
_start : function (a) {
var d = {},
e,
c,
a = k(a);
e = b.group[a] || null;
if (!e)
return !1;
d = f.extend(!0, {}, b.opts, e);
e = d.margin;
c = d.padding;
"number" === f.type(e) && (d.margin = [e, e, e, e]);
"number" === f.type(c) &&
(d.padding = [c, c, c, c]);
d.modal && f.extend(!0, d, {
closeBtn : !1,
closeClick : !1,
nextClick : !1,
arrows : !1,
mouseWheel : !1,
keys : null,
helpers : {
overlay : {
closeClick : !1
}
}
});
d.autoSize && (d.autoWidth = d.autoHeight = !0);
"auto" === d.width && (d.autoWidth = !0);
"auto" === d.height && (d.autoHeight = !0);
d.group = b.group;
d.index = a;
b.coming = d;
if (!1 === b.trigger("beforeLoad"))
b.coming = null;
else {
c = d.type;
e = d.href;
if (!c)
return b.coming = null, b.current && b.router && "jumpto" !== b.router ? (b.current.index = a, b[b.router](b.direction)) : !1;
b.isActive =
!0;
if ("image" === c || "swf" === c)
d.autoHeight = d.autoWidth = !1, d.scrolling = "visible";
"image" === c && (d.aspectRatio = !0);
"iframe" === c && n && (d.scrolling = "scroll");
d.wrap = f(d.tpl.wrap).addClass("fancybox-" + (n ? "mobile" : "desktop") + " fancybox-type-" + c + " fancybox-tmp " + d.wrapCSS).appendTo(d.parent || "body");
f.extend(d, {
skin : f(".fancybox-skin", d.wrap),
outer : f(".fancybox-outer", d.wrap),
inner : f(".fancybox-inner", d.wrap)
});
f.each(["Top", "Right", "Bottom", "Left"], function (a, b) {
d.skin.css("padding" + b, v(d.padding[a]))
});
b.trigger("onReady");
if ("inline" === c || "html" === c) {
if (!d.content || !d.content.length)
return b._error("content")
} else if (!e)
return b._error("href");
"image" === c ? b._loadImage() : "ajax" === c ? b._loadAjax() : "iframe" === c ? b._loadIframe() : b._afterLoad()
}
},
_error : function (a) {
f.extend(b.coming, {
type : "html",
autoWidth : !0,
autoHeight : !0,
minWidth : 0,
minHeight : 0,
scrolling : "no",
hasError : a,
content : b.coming.tpl.error
});
b._afterLoad()
},
_loadImage : function () {
var a = b.imgPreload = new Image;
a.onload = function () {
this.onload = this.onerror = null;
b.coming.width =
this.width;
b.coming.height = this.height;
b._afterLoad()
};
a.onerror = function () {
this.onload = this.onerror = null;
b._error("image")
};
a.src = b.coming.href;
!0 !== a.complete && b.showLoading()
},
_loadAjax : function () {
var a = b.coming;
b.showLoading();
b.ajaxLoad = f.ajax(f.extend({}, a.ajax, {
url : a.href,
error : function (a, e) {
b.coming && "abort" !== e ? b._error("ajax", a) : b.hideLoading()
},
success : function (d, e) {
"success" === e && (a.content = d, b._afterLoad())
}
}))
},
_loadIframe : function () {
var a = b.coming,
d = f(a.tpl.iframe.replace(/\{rnd\}/g,
(new Date).getTime())).attr("scrolling", n ? "auto" : a.iframe.scrolling).attr("src", a.href);
f(a.wrap).bind("onReset", function () {
try {
f(this).find("iframe").hide().attr("src", "//about:blank").end().empty()
} catch (a) {}
});
a.iframe.preload && (b.showLoading(), d.one("load", function () {
f(this).data("ready", 1);
n || f(this).bind("load.fb", b.update);
f(this).parents(".fancybox-wrap").width("100%").removeClass("fancybox-tmp").show();
b._afterLoad()
}));
a.content = d.appendTo(a.inner);
a.iframe.preload || b._afterLoad()
},
_preloadImages : function () {
var a =
b.group,
d = b.current,
e = a.length,
c = d.preload ? Math.min(d.preload, e - 1) : 0,
f,
g;
for (g = 1; g <= c; g += 1)
f = a[(d.index + g) % e], "image" === f.type && f.href && ((new Image).src = f.href)
},
_afterLoad : function () {
var a = b.coming,
d = b.current,
e,
c,
j,
g,
h;
b.hideLoading();
if (a && !1 !== b.isActive)
if (!1 === b.trigger("afterLoad", a, d))
a.wrap.stop(!0).trigger("onReset").remove(), b.coming = null;
else {
d && (b.trigger("beforeChange", d), d.wrap.stop(!0).removeClass("fancybox-opened").find(".fancybox-item, .fancybox-nav").remove());
b.unbindEvents();
e = a.content;
c = a.type;
j = a.scrolling;
f.extend(b, {
wrap : a.wrap,
skin : a.skin,
outer : a.outer,
inner : a.inner,
current : a,
previous : d
});
g = a.href;
switch (c) {
case "inline":
case "ajax":
case "html":
a.selector ? e = f("<div>").html(e).find(a.selector) : s(e) && (e.data("fancybox-placeholder") || e.data("fancybox-placeholder", f('<div class="fancybox-placeholder"></div>').insertAfter(e).hide()), e = e.show().detach(), a.wrap.bind("onReset", function () {
f(this).find(e).length && e.hide().replaceAll(e.data("fancybox-placeholder")).data("fancybox-placeholder",
!1)
}));
break;
case "image":
e = a.tpl.image.replace("{href}", g);
break;
case "swf":
e = '<object id="fancybox-swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="100%" height="100%"><param name="movie" value="' + g + '"></param>',
h = "",
f.each(a.swf, function (a, b) {
e += '<param name="' + a + '" value="' + b + '"></param>';
h += " " + a + '="' + b + '"'
}),
e += '<embed src="' + g + '" type="application/x-shockwave-flash" width="100%" height="100%"' + h + "></embed></object>"
}
(!s(e) || !e.parent().is(a.inner)) && a.inner.append(e);
b.trigger("beforeShow");
a.inner.css("overflow", "yes" === j ? "scroll" : "no" === j ? "hidden" : j);
b._setDimension();
b.reposition();
b.isOpen = !1;
b.coming = null;
b.bindEvents();
if (b.isOpened) {
if (d.prevMethod)
b.transitions[d.prevMethod]()
} else
f(".fancybox-wrap").not(a.wrap).stop(!0).trigger("onReset").remove();
b.transitions[b.isOpened ? a.nextMethod : a.openMethod]();
b._preloadImages()
}
},
_setDimension : function () {
var a = b.getViewport(),
d = 0,
e = !1,
c = !1,
e = b.wrap,
j = b.skin,
g = b.inner,
h = b.current,
c = h.width,
i = h.height,
l = h.minWidth,
t = h.minHeight,
m = h.maxWidth,
n = h.maxHeight,
r = h.scrolling,
p = h.scrollOutside ? h.scrollbarWidth : 0,
w = h.margin,
y = k(w[1] + w[3]),
q = k(w[0] + w[2]),
x,
z,
s,
C,
A,
F,
B,
D,
u;
e.add(j).add(g).width("auto").height("auto").removeClass("fancybox-tmp");
w = k(j.outerWidth(!0) - j.width());
x = k(j.outerHeight(!0) - j.height());
z = y + w;
s = q + x;
C = E(c) ? (a.w - z) * k(c) / 100 : c;
A = E(i) ? (a.h - s) * k(i) / 100 : i;
if ("iframe" === h.type) {
if (u = h.content, h.autoHeight && 1 === u.data("ready"))
try {
u[0].contentWindow.document.location && (g.width(C).height(9999), F = u.contents().find("body"), p && F.css("overflow-x",
"hidden"), A = F.height())
} catch (G) {}
} else if (h.autoWidth || h.autoHeight)
g.addClass("fancybox-tmp"), h.autoWidth || g.width(C), h.autoHeight || g.height(A), h.autoWidth && (C = g.width()), h.autoHeight && (A = g.height()), g.removeClass("fancybox-tmp");
c = k(C);
i = k(A);
D = C / A;
l = k(E(l) ? k(l, "w") - z : l);
m = k(E(m) ? k(m, "w") - z : m);
t = k(E(t) ? k(t, "h") - s : t);
n = k(E(n) ? k(n, "h") - s : n);
F = m;
B = n;
h.fitToView && (m = Math.min(a.w - z, m), n = Math.min(a.h - s, n));
z = a.w - y;
q = a.h - q;
h.aspectRatio ? (c > m && (c = m, i = k(c / D)), i > n && (i = n, c = k(i * D)), c < l && (c = l, i = k(c / D)), i < t &&
(i = t, c = k(i * D))) : (c = Math.max(l, Math.min(c, m)), h.autoHeight && "iframe" !== h.type && (g.width(c), i = g.height()), i = Math.max(t, Math.min(i, n)));
if (h.fitToView)
if (g.width(c).height(i), e.width(c + w), a = e.width(), y = e.height(), h.aspectRatio)
for (; (a > z || y > q) && (c > l && i > t) && !(19 < d++); )
i = Math.max(t, Math.min(n, i - 10)), c = k(i * D), c < l && (c = l, i = k(c / D)), c > m && (c = m, i = k(c / D)), g.width(c).height(i), e.width(c + w), a = e.width(), y = e.height();
else
c = Math.max(l, Math.min(c, c - (a - z))), i = Math.max(t, Math.min(i, i - (y - q)));
p && ("auto" === r && i < A && c + w +
p < z) && (c += p);
g.width(c).height(i);
e.width(c + w);
a = e.width();
y = e.height();
e = (a > z || y > q) && c > l && i > t;
c = h.aspectRatio ? c < F && i < B && c < C && i < A : (c < F || i < B) && (c < C || i < A);
f.extend(h, {
dim : {
width : v(a),
height : v(y)
},
origWidth : C,
origHeight : A,
canShrink : e,
canExpand : c,
wPadding : w,
hPadding : x,
wrapSpace : y - j.outerHeight(!0),
skinSpace : j.height() - i
});
!u && (h.autoHeight && i > t && i < n && !c) && g.height("auto")
},
_getPosition : function (a) {
var d = b.current,
e = b.getViewport(),
c = d.margin,
f = b.wrap.width() + c[1] + c[3],
g = b.wrap.height() + c[0] + c[2],
c = {
position : "absolute",
top : c[0],
left : c[3]
};
d.autoCenter && d.fixed && !a && g <= e.h && f <= e.w ? c.position = "fixed" : d.locked || (c.top += e.y, c.left += e.x);
c.top = v(Math.max(c.top, c.top + (e.h - g) * d.topRatio));
c.left = v(Math.max(c.left, c.left + (e.w - f) * d.leftRatio));
return c
},
_afterZoomIn : function () {
var a = b.current;
a && (b.isOpen = b.isOpened = !0, b.wrap.css("overflow", "visible").addClass("fancybox-opened"), b.update(), (a.closeClick || a.nextClick && 1 < b.group.length) && b.inner.css("cursor", "pointer").bind("click.fb", function (d) {
!f(d.target).is("a") && !f(d.target).parent().is("a") &&
(d.preventDefault(), b[a.closeClick ? "close" : "next"]())
}), a.closeBtn && f(a.tpl.closeBtn).appendTo(b.skin).bind(n ? "touchstart.fb" : "click.fb", function (a) {
a.preventDefault();
b.close()
}), a.arrows && 1 < b.group.length && ((a.loop || 0 < a.index) && f(a.tpl.prev).appendTo(b.outer).bind("click.fb", b.prev), (a.loop || a.index < b.group.length - 1) && f(a.tpl.next).appendTo(b.outer).bind("click.fb", b.next)), b.trigger("afterShow"), !a.loop && a.index === a.group.length - 1 ? b.play(!1) : b.opts.autoPlay && !b.player.isActive && (b.opts.autoPlay =
!1, b.play()))
},
_afterZoomOut : function (a) {
a = a || b.current;
f(".fancybox-wrap").trigger("onReset").remove();
f.extend(b, {
group : {},
opts : {},
router : !1,
current : null,
isActive : !1,
isOpened : !1,
isOpen : !1,
isClosing : !1,
wrap : null,
skin : null,
outer : null,
inner : null
});
b.trigger("afterClose", a)
}
});
b.transitions = {
getOrigPosition : function () {
var a = b.current,
d = a.element,
e = a.orig,
c = {},
f = 50,
g = 50,
h = a.hPadding,
i = a.wPadding,
l = b.getViewport();
!e && (a.isDom && d.is(":visible")) && (e = d.find("img:first"), e.length || (e = d));
s(e) ? (c = e.offset(),
e.is("img") && (f = e.outerWidth(), g = e.outerHeight())) : (c.top = l.y + (l.h - g) * a.topRatio, c.left = l.x + (l.w - f) * a.leftRatio);
if ("fixed" === b.wrap.css("position") || a.locked)
c.top -= l.y, c.left -= l.x;
return c = {
top : v(c.top - h * a.topRatio),
left : v(c.left - i * a.leftRatio),
width : v(f + i),
height : v(g + h)
}
},
step : function (a, d) {
})
})(window, document, jQuery);

Related

make a function which calculate the number of same nearby character in flutter like aabcddaabb => 2abc2d2a2b

can anybody help me to build the function mentioned above I am using dart in the flutter and want this function
make a function which calculate the number of same nearby character in flutter like aabcddaabb => 2abc2d2a2b
Same
void main() {
var input = 'aabcddaabb';
print(getret(input));
}
String getret(String input) {
var ret = '';
var cc = '';
var co = 0;
cut(){
var c = input[0];
input = input.substring(1);
return c;
}
write(){
if(co == 1) ret = '$ret$cc';
if(co > 1) ret = '$ret$co$cc';
}
while(input.isNotEmpty){
final c = cut();
if(c != cc){
write();
cc = c;
co = 1;
}else{
co ++;
}
}
write();
return ret; // 2abc2d2a2b
}
There's probably a smarter and shorter way to do it, but here's a possible solution:
String string = 'aaabcddaabb';
String result = '';
String lastMatch = '';
int count = 0;
while (string.isNotEmpty) {
if (string[0] != lastMatch) {
result += '${count > 1 ? count : ''}$lastMatch';
lastMatch = string[0];
count = 0;
}
count++;
string = string.substring(1);
}
result += '${count > 1 ? count : ''}$lastMatch';
print(result); //3abc2d2a2b
I also came up with this smarter solution. Even though it's nice that it's a single expression it's maybe not very readable:
String string = 'aaabcddaabb';
String result = string.split('').fold<String>(
'',
(r, e) => r.isNotEmpty && e == r[r.length - 1]
? r.length > 1 &&
int.tryParse(r.substring(r.length - 2, r.length - 1)) != null
? '${r.substring(0, r.length - 2)}${int.parse(r.substring(r.length - 2, r.length - 1)) + 1}$e'
: '${r.substring(0, r.length - 1)}2$e'
: '$r$e');
print(result); //3abc2d2a2b

Unable to create a constant value of type <object>. Only primitive types or enumeration types are supported in this context

I am using the following code:
public static Grid.GridResult GetExamDetailsForGrid(Grid.GridFilter Filter, int userid, int _user_roleid, int selectedYear,string Tin,string Measure, DateTime? Startdate, DateTime? Enddate)
{
Grid.GridResult _examsEntered = new Grid.GridResult();
using (var entity = new PQRSEntityContainer())
{
((IObjectContextAdapter)entity).ObjectContext.CommandTimeout = 120;
var Measureid = 0;
if(!string.IsNullOrEmpty(Measure))
{
Measureid = entity.tbl_Lookup_Measure.Where(m => m.CMSYear == selectedYear && m.Measure_num == Measure)
.Select(v => v.Measure_ID).FirstOrDefault();
}
var _username = CurrentUser.UserName;
var npi = FileProcessBL.getNPINumber(userid);
var cmsYear = selectedYear != 0 ? selectedYear : 0;
var Newtin= string.IsNullOrEmpty(Tin) ? null : Tin;
var NewStartdate = Startdate ==null ? null : Startdate;
var NewEnddate = Enddate == null ? null : Enddate;
var NewMes= string.IsNullOrEmpty(Measure) ? null : Measure;
var liDetails = (from ex in entity.tbl_Exam.Where(i => i.Physician_NPI == npi && i.CMS_Submission_Year == cmsYear
&& i.Exam_TIN == (Newtin==null?i.Exam_TIN:Newtin)
&& i.Exam_Date >= (NewStartdate == null ? i.Exam_Date : NewStartdate)
&& i.Exam_Date <= (NewEnddate == null ? i.Exam_Date : NewEnddate))
from exmes in entity.tbl_Exam_Measure_Data.Where(i => i.Exam_Id == ex.Exam_Id
&& i.Measure_ID== (Measureid == 0 ? i.Measure_ID : Measureid) ).DefaultIfEmpty()
from nume in entity.tbl_lookup_Numerator_Code.Where(nume => exmes.tbl_Lookup_Measure.Measure_ID == nume.tbl_Lookup_Measure.Measure_ID && exmes.Numerator_response_value == nume.Numerator_response_Value).DefaultIfEmpty()
join sc in entity.tbl_Lookup_Data_Source on ex.DataSource_Id equals sc.DataSource_Id
where exmes.Exam_Id != null
select new MesCasesGrid
{
NPI = ex.Physician_NPI,
TIN = ex.Exam_TIN == null ? "" : ex.Exam_TIN,
ExamID = ex.Exam_Id,
//MeasureID = exMes.Measure_ID,
MeasureID = (exmes != null) ? exmes.Measure_ID : 0,
MeasureNum = (exmes != null) ? exmes.tbl_Lookup_Measure.Measure_num : null,
CPTCode = (exmes != null) ? exmes.Denominator_proc_code : null,
///NumeratorCode = (exmes!=null)?exmes.tbl_Lookup_Measure.tbl_lookup_Numerator_Code.Select(i=>i.Numerator_Code).FirstOrDefault():null,
NumeratorCode = nume.Numerator_Code,
Created_Date = ex.Created_Date,
ExamDate = ex.Exam_Date,
UniqueExamID = ex.Exam_Unique_ID,
PatientGender = (ex.Patient_Gender == "M" ? "Male" : ex.Patient_Gender == "F" ? "Female" : ex.Patient_Gender == "O" ? "Other" : ex.Patient_Gender == "U" ? "Unknown" : ""),
PatientID = ex.Patient_ID,
isEncrypt = ex.IsEncrypt,
PatientAge = ex.Patient_Age,
StatusDesc = (exmes != null) ? exmes.tbl_Lookup_Measure_Status.Status_Desc : null,
///Type =ex.DataSource,
Type = sc.DataSource,
cmsYear = ex.CMS_Submission_Year
}).Distinct().ToList();
if (_user_roleid == Constants.FacilityAdminID || _user_roleid == Constants.FacilityUserID || _user_roleid == Constants.RegistryAdminID
|| _user_roleid == Constants.SuperCorporateAdminID || _user_roleid == Constants.CorporateAdminID || _user_roleid == Constants.ServiceUserID) // jira-579
{
var facilityTins = entity.sp_getFacilityTIN(_username).Select(x => x.TIN).ToList();
liDetails = liDetails.Where(i => facilityTins.Contains(i.TIN)).Select(x => x).Distinct().ToList();
}
var value = Convert.ToBoolean(1);
foreach (var item in liDetails)
{
if (item.isEncrypt == value && item.PatientID != null)
{
try
{
var patidDecrypt = AesHelper.Decrypt256(item.PatientID);
item.PatientID = patidDecrypt;
}
catch (Exception ex)
{
}
}
}
return _examsEntered;
}
}
I have recently added the following code above method:
i.Measure_ID == && i.Measure_ID== (Measureid == 0 ? i.Measure_ID : Measureid)
When adding the highlighted code to this method I am getting following error:
:Error in RecordEnteredGridBind()
System.NotSupportedException: Unable to create a constant value of type 'DAL.Entities.tbl_Exam_Measure_Data'. Only primitive types or enumeration types are supported in this context.
at System.Data.Objects.ELinq.ExpressionConverter.ConstantTranslator.TypedTranslate(ExpressionConverter parent, ConstantExpression linq)
at System.Data.Objects.ELinq.ExpressionConverter.TypedTranslator1.Translate(ExpressionConverter parent, Expression linq)
at System.Data.Objects.ELinq.ExpressionConverter.TranslateExpression(Expression linq)
at System.Data.Objects.ELinq.ExpressionConverter.NewArrayInitTranslator.<>c__DisplayClass1_0.<TypedTranslate>b__0(Expression e)
at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()
at System.Data.Common.CommandTrees.ExpressionBuilder.Internal.EnumerableValidator3.Validate(IEnumerable1 argument, String argumentName, Int32 expectedElementCount, Boolean allowEmpty, Func3 map, Func2 collect, Func3 deriveName)
at System.Data.Common.CommandTrees.ExpressionBuilder.Internal.EnumerableValidator3.Validate()
at System.Data.Common.CommandTrees.ExpressionBuilder.Internal.ArgumentValidation.CreateExpressionList(IEnumerable1 arguments, String argumentName, Boolean allowEmpty, Action2 validationCallback)
at System.Data.Common.CommandTrees.ExpressionBuilder.Internal.ArgumentValidation.ValidateNewCollection(IEnumerable`1 elements, DbExpressionList& validElements)
I have tried lot of ways but not working. So, Can anyone help me?

Unable to register new color javascript tracking.js

I'm trying to add an identification to a green color.
All default colors work fine but I have not been able to add a new color for color with camera.
for more info : ColorTracker
window.onload = function() {
var video = document.getElementById('video');
var canvas = document.getElementById('canvas');
var context = canvas.getContext('2d');
var tracker = new tracking.ColorTracker();
tracking.ColorTracker.registerColor('green', function (r, g, b) {
if (r < 50 && g > 200 && b < 50) {
return true;
}
return false;
});
tracking.track('#video', tracker, { camera: true });
tracker.on('track', function(event) {
context.clearRect(0, 0, canvas.width, canvas.height);
event.data.forEach(function(rect) {
if (rect.color === 'custom') {
rect.color = tracker.customColor;
}
context.strokeStyle = rect.color;
context.strokeRect(rect.x, rect.y, rect.width, rect.height);
context.font = '11px Helvetica';
context.fillStyle = "#fff";
context.fillText('x: ' + rect.x + 'px', rect.x + rect.width + 5, rect.y + 11);
context.fillText('y: ' + rect.y + 'px', rect.x + rect.width + 5, rect.y + 22);
});
});
initGUIControllers(tracker);
};
You are doing it right, just the color tracking is very picky. It will choose whatever is closest to the G in the RGB color. It does pick up some black and other colors because of that. I would recommend getting the RGB color of the exact green you want to track and go off of that. I included the few I have working in my project( this does not mean these will work for your green)
tracking.ColorTracker.registerColor('darkgreen', function (r, g, b) {
if (r < 120 && r > 80 && g < 150 && b < 70) {
return true;
}
return false;
});
tracking.ColorTracker.registerColor('lightgreen', function (r, g, b) {
if (r < 30 && g < 100 && b < 30) {
return true;
}
return false;
});
tracking.ColorTracker.registerColor('green', function (r, g, b) {
if (r < 30 && g < 50 && b < 30) {
return true;
}
return false;
});

coffeescript strange behavior in subtraction

I must be going crazy. Coffeescript is continualy returning '0' for the difference between two non-equal integers.
x = #location[0]
y = #start[0]
console.log "#{x} - #{y} = #{x-y}"
This is outputting:
350 - 322 = 0
250 - 278 = 0
... and so on
I'm completely confused!
Edit: Here's the source in both coffee and the compiled js
class Branch
constructor: (#length, #start, #angle, #generation, #parent) ->
return if #generation >= RECURSION_LIMIT
#angleVariation = pi/3
#ratio = 2/(1+root(5))
#maxChildren = 10
#parent ?= null
#unit = 2
#children = []
#location = #start
#childLocations = [Math.random()*#length*#ratio/2+(#length*#ratio) \
for n in [0...#maxChildren]]
grow: ->
gl.beginPath()
moveTo #location
#location[0] += #unit * cos(#angle)
#location[1] -= #unit * sin(#angle)
lineTo #location
gl.stroke()
console.log #getLength()
if #getLength() >= #childLocations[#children.length]
#birthChild()
getLength: ->
x = #location[1]
y = #start[1]
console.log "#{x} - #{y} = #{x-y}"
return 1 #root( (#location[0]-#start[0])**2 + (#location[1]-#start[1])**2 )
birthChild: ->
angle = #angle + (Math.random()*#angleVariation*2) - #angleVariation
child = new Branch #length * #ratio, #location, angle, #generation+1, this
And in js:
Branch = (function() {
function Branch(length, start, angle, generation, parent) {
var n, _ref;
this.length = length;
this.start = start;
this.angle = angle;
this.generation = generation;
this.parent = parent;
if (this.generation >= RECURSION_LIMIT) {
return;
}
this.angleVariation = pi / 3;
this.ratio = 2 / (1 + root(5));
this.maxChildren = 10;
if ((_ref = this.parent) == null) {
this.parent = null;
}
this.unit = 2;
this.children = [];
this.location = this.start;
this.childLocations = [
(function() {
var _i, _ref1, _results;
_results = [];
for (n = _i = 0, _ref1 = this.maxChildren; 0 <= _ref1 ? _i < _ref1 : _i > _ref1; n = 0 <= _ref1 ? ++_i : --_i) {
_results.push(Math.random() * this.length * this.ratio / 2 + (this.length * this.ratio));
}
return _results;
}).call(this)
];
}
Branch.prototype.grow = function() {
gl.beginPath();
moveTo(this.location);
this.location[0] += this.unit * cos(this.angle);
this.location[1] -= this.unit * sin(this.angle);
lineTo(this.location);
gl.stroke();
console.log(this.getLength());
if (this.getLength() >= this.childLocations[this.children.length]) {
return this.birthChild();
}
};
Branch.prototype.getLength = function() {
var x, y;
x = this.location[1];
y = this.start[1];
console.log("" + x + " - " + y + " = " + (x - y));
return 1;
};
Branch.prototype.birthChild = function() {
var angle, child;
angle = this.angle + (Math.random() * this.angleVariation * 2) - this.angleVariation;
return child = new Branch(this.length * this.ratio, this.location, angle, this.generation + 1, this);
};
return Branch;
})();

can't access static method of a simple cs file in xaml.cs file

I'm creating an app for my semester project. In this project I have a simple class file and a few xaml pages. In one xaml page the code checks the value of a string and depending on that value runs a countdown timer. If the value of string is equal to a certain string then it should call a method from simple class where the value of string is changed and then it should navigate to the next xaml page.
When I call the function the application breaks. No error or anything, it just breaks. I don't know why. I have called other functions of same class file in other xaml files and they work perfect but here I'm having trouble. I guess it has something to do with timer.
xaml.cs:
namespace TrafficGuru
{
public partial class Page2 : PhoneApplicationPage
{
DispatcherTimer countDownTimer;
int check;
public Page2()
{
InitializeComponent();
tbl.Text = global.str;
if (global.str == "YOUR LIGHT IS ON FOR : ")
{
check = 0;
}
if (global.str == "YOUR LIGHT WILL BE ON IN:")
{
check = 1;
}
if (global.str == "YOUR LIGHT WILL NOT BE ON FOR UNTIL ATLEAST " + global.x * 15 + " MORE SECS.YOU WILL GET AN UPDATE IN:")
{
check = 2;
}
countDownTimer = new DispatcherTimer();
countDownTimer.Interval = new TimeSpan(0, 0, 0, 1);
countDownTimer.Tick += new EventHandler(countDownTimerEvent);
countDownTimer.Start();
test.Content = "" + "seconds remaining";
}
int count = global.cdt;
void test_Click(object sender, EventArgs e) { }
void countDownTimerEvent(object sender, EventArgs e)
{
test.Content = count + " Seconds";
if (count > 0)
{
count--;
}
else if (count == 0)
{
if (check == 0)
{
test.Content = "STOP!!";
}
else if (check == 1)
{
test.Content = "GO!!!";
}
if(check==2)
{
string x= global.rego();//the method i m trying to call its public and static
NavigationService.Navigate(new Uri("/Page3.xaml", UriKind.RelativeOrAbsolute));*/
}
}
}
}
}
globalx class code::
if (x == 1)
{
str = "YOUR LIGHT WILL BE ON IN:";
}
cdt = x*15;
l[m].resetcount();
a[m] = 0;
l[m].setlight("RED");
c = 9;
}
if (l[0].getcount() == 0 || s > 0)
{
l[0].Createcar();
}
a[0] += l[0].getcount();
t[0] = l[0].gettime();
if (l[1].getcount() == 0 || s > 0)
{
l[1].Createcar();
}
a[1] += l[1].getcount();
t[1] = l[1].gettime();
if (l[2].getcount() == 0 || s > 0)
{
l[2].Createcar();
}
a[2] = l[2].getcount();
t[2] = l[2].gettime();
if (l[3].getcount() == 0 || s > 0)
{
l[3].Createcar();
}
a[3] += l[3].getcount();
t[3] = l[3].gettime();
s++;
if (s % 2 != 0)
{
var now1 = DateTime.Now;
tv = (now1 - begin).TotalMilliseconds;
tym = Convert.ToInt32(tv);
int[] pkl = { 0, 0 };
maxi(a, t, s, tym, ref pkl);
m = pkl[0];
}
else
{
var now1 = DateTime.Now;
tv = (now1 - begin).TotalMilliseconds;
tym = Convert.ToInt32(tv);
int[] pkj = { 0, 0 };
maxi(a, t, s, tym, ref pkj);
q = pkj[0];
}
return str;
}
COMPLETE GLOBAL CLASS WITH GO AND REGO
public static class globalx
{
public static int n;
public static int s;
public static int m;
public static int q;
public static int c;
public static int f;
public static lane[] l = new lane[4];
public static double tv;
public static int tym;
public static int[] a = { 0, 0, 0, 0 };
public static int[] t = new int[4];
public static string str="asdf";
public static int cdt; //countdowntime
public static int x;
public static DateTime begin;
public static void start()
{
begin = DateTime.Now;
for (int i = 0; i < 4; i++)
{ l[i] = new lane(); }
var now = DateTime.Now;
tv = (now - begin).TotalMilliseconds;
tym = Convert.ToInt32(tv);
l[0].Createcar();
a[0] += l[0].getcount();
t[0] = l[0].gettime();
l[1].Createcar();
a[1] += l[1].getcount();
t[1] = l[1].gettime();
l[2].Createcar();
a[2] += l[2].getcount();
t[2] = l[2].gettime();
l[3].Createcar();
a[3] += l[3].getcount();
t[3] = l[3].gettime();
now = DateTime.Now;
tv = (now - begin).TotalMilliseconds;
tym = Convert.ToInt32(tv);
int[] r = { 88, 99 };
maxi(a, t, s, tym, ref r);
m = r[0];
q = r[1];
c = 0;
f = 9;
}
public static string go()
{
l[m].setlight("GREEN");
var now = DateTime.Now;
tv = (now - begin).TotalMilliseconds;
tym = Convert.ToInt32(tv);
l[m].settime(tym);
if (n == m + 1)
{
c = 0;
str = "YOUR LIGHT IS ON FOR : ";
cdt = 15;
l[m].resetcount();
a[m] = 0;
l[m].setlight("RED");
}
if (n == q + 1)
{
c = 9;
str = "YOUR LIGHT WILL BE ON IN:";
cdt = 15;
l[m].resetcount();
a[m] = 0;
l[m].setlight("RED");
}
if (n != m + 1 && n != q + 1)
{
x = m + 1 - n;
if (x < 0)
{
x = 0 - x;
}
str = "YOUR LIGHT WILL NOT BE ON FOR UNTIL ATLEAST " + x * 15 + " MORE SECS.YOU WILL GET AN UPDATE IN:";
if (x == 1)
{
str = "YOUR LIGHT WILL BE ON IN:";
}
cdt = x*15;
a[m] = 0;
l[m].setlight("RED");
c = 9;
}
if (l[0].getcount() == 0 || s > 0)
{
l[0].Createcar();
}
a[0] += l[0].getcount();
t[0] = l[0].gettime();
if (l[1].getcount() == 0 || s > 0)
{
l[1].Createcar();
}
a[1] += l[1].getcount();
t[1] = l[1].gettime();
if (l[2].getcount() == 0 || s > 0)
{
l[2].Createcar();
}
a[2] = l[2].getcount();
t[2] = l[2].gettime();
if (l[3].getcount() == 0 || s > 0)
{
l[3].Createcar();
}
a[3] += l[3].getcount();
t[3] = l[3].gettime();
s++;
if (s % 2 != 0)
{
var now1 = DateTime.Now;
tv = (now1 - begin).TotalMilliseconds;
tym = Convert.ToInt32(tv);
int[] pkl = { 0, 0 };
maxi(a, t, s, tym, ref pkl);
m = pkl[0];
}
else
{
var now1 = DateTime.Now;
tv = (now1 - begin).TotalMilliseconds;
tym = Convert.ToInt32(tv);
int[] pkj = { 0, 0 };
maxi(a, t, s, tym, ref pkj);
q = pkj[0];
}
return str;
}
public static string rego()
{
{
l[q].setlight("GREEN");
var now = DateTime.Now;
tv = (now - begin).TotalMilliseconds;
tym = Convert.ToInt32(tv);
l[q].settime(tym);
if (n == q + 1)
{
f = 0;
str = "YOUR LIGHT IS ON FOR : ";
cdt=15;
}
if (n == m + 1)
{
str = "YOUR LIGHT WILL BE ON IN:";
cdt=15;
l[q].resetcount();
a[q] = 0;
l[q].setlight("RED");
f = 9;
}
if (n != m + 1 && n != q + 1)
{
x = m + 1 - n;
if (x < 0)
{
x = 0 - x;
}
str = "YOUR LIGHT WILL NOT BE ON FOR UNTIL ATLEAST " + x * 15 + " MORE SECS.YOU WILL GET AN UPDATE IN:";
if (x == 1)
{
str = "YOUR LIGHT WILL BE ON IN:";
}
cdt = x * 15;
a[q] = 0;
l[q].setlight("RED");
f = 9;
}
}
if (l[0].getcount() == 0 || s > 0)
{
l[0].Createcar();
}
a[0] += l[0].getcount();
t[0] = l[0].gettime();
if (l[1].getcount() == 0 || s > 0)
{
l[1].Createcar();
}
a[1] += l[1].getcount();
t[1] = l[1].gettime();
if (l[2].getcount() == 0 || s > 0)
{
l[2].Createcar();
}
a[2] = l[2].getcount();
t[2] = l[2].gettime();
if (l[3].getcount() == 0 || s > 0)
{
l[3].Createcar();
}
a[3] += l[3].getcount();
t[3] = l[3].gettime();
s++;
if (s % 2 != 0)
{
var now = DateTime.Now;
tv = (now - begin).TotalMilliseconds;
tym = Convert.ToInt32(tv);
int[] pkl = { 0, 0 };
maxi(a, t, s, tym, ref pkl);
m = pkl[0];
}
else
{
var now = DateTime.Now;
tv = (now - begin).TotalMilliseconds;
tym = Convert.ToInt32(tv);
int[] pkj = { 0, 0 };
maxi(a, t, s, tym, ref pkj);
q = pkj[0];
}
return str;
}
Sourround your code with try catch and see what's the message.
try
{
// Your Code
}
catch (Exception ex)
{
Debug.writeline(ex.Message);
}