up/down arrow scroll not working - javascript

up/down arrow scroll not working in jquery scrolify plugin.I want to do the scroll with both page up/down button and in up/down arrow button click.
page up/down arrow working fine as I expect.up/down button click not scroll as page scroll
if(e.keyCode==33 ) { //working
if(index>0) {
if(atTop()) {
e.preventDefault();
index--;
//index, instant, callbacks
animateScroll(index,false,true);
}
}
} else if(e.keyCode==34) { //working
if(index<heights.length-1) {
if(atBottom()) {
e.preventDefault();
index++;
//index, instant, callbacks
animateScroll(index,false,true);
}
}
}
if(e.keyCode==38) { //not working
if(index>0) {
if(atTop()) {
e.preventDefault();
index--;
//index, instant, callbacks
animateScroll(index,false,true);
console.log('up arrow');
}
}
} else if(e.keyCode==40) { //not working
if(index<heights.length-1) {
if(atBottom()) {
e.preventDefault();
index++;
//index, instant, callbacks
animateScroll(index,false,true);
console.log('down arrow');
}
}
}
/*!
* jQuery Scrollify
* Version 1.0.5
*
* Requires:
* - jQuery 1.7 or higher
*
* https://github.com/lukehaas/Scrollify
*
* Copyright 2016, Luke Haas
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
If section being scrolled to is an interstitialSection and the last section on page
then value to scroll to is current position plus height of interstitialSection
*/
(function (global,factory) {
"use strict";
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], function($) {
return factory($, global, global.document);
});
} else if (typeof module === 'object' && module.exports) {
// Node/CommonJS
module.exports = function( root, jQuery ) {
if ( jQuery === undefined ) {
// require('jQuery') returns a factory that requires window to
// build a jQuery instance, we normalize how we use modules
// that require this pattern but the window provided is a noop
// if it's defined (how jquery works)
if ( typeof window !== 'undefined' ) {
jQuery = require('jquery');
} else {
jQuery = require('jquery')(root);
}
}
factory(jQuery, global, global.document);
return jQuery;
};
} else {
// Browser globals
factory(jQuery, global, global.document);
}
}(typeof window !== 'undefined' ? window : this, function ($, window, document, undefined) {
"use strict";
var heights = [],
names = [],
elements = [],
overflow = [],
index = 0,
currentIndex = 0,
interstitialIndex = 1,
hasLocation = false,
timeoutId,
timeoutId2,
$window = $(window),
top = $window.scrollTop(),
scrollable = false,
locked = false,
scrolled = false,
manualScroll,
swipeScroll,
util,
disabled = false,
scrollSamples = [],
scrollTime = new Date().getTime(),
firstLoad = true,
initialised = false,
wheelEvent = 'onwheel' in document ? 'wheel' : document.onmousewheel !== undefined ? 'mousewheel' : 'DOMMouseScroll',
settings = {
//section should be an identifier that is the same for each section
section: ".section",
//sectionName: "section-name",
interstitialSection: "",
easing: "easeOutExpo",
scrollSpeed: 500,
offset : 0,
scrollbars: true,
target:"html,body",
standardScrollElements: false,
setHeights: true,
overflowScroll:true,
before:function() {},
after:function() {},
afterResize:function() {},
afterRender:function() {}
};
function animateScroll(index,instant,callbacks) {
if(currentIndex===index) {
callbacks = false;
}
if(disabled===true) {
return true;
}
if(names[index]) {
scrollable = false;
if(callbacks) {
settings.before(index,elements);
}
interstitialIndex = 1;
if(settings.sectionName && !(firstLoad===true && index===0)) {
if(history.pushState) {
try {
history.replaceState(null, null, names[index]);
} catch (e) {
if(window.console) {
console.warn("Scrollify warning: This needs to be hosted on a server to manipulate the hash value.");
}
}
} else {
window.location.hash = names[index];
}
}
if(instant) {
$(settings.target).stop().scrollTop(heights[index]);
if(callbacks) {
settings.after(index,elements);
}
} else {
locked = true;
if( $().velocity ) {
$(settings.target).stop().velocity('scroll', {
duration: settings.scrollSpeed,
easing: settings.easing,
offset: heights[index],
mobileHA: false
});
} else {
$(settings.target).stop().animate({
scrollTop: heights[index]
}, settings.scrollSpeed,settings.easing);
}
if(window.location.hash.length && settings.sectionName && window.console) {
try {
if($(window.location.hash).length) {
console.warn("Scrollify warning: There are IDs on the page that match the hash value - this will cause the page to anchor.");
}
} catch (e) {
console.warn("Scrollify warning:", window.location.hash, "is not a valid jQuery expression.");
}
}
$(settings.target).promise().done(function(){
currentIndex = index;
locked = false;
firstLoad = false;
if(callbacks) {
settings.after(index,elements);
}
});
}
}
}
function isAccelerating(samples) {
function average(num) {
var sum = 0;
var lastElements = samples.slice(Math.max(samples.length - num, 1));
for(var i = 0; i < lastElements.length; i++){
sum += lastElements[i];
}
return Math.ceil(sum/num);
}
var avEnd = average(10);
var avMiddle = average(70);
if(avEnd >= avMiddle) {
return true;
} else {
return false;
}
}
$.scrollify = function(options) {
initialised = true;
$.easing['easeOutExpo'] = function(x, t, b, c, d) {
return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
};
manualScroll = {
/*handleMousedown:function() {
if(disabled===true) {
return true;
}
scrollable = false;
scrolled = false;
},*/
handleMouseup:function() {
if(disabled===true) {
return true;
}
scrollable = true;
if(scrolled) {
//instant,callbacks
manualScroll.calculateNearest(false,true);
}
},
handleScroll:function() {
if(disabled===true) {
return true;
}
if(timeoutId){
clearTimeout(timeoutId);
}
timeoutId = setTimeout(function(){
scrolled = f;
if(scrollable===false) {
return false;
}
scrollable = false;
//instant,callbacks
manualScroll.calculateNearest(false,false);
}, 200);
},
calculateNearest:function(instant,callbacks) {
top = $window.scrollTop();
var i =1,
max = heights.length,
closest = 0,
prev = Math.abs(heights[0] - top),
diff;
for(;i<max;i++) {
diff = Math.abs(heights[i] - top);
if(diff < prev) {
prev = diff;
closest = i;
}
}
if(atBottom() || atTop()) {
index = closest;
//index, instant, callbacks
animateScroll(closest,instant,callbacks);
}
},
/*wheel scroll*/
wheelHandler:function(e) {
if(disabled===true) {
return true;
} else if(settings.standardScrollElements) {
if($(e.target).is(settings.standardScrollElements) || $(e.target).closest(settings.standardScrollElements).length) {
return true;
}
}
if(!overflow[index]) {
e.preventDefault();
}
var currentScrollTime = new Date().getTime();
e = e || window.event;
var value = e.originalEvent.wheelDelta || -e.originalEvent.deltaY || -e.originalEvent.detail;
var delta = Math.max(-1, Math.min(1, value));
//delta = delta || -e.originalEvent.detail / 3 || e.originalEvent.wheelDelta / 120;
if(scrollSamples.length > 149){
scrollSamples.shift();
}
//scrollSamples.push(Math.abs(delta*10));
scrollSamples.push(Math.abs(value));
if((currentScrollTime-scrollTime) > 200){
scrollSamples = [];
}
scrollTime = currentScrollTime;
if(locked) {
return false;
}
if(delta<0) {
if(index<heights.length-1) {
if(atBottom()) {
if(isAccelerating(scrollSamples)) {
e.preventDefault();
index++;
locked = true;
//index, instant, callbacks
animateScroll(index,false,true);
} else {
return false;
}
}
}
} else if(delta>0) {
if(index>0) {
if(atTop()) {
if(isAccelerating(scrollSamples)) {
e.preventDefault();
index--;
locked = true;
//index, instant, callbacks
animateScroll(index,false,true);
} else {
return false
}
}
}
}
},
/*end of wheel*/
keyHandler:function(e) {
if(disabled===true) {
return true;
}
if(locked===true) {
return false;
}
if(e.keyCode==33 ) {
if(index>0) {
if(atTop()) {
e.preventDefault();
index--;
//index, instant, callbacks
animateScroll(index,false,true);
}
}
} else if(e.keyCode==34) {
if(index<heights.length-1) {
if(atBottom()) {
e.preventDefault();
index++;
//index, instant, callbacks
animateScroll(index,false,true);
}
}
}
if(e.keyCode==38) {
if(index>0) {
if(atTop()) {
e.preventDefault();
index--;
//index, instant, callbacks
animateScroll(index,false,true);
console.log('up arrow');
}
}
} else if(e.keyCode==40) {
if(index<heights.length-1) {
if(atBottom()) {
e.preventDefault();
index++;
//index, instant, callbacks
animateScroll(index,false,true);
console.log('down arrow');
}
}
}
/*home, end button testing*/
if(e.keyCode==35) {
for(index=6;index<1;index--)
{
console.log("worked on end button");
}
}
else if(e.keyCode==36) {
for(index=0;intex<1;index++)
{
console.log("worked on home button");
}
}
/*home,end button end*/
},
init:function() {
if(settings.scrollbars) {
$window.on('mousedown', manualScroll.handleMousedown);
$window.on('mouseup', manualScroll.handleMouseup);
$window.on('scroll', manualScroll.handleScroll);
} else {
$("body").css({"overflow":"hidden"});
}
$window.on(wheelEvent,manualScroll.wheelHandler);
$(document).bind(wheelEvent,manualScroll.wheelHandler);
$window.on('keydown', manualScroll.keyHandler);
}
};
swipeScroll = {
touches : {
"touchstart": {"y":-1,"x":-1},
"touchmove" : {"y":-1,"x":-1},
"touchend" : false,
"direction" : "undetermined"
},
options:{
"distance" : 30,
"timeGap" : 800,
"timeStamp" : new Date().getTime()
},
touchHandler: function(event) {
if(disabled===true) {
return true;
} else if(settings.standardScrollElements) {
if($(event.target).is(settings.standardScrollElements) || $(event.target).closest(settings.standardScrollElements).length) {
return true;
}
}
var touch;
if (typeof event !== 'undefined'){
if (typeof event.touches !== 'undefined') {
touch = event.touches[0];
switch (event.type) {
case 'touchstart':
swipeScroll.touches.touchstart.y = touch.pageY;
swipeScroll.touches.touchmove.y = -1;
swipeScroll.touches.touchstart.x = touch.pageX;
swipeScroll.touches.touchmove.x = -1;
swipeScroll.options.timeStamp = new Date().getTime();
swipeScroll.touches.touchend = false;
case 'touchmove':
swipeScroll.touches.touchmove.y = touch.pageY;
swipeScroll.touches.touchmove.x = touch.pageX;
if(swipeScroll.touches.touchstart.y!==swipeScroll.touches.touchmove.y && (Math.abs(swipeScroll.touches.touchstart.y-swipeScroll.touches.touchmove.y)>Math.abs(swipeScroll.touches.touchstart.x-swipeScroll.touches.touchmove.x))) {
//if(!overflow[index]) {
event.preventDefault();
//}
swipeScroll.touches.direction = "y";
if((swipeScroll.options.timeStamp+swipeScroll.options.timeGap)<(new Date().getTime()) && swipeScroll.touches.touchend == false) {
swipeScroll.touches.touchend = true;
if (swipeScroll.touches.touchstart.y > -1) {
if(Math.abs(swipeScroll.touches.touchmove.y-swipeScroll.touches.touchstart.y)>swipeScroll.options.distance) {
if(swipeScroll.touches.touchstart.y < swipeScroll.touches.touchmove.y) {
swipeScroll.up();
} else {
swipeScroll.down();
}
}
}
}
}
break;
case 'touchend':
if(swipeScroll.touches[event.type]===false) {
swipeScroll.touches[event.type] = true;
if (swipeScroll.touches.touchstart.y > -1 && swipeScroll.touches.touchmove.y > -1 && swipeScroll.touches.direction==="y") {
if(Math.abs(swipeScroll.touches.touchmove.y-swipeScroll.touches.touchstart.y)>swipeScroll.options.distance) {
if(swipeScroll.touches.touchstart.y < swipeScroll.touches.touchmove.y) {
swipeScroll.up();
} else {
swipeScroll.down();
}
}
swipeScroll.touches.touchstart.y = -1;
swipeScroll.touches.touchstart.x = -1;
swipeScroll.touches.direction = "undetermined";
}
}
default:
break;
}
}
}
},
down: function() {
if(index<=heights.length-1) {
if(atBottom() && index<heights.length-1) {
index++;
//index, instant, callbacks
animateScroll(index,false,true);
} else {
if(Math.floor(elements[index].height()/$window.height())>interstitialIndex) {
interstitialScroll(parseInt(heights[index])+($window.height()*interstitialIndex));
interstitialIndex += 1;
} else {
interstitialScroll(parseInt(heights[index])+(elements[index].height()-$window.height()));
}
}
}
},
up: function() {
if(index>=0) {
if(atTop() && index>0) {
index--;
//index, instant, callbacks
animateScroll(index,false,true);
} else {
if(interstitialIndex>2) {
interstitialIndex -= 1;
interstitialScroll(parseInt(heights[index])+($window.height()*interstitialIndex));
} else {
interstitialIndex = 1;
interstitialScroll(parseInt(heights[index]));
}
}
}
},
init: function() {
if (document.addEventListener) {
document.addEventListener('touchstart', swipeScroll.touchHandler, false);
document.addEventListener('touchmove', swipeScroll.touchHandler, false);
document.addEventListener('touchend', swipeScroll.touchHandler, false);
}
}
};
util = {
refresh:function(withCallback) {
clearTimeout(timeoutId2);
timeoutId2 = setTimeout(function() {
sizePanels();
calculatePositions(true);
if(withCallback) {
settings.afterResize();
}
},400);
},
handleUpdate:function() {
util.refresh(false);
},
handleResize:function() {
util.refresh(true);
}
};
settings = $.extend(settings, options);
sizePanels();
calculatePositions(false);
if(true===hasLocation) {
//index, instant, callbacks
animateScroll(index,false,true);
} else {
setTimeout(function() {
//instant,callbacks
manualScroll.calculateNearest(true,false);
},200);
}
if(heights.length) {
manualScroll.init();
swipeScroll.init();
$window.on("resize",util.handleResize);
if (document.addEventListener) {
window.addEventListener("orientationchange", util.handleResize, false);
}
}
function interstitialScroll(pos) {
if( $().velocity ) {
$(settings.target).stop().velocity('scroll', {
duration: settings.scrollSpeed,
easing: settings.easing,
offset: pos,
mobileHA: false
});
} else {
$(settings.target).stop().animate({
scrollTop: pos
}, settings.scrollSpeed,settings.easing);
}
}
function sizePanels() {
var selector = settings.section;
overflow = [];
if(settings.interstitialSection.length) {
selector += "," + settings.interstitialSection;
}
$(selector).each(function(i) {
var $this = $(this);
if(settings.setHeights) {
if($this.is(settings.interstitialSection)) {
overflow[i] = false;
} else {
if(($this.css("height","auto").outerHeight()<$window.height()) || $this.css("overflow")==="hidden") {
$this.css({"height":$window.height()});
overflow[i] = false;
} else {
$this.css({"height":$this.height()});
if(settings.overflowScroll) {
overflow[i] = true;
} else {
overflow[i] = false;
}
}
}
} else {
if(($this.outerHeight()<$window.height()) || (settings.overflowScroll===false)) {
overflow[i] = false;
} else {
overflow[i] = true;
}
}
});
}
function calculatePositions(resize) {
var selector = settings.section;
if(settings.interstitialSection.length) {
selector += "," + settings.interstitialSection;
}
heights = [];
names = [];
elements = [];
$(selector).each(function(i){
var $this = $(this);
if(i>0) {
heights[i] = parseInt($this.offset().top) + settings.offset;
} else {
heights[i] = parseInt($this.offset().top);
}
if(settings.sectionName && $this.data(settings.sectionName)) {
names[i] = "#" + $this.data(settings.sectionName).replace(/ /g,"-");
} else {
if($this.is(settings.interstitialSection)===false) {
names[i] = "#" + (i + 1);
} else {
names[i] = "#";
if(i===$(selector).length-1 && i>1) {
heights[i] = heights[i-1]+parseInt($this.height());
}
}
}
elements[i] = $this;
try {
if($(names[i]).length && window.console) {
console.warn("Scrollify warning: Section names can't match IDs on the page - this will cause the browser to anchor.");
}
} catch (e) {}
if(window.location.hash===names[i]) {
index = i;
hasLocation = true;
}
});
if(true===resize) {
//index, instant, callbacks
animateScroll(index,false,false);
} else {
settings.afterRender();
}
}
function atTop() {
if(!overflow[index]) {
return true;
}
top = $window.scrollTop();
if(top>parseInt(heights[index])) {
return false;
} else {
return true;
}
}
function atBottom() {
if(!overflow[index]) {
return true;
}
top = $window.scrollTop();
if(top<parseInt(heights[index])+(elements[index].outerHeight()-$window.height())-28) {
return false;
} else {
return true;
}
}
}
function move(panel,instant) {
var z = names.length;
for(;z>=0;z--) {
if(typeof panel === 'string') {
if (names[z]===panel) {
index = z;
//index, instant, callbacks
animateScroll(z,instant,true);
}
} else {
if(z===panel) {
index = z;
//index, instant, callbacks
animateScroll(z,instant,true);
}
}
}
}
$.scrollify.move = function(panel) {
if(panel===undefined) {
return false;
}
if(panel.originalEvent) {
panel = $(this).attr("href");
}
move(panel,false);
};
$.scrollify.instantMove = function(panel) {
if(panel===undefined) {
return false;
}
move(panel,true);
};
$.scrollify.next = function() {
if(index<names.length) {
index += 1;
animateScroll(index,false,true);
}
};
$.scrollify.previous = function() {
if(index>0) {
index -= 1;
//index, instant, callbacks
animateScroll(index,false,true);
}
};
$.scrollify.instantNext = function() {
if(index<names.length) {
index += 1;
//index, instant, callbacks
animateScroll(index,true,true);
}
};
$.scrollify.instantPrevious = function() {
if(index>0) {
index -= 1;
//index, instant, callbacks
animateScroll(index,true,true);
}
};
$.scrollify.destroy = function() {
if(!initialised) {
return false;
}
if(settings.setHeights) {
$(settings.section).each(function() {
$(this).css("height","auto");
});
}
$window.off("resize",util.handleResize);
if(settings.scrollbars) {
$window.off('mousedown', manualScroll.handleMousedown);
$window.off('mouseup', manualScroll.handleMouseup);
$window.off('scroll', manualScroll.handleScroll);
}
$window.off(wheelEvent,manualScroll.wheelHandler);
$window.off('keydown', manualScroll.keyHandler);
if (document.addEventListener) {
document.removeEventListener('touchstart', swipeScroll.touchHandler, false);
document.removeEventListener('touchmove', swipeScroll.touchHandler, false);
document.removeEventListener('touchend', swipeScroll.touchHandler, false);
}
heights = [];
names = [];
elements = [];
overflow = [];
};
$.scrollify.update = function() {
if(!initialised) {
return false;
}
util.handleUpdate();
};
$.scrollify.current = function() {
return elements[index];
};
$.scrollify.disable = function() {
disabled = true;
};
$.scrollify.enable = function() {
disabled = false;
if (initialised) {
//instant,callbacks
manualScroll.calculateNearest(false,false);
}
};
$.scrollify.isDisabled = function() {
return disabled;
};
$.scrollify.setOptions = function(updatedOptions) {
if(!initialised) {
return false;
}
if(typeof updatedOptions === "object") {
settings = $.extend(settings, updatedOptions);
util.handleUpdate();
} else if(window.console) {
console.warn("Scrollify warning: Options need to be in an object.");
}
};
}));

