Beispiel #1
0
		public static void InputKeypressHandler(jQueryEvent evt, InputElement el, TransformCharDelegate transformChar) {
			if (evt.AltKey || evt.CtrlKey)
				return; // don't ever change Alt+key or Ctrl+key

			if (jQuery.Browser.MSIE) {
				if (evt.Which == 13)
					return; // Enter seems to be the only non-printable key we catch in IE.
				char newc = transformChar((char)evt.Which);
				if (newc == 0) {
					evt.PreventDefault();
				}
				else if (newc != evt.Which) {
					((dynamic)evt).originalEvent.keyCode = newc;
				}
			}
			else {
				if (evt.Which == 0)
					return; // Firefox, and likely other non-IE browsers, lets us trap non-characters, but we don't want that.

				char newc = transformChar((char)evt.Which);
				if (newc == 0) {
					evt.PreventDefault();
				}
				else if (newc != evt.Which) {
					int startPos = ((dynamic)el).selectionStart,
					    endPos   = ((dynamic)el).selectionEnd;
					string oldVal = el.Value;
					el.Value = oldVal.Substr(0, startPos) + String.FromCharCode(newc) + oldVal.Substr(endPos);
					((dynamic)el).setSelectionRange(startPos + 1, startPos + 1);
					evt.PreventDefault();
				}
			}
		}
        private void SubmitForm(jQueryEvent e)
        {
            e.PreventDefault();

            string currentPassword = jQuery.Select("#change-password-current-password").GetValue();
            string password = jQuery.Select("#change-password-new-password").GetValue();
            string password2 = jQuery.Select("#change-password-new-password2").GetValue();

            if (currentPassword == "" || password == "" || password2 == "" || submittingForm)
            {
                return;
            }

            if (password.Length < 8 || password != password2)
            {
                ErrorModal.ShowError(Strings.Get("AddUserInvalidInput"));
                return;
            }

            submittingForm = true;

            ChangePasswordRequest request = new ChangePasswordRequest();
            request.currentPassword = currentPassword;
            request.newPassword = password;
            request.newPassword2 = password2;

            Request.Send(request, SubmitSuccess, SubmitFailure);
        }
		private void OnAddNearbyClick(jQueryEvent e)
		{
			try
			{
				Service.GetSurroundingPlaces(
					int.Parse(this.view.uiRadiusPlaceAutoComplete.Value),
					int.Parse(this.view.uiNumberOfSurroundingTownsDropDown.Value),
					delegate(PlaceStub[] result, object context, string name)
					{
						for (int i = 0; i < result.Length; i++)
						{
							this.view.uiPlacesMultiSelector.AddItem(result[i].name, result[i].k.ToString());
						}
						this.view.uiRadiusPlaceAutoComplete.Clear();
					},
					Trace.WebServiceFailure,
					null,
					5000
				);
				
			}
			catch(Exception)
			{
				
			}
			e.PreventDefault();
		}
		private void OnKeyDown(jQueryEvent e)
		{
			if ("ABCDEFGHIJKLMNOPQRSTUVWXYZ,.;#[]".IndexOf(String.FromCharCode(e.Which)) > -1)
			{
				e.PreventDefault();
			}
		}
Beispiel #5
0
        private void SubmitForm(jQueryEvent e)
        {
            e.PreventDefault();

            string name = jQuery.Trim(jQuery.Select("#admin-user-add-name").GetValue());
            string password = jQuery.Select("#admin-user-add-password").GetValue();
            string password2 = jQuery.Select("#admin-user-add-password2").GetValue();

            if (name == "" || password == "" || password2 == "" || submittingForm)
            {
                return;
            }

            RegularExpression regex = new RegularExpression("[^a-zA-Z0-9]");

            if (regex.Test(name) || password.Length < 8 || password != password2)
            {
                ErrorModal.ShowError(Strings.Get("AddUserInvalidInput"));
                return;
            }

            submittingForm = true;

            AdminUserAddRequest request = new AdminUserAddRequest();
            request.username = name;
            request.password = password;
            request.password2 = password2;
            request.admin = jQuery.Select("#admin-user-add-administrator").Is(":checked");

            Request.Send(request, SubmitSuccess, SubmitFailure);
        }
Beispiel #6
0
        private void ReportLinkClick(jQueryEvent e)
        {
            e.PreventDefault();

            var dialog = new ReportDialog(new ReportDialogOptions
            {
                ReportKey = J(e.Target).GetDataValue("key").As<string>()
            });
        }
