コード例 #1
0
ファイル: JsObject.py プロジェクト: epykure/epyk-ui
    def toString(self, explicit: bool = True):
        """
    Description:
    ------------
    Converts an Object to a string, and returns the result

    Usage::

      jsObj.objects.get("MyObject").toString()

    Related Pages:

      https://www.w3schools.com/JS/js_number_methods.asp

    Attributes:
    ----------
    :param bool explicit: Optional, default True. Parameter to force the String conversion on the Js side

    :return: A Javascript String
    """
        from epyk.core.js.primitives import JsString

        if not explicit:
            return JsString.JsString("%s" % self.varId, is_py_data=False)

        return JsString.JsString("%s.toString()" % self.varId,
                                 is_py_data=False)
コード例 #2
0
    def href(self,
             href: Union[str, primitives.JsDataModel] = None,
             secured: bool = False):
        """
    Description:
    ------------
    The href property sets or returns the entire URL of the current component.

    Usage::

      page.js.location.href("https://www.w3schools.com/howto/howto_js_fullscreen.asp")

    Related Pages:

      https://www.w3schools.com/jsref/prop_loc_href.asp

    Attributes:
    ----------
    :param Union[str, primitives.JsDataModel] href: Optional. Set the href property.
    :param bool secured: Optional.

    :return: A String, representing the entire URL of the page, including the protocol (like http://).
    """
        if href is None:
            return JsString.JsString("location.href", is_py_data=False)

        if not hasattr(href, 'toStr') and href.startswith("www."):
            href = r"http:\\%s" % href if not secured else r"https:\\%s" % href
        return JsObject.JsObject("location.href = %s" %
                                 JsUtils.jsConvertData(href, None))
コード例 #3
0
    def formatMoney(self, jsObj, decPlaces=0, countryCode='UK'):
        """
    Description:
    ------------
    Wrapper function

    Related Pages:

      https://en.wikipedia.org/wiki/Decimal_separator
    https://docs.oracle.com/cd/E19455-01/806-0169/overview-9/index.html

    Attributes:
    ----------
    :param jsObj: The base Javascript Python object
    :param decPlaces: The number of decimal
    """
        thouSeparator, decSeparator = (
            ",", ".") if countryCode.upper() in ["UK", 'US'] else (" ", ".")
        jsObj.extendProto(self,
                          "formatMoney",
                          '''
      var n = this, decPlaces = isNaN(decPlaces = Math.abs(decPlaces)) ? 2 : decPlaces, decSeparator = decSeparator == undefined ? "." : decSeparator,
      thouSeparator = thouSeparator == undefined ? "," : thouSeparator, sign = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0).toFixed(decPlaces)) + "",
      j = (j = i.length) > 3 ? j % 3 : 0;
      return sign + (j ? i.substr(0, j) + thouSeparator : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thouSeparator) + (decPlaces ? decSeparator + Math.abs(n - i).toFixed(decPlaces).slice(2) : "");
      ''',
                          pmts=["decPlaces", "thouSeparator", "decSeparator"])
        from epyk.core.js.primitives import JsString
        return JsString.JsString(
            "%s.formatMoney(%s, '%s', '%s')" %
            (self.varId, decPlaces, thouSeparator, decSeparator),
            isPyData=False)
コード例 #4
0
ファイル: JsArray.py プロジェクト: epykure/epyk-ui
    def join(self, sep: Union[primitives.JsDataModel, str]):
        """
    Description:
    -----------
    The join() method joins the elements of an array into a string, and returns the string.

    Usage::

      page.js.array(varName="newUrl").join("&")

    Related Pages:

      https://www.w3schools.com/jsref/jsref_join.asp

    Attributes:
    ----------
    :param Union[primitives.JsDataModel, str] sep: Optional. The separator to be used. If omitted, the elements are
    separated with a comma.
    :return: A String, representing the array values, separated by the specified separator.
    """
        from epyk.core.js.primitives import JsString

        sep = JsUtils.jsConvertData(sep, None)
        return JsString.JsString(
            "%s.join(%s)" % (self.varId, JsUtils.jsConvertData(sep, None)),
            is_py_data=False)
コード例 #5
0
ファイル: __init__.py プロジェクト: ylwb/epyk-ui
 def var(self):
   """
   Description:
   ------------
   Property to return the variable name as a valid pyJs object
   """
   return JsString.JsString(self.varId, isPyData=False)
