Ejemplo n.º 1
0
function pageLoaded(args) {
    var page = args.object;
    page.bindingContext = createViewModel();

    var gridview = view.getViewById(page, "grid");
    var labelview = view.getViewById(page, "v01");
    
    var labelview21 = view.getViewById(page, "v21");
    
    var movingLabel = new labelModule.Label();
    gridModule.GridLayout.setColumn(movingLabel, 0);
    gridModule.GridLayout.setRow(movingLabel, 0);
    movingLabel.text = "8";
    movingLabel.cssClass = "tile";
    labelview21.addChild(movingLabel);

    gridview.on(gestures.GestureTypes.swipe, function (args) {
        console.log("Swipe Grd");
        
        var label = new labelModule.Label();
        gridModule.GridLayout.setColumn(label, 0);
        gridModule.GridLayout.setRow(label, 0);
        label.text = "8";
        label.cssClass = "tile";
        labelview.addChild(label);
        
        movingLabel.animate({
            translate: { x: 0, y: 100},    
            duration: 1000,
            curve: enums.AnimationCurve.easeIn
        });
    });
}
Ejemplo n.º 2
0
function onNavigatedTo(args) {
	page = args.object;
	hotButton = view.getViewById(page, "hotBtn");
	coldButton = view.getViewById(page, "coldBtn");
	imageElement = view.getViewById(page, "imageElement");
	page.bindingContext = model;
	if (global.connectivity.getConnectionType() === connectivity.connectionType.none) {
		global.crash.play();
		Toast.makeText("No internet connection.").show();
	} else {
		model.loadItem(args.context);
		attachEvents(imageElement);
	}
}
Ejemplo n.º 3
0
function loginTap(args) {
    var usernameField = view.getViewById(page, "username");
    if (usernameField.text == "") {
        alert("Please enter username.");
        return;
    }

    var passwordField = view.getViewById(page, "password");
    if (passwordField.text == "") {
        alert("Please enter password.");
        return;
    }

    /*
     * Everlive is the SDK of the BAAS we are using as part of the
     * Telerik Platform. (see more here: http://platform.telerik.com)
     * 
     * For more info on what this SDK offers - http://docs.telerik.com/platform/backend-services/what-are-telerik-backend-services
     *
     * You can use any other JavaScript or native SDKs with NativeScript.
     */
    var el = new everlive(global.TELERIK_BAAS_KEY);
    var activityIndicator = view.getViewById(page, "activityIndicator");
    activityIndicator.busy = true;

    el.Users.login(usernameField.text,
        passwordField.text,
        function (data) {
            activityIndicator.busy = false;
            saveToken(data.result.access_token);
            frameModule.topmost().navigate("app/views/main");
        },
        function (error) {
            activityIndicator.busy = false;
            
            /*
             * Here you can see a more advanced usage of the dialogs.alert.
             * You can specify the dialog header and the string used for the OK button.
             * 
             * For more options you can check the docs - http://docs.nativescript.org/ui-dialogs
             */
            alert({
                title: "Error logging you in!",
                message: error.message,
                okButtonText: "Close"
            });
        }
    );
}
Ejemplo n.º 4
0
function pageLoaded(args) {
    var page = args.object;

    var countries = [
        { name: "Nederland" },
        { name: "Belgie" },
        { name: "Luxemburg" },
        { name: "Duitsland" },
        { name: "Frankrijk" },
        { name: "Spanje" },
        { name: "Portugal" },
        { name: "Polen" },
        { name: "Schotland" },
        { name: "Ierland" },
        { name: "Griekenland" },
        { name: "Turkije" },
        { name: "Zwitserland" },
        { name: "Oosterijk" },
        { name: "Denemarken" },
        { name: "Japan" },
        { name: "Aruba" },
        { name: "Noorwegen" },
        { name: "Zweden" },
        { name: "Finland" }
    ];

    page.bindingContext = { countries };

    // Will work!
    var listView1 = listviewModule.getViewById(page, "listView1");
}
        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");
        },