I think you are listening wrong event. Use keydown event this will work.
working fiddle

Related

Uncaught Error: cannot call methods on prior to initialization; attempted to call method

I have a javascript method in a partial view .Net 6 MVC like this: After upgrading to JQuery 3.6.1 and JQuery UI 1.13.2. I am getting errors like:
Uncaught Error: cannot call methods on NumericBox prior to initialization; attempted to call method 'isNumeric'. Please suggest. Thanks.
function CompareDialog() {
var aReleased;
$(".weighting-total").NumericBox("setValue", $(".weighting").NumericBoxSum());
}
The javascript for the NumericBox and NumericBoxSum:
$.widget("Data.NumericBox", {
options: {
allowReservedValues: undefined,
readOnly: undefined,
decimalPlaces: undefined,
showZero: undefined,
allowNegative: undefined,
thousandSeperator: undefined
},
_create: function () {
this._super();
var that = this;
// Option: Allow Reserved Values
if (this.options.allowReservedValues == undefined) {
if (this.element.data("allow-reserved-values") != undefined) {
this.options.allowReservedValues = JSON.parse(this.element.data("allow-reserved-values").toLowerCase());
}
else {
this.options.allowReservedValues = false;
}
}
// Option: Read Only
if (this.options.readOnly != undefined) {
this.element.prop("readonly", this.options.readOnly);
}
// Option: Decimal Places
if (this.options.decimalPlaces == undefined) {
if (this.element.data("decimal-places") != undefined) {
this.options.decimalPlaces = parseInt(this.element.data("decimal-places"));
}
else {
this.options.decimalPlaces = 0;
}
}
// Option: Show Zero
if (this.options.showZero == undefined) {
if (this.element.data("show-zero") != undefined) {
this.options.showZero = JSON.parse(this.element.data("show-zero").toLowerCase());
}
else {
this.options.showZero = true;
}
}
// Option: Allow Negative
if (this.options.allowNegative == undefined) {
if (this.element.data("allow-negative") != undefined) {
this.options.allowNegative = JSON.parse(this.element.data("allow-negative").toLowerCase());
}
else {
this.options.allowNegative = false;
}
}
// Option: Thousand Seperator
if (this.options.thousandSeperator == undefined) {
if (this.element.data("thousand-seperator") != undefined) {
this.options.thousandSeperator = this.element.data("thousand-seperator");
}
else {
this.options.thousandSeperator = ",";
}
}
// Set client-side validation to ignore N/Avail and N/Appl values
if ($.validator.defaults.ignore.indexOf(".fd-not-available") < 0) {
$.validator.setDefaults({
ignore: $.validator.defaults.ignore + ",.fd-not-available,.fd-not-applicable"
});
}
// Define validation for hyphens
if (this.options.allowNegative) {
if ($.validator.methods["val-hyphen"] === undefined) {
$.validator.addMethod("val-hyphen", function (value, element) {
var message = $(element).data("val-number");
if (value == "-") {
return false;
}
return true;
}, $.validator.format("{0}"));
}
this.element.attr("val-hyphen", this.element.data("val-number"));
}
// Handle paste
this.element.on("paste", function (event) {
if ($(this).hasClass("fd-not-available") || $(this).hasClass("fd-not-applicable")) {
$(this).val("").removeClass("fd-not-available fd-not-applicable");
}
});
// Handle clearing of textbox
this.element.on("input", function (event) {
if ($(this).val() == "") {
$(this).removeClass("fd-not-available fd-not-applicable");
}
});
this.element.keydown(function (event) {
if (that.isReserved()) {
if (!$(this).prop("readonly") && (event.which == 8 || event.which == 46)) {
$(this).val("").removeClass("fd-not-available fd-not-applicable").select();
event.preventDefault();
}
}
});
this.element.keypress(function (event) {
if (that.element.prop("readonly")) {
event.preventDefault();
return;
}
if (event.which == 78 || event.which == 110) { // N
if (that.options.allowReservedValues) {
that.setReserved(ReservedValue.NotAvailable);
$(this).change();
}
event.preventDefault();
return;
}
if (event.which == 80 || event.which == 112) { // P
if (that.options.allowReservedValues) {
that.setReserved(ReservedValue.NotApplicable);
$(this).change();
}
event.preventDefault();
return;
}
if (event.which == 45) { // -
if (!that.options.allowNegative) {
event.preventDefault();
return;
}
if (that.isReserved()) {
that.setValue("");
}
that.refresh();
return;
}
if (event.which == 46) { // .
if (that.options.decimalPlaces == 0) {
event.preventDefault();
return;
}
if (that.isReserved()) {
that.setValue("");
}
that.refresh();
return;
}
if (event.which >= 48 && event.which <= 57) { // 0 - 9
if (that.isReserved()) {
$(this).val("");
}
if (that.isReserved()) {
that.setValue("");
}
that.refresh();
return;
}
event.preventDefault();
});
this.element.focusin(function (event) {
var value = that._internalFormat($(this).val());
$(this).val(value);
});
this.element.focusout(function (event) {
var value = that._externalFormat($(this).val());
$(this).val(value);
});
this.element.val(this._externalFormat(this.element.val()));
this.refresh();
},
_externalFormat: function (value) {
if ($.isNumeric(value)) {
if (parseFloat(value) == 0 && !this.options.showZero) {
return "";
}
else if (!ReservedValue.isReserved(value)) {
var signPart = value > -1 && value < 0 ? "-" : ""; // Required: In the following statement parseInt removes the sign for small negative numbers
var integerPart = parseInt(numeral(value).format("0" + (0).toFixed(this.options.decimalPlaces).substr(1)));
var fractionalPart = Big(value).minus(Big(integerPart)).abs();
var display = signPart + numeral(integerPart).format("0" + this.options.thousandSeperator + "0") +
fractionalPart.toFixed(this.options.decimalPlaces).substr(1);
return display;
}
}
return value;
},
_internalFormat: function (value) {
try {
value = value.replace(/,/g, "");
if ($.isNumeric(value)) {
if (this.options.decimalPlaces == 0) {
value = parseInt(value);
}
else {
value = Big(value).format("0" + (0).toFixed(this.options.decimalPlaces).substr(1)).toString();
}
}
return value;
}
catch (e) {
return value;
}
},
refresh: function () {
var value = this._internalFormat(this.element.val());
if (this.options.allowReservedValues) {
if (value == ReservedValue.NotAvailable) {
this.element.val(ReservedValue.text(value)).removeClass("fd-not-applicable").addClass("fd-not-available");
}
else if (value == ReservedValue.NotApplicable) {
this.element.val(ReservedValue.text(value)).removeClass("fd-not-available").addClass("fd-not-applicable");
}
else {
if (this.element.hasClass("fd-not-available") || this.element.hasClass("fd-not-applicable")) {
this.element.removeClass("fd-not-available fd-not-applicable");
}
}
}
return this;
},
setValue: function (value) {
this.element.val(this._externalFormat(value));
this.refresh();
},
getValue: function () {
return this._internalFormat(this.element.val());
},
isNumeric: function (includeReservedValues) {
includeReservedValues = includeReservedValues === undefined ? false : includeReservedValues;
if (!includeReservedValues && this.isReserved()) {
return false;
}
else {
return $.isNumeric(this.getValue());
}
},
isReserved: function (resval) {
var value = ReservedValue.parse(this._internalFormat(this.element.val()));
if (resval === undefined) {
return ReservedValue.isReserved(value);
}
else {
return value == resval;
}
},
setReserved: function (resval) {
this.element.val(resval).valid();
this.refresh();
},
getReserved: function () {
return ReservedValue.parse(this._internalFormat(this.element.val()));
}
});
$.fn.NumericBoxSum = function (blankIfNoNumerics) {
var NumericCount = 0;
var sum = 0.0;
blankIfNoNumerics = blankIfNoNumerics === undefined ? false : blankIfNoNumerics;
this.each(function () {
if ($(this).NumericBox("isNumeric")) {
sum += parseFloat($(this).NumericBox("getValue"));
NumericCount++;
}
});
if (NumericCount == 0 && blankIfNoNumerics) {
sum = "";
}
return sum;
};