コード例 #6
0
    def mail(self, mails: List[str], subject: str, body: str):
        """
    Description:
    ------------
    The mailto link when clicked opens users default email program or software.
    A new email page is created with "To" field containing the address of the name specified on the link by default.

    Usage::

      page.js.location.mail(["*****@*****.**"], "This is a test", "This is the email's content")

    Related Pages:

      http://www.tutorialspark.com/html5/HTML5_email_mailto.php

    Attributes:
    ----------
    :param list[str] mails: The email addresses.
    :param str subject: The email's subject.
    :param str body: The email's content.

    :return: THe Javascript string.
    """
        if isinstance(mails, list):
            mails = ";".join(mails)
        return self.href(
            JsString.JsString(
                "'mailto:%s?subject=%s&body='+ encodeURIComponent('%s')" %
                (mails, subject, body),
                is_py_data=False))
コード例 #7
0
ファイル: JsEvents.py プロジェクト: ylwb/epyk-ui
    def metaKey(self):
        """
    The metaKey property returns a Boolean value that indicates whether or not the "META" key was pressed when a key event was triggered.

    https://www.w3schools.com/jsref/event_metakey.asp
    """
        return JsString.JsString("event.metaKey", isPyData=False)
コード例 #8
0
ファイル: JsLocation.py プロジェクト: ylwb/epyk-ui
    def href(self, href=None, secured=False):
        """
    Description:
    ------------
    The href property sets or returns the entire URL of the current p

    Usage::

      rptObj.js.location.href("https://www.w3schools.com/howto/howto_js_fullscreen.asp")

    Related Pages:

      https://www.w3schools.com/jsref/prop_loc_href.asp

    Attributes:
    ----------
    :param href: Set the href property

    :return: A String, representing the entire URL of the page, including the protocol (like http://)
    """
        if href is None:
            return JsString.JsString("location.href", isPyData=False)

        if not hasattr(href, 'toStr') and href.startswith("www."):
            href = r"http:\\%s" % href if not secured else r"https:\\%s" % href
        return JsObject.JsObject("location.href = %s" %
                                 JsUtils.jsConvertData(href, None))
コード例 #9
0
    def text(self):
        """
    Description:
    -----------

    """
        return JsString.JsString("%s.getData('text')" % self.varId,
                                 isPyData=False)
コード例 #10
0
ファイル: JsData.py プロジェクト: epykure/epyk-ui
 def text(self):
     """
 Description:
 -----------
 Get text data from a datatransfer object.
 """
     return JsString.JsString("%s.getData('text')" % self.varId,
                              is_py_data=False)
コード例 #11
0
    def getData(self, format="text"):
        """
    Description:
    -----------

    :param format:
    """
        return JsString.JsString("%s.getData(%s)" % (self.varId, format),
                                 isPyData=False)
コード例 #12
0
ファイル: JsNavigator.py プロジェクト: ylwb/epyk-ui
    def platform(self):
        """
    The platform property returns the browser platform (operating system)

    Related Pages:

      https://www.w3schools.com/js/js_window_navigator.asp
    """
        return JsString.JsString("navigator.platform", isPyData=False)
コード例 #13
0
ファイル: JsNavigator.py プロジェクト: ylwb/epyk-ui
    def appVersion(self):
        """
    The appVersion property returns version information about the browser

    Related Pages:

      https://www.w3schools.com/js/js_window_navigator.asp
    """
        return JsString.JsString("navigator.appVersion", isPyData=False)
コード例 #14
0
ファイル: JsNavigator.py プロジェクト: ylwb/epyk-ui
    def product(self):
        """
    The product property returns the product name of the browser engine

    Related Pages:

      https://www.w3schools.com/js/js_window_navigator.asp
    """
        return JsString.JsString("navigator.product", isPyData=False)
コード例 #15
0
ファイル: JsNavigator.py プロジェクト: ylwb/epyk-ui
    def appName(self):
        """
    The appName property returns the application name of the browser

    Related Pages:

      https://www.w3schools.com/js/js_window_navigator.asp
    """
        return JsString.JsString("navigator.appName", isPyData=False)
コード例 #16
0
ファイル: JsNavigator.py プロジェクト: ylwb/epyk-ui
    def userAgent(self):
        """
    The userAgent property returns the user-agent header sent by the browser to the server

    Related Pages:

      https://www.w3schools.com/js/js_window_navigator.asp

    """
        return JsString.JsString("navigator.userAgent", isPyData=False)
コード例 #17
0
ファイル: html_dom.py プロジェクト: epykure/epyk-extensions
    def currentMonthName(self):
        """
    Description:
    ------------
    Calendar month in plain english. E.x. January

    :return:
    """
        return JsString.JsString("%s.currentYear" % self._src.js.varName,
                                 report=self._report)
コード例 #18
0
ファイル: JsNavigator.py プロジェクト: ylwb/epyk-ui
    def language(self):
        """
    The language property returns the language version of the browser.

    Related Pages:

      https://www.w3schools.com/jsref/prop_nav_language.asp

    :return:
    """
        return JsString.JsString("navigator.language", isPyData=False)
