exports.add = function() { // Check for empty submissions if (pageData.get("grocery").trim() !== "" && pageData.get("disc").trim() !== "") { // Dismiss the keyboard page.getViewById("grocery").dismissSoftInput(); page.getViewById("disc").dismissSoftInput(); groceryList.add(pageData.get("grocery"),pageData.get("disc")) .catch(function(error) { // console.log(error); dialogsModule.alert({ message: "An error occurred while adding an item to your list.", okButtonText: "OK" }); }); // Empty the input field pageData.set("disc", ""); pageData.set("grocery", ""); } else { dialogsModule.alert({ message: "Enter a grocery item", okButtonText: "OK" }); } };
function navigatedTo(args) { console.log('=== menu-chapters.js navigatedTo'); _chapters.set('pathId', args.context.pathId); _chapters.set('selectedIndex', args.context.selectedIndex); // //inspect(args.context.pathId); //inspect(args.context.selectedIndex); //var elTypeBar = page.getViewById('typeSegmentedBar'); //var typeBarBindingOptions = { // sourceProperty: 'subMenuSelectedIndex', // targetProperty: 'selectedIndex', // twoWay: true //}; //elTypeBar.bind(typeBarBindingOptions, RekData.nav); //let apa = RekData.getSubmenu(args.context.pathId, args.context.selectedIndex); // //var grid = page.getViewById('gridlay'); // //grid.bindingContext = apa; // //var elTypeSegmentedBar = page.getViewById('typeSegmentedBar'); // //elTypeSegmentedBar.bindingContext = RekData.getSubmenuSelectedIndex(); }
exports.add = function() { if (pageData.get("isShowingRecent")) { return; } if (pageData.get("grocery").trim() === "") { dialogsModule.alert({ message: "Enter a grocery item.", okButtonText: "OK" }); return; } showPageLoadingIndicator(); page.getViewById("grocery").dismissSoftInput(); groceryList .add(pageData.get("grocery")) .catch(function(error) { console.log(error); dialogsModule.alert({ message: "An error occurred while adding an item to your list.", okButtonText: "OK" }); }) .then(function() { groceryListElement.scrollToIndex(0); hidePageLoadingIndicator(); }); // Clear the textfield pageData.set("grocery", ""); };
function createViewModel() { var viewModel = new Observable(); viewModel.set("isEngLang", isEngLang); viewModel.getItem = function () { var url = viewModel.resolveServiceURL(); http.request({ url: url, method: "GET" }).then(function (response) { //http://10.0.2.2:89 or http://10.0.3.2:89 is your localhost because of the VM and the emulator //E.g. http://10.0.3.2:89/api/mycustomservice/newsitems?$select=Id,Title,PublicationDate var item = response.content.toJSON(); viewModel.set("title", item.Title); viewModel.set("publicationDate", item.PublicationDate); viewModel.set("content", item.Content); viewModel.set("author", item.Author); if (item.RelatedMedia) { viewModel.set("relatedMedia", item.RelatedMedia); } }, function (e) { alert("Please review your endpoint. Error message: " + e); console.log(e); }); }; viewModel.refreshInES = function () { if(isEngLang) { viewModel.refreshUI("ES"); } }; viewModel.refreshInEN = function () { if(!isEngLang) { viewModel.refreshUI("EN"); } }; viewModel.refreshUI = function (lang) { isEngLang = !isEngLang; viewModel.set("isEngLang", isEngLang); LANG = lang; viewModel.getItem(); }; viewModel.resolveServiceURL = function () { var result = ServiceEndPoint; result += viewModel.servicePath; result = formatString(result, [viewModel.id, LANG]); return result; } return viewModel; }
function loaded(args) { console.log('=== menu-chapters.js loaded'); _page = args.object; _page.bindingContext = _chapters; _chapters.set('selectedIndex', 1); _chapters.set('chapters', {}); _chapters.set('pathId', ''); }
exports.save = function() { if (!checkFieldValue('name')) return; if (!checkFieldValue('server')) return; appSettings.setBoolean('setup', true); appSettings.setString('name', settings.get('name')); appSettings.setString('server', settings.get('server')); page.closeModal(); };
var refresh = setInterval(function() { start++; if (start >= 100) { model.set("isBusy", false); model.set("isLoaded", "LOADED"); clearInterval(refresh); } }, 25)
var refresh = setInterval(function() { start++; if (start % 2 === 0) { model.set("imgSrc", "~/resources/images/homer1.gif"); } else { model.set("imgSrc", "~/resources/images/homer2.gif"); } }, 500)
exports.toggleRecent = function() { var isShowingRecent = !pageData.get("isShowingRecent"); pageData.set("isShowingRecent", isShowingRecent); if (!isShowingRecent) { addFromHistory(); } };
// Event handler for Page "navigatingTo" event attached in main-page.xml function onLoaded(args) { // Get the event sender page = args.object; // addTabViewItem(); var vm = new observable_1.Observable(); vm.set("isItemVisible", false); page.bindingContext = vm; }
var generateImage = _.debounce(function() { var image = imageManipulation.addText({ image: originalImage, topText: viewModel.get("topText"), bottomText: viewModel.get("bottomText"), fontSize: viewModel.get("fontSize"), isBlackText: viewModel.get("isBlackText") }); viewModel.set("memeImage", image); }, 10, { leading: true });
exports.navigatedTo = function() { originalImage = page.navigationContext; viewModel.set("memeImage", page.navigationContext); viewModel.addEventListener(observable.Observable.propertyChangeEvent, function(changes) { if (changes.propertyName === "memeImage") { return; } generateImage(); }); };
function loaded(args) { page = args.object; page.bindingContext = sections; sections.set('selectedIndex', 1); var newSections = (0, _sharedUtilsDataStore.getMasterData)().filter(function (b) { return b[typeNames[sections.selectedIndex]] === true; }).map(function (chapter) { return { name: chapter.name, id: chapter.id }; }).sort(); sections.set('sections', newSections); }
function carregaDetalhe() { var context = _page.navigationContext; detalhe.set('escudo', context.escudo); detalhe.set('time', context.time); detalhe.set('nome', 'Técnico: ' + context.nome); httpRequest.getJSON('https://api.cartolafc.globo.com/time/' + context.slug) .then(function(retorno) { detalhe.set('patrimonio', 'C$ ' + retorno.patrimonio.toFixed(2)); detalhe.set('pontuacao', 'Pontuação: ' + retorno.pontos.toFixed(2) + ' pts'); }); }
somePropertyChange: function(args) { if (args.propertyName === "checked") { if (args.value === true) { model.set("isSwitched", "ON"); } else { model.set("isSwitched", "OFF"); } } if (args.propertyName === "value") { } },
exports.saveLocally = function() { _viewData.set("isBusy", true); analyticsMonitor.trackFeature("CreateTemplate.SaveLocally"); var image = _viewData.get("imageSource"); if (image) { templates.addNewLocalTemplate(_uniqueImageNameForSession, image); } //todo ... what should be done without an image? _viewData.set("isBusy", false); navigation.goHome(); };
exports.loaded = function(args) { _page = args.object; if (applicationModule.ios) { _page.ios.title = "New Template"; } _page.bindingContext = _viewData; _uniqueImageNameForSession = utilities.generateUUID() + ".png"; _viewData.set("pictureTaken", false); _viewData.set("isBusy", false); _viewData.set("imageSource", null); };
exports.loaded = function(args) { console.log("hello topoWebView"); page = args.object; page.bindingContext = pageData; setupWebViewInterface(page); pageData.on(Observable.propertyChangeEvent, function(args) { _loadtopo(pageData.get("curTopo")); }); pageData.set("curTopo",1); };
exports.sendMessage = function (args) { if (pageData.get("message").trim() === "") { Dialog.alert({ message: "Your need to enter a message before sending a message", okButtonText: "OK" }); return false; } Page.getViewById("message").dismissSoftInput(); data.sendMessage(pageData.get("message")); pageData.set("message", ""); }
groceryList.load().then(function() { pageData.set("isLoading", false); listView.animate({ opacity: 1, duration: 1000 }); });
function loaded(args) { _page = args.object; _page.bindingContext = _sections; _sections.set('selectedIndex', 1); console.log('=== loaded'); var newSections = (0, _sharedUtilsDataStore.getMasterData)().filter(function (b) { return b[_typeNames[_sections.selectedIndex]] === true; }).map(function (chapter) { return { name: chapter.name, id: chapter.id }; }) //.map(chapter => ({name: chapter.name, id: chapter.id}) .sort(); _sections.set('sections', newSections); }
_chapters.on(_dataObservable.Observable.propertyChangeEvent, function (propertyChangeData) { console.log('_sections property ' + propertyChangeData.propertyName + ' has been changed and the new value is: ' + propertyChangeData.value); if (propertyChangeData.propertyName === 'selectedIndex') { //inspect(_chapters.get('selectedIndex')); //inspect(_chapters.get('pathId')); var newChapters = (0, _sharedUtilsDataStore.getMasterData)().filter(function (section) { return section.id === _chapters.get('pathId'); }); if (newChapters.length === 1) { newChapters = newChapters[0].chapters.filter(function (b) { return b[_typeNames[_chapters.get('selectedIndex')]] === true; }).map(function (section) { return { name: section.name, id: section.id }; }).sort(); (0, _sharedUtilsDebug.inspect)(newChapters); _chapters.set('chapters', newChapters); } else { console.log('ERROR: NOT EXACTLY 1'); //todo error handle if response is not exactly 1 } //let newSections = getMasterData() // .filter(b => b[_typeNames[propertyChangeData.value]] === true) // .map(chapter => ({ name: chapter.name, id: chapter.id })) // .sort(); //_sections.set('sections', newSections) } });
callback : function(beacons){ var items =[]; for (var i = 0; i < beacons.length; i++) { var beacon = beacons[i]; if (beacon.major > 0){ var distance = "NA"; var identifier = "Major:" + beacon.major + " Minor:" + beacon.minor; if (beacon.proximity) { distance = beacon.proximity; } var item = { "proximity" : beacon.proximity, "identifier": identifier, "distance": "Distance: " + distance, "rssi": "Power: " + beacon.rssi + "dBm" }; items.push(item); } } data.set("beacons", new observableArrayModule.ObservableArray(items)); }
onLoaded: function(args) { var page = args.object; page.bindingContext = model; topmost = frameModule.topmost(); // Button var button = view.getViewById(page, "myBtn"); var options = { sourceProperty: "buttonTitle", targetProperty: "text" }; button.bind(options, model); model.set("buttonTitle", "Cancel"); // Label var label = view.getViewById(page, "myLabel"); var options = { sourceProperty: "oldText", targetProperty: "text" }; label.bind(options, model); model.set("oldText", "Changed"); model.set("switch", true); if (model.get("switch")) { } // Text field var txtField = view.getViewById(page, "myField"); var options = { sourceProperty: "oldText", targetProperty: "text" }; txtField.bind(options, model); model.set("oldText", "My text input"); },
notesList.load().then(function() { pageData.set("isLoading", false); console.log("load callback...") listView.animate({ opacity: 1, duration: 600 }) });
function pageLoaded(args) { var page = args.object; slideContainer = page.getViewById('slideContainer'); // console.log(slideContainer); var items = new observableArray.ObservableArray(); var cash = new observableArray.ObservableArray(); viewModel = new observable.Observable(); items.push('Menu','About','About'); cash.push('Income','Cash Flow From Operations','Operations1','Operations2'); console.log(cash); viewModel.set("cash", cash); viewModel.set("items", items); viewModel.set("selectedIndex", 1); page.bindingContext = viewModel; }
.then(function () { loader.busy = true; animationComplete = true; console.log("Animation finished"); if(loadedObservable.get("loaded")){ doNavigation(); } })
exports.addFromHistory = function() { pageData.set("isHistoryLoading", true); groceryList.restore() .catch(handleAddError) .then(function() { pageData.set("isHistoryLoading", false); }); };
exports.submitToEverlive = function() { _viewData.set("isBusy", true); var image = _viewData.get("imageSource"); if (image) { analyticsMonitor.trackFeatureStart("CreateTemplate.SavedToEverlive"); templates.addNewPublicTemplate(_uniqueImageNameForSession, image) .then(function(){ analyticsMonitor.trackFeature("CreateTemplate.SavedToEverlive"); analyticsMonitor.trackFeatureStop("CreateTemplate.SavedToEverlive"); navigation.goHome(); }); } _viewData.set("isBusy", false); };
function pageLoaded(args) { var page = args.object; if (page.ios) { var controller = frameModule.topmost().ios.controller; // show the navbar frameModule.topmost().ios.navBarVisibility = "always"; // set the title page.ios.title = 'Estimote Beacons'; var navigationBar = controller.navigationBar; // set bar color to system blue constant // set bar color to a nice dark blue with RGBA navigationBar.barTintColor = UIColor.colorWithRedGreenBlueAlpha(157/255, 182/255, 168/255, 1); navigationBar.titleTextAttributes = new NSDictionary([UIColor.whiteColor()], [NSForegroundColorAttributeName]); navigationBar.barStyle = 1; } var items = new observableArrayModule.ObservableArray([]); data.set("beacons", items); page.bindingContext = data; this.options = { callback : function(beacons){ var items =[]; for (var i = 0; i < beacons.length; i++) { var beacon = beacons[i]; if (beacon.major > 0){ var distance = "NA"; var identifier = "Major:" + beacon.major + " Minor:" + beacon.minor; if (beacon.proximity) { distance = beacon.proximity; } var item = { "proximity" : beacon.proximity, "identifier": identifier, "distance": "Distance: " + distance, "rssi": "Power: " + beacon.rssi + "dBm" }; items.push(item); } } data.set("beacons", new observableArrayModule.ObservableArray(items)); } }; new Estimote(this.options).startRanging(); }