There's something wrong with my shunting yards algorithms

I got some problem on working with shunting yards algorithm : I use it to parse an equation then use that equation to draw an graph, but somehow it's parsing x^2-0.5x+1 to -0.5x+1, is there anyways to fix that
Here the link to the test code : https://codepen.io/Inasaya-Flanderin/pen/ExbbgQm
This is the code part:
function parse(rpn) {
let stack = [];
Array.from(rpn).forEach((t) => {
let tr = null;
if (isNumber(t) || isVariable(t)) {
tr = genNode(t, false);
} else {
if (Object.keys(binary_functions).includes(t)) {
tr = genNode(binary_functions[t], true, false);
let a = stack.pop();
let b = stack.pop();
if (typeof a === 'number') {
tr.right = genNode(a, false);
} else {
tr.right = a;
}
if (typeof b === 'number') {
tr.left = genNode(b, false);
} else {
tr.left = b;
}
} else if (Object.keys(unary_functions).includes(t)) {
tr = genNode(unary_functions[t]);
a = stack.pop();
if (typeof a === 'number') {
tr.left = genNode(a, false);
} else {
tr.left = a;
}
}
}
tr.name = t;
stack.push(tr);
});
return stack.pop();
}
function eval(tree) {
if (tree.func) {
if (tree.unary) {
return tree.val.eval(eval(tree.left));
} else {
return tree.val.eval(eval(tree.left), eval(tree.right));
}
} else {
if (constant_names.includes(tree.val)) {
return constants[tree.val];
} else if (varnames.includes(tree.val)) {
return variables[tree.val];
} else {
return tree.val;
}
}
}