Ejemplo n.º 6
0
function pageNavigatedTo(args) {
    var page = args.object;

    viewModel = new vmModule.ActivityViewModel();
    viewModel.activity = page.navigationContext;
    
    page.bindingContext = viewModel
    
    if (platformModule.device.os === "iOS") {
        var scrollView = viewModule.getViewById(page, "scrollView");
        scrollView.ios.directionalLockEnabled = true;
        
        var listView = viewModule.getViewById(page, "commentsList");
        listView.ios.scrollEnabled = false;
    }
    
    MONITOR.trackFeature('View.Activity');
}
Ejemplo n.º 7
0
exports.pageNavigatedTo = function (args) {

    page = args.object;
    viewModel = new Observable.Observable(data);
    page.bindingContext = viewModel;

    container = view.getViewById(page, 'container');

};
Ejemplo n.º 8
0
exports.loaded = function(args) {
    var page = args.object;
    if(appSettings.getBoolean("logged")) {
        page.getViewById("email").text = global.useremail;
    }
    var tab1 = view.getViewById(page, "mainStack");
    tab1.observe(gestures.GestureTypes.tap, function (args) {
        /*
        page.getViewById("phone").dismissSoftInput();
        page.getViewById("yourname").dismissSoftInput();
        page.getViewById("email").dismissSoftInput();
        */
    });
};
Ejemplo n.º 9
0
 ViewModelBase.prototype.disableAutoCorrect = function (page, viewName) {
     /*
     * we will have cross-platform way to disable intellisense for the textfield in v1
     *
     * https://github.com/NativeScript/cross-platform-modules/issues/147
     * https://github.com/NativeScript/cross-platform-modules/issues/146
     *
     */
     if (platformModule.device.os === IOS_OS_NAME) {
         var view = viewModule.getViewById(page, "username");
         view.ios.autocorrectionType = UITextAutocorrectionType.UITextAutocorrectionTypeNo;
         view.ios.autocapitalizationType = UITextAutocapitalizationType.UITextAutocapitalizationTypeNone;
     }
 };
