In jsdoc default template, nav bar is constructed in publish.js buildNav function.
e.g.
nav += buildMemberNav(members.events, 'Events', seen, linkto);
However, there's no members.functions.
I'd like to know how to list all the functions (under every Namespace, class) in the nav bar.
I find a template https://github.com/nijikokun/minami/blob/master/publish.js#L298-L333 , where they create a sub list of methods for each class, as the reference.
Say, if we want to list all the functions under every namespace in the nav bar, we can have the following code to add the related html
var methods = find({kind:'function', memberof: item.longname});
item here in our case, is member.namespace
if (methods.length) {
itemsNav += "<ul class='methods'>";
methods.forEach(function (method) {
itemsNav += "<li data-type='method'>";
itemsNav += linkto(method.longname, method.name);
itemsNav += "</li>";
});
itemsNav += "</ul>";
}
Related
My page contains 3 tabs, if i forward to next page from tab3 and then coming back from that page using $ionicHistory.goBack() it redirects to tab1. how to make it redirects to tab3 itself
function sample($scope,$ionicHistory){
$ionicHistory.goBack();
};
}
I'm not sure it's possible to do that just through $state. I'm new to Ionic myself as I had my first peek back in December (2016). However, I happened to have this exact scenario. This is how I solved it.
In my case, I was not using tabs. Instead, I had three different DIVs that were visible depending on the "tab number". When initializing the view, I set it to "1" and used the property to control what code is executed.
I'm guessing that the control you're using has a property like that to identify and set the particular tab you need, as this is the most likely way to change tabs on tab-click. Consider putting the value of that property "tab #" into the appropriate service used by the controller. This is a stripped-down version of actual code in one of my services defined via Factory.
YourService.js:
// controllers are instances. When navigating away, state is lost. This
// tracks the tab we wish to view when we load the home page.
var activeHomePageTab = 1;
var service = {
getActiveTab: getActiveTab,
setActiveTab: setActiveTab,
...
};
return service;
////////////////
function getActiveTab() { return activeHomePageTab; }
function setActiveTab(num) { activeHomePageTab = num; }
...
Here, the functions are private. In your controller, when you set your tab, also set this property. As a singleton, this will remain in effect as long as your application is running.
Next, in your init() routine, when the controller is loaded, check for this property and set the tab if it is defined:
function init() {
var tab = YourService.getActiveTab();
if (tab !== undefined) {
setTab(tab);
} else {
setTab(1)
}
...
}
Of course, there are other ways - maybe using Value or a property on a Constant object.
Could someone point to me what is wrong with my code. I have successfully added custom fields on the standard js file (SearchResult.view.js). I know that this is not the best practice on how to add custom fields. So I implemented a pre post method for adding custom fields.
Unfortunately when I moved my custom code block to the pre post method, instead of adding one 1 row (field) it adds multiple rows. I tried creating a counter but it doesn't work also
Below is my custom js code. Thanks in advance!
function ADDCUSTOMFIELD1(){
};
ADDCUSTOMFIELD1.prototype.CUSTOM_POST_EXIT = function(methodName,view,controller, methodSignaure) {
if (!sap.ui.getCore().byId("ni_home"))
return;
else add_custom_item();
};
function add_custom_item(){
if (sap.ui.getCore().byId("subMatrix")){
// Supplier Name
matrixSubRow = new sap.ui.commons.layout.MatrixLayoutRow();
control = new sap.ui.commons.Label({
text : Appcc.getText("SUPPLIER_TEXT") + ":"
});// control.addStyleClass("search_middle_spacing");
matrixCell = new sap.ui.commons.layout.MatrixLayoutCell();
matrixCell.addContent(control);
control = new sap.ui.commons.Label();
control.bindProperty("text", "vendor_name");
if (sap.ui.getCore().getConfiguration().getRTL()) {
control.addStyleClass("search_middle_spacingNewRTL");
Appcc.addStyleClass(control, 'search_middle_spacingNew', true);
} else
control.addStyleClass("search_middle_spacingNew");
matrixCell.addContent(control);
// control = new sap.ui.commons.Label();
// control.bindProperty("text", "itm_price");
// control.addStyleClass("search_middle_spacing");
// matrixCell.addContent(control);
matrixSubRow.addCell(matrixCell);
sap.ui.getCore().byId("subMatrix").addRow(matrixSubRow);
}
}
Your custom code block adds multiple rows because the CUSTOM_POST_EXIT function is called for every event on a view. Multiple events on a single view are fired (beforerender, render, ondatamodelloaded, etc). The methodName argument is the name of the event. Try this
function ADDCUSTOMFIELD1() {};
ADDCUSTOMFIELD1.prototype.CUSTOM_POST_EXIT = function(methodName, view, controller, methodSignaure) {
var viewId = controller && controller.getView().getId();
console.log(viewId, methodName)
if (viewId === 'name_of_your_view' && methodName === 'onDataModelLoaded')
//implement your customization
}
}
You should see this function is being called for every view on your page an multiple times per view.
So you should check for which view and eventName the CUSTOM_POST_EXIT method is being called for and implement your customization only in 1 view/event combination.
I am using Ionic v1.0.0-rc.2.
As controller + views are cached in Ionic, one has to take care to properly initialize the controller $scope.
I am using the following callback to do this:
$scope.$on('$ionicView.beforeEnter', function(){
...
}
However, to know how to initialize the $scope I need to know how the view was called:
Was it called by a back button (A --> B --> back to A)
in this case I want to leave most items as is
Was it returned to after pressing a back button (A --> B --> back to A --> return to B)
in this case I want to leave most items as is
Was it entered following a new path (not back or forward) ... note that the the view may have already been instantiated from previous navigations
in this case I want to re-initialize the view
I have been looking at the documentation below, but could not find a way of doing this, or what parameters, if any, are passed into the callback function. Any documentation pointers would be great.
http://ionicframework.com/docs/api/directive/ionView/
http://blog.ionic.io/navigating-the-changes/
To determine what's going on in routes I chain this:
// Add state change hooks to log issues to console
.run(['$rootScope', '$state', '$urlMatcherFactory', function($rootScope, $state, $urlMatcherFactory) {
$rootScope.$state = $state;
function message(to, toP, from, fromP) { return from.name + angular.toJson(fromP) + " -> " + to.name + angular.toJson(toP); }
$rootScope.$on("$stateChangeStart", function(evt, to, toP, from, fromP) { console.log("Start: " + message(to, toP, from, fromP)); });
$rootScope.$on("$stateChangeSuccess", function(evt, to, toP, from, fromP) { console.log("Success: " + message(to, toP, from, fromP)); });
$rootScope.$on("$stateChangeError", function(evt, to, toP, from, fromP, err) { console.log("Error: " + message(to, toP, from, fromP), err); });
}])
This should get you going in the right direction with some customization.
I'm trying to add a CSS property dynamically to a control.
I have a group of RadioButton. On selection of any one of the buttons, I want to make one layout visible.
Below are some of the snippets I tried, none of them seem to work!
Snippet-1
showhide: function(){
var fcid = sap.ui.getCore().byId("FC7");
fcid.visibility = "hidden";
}
Snippet-2
showhide: function(){
var fcid = sap.ui.getCore().byId("FC7");
jquery('#fcid').css("visibility","hidden");
}`
Snippet-3
showhide: function(){
var fcid = sap.ui.getCore().byId("FC7");
jquery('#fcid').hide();
}
You cannot use fcid.visibility = "hidden"; and expect it to behave like a DOM object; it's not, it's a Javascript class with getters, setters, events, aggregations, etc.
Therefore, you should use the control's properties instead: fcid.setVisible(true);
See the API docs for the correct signature of the control/layout properties
You can:
var fcid = ...byId("FC7");
fcid.setVisible(false);
Or
fcid.$().hide(); // or every other jquery method
Or
fcid.addStyleClass("hiddenObject");
Last one with Css-Class:
.hiddenObject { display:none; }
I'm currently learning scala, and making an encryption program with a basic scala swing UI.
I added 2 swing buttons which text is held by 2 var.
The code looks like this :
var encText = "Encrypt"
var decText = "Decrypt"
def top = new MainFrame {
title = "Data Guardian"
minimumSize = new Dimension(500, 200)
contents = new GridPanel(2, 2) {
hGap = 3; vGap = 3
contents += new Button {
text = encText
reactions += {
case ButtonClicked(_) => Main.startEnc
}
}
contents += new Button {
text = decText
reactions += {
case ButtonClicked(_) => Main.startDec
}
}
}
size = new Dimension(150, 40)
}
Those "text" var will be changed often during the encryption/decryption process by various methods, but when they do change, the text displayed on the buttons doesn't.
I'd like to know a way to make the displayed text of the buttons automatically change when the var that holds that text changes.
Thanks a lot for your insight :)
Make the strings private and write getters/setters that change the button text as a side-effect.
You'll need to give the buttons names, rather than having anonymous instances as you do above.