Beispiel #7
0
        private void NavMangasClicked(jQueryEvent e)
        {
            e.PreventDefault();

            if (this.GetType() != typeof(AdminMangasModule))
            {
                AdminMangasModule.Instance.Show(null);
            }
        }
Beispiel #8
0
        private void NavLogoutClicked(jQueryEvent e)
        {
            e.PreventDefault();

            LoginRequest request = new LoginRequest();
            request.password = "******";

            Request.Send(request, LogoutSuccessful, LogoutSuccessful);
        }
Beispiel #9
0
        private void NavSettingsClicked(jQueryEvent e)
        {
            e.PreventDefault();

            if (this.GetType() != typeof(SettingsModule))
            {
                SettingsModule.Instance.Show(null);
            }
        }
Beispiel #10
0
        private void NavFoldersClicked(jQueryEvent e)
        {
            e.PreventDefault();

            if (this.GetType() != typeof(FoldersModule))
            {
                FoldersModule.Instance.Show(null);
            }
        }
Beispiel #11
0
		void GoLicense(jQueryEvent evt)
		{
			evt.PreventDefault ();
			Work.Empty ();
			Work.Append (@"<div class=""well"">
			             <p>Copyright AICL.</p>
			             <p>Licensed under the Apache License, Version 2.0 (the ""License""); you may not use this work except in compliance with the License. You may obtain a copy of the License in the LICENSE file, or at:</p><p><a target=""_blank"" href=""http://www.apache.org/licenses/LICENSE-2.0"">http://www.apache.org/licenses/LICENSE-2.0</a></p><p>Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an ""AS IS"" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.</p></div>");

			             }
        private void BrowseButtonClicked(jQueryEvent e)
        {
            e.PreventDefault();

            if (collectionId > 0)
            {
                AdminFinderModal.ShowDialog(jQuery.Select("#admin-manga-edit-path"), collectionId);
            }
        }
Beispiel #13
0
		void GoContact(jQueryEvent evt)
		{
			evt.PreventDefault ();
			Work.Empty ();
			Work.Append (@"<div class=""well"">
	<p><a target=""_blank"" href=""https://github.com/angelcolmenares"">https://github.com/angelcolmenares</a>
	<p><a target=""_blank"" href=""https://github.com/aicl"">https://github.com/aicl</a>
	</p></div>");

		}
Beispiel #14
0
		void GoAbout(jQueryEvent evt)
		{
			evt.PreventDefault ();
			Work.Empty ();
			Work.Append (@"<div class=""well"">
<p>Cayita is a library for building responsive webapps using C#  as base language and the Saltarelle compiler 
<a href=""http://www.saltarelle-compiler.com"" target=""_blank"">
http://www.saltarelle-compiler.com
</a>
</p>
</p></div>");

		}
		protected void KeyDown(jQueryEvent e)
		{
			if (e.Which == (int)39/*Key.Right*/)
			{
				if (OnArrowKeyPress != null)
					OnArrowKeyPress(this, EventArgs.Empty);
				if (OnPhotoNextClick != null)
					OnPhotoNextClick(this, EventArgs.Empty);
				e.PreventDefault();
			}
			else if (e.Which == (int)37/*Key.Left*/)
			{
				if (OnArrowKeyPress != null)
					OnArrowKeyPress(this, EventArgs.Empty); 
				if (OnPhotoPrevClick != null)
					OnPhotoPrevClick(this, EventArgs.Empty);
				e.PreventDefault();
			}
			//else if (e.KeyCode == (int)Key.Up)
			//{
			//    if (OnArrowKeyPress != null)
			//        OnArrowKeyPress(this, EventArgs.Empty);
			//    if (OnPhotoUpClick != null)
			//        OnPhotoUpClick(this, EventArgs.Empty);
			//    e.PreventDefault();
			//}
			//else if (e.KeyCode == (int)Key.Down)
			//{
			//    if (OnArrowKeyPress != null)
			//        OnArrowKeyPress(this, EventArgs.Empty);
			//    if (OnPhotoDownClick != null)
			//        OnPhotoDownClick(this, EventArgs.Empty);
			//    e.PreventDefault();
			//}
			else
			{
				NonArrowKeyDown(e);
			}
		}
Beispiel #16
0
        private void BrowseButtonClicked(jQueryEvent e)
        {
            e.PreventDefault();

            string cidString = jQuery.Select("#admin-manga-add-collection").GetValue();

            if (cidString == null || cidString == "" || submittingForm)
            {
                return;
            }

            AdminFinderModal.ShowDialog(jQuery.Select("#admin-manga-add-path"), int.Parse(cidString, 10));
        }
        private void EditCustomer(Element el, jQueryEvent evt)
        {
            var tr = jQuery.FromElement(el).Closest("tr");
            string dataStr = tr.GetAttribute("data-customer");
            var data = !string.IsNullOrEmpty(dataStr) ? Json.Parse<CustomerViewModel>(dataStr) : new CustomerViewModel();

            jQuery.Select("#customerId").Value(data.Id.HasValue ? data.Id.ToString() : "");
            jQuery.Select("#customerName").Value(data.Name ?? "");
            jQuery.Select("#customerProfitToDate").Value(data.ProfitToDate.ToString());

            ((DialogObject)jQuery.Select("#customerForm")).Open();

            evt.PreventDefault();
        }
Beispiel #18
0
        private void SubmitSearchForm(jQueryEvent e)
        {
            e.PreventDefault();

            MangaFilter filter = new MangaFilter();
            MangaSearchFilter search = filter.search = new MangaSearchFilter();
            search.title = jQuery.Select("#search-title").GetValue();
            search.folderSetting = Settings.SearchFolderSetting = int.Parse(jQuery.Select("#search-folder").GetValue(), 10);
            search.folder = MangasModule.Instance.CurrentFolder;
            search.author = jQuery.Select("#search-author").GetValue();
            search.series = jQuery.Select("#search-series").GetValue();
            search.publisher = jQuery.Select("#search-publisher").GetValue();
            search.year = int.Parse(jQuery.Select("#search-year").GetValue(), 10);
            if (Number.IsNaN(search.year))
            {
                search.year = -1;
            }

            MangasModule.Instance.Refresh(filter);
        }
		private void photoClick(jQueryEvent e)
		{
			e.PreventDefault();

			for (int i = 0; i < cells.Length; i++)
			{
				//                                  Image  Div(?)     TableCell
				if (cells[i] == (TableCellElement)e.Target.ParentNode.ParentNode)
				{
					SelectedIndex = i;
					break;
				}
			}

			highlightCell();

			if (OnChangePhoto != null)
				OnChangePhoto(this, new IntEventArgs(SelectedIndex));

		}
Beispiel #20
0
		private void Element_KeyPress(jQueryEvent e) {
			if (!RaiseKeyPress(e.Which)) {
				e.PreventDefault();
				return;
			}

			switch (e.Which) {
				case 32: {
					// Space - used to toggle checkmark if there is one.
					if (hasChecks) {
						if (selectedNode != null) {
							SetTreeNodeCheckState(selectedNode, selectedNode.checkState == TreeNodeCheckState.yes ? TreeNodeCheckState.no : TreeNodeCheckState.yes);
						}
						e.PreventDefault();
					}
					break;
				}
			
				case 37: {
					// key left - if current node exists and is expanded: collapse it, otherwise navigate to its parent
					if (selectedNode != null) {
						if (selectedNode.children.Count > 0 && selectedNode.expanded)
							DoSetTreeNodeExpanded(selectedNode, false, false);
						else if (selectedNode.parent != invisibleRoot)
							SetSelection(selectedNode.parent, true, true);
					}
					else if (invisibleRoot.children.Count > 0)
						SetSelection(invisibleRoot.children[0], true, true);
					e.PreventDefault();
					break;
				}

				case 38:
					// key up - navigate to the parent or to the most expanded node in the tree of the previous sibling
					if (selectedNode != null) {
						int index = GetTreeNodeChildIndex(selectedNode);
						if (index == 0) {
							if (selectedNode.parent != invisibleRoot)
								SetSelection(selectedNode.parent, true, true);
						}
						else {
							TreeNode n = (TreeNode)selectedNode.parent.children[index - 1];
							while (n.children.Count > 0 && n.expanded)
								n = (TreeNode)n.children[n.children.Count - 1];
							SetSelection(n, true, true);
						}
					}
					else if (invisibleRoot.children.Count > 0)
						SetSelection(invisibleRoot.children[0], true, true);

					e.PreventDefault();
					break;
					
				case 39:
					// key right - if current node has children: expand if collapsed, navigate to first child if expanded
					if (selectedNode != null) {
						if (selectedNode.children.Count > 0) {
							if (selectedNode.expanded) {
								SetSelection((TreeNode)selectedNode.children[0], true, true);
							}
							else {
								DoSetTreeNodeExpanded(selectedNode, true, false);
							}
						}
					}
					else if (invisibleRoot.children.Count > 0)
						SetSelection((TreeNode)invisibleRoot.children[0], true, true);

					e.PreventDefault();
					break;
					
				case 40: {
					// key down - navigate to the first child if the selected node is expanded, otherwise navigate to the next sibling of the closest node which has a next sibling.
					if (selectedNode != null) {
						if (selectedNode.children.Count > 0 && selectedNode.expanded) {
							SetSelection((TreeNode)selectedNode.children[0], true, true);
						}
						else {
							TreeNode n = selectedNode;
							for (;;) {
								if (n.parent == null)
									break;	// Obviously we are already at the last position.
								int index = GetTreeNodeChildIndex(n);
								if (index < n.parent.children.Count - 1) {
									SetSelection((TreeNode)n.parent.children[index + 1], true, true);
									break;
								}
								n = n.parent;
							}
						}
					}
					else if (invisibleRoot.children.Count > 0)
						SetSelection(invisibleRoot.children[0], true, true);

					e.PreventDefault();
					break;
				}
			}
		}
Beispiel #21
0
        private static void LaunchGlobalSettings(jQueryEvent e)
        {
            if(e != null)
                e.PreventDefault();

            IntentOptions options = new IntentOptions();
            options.Action = "android.settings.SETTINGS";

            Chameleon.Intent(options);
        }
Beispiel #22
0
 private static void HandleWiFiClick(jQueryEvent e)
 {
     e.PreventDefault();
     SwitchType switch_type = GetSwitchByName("wifi");
     if(switch_type.State=="disabled"){
         ApplySwitchState(switch_type,"highlighted",delegate()
         {
             SetWiFiState(true);
         });
     }else{
         ApplySwitchState(switch_type,"disabled",delegate()
         {
             SetWiFiState(false);
         });
     }
 }
Beispiel #23
0
 private static void HandleVibrateClick(jQueryEvent e)
 {
     e.PreventDefault();
     SwitchType switch_type = GetSwitchByName("vibrate");
     if(switch_type.State=="disabled"){
         ApplySwitchState(switch_type,"highlighted");
     }else{
         ApplySwitchState(switch_type,"disabled");
     }
 }
Beispiel #24
0
        private static void HandleGPSClick(jQueryEvent e)
        {
            e.PreventDefault();

            IntentOptions options = new IntentOptions();
            options.Action = "android.settings.LOCATION_SOURCE_SETTINGS";
            Chameleon.Intent(options);
        }
Beispiel #25
0
        private static void HandleBrightnessClick(jQueryEvent e)
        {
            e.PreventDefault();

            //launch display settings
            IntentOptions options = new IntentOptions();
            options.Action = "android.settings.DISPLAY_SETTINGS";
            Chameleon.Intent(options);
        }
Beispiel #26
0
        private void SubmitLogin(jQueryEvent e)
        {
            e.PreventDefault();

            if (loggingIn)
            {
                return;
            }

            LoginRequest request = new LoginRequest();
            request.username = jQuery.Select("#login-modal-username").GetValue();
            request.password = jQuery.Select("#login-modal-password").GetValue();

            if (String.IsNullOrEmpty(request.username) || String.IsNullOrEmpty(request.password))
            {
                return;
            }

            loggingIn = true;
            Request.Send(request, LoginSuccess, LoginFailure);
        }
Beispiel #27
0
        private void CancelButtonClicked(jQueryEvent e)
        {
            e.PreventDefault();
            if (loggingIn)
            {
                return;
            }

            InternalHide();
            if (!Script.IsNullOrUndefined(failureCallback))
            {
                failureCallback(new Exception(Strings.Get("LoginCancelled")));
            }
        }
		void placeSelectedChangeLinkClick(jQueryEvent e)
		{
			e.PreventDefault();

			initialisePlaceDropDown();

		}
		void countrySelectedChangeLinkClick(jQueryEvent e)
		{
			e.PreventDefault();

			initialiseCountryDropDown();
			
		}
		void brandSelectedChangeLinkClick(jQueryEvent e)
		{
			e.PreventDefault();

			initialiseBrandDropDown();

		}