exports.load = function(args) {
  var page = args.object;
  var username = viewModule.getViewById(page, "username");
  pageData.set("logoSource", images.logo);
dialogs.alert("images.logo = " + images.logo);
  page.bindingContext = pageData;
  // Turn off autocorrect and autocapitalization for iOS
  if (username.ios) {
      username.ios.autocapitalizationType =
          UITextAutocapitalizationType.UITextAutocapitalizationTypeNone;
      username.ios.autocorrectionType =
          UITextAutocorrectionType.UITextAutocorrectionTypeNo;
  }
};
Ejemplo n.º 11
0
function onLoaded(args){
	page = args.object;

	takeAccessTokenFromFile();

	playlistViewModel  = playlistViewModule.listViewModel;
	page.bindingContext = playlistViewModel;

	var listView = view.getViewById(page, 'lv_playlists');
	listView.on('itemTap', requestTapedPlaylist);

	if(playlistViewModel.length == 0) {
		makePlaylistRequest();
	}
}
exports.add = function() {
    // Check for empty submissions
    if (pageData.get("trees").trim() !== "") {
        // Dismiss the keyboard
        viewModule.getViewById(page, "trees").dismissSoftInput();
        treesList.add(pageData.get("trees"))
            .catch(function() {
                dialogsModule.alert({
                    message: "An error occurred while adding an item to your list.",
                    okButtonText: "OK"
                });
            });
        // Empty the input field
        pageData.set("trees", "");
    } else {
        dialogsModule.alert({
            message: "Enter a new tree item.",
            okButtonText: "OK"
        });
    }
};
Ejemplo n.º 13
0
exports.pageNavigatedTo = function (args) {

    page = args.object;
    var container = view.getViewById(page, "web-view-source");
    var id = page.navigationContext.id;
    var title = page.navigationContext.title;
    var subTitle = page.navigationContext.subTitle || false;
    var date = page.navigationContext.date || false;
    var content = page.navigationContext.content || "~/data/" + id + ".html";

    //add view model
    viewModel.id = id;
    viewModel.title = title;
    viewModel.content = content;
    viewModel.subTitle = subTitle;
    viewModel.date = date;

    //at the end
    page.bindingContext = viewModel;

};
Ejemplo n.º 14
0
function onSearch() {
    while (filteredUsers.length > 0) {
        filteredUsers.pop();
    }

    var searchBox = view.getViewById(page, "search-box");
    var searchText = searchBox.text.toLowerCase();

    userService.getAllUsers()
        .then(function (data) {
                var users = data.result;
                for (var i = 0; i < users.length; i++) {
                    if (users[i].Email.toLowerCase().indexOf(searchText) >= 0) {
                        filteredUsers.push(users[i]);
                    }
                }
            },
            function (error) {
                alert(JSON.stringify(error));
            });

    pageData.set("filteredUsers", filteredUsers);
}
Ejemplo n.º 15
0
function sendTapped(args) {
  var sender = args.object;
  var parent = sender.parent;

  if (parent) {
    var textInput = view.getViewById(parent, "cityName");

    requestBody += "&args=" + textInput.text;

    console.log("**** " + textInput.text);

    http.request({ url: requestUrl + "/showWeather", method: "POST",
                   headers: spark.requestHeaders,
                   content: requestBody }).then(function (response) {
        var statusCode = response.statusCode;

        console.log("**** " + statusCode);
    }, function (e) {
        console.log("ERROR ***** " + JSON.stringify(e));
        done(e);
    });
  }
}
exports.onLoaded = function(args) {
    page = args.object;
    updateStackLayout = view.getViewById(page, "updateStackLayout");
    
    var scrapbook = new observable.fromObject({
        pages: new observableArray.ObservableArray(),
        selectedPage: null,
        calAge: function (birthDate) {
            var now = Date.now();
            var diff = Math.abs(now - birthDate) / 1000 / 31536000;

            return diff.toFixed(1);
        }
    });

    var pages = fileSystemService.fileSystemService.getPages();

    if (pages.length !== 0) {
        pages.forEach(function (item) {
            var model = new scrapbookPageModel();
            
            model.id = item.id;
            model.title = item.title;
            model.gender = item.gender;
            model.birthDate = item.birthDate;
            model.image = item.image;
            model.lat = item.lat;
            model.long = item.long;
            model.isActive = item.isActive;
            
            scrapbook.pages.push(model);
        });
    }

    page.bindingContext = scrapbook;
};
function pageLoaded(args)
{
    var page = args.object;
    var tabView1 = view.getViewById(page, "tabView1");
    tabView1.selectedIndex = 1;
}
Ejemplo n.º 18
0
function onSaveButtonTap(args) {

    var nameField = view.getViewById(page, "name");
    var name = nameField.text;
    if (name == "") {
        alert("Please enter your name.");
        return;
    }

    var emailField = view.getViewById(page, "email");
    var email = emailField.text;
    if (email == "") {
        alert("Please enter your email.");
        return;
    }

    var usernameField = view.getViewById(page, "username");
    var username = usernameField.text;
    if (username == "") {
        alert("Please enter username.");
        return;
    }

    var passwordField = view.getViewById(page, "password");
    var password = passwordField.text;
    if (password == "") {
        alert("Please enter password.");
        return;
    }

    var passwordRepeatField = view.getViewById(page, "passwordRepeat");
    if (passwordRepeatField.text != password) {
        alert("Passwords did not match.");
        return;
    }
    var el = new everlive({
        apiKey: TELERIK_BAAS_KEY,
        token: localSettings.getString(TOKEN_DATA_KEY)
    });
    var activityIndicator = view.getViewById(page, "activityIndicator");
    activityIndicator.busy = true;

    var attrs = {
        Email: email,
        DisplayName: name
    };

    el.Users.register(username,
        password,
        attrs,
        function (data) {
            activityIndicator.busy = false;
            alert({
                title: "Registration sucess!",
                message: "Please login with your credentials now.",
                okButtonText: "Close"
            });
            frameModule.topmost().goBack();
        },
        function (error) {
            activityIndicator.busy = false;
            alert({
                title: "Registration problem!",
                message: error.message,
                okButtonText: "Close"
            });
        });
}
Ejemplo n.º 19
0
 viewModel.showMenu = function (args) {
     var sideMenu = view.getViewById(viewModel.currentPage, mainMenuId);
     if (sideMenu) {
         sideMenu.showDrawer();
     }
 };
Ejemplo n.º 20
0
exports.loaded = function(args) {
    var page = args.object;
    page.bindingContext = user;
    email = viewModule.getViewById(page, "email");
};
 HelloWorldModel.prototype.getTempFieldValue = function() {
     var tempField = view.getViewById(this.thePage, "tempInput"); //have to get field manually
     var tempVal = tempField.ios.text;
     return tempVal;
 };
Ejemplo n.º 22
0
 LayoutBase.prototype.getChildById = function (id) {
     return view.getViewById(this, id);
 };
Ejemplo n.º 23
0
 global.getElementById = function (id) {
     return view.getViewById(getCurrentActiveModel(), id);
 };
function setFocusToTextField() {
    var page = frameModule.topmost().currentPage;
    var commentTextBox = viewModule.getViewById(page, "add-activity-text");
    
    commentTextBox.focus();
}
Ejemplo n.º 25
0
 view.View.prototype.getElementById = function (id) {
     return view.getViewById(this, id);
 };