コード例 #19
0
ファイル: JsEvents.py プロジェクト: ylwb/epyk-ui
    def preventDefault(self):
        """
    Description:
    ------------
    Cancels the event if it is cancelable, meaning that the default action that belongs to the event will not occur

    Related Pages:

      https://www.w3schools.com/jsref/event_preventdefault.asp
    """
        return JsString.JsString("event.preventDefault()", isPyData=False)
コード例 #20
0
ファイル: JsEvents.py プロジェクト: ylwb/epyk-ui
    def timeStamp(self):
        """
    Description:
    ------------
    Returns the time (in milliseconds relative to the epoch) at which the event was created

    Related Pages:

      https://www.w3schools.com/jsref/event_timestamp.asp
    """
        return JsString.JsString("event.timeStamp", isPyData=False)
コード例 #21
0
    def rootMargin(self):
        """
    Description:
    ------------
    The IntersectionObserver interface's read-only rootMargin property is a string with syntax similar to that of the CSS margin property.

    Related Pages:

      https://developer.mozilla.org/en-US/docs/Web/API/IntersectionObserver/rootMargin
    """
        return JsString.JsString("%s.rootMargin", isPyData=False)
コード例 #22
0
ファイル: JsEvents.py プロジェクト: ylwb/epyk-ui
    def target(self):
        """
    Description:
    ------------
    Returns the element that triggered the event

    Related Pages:

      https://www.w3schools.com/jsref/event_target.asp
    """
        return JsString.JsString("event.target")
コード例 #23
0
ファイル: JsEvents.py プロジェクト: ylwb/epyk-ui
    def defaultPrevented(self):
        """
    Description:
    ------------
    The defaultPrevented event property checks whether the preventDefault() method was called for the event.

    Related Pages:

      https://www.w3schools.com/jsref/event_defaultprevented.asp
    """
        return JsString.JsString("event.defaultPrevented", isPyData=False)
コード例 #24
0
ファイル: JsEvents.py プロジェクト: ylwb/epyk-ui
    def metaKey(self):
        """
    Description:
    ------------
    The metaKey property returns a Boolean value that indicates whether or not the "META" key was pressed when a touch event was triggered.

    Related Pages:

      https://www.w3schools.com/jsref/event_touch_metakey.asp
    """
        return JsString.JsString("event.metaKey", isPyData=False)
コード例 #25
0
ファイル: JsEvents.py プロジェクト: ylwb/epyk-ui
    def cancelBubble(self):
        """
    Description:
    ------------
    The cancelBubble() method prevents the event-flow from bubbling up to parent elements.

    Related Pages:

      https://www.w3schools.com/jsref/event_cancelbubble.asp
    """
        return JsString.JsString("event.cancelBubble = true")
コード例 #26
0
ファイル: JsEvents.py プロジェクト: ylwb/epyk-ui
    def code(self):
        """
    Description:
    ------------
    The code property returns the key that triggered the event.

    Related Pages:

      https://www.w3schools.com/jsref/event_key_code.asp
    """
        return JsString.JsString("event.code", isPyData=False)
コード例 #27
0
ファイル: JsEvents.py プロジェクト: ylwb/epyk-ui
    def keyCode(self):
        """
    Description:
    ------------
    The keyCode property returns the Unicode character code of the key that triggered the onkeypress event, or the Unicode key code of the key that triggered the onkeydown or onkeyup event.

    Related Pages:

      https://www.w3schools.com/jsref/event_key_keycode.asp
    """
        return JsString.JsString("event.keyCode", isPyData=False)
コード例 #28
0
ファイル: JsEvents.py プロジェクト: ylwb/epyk-ui
    def key(self):
        """
    Description:
    ------------
    The getModifierState() method returns true if the specified modifier key was pressed, or activated.

    Related Pages:

      https://www.w3schools.com/jsref/event_key_key.asp
    """
        return JsString.JsString("event.key", isPyData=False)
コード例 #29
0
ファイル: JsObject.py プロジェクト: poolppy/epyk-ui
    def toString(self, explicit=True):
        """
    Converts a Object to a string, and returns the result

    Example
    jsObj.objects.get("MyObject").toString()

    Documentation
    https://www.w3schools.com/JS/js_number_methods.asp

    :param explicit: Optional, default True. Parameter to force the String conversion on the Js side

    :return: A Javascript String
    """
        from epyk.core.js.primitives import JsString

        if not explicit:
            return JsString.JsString("%s" % self.varId, isPyData=False)

        return JsString.JsString("%s.toString()" % self.varId, isPyData=False)
コード例 #30
0
ファイル: JsEvents.py プロジェクト: ylwb/epyk-ui
    def stopPropagation(self):
        """
    Description:
    ------------
    Prevents further propagation of an event during event flow

    Related Pages:

      https://www.w3schools.com/jsref/event_stoppropagation.asp
    """
        return JsString.JsString("event.stopPropagation()", isPyData=False)