It all works, but the button never becomes enabled

This all seems to work, but the button (bSaveNewTag) never becomes enabled. Going through it, I am guessing that countTag is not populated in time, but I don't get how to make it wait for a return value.
I have gone through with alerts which has made come to the above conclusion, but my knowledge of Javascript is very basic, so don't know what to do and when searching for answers, what I do find, I don't understand and can't figure out how to implement.
function checkIfNewTagExists(potentialTag) {
var countTag = 0;
$.ajax({
url: "/CSC/api/checkTag/" + potentialTag + "/",
dataType: "json",
success: function (data) {
$.map(data, function (item) {
countTag = parseInt(item.cTag, 10);
});
},
complete: function () {
if (countTag > 0) {
$('#newTag').css({ 'opacity': 1 });
$('#tbNewTagName').addClass("missing");
} else {
$('#newTag').css({ 'opacity': 0 });
}
return countTag;
}
});
}
function checkNewTag() {
var countTag = 0;
var potentialTag = '';
var val = Page_ClientValidate("vgNewTag");
var el = $("#bSaveNewTag")
for (i = 0; i < Page_Validators.length; i++) {
if (Page_Validators[i].isvalid) {
$("#" + Page_Validators[i].controltovalidate).removeClass("missing");
} else {
$("#" + Page_Validators[i].controltovalidate).addClass("missing");
}
}
potentialTag = $('#tbNewTagName').val();
if (potentialTag == '') {
countTag = 1;
} else {
countTag = checkIfNewTagExists(potentialTag);
}
if (val && countTag === 0) {
el.prop("disabled", false);
} else {
el.prop("disabled", true);
return false;
}
}
If you did not understand my comments above, or the article I referenced, here is the breakdown of what you should do.
function checkIfNewTagExists(potentialTag, callback) {
var countTag = 0;
$.ajax({
url: "/CSC/api/checkTag/" + potentialTag + "/",
dataType: "json",
success: function (data) {
$.map(data, function (item) {
countTag = parseInt(item.cTag, 10);
});
},
complete: function () {
if (countTag > 0) {
$('#newTag').css({ 'opacity': 1 });
$('#tbNewTagName').addClass("missing");
} else {
$('#newTag').css({ 'opacity': 0 });
}
//return countTag;
callback(countTag);
}
});
}
Then this part:
potentialTag = $('#tbNewTagName').val();
if (potentialTag == '') {
countTag = 1;
} else {
countTag = checkIfNewTagExists(potentialTag);
}
if (val && countTag === 0) {
el.prop("disabled", false);
} else {
el.prop("disabled", true);
return false;
}
Should be (something) like this:
potentialTag = $('#tbNewTagName').val();
if (potentialTag == '') {
countTag = 1;
el.prop("disabled", true);
} else {
//countTag = checkIfNewTagExists(potentialTag);
checkIfNewTagExists(function(cTag){
countTag = cTag;
if (val && countTag === 0) {
el.prop("disabled", false);
} else {
el.prop("disabled", true);
}
});
}
Now, I can see you have the return false; in the last else line of checkNewTag. If you intend to return something to the calling line, you should also use a callback function instead of var x = checkNewTag();

