cordova-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MMrko <...@git.apache.org>
Subject [GitHub] cordova-lib pull request: CB-8043 CB-6462 CB-6105 Refactor orienta...
Date Fri, 02 Jan 2015 12:41:43 GMT
Github user MMrko commented on a diff in the pull request:

    https://github.com/apache/cordova-lib/pull/128#discussion_r22409503
  
    --- Diff: cordova-lib/src/configparser/ConfigParser.js ---
    @@ -219,6 +258,47 @@ ConfigParser.prototype = {
         },
     
         /**
    +     * Finds the value of the orientation <preference>.
    +     *
    +     * @param  {String} [platform]  Platform name
    +     * @return {String}             Global/platform-specific orientation (or undefined
if both are undefined)
    +     */
    +    getOrientation: function (platform) {
    +
    +        var globalOrientation = this.getGlobalPreference('orientation');
    +        var platformOrientation = null;
    +        var platformSupportedOrientations = null;
    +
    +        // Check if the value of the global orientation preference is invalid
    +        if (globalOrientation && !_.contains(PREFERENCE_ORIENTATION_VALUES, globalOrientation))
{
    +            events.emit( 'warn', [ 'Unknown value for global orientation preference:',
globalOrientation ].join(' ') );
    +            globalOrientation = undefined;
    +        }
    +
    +        if (!platform) {
    +            return globalOrientation;
    +        }
    +
    +        platformSupportedOrientations = supportedPreferences.orientation[platform];
    +
    +        if (!platformSupportedOrientations) {
    +            throw new CordovaError([ 'No supported orientations defined for platform',
platform ].join (' '));
    +        }
    +
    +        platformOrientation = this.getPlatformPreference('orientation', platform);
    +
    +        // Check if the value of the platform-specific orientation preference is invalid
    +        if (platformOrientation && !_.contains(platformSupportedOrientations,
platformOrientation)) {
    --- End diff --
    
    Yep, that would've been a better approach. In the end supportedOrientations.json seemed
to be useful only for validating user input so I omitted this check for platform-specific
support altogether.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@cordova.apache.org
For additional commands, e-mail: dev-help@cordova.apache.org


Mime
View raw message