results_ready are not defined

I have typescript function
Here is code of function
export class Step1{
constructor(){
this.begin_search();
this.results_ready();
}
private results_ready():void{
$(function() {
Filter.load_filter();
let loading_more_results = false;
let loading_more_offset = 0;
if ((gon.search['search_type'] === 'hotel') || (gon.search['search_type'] === 'package')) {
HotelResults.load_step_1_hotel_results();
} else {
AirResults.load_step_1_air_results();
}
if (gon.search['search_type'] === 'package') {
for (let i of Array.from($('.step_1_air_form'))) {
$('.tip', i).tooltipster({ contentAsHTML: true });
}
$('.step_1_air_form:not(.item_loaded) input[type=checkbox]').on('click', () =>
$('.step_1_hotel_form').each(function() {
return HotelResults.update_price_on_button_hotel($(this));
})
);
}
$('.topnav a').each(function() {
if ($(this).target === '') { $(this).target = '_blank'; }
});
$('.fancybox').fancybox();
$('.list_view').on('click', function() {
$('.img-selected').removeClass('img-selected');
$(this).parent().addClass('img-selected');
$('#filter_view').val('list');
FilterFunctions.onFilterChange();
return false;
});
$('.gallery_view').on('click', function() {
$('.img-selected').removeClass('img-selected');
$(this).parent().addClass('img-selected');
$('#filter_view').val('gallery');
FilterFunctions.onFilterChange();
return false;
});
$('.map_view').on('click', function() {
$('.img-selected').removeClass('img-selected');
$(this).parent().addClass('img-selected');
$('#filter_view').val('map');
FilterFunctions.onFilterChange();
return false;
});
$(window).scroll(function() {
if ($(".right_banner img").length > 0) {
let offset;
if ($('#header').css('position') === 'fixed') {
offset = 75;
} else {
offset = 15;
}
if (($(".right_banner img").css('position') === 'static') && ($(window).scrollTop() > ($(".right_banner").offset().top - offset))) {
$(".right_banner img").css("left", $(".right_banner").offset().left);
$(".right_banner img").css("top", offset);
$(".right_banner img").css("position", "fixed");
}
if (($(".right_banner img").css('position') === 'fixed') && ($(window).scrollTop() <= ($(".right_banner").offset().top - offset))) {
$(".right_banner img").css("position", 'static');
}
}
if ((($('#filter_view').length === 0) || ($('#filter_view').val() !== 'map')) && !loading_more_results && (($(window).scrollTop() + $(window).height()) > ($(document).height() - 1250))) {
let loading_more_results = true;
return Itinerary.loadMoreResults();
}
});
return $(window).resize(function() {
if ($(".right_banner img").css('position') === 'fixed') {
$(".right_banner img").css("position", 'static');
$(".right_banner img").css("left", $(".right_banner").offset().left);
return $(".right_banner img").css("position", "fixed");
}
});
});
};
}
I use it in webpack pack like this
$(document).ready(() => {
Translation.addDict(gon.translations);
Track.initialize();
new Searchfield();
let step1 = new Step1();
if (!gon.search['searched']) {
step1.begin_search();
step1.results_ready();
}
/*if (gon && gon.search['id'] && $('.offer_hotel_addon').length > 0) {
check_status();
}*/
});
But when I run website I have this error at console
results_ready is not defined
Why I get this error if it's defined in first function?
Thank's for help so much

How to set width on this javascript button?

in the html i have this call to a java script function:
<span class="lotusBtn lotusBtnAction">
<a dojoType="quickr.widgets.menu.placeActionsMenu" linkText="##[PLACE.ACTIONS.PLACE_ACTIONS]##"></a>
</span>
this java script file looks as follows:
dojo.provide("quickr.widgets.menu.placeActionsMenu");
dojo.require("quickr.widgets.menu.baseMenu");
dojo.require("quickr.widgets.modal.list");
dojo.require("quickr.widgets.misc.connectors");
dojo.declare("quickr.widgets.menu._placeActionsMenu",
[quickr.widgets.menu.baseMenu],
{
linkText: "",
// Assumes that the page must reload in order to go between a place and a room
// TODO: Replace this with an event based system
isRoom: q_GeneralUtils.isRoom(),
postMixInProperties: function() {
this.inherited('postMixInProperties', arguments);
},
postCreate: function() {
// make dropdown menu
var label = (this.isRoom ? "PLACE.ACTIONS.ROOM_ACTIONS": "PLACE.ACTIONS.PLACE_ACTIONS");
this.createDropDownMenuOnButton(this.domNode, label, true);
this._populate();
if(dojo.isIE < 8) {
dojo.addOnLoad(function() {
if(document.body.dir == 'rtl') {
var container = dojo.query('#pagePlaceBar .lotusBtnContainer');
var actionsNode = container.query('.lotusBtnAction');
actionsNode.removeClass('lotusLeft');
actionsNode.addClass('lotusRight');
container.addContent(actionsNode[0], "last");
}
});
}
},
_item: function(label, action, bDisabled) {
return {label: q_LocaleUtils.getStringResource(label), action: action, disabled: bDisabled};
},
_addItem: function(label, action) {
this.addItem(q_LocaleUtils.getStringResource(label), action);
},
_addItemDisabled: function(label) {
this.addItemDisabled(q_LocaleUtils.getStringResource(label));
},
_createFromForm: function(formUnid, defFolder) {
if (!defFolder || defFolder == "") {
defFolder = this._getLibraryOrRoomIndex();
}
// TO DO: CHANGE THIS WHEN THERE IS A FOLDER PICKER!
var oEvt = new quickr.widgets.misc.eventlink(
{
event: this.ACTION.PAGE.CREATE,
args: { folderUnid: defFolder, formUnid: formUnid }
}
);
window.location.href = oEvt.getEventLinkFromProperties(oEvt.getLinkArguments());
oEvt.destroyRecursive();
},
_populate: function() {
if (q_BaseLoader.user.baseAccess > window.q_GeneralUtils.access.level.reader) {
var aForms = q_BaseLoader.defaultForms;
var createList = [];
var aForms = this._getFormsList(true);
for (var ii = 0; ii < aForms.length; ii++) {
var oFrm = aForms[ii];
if (this._isPredefinedForm(oFrm, "CustomLibrary"))
{
if (true == q_BaseLoader.ecm.enabled) createList.push(this._item("PLACE.PLACE_ACTIONS.NEW_WIDGET", dojo.hitch(this, "_getDefaultCreateFolder", dojo.hitch(this, "_createLibraryConnectorPage"), undefined),false));
}
else
if (this._isPredefinedForm(oFrm, "SingleUpload")) {
createList.push(this._item("PLACE.PLACE_ACTIONS.NEW_UPLOAD", dojo.hitch(this, "_getDefaultCreateFolder", dojo.hitch(this, "_createUpload"), undefined),false));
}
else
if (this._isPredefinedForm(oFrm, "ImportedFile")) {
createList.push(this._item("PLACE.PLACE_ACTIONS.NEW_IMPORTED_PAGE", dojo.hitch(this, "_getDefaultCreateFolder", dojo.hitch(this, "_createImportedPage"), undefined), false));
}
else
if (this._isPredefinedForm(oFrm, "List")) {
if (q_BaseLoader.user.baseAccess < window.q_GeneralUtils.access.level.manager && window.q_FolderUtils.getFirstFolderInTOC(null, false) == null) {
createList.push(this._item("PLACE.PLACE_ACTIONS.NEW_LIST", null, true));
} else {
createList.push(this._item("PLACE.PLACE_ACTIONS.NEW_LIST", dojo.hitch(this, "_getDefaultCreateFolder", dojo.hitch(this, "_createListFolder"), false), false));
}
}
else
if (this._isPredefinedForm(oFrm, "HTMLPage")) {
}
else
{
createList.push(this._item(oFrm.name, dojo.hitch(this, "_getDefaultCreateFolder", dojo.hitch(this, "_createFromForm", oFrm.unid), undefined),false));
}
}
//Comment by haoxiangyu on10/14/2011. for lineitem "Editor can not create folder"
//Originally, blow code makes editor can not create folder in room, but can do it in place
/*
if (q_BaseLoader.user.baseAccess < window.q_GeneralUtils.access.level.manager && window.q_FolderUtils.getFirstFolderInTOC(null, false) == null) {
createList.push(this._item("PLACE.PLACE_ACTIONS.NEW_FOLDER", null, true));
} else {
createList.push(this._item("PLACE.PLACE_ACTIONS.NEW_FOLDER", dojo.hitch(this, "_getDefaultCreateFolder", dojo.hitch(this, "_createFolder"), false)));
}*/
if (window.q_FolderUtils.canCreateFolder() ){
if (q_BaseLoader.user.baseAccess < window.q_GeneralUtils.access.level.manager && window.q_FolderUtils.getFirstFolderInTOC(null, false) == null) {
createList.push(new dijit.MenuSeparator());
createList.push(this._item("PLACE.PLACE_ACTIONS.NEW_FOLDER", null, true));
} else {
createList.push(new dijit.MenuSeparator());
createList.push(this._item("PLACE.PLACE_ACTIONS.NEW_FOLDER", dojo.hitch(this, "_getDefaultCreateFolder", dojo.hitch(this, "_createFolder"), false)));
}
}else{
createList.push(new dijit.MenuSeparator());
createList.push(this._item("PLACE.PLACE_ACTIONS.NEW_FOLDER", null, true));
}
//if no folders, add a disabled "New" item...
if (q_BaseLoader.user.baseAccess < window.q_GeneralUtils.access.level.manager && window.q_FolderUtils.getFirstFolderInTOC() == null) {
this._addItemDisabled("PLACE.PLACE_ACTIONS.NEW_PAGE");
} else {
var submenu = this.addSubmenu(q_LocaleUtils.getStringResource("PLACE.PLACE_ACTIONS.NEW_PAGE"), createList);
}
}
if (q_BaseLoader.user.baseAccess > window.q_GeneralUtils.access.level.reader && q_BaseLoader.user.canManageTOC == true) {
//this._addItemDisabled("PLACE.PLACE_ACTIONS.NEW_FORM"); // would use listfolder.htm
if ((q_BaseLoader.user.canManagePlace) && (q_BaseLoader.environment.createRoom) && (!q_BaseLoader.environment.isOffline)) {
this._addItem("PLACE.PLACE_ACTIONS.NEW_ROOM", dojo.hitch(this, "_createRoom"));
}
}
this.addSeparator();
//if(!q_BaseLoader.sametime.enabled85 && q_BaseLoader.sametime.serverLocation != '')
// this._addItem("PLACE.PLACE_ACTIONS.CHAT_WITH_MEMBERS", dojo.hitch(this, "_chatwithMembers"));
if (q_BaseLoader.place.show.sitemap) {
this._addItem("PLACE.PLACE_ACTIONS.SITE_MAP", dojo.hitch(this, "_goToSiteMap"));
}
if (q_BaseLoader.place.show.placeoffline == true && (this.getRoomName().toLowerCase() =="main.nsf") && (this.baseContext.user.DN != "Anonymous")) {
if (q_BaseLoader.offline.enabled && (dojo.isIE || dojo.isFF)) {
this._addItem("PLACE.PLACE_ACTIONS.OFFLINE", dojo.hitch(this, "_offline"));
}
else if (q_BaseLoader.offline.enabled == false) {
this._addItemDisabled("PLACE.PLACE_ACTIONS.OFFLINE");
}
}
if (q_BaseLoader.place.show.whatsNew) {
this._addItem("WHATS_NEW.TITLE", dojo.hitch(this, "_whatsNew"));
}
var showPrefs = window.connectors.showPreferences();
var showAddToConnectorsUI = window.connectors.showAddToConnectors();
if (showPrefs || (showAddToConnectorsUI == true )) //AVAILABLE))
{
this.addSeparator();
}
if (showPrefs) this._addItem(q_LocaleUtils.getStringResource("PLACE.PLACE_ACTIONS.PREFERENCES").replace("{0}", window.q_BaseLoader.place.title), dojo.hitch(this, "_showPreferences"));
if (showAddToConnectorsUI== 1) this._addItem(q_LocaleUtils.getStringResource("PLACE.PLACE_ACTIONS.ADD_TO_CONNECTORS").replace("{0}", window.q_BaseLoader.place.title), dojo.hitch(this, "_addToConnectors"));
this.publishEvent(this.ACTION.MENU.POPCOM.PLACE_ACTIONS, this._menu);
},
_publishEvent: function(e, a) {
if (typeof a == "undefined") a = new Object();
/* No need to put it in the url
var oEvt = new quickr.widgets.misc.eventlink(
{
event: e,
args: a
}
);
window.location.href = oEvt.getEventLinkFromProperties(oEvt.getLinkArguments());
oEvt.destroyRecursive();
*/
//just publish the event directly. No neeed to put it in the url
this.publishEvent(e, a);
},
_getFolderUnid: function()
{
var _LIBRARYFOLDER = 'CD0EF97D625305B90525670800167213';
var _ROOMINDEX = 'A7986FD2A9CD47090525670800167225';
return this.isRoom ? _ROOMINDEX : _LIBRARYFOLDER;
},
_getLibraryOrRoomIndex: function() {
var _PLACEINDEX = 'CE6A3D6B1F546C9405256708001671FF';
var _ROOMINDEX = 'A7986FD2A9CD47090525670800167225';
return this.isRoom ? _ROOMINDEX : _PLACEINDEX;
},
_chatwithMembers: function() {
openPeopleOnline();
},
_getDefaultCreateFolder: function(callback, bAllowIndex) {
if (typeof callback == "undefined") callback = null;
// SPR: #ESEO89JKU9
var unid = window.q_GeneralUtils.getUnidFromUrl();
if (unid) {
var folder = window.q_BaseLoader.allViews[unid];
if (typeof folder == "undefined") {
var type = window.q_GeneralUtils.getParameterFromUrl('type');
if (type == "0") {
var document_xml = "";
var document_url = window.q_RestUtils.getURI("document",unid) + "/feed?includePropertySheets=true&includeAllFields=true";
window.q_AjaxUtils.get ( {
sync: true,
url: document_url,
//I found out that the response is NOT declared as XML.
handleAs: "text",
timeout: 5000,
load: function(response, ioArgs){
document_xml = response;
},
// The ERROR function will be called in an error case.
error: function(response, ioArgs){
}
});
if(document_xml != null && document_xml != "") {
var document_xmldoc = window.q_XmlUtils.getXmlDocFromString(document_xml);
var document_FolderUNID = window.q_XmlUtils.getDocSnxValue(document_xmldoc, "h_FolderUNID");
if (document_FolderUNID) {
folder = window.q_BaseLoader.allViews[document_FolderUNID];
}
}
if (typeof folder == "undefined") {
return window.q_FolderUtils.getFirstFolderInTOC(callback, bAllowIndex);
}
} else {
return window.q_FolderUtils.getFirstFolderInTOC(callback, bAllowIndex);
}
}
// filter out Index, Forums, Calendar, Tasks, Customize and Trash in TOC
// also filter out Lists
if ((folder.systemName && (folder.systemName == "h_Index"
|| folder.systemName == "h_49B9AB68350FB355482576890021FE8D"
|| folder.systemName == "h_Calendar"
|| folder.systemName == "h_TaskList"
|| folder.systemName == "h_Tailor"
|| folder.systemName == "h_TrashList")) ||
(folder.folderSubStyle && (folder.folderSubStyle == "h_List"))) {
return window.q_FolderUtils.getFirstFolderInTOC(callback, bAllowIndex);
}
if (folder && folder.proxyUnid && folder.proxyUnid.length > 0) {
unid = folder.proxyUnid;
if (callback && typeof callback == "function") {
callback(unid);
}
return unid;
}
} else {
window.q_FolderUtils.getFirstFolderInTOC(callback, bAllowIndex);
}
},
_allowPageNav: function() {
return q_DocUtils.state.allowPageNav();
},
_createFolder: function(defFolder) {
if (!defFolder || defFolder == "") {
if (q_BaseLoader.user.baseAccess < window.q_GeneralUtils.access.level.manager) {//if not a manager need to alert the user they can't do this
window.q_GeneralUtils.qkrWarning(q_LocaleUtils.getStringResource("PLACE.PLACE_ACTIONS.NO_FOLDERS"));
return;
}
defFolder = "toc";
}
if (this._allowPageNav()) {
this.publishEvent(this.ACTION.FOLDER.CREATE, {folderUnid: defFolder});
}
},
_createRoom: function() {
if (this._allowPageNav()) {
this.publishEvent(this.ACTION.ROOM.CREATE, {});
}
},
_createImportedPage: function(defFolder) {
if (!defFolder || defFolder == "") {
defFolder = this._getLibraryOrRoomIndex();
}
if (this._allowPageNav()) {
this.publishEvent(
this.ACTION.MODALPAGE.CREATE,
{
folderUnid: defFolder,
modal: true,
formUnid: q_BaseLoader.defaultForms["ImportedFile"].unid,
createParms: {
xsl: "importedPage_create.xsl",
formName: "CreateModalPage",
title: "FOLDER.NEW_MENU.IMPORTED_PAGE"
}
}
);
}
},
_createPage: function(defFolder) {
if (!defFolder || defFolder == "") {
defFolder = this._getLibraryOrRoomIndex();
}
// TO DO: CHANGE THIS WHEN THERE IS A FOLDER PICKER!
var oEvt = new quickr.widgets.misc.eventlink(
{
event: this.ACTION.PAGE.CREATE,
args: {folderUnid: defFolder, formUnid: q_BaseLoader.defaultForms["BasicPage"].unid}
}
);
window.location.href = oEvt.getEventLinkFromProperties(oEvt.getLinkArguments());
oEvt.destroyRecursive();
},
_createLinkPage: function(defFolder) {
if (!defFolder || defFolder == "") {
defFolder = this._getLibraryOrRoomIndex();
}
// TO DO: CHANGE THIS WHEN THERE IS A FOLDER PICKER!
var oEvt = new quickr.widgets.misc.eventlink(
{
event: this.ACTION.PAGE.CREATE,
args: { folderUnid: defFolder, formUnid: q_BaseLoader.defaultForms["URLLinkPage"].unid }
}
);
window.location.href = oEvt.getEventLinkFromProperties(oEvt.getLinkArguments());
oEvt.destroyRecursive();
},
_createUpload: function(defFolder) {
// TO DO: CHANGE THIS WHEN THERE IS A FOLDER PICKER!
if (!defFolder || defFolder == "") {
defFolder = this._getLibraryOrRoomIndex();
}
if (this._allowPageNav()) {
this.publishEvent(this.ACTION.UPLOAD.CREATE,
{folderUnid: defFolder, modal: true, formUnid: q_BaseLoader.defaultForms["SingleUpload"].unid });
}
},
_createLibraryConnectorPage: function(defFolder) {
// TO DO: CHANGE THIS WHEN THERE IS A FOLDER PICKER!
if (!defFolder || defFolder == "") {
defFolder = this._getLibraryOrRoomIndex();
}
if (this._allowPageNav()) {
this.publishEvent(this.ACTION.CUSTOMLIBRARY.CREATE,
{ folderUnid: defFolder, modal: true, unid: q_BaseLoader.defaultForms["CustomLibrary"].unid });
}
},
_addToConnectors: function() {
window.location.href = window.connectors.getAddPlaceURL();
},
_showPreferences: function() {
window.connectors.showPreferencesDialog("");
},
_goToCreatePage: function() {
q_GeneralUtils.goToCreatePage();
},
_createListFolder: function (defFolder) {
if (this._allowPageNav()) {
if (!defFolder || defFolder == "") {
if (q_BaseLoader.user.baseAccess < window.q_GeneralUtils.access.level.manager) {//if not a manager need to alert the user they can't do this
window.q_GeneralUtils.qkrWarning(q_LocaleUtils.getStringResource("PLACE.PLACE_ACTIONS.NO_FOLDERS"));
return;
}
defFolder = "toc";
}
this.publishEvent(this.ACTION.LIST.CREATE, {folderUnid: defFolder});
}
},
_whatsNew: function () {
var oEvt = new quickr.widgets.misc.eventlink(
{
event: this.ACTION.PAGE.OPEN,
args: {systemName: "h_WhatsNew", period: "day" }
}
);
document.location.href = oEvt.getEventLinkFromProperties(oEvt.getLinkArguments());
oEvt.destroyRecursive();
},
_offline: function() {
this.publishEvent(
this.ACTION.DIALOG.OPEN,
{
fullScreen: true,
title: 'PLACE.PLACE_ACTIONS.OFFLINE_TITLE',
href: this.getRootUrl() + this.getBaseUrl() + '/$defaultview/A22C4328A85E9873052568B0005C0C98/?OpenDocument'
}
);
},
_goToSiteMap: function () {
var windowWidth=275;
var windowHeight=300;
window.currentRoom = { roomNsf: window.q_GeneralUtils.getRoomNSF() };
var remoteUrl = window.q_GeneralUtils.getPlaceUrl() + "/" + "Main.nsf" + "/?OpenDatabase&Form=h_SiteMapUI&NoWebCaching";
var remoteWindow = window.open( remoteUrl, "Remote", "resizable=yes,width=" + windowWidth + ",height=" + windowHeight + ",top=20,left=20,toolbar=no,scrollbars=yes,menubar=no,status=no");
if (remoteWindow != null) {
remoteWindow.focus();
}
}
});
dojo.declare("quickr.widgets.menu.placeActionsMenu",
[quickr.widgets.menu._placeActionsMenu],
{
}
);
Where would i change the width of this button?
Width is changed using CSS.
You can do it inline like...
<span class="lotusBtn lotusBtnAction" style="width:300px">
or in a CSS file like..
.lotusBtn{width:300px}

Categories

Resources