Skip to content

Commit

Permalink
Merge pull request #328 from suskind/develop
Browse files Browse the repository at this point in the history
Added Cookie, Date, Json, Url samples. Fixed method list in docs
  • Loading branch information
Claudio Gamboa committed Apr 7, 2014
2 parents f89e0e9 + f70509d commit c61a2e3
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 90 deletions.
6 changes: 5 additions & 1 deletion src/js/Ink/UI/Common/1/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Ink.createModule('Ink.UI.Common', '1', ['Ink.Dom.Element_1', 'Ink.Net.Ajax_1','I
return ret;
};

/**
* @namespace Ink.UI.Common_1
*/

var Common = {

/**
Expand Down Expand Up @@ -746,4 +750,4 @@ Ink.createModule('Ink.UI.Common', '1', ['Ink.Dom.Element_1', 'Ink.Net.Ajax_1','I

return Common;

});
});
20 changes: 6 additions & 14 deletions src/js/Ink/Util/Cookie/1/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Ink.createModule('Ink.Util.Cookie', '1', [], function() {

'use strict';

/**
* @namespace Ink.Util.Cookie_1
*/
var Cookie = {

/**
Expand All @@ -18,11 +21,7 @@ Ink.createModule('Ink.Util.Cookie', '1', [], function() {
* @return {String|Object} If the name is specified, it returns the value of that key. Otherwise it returns the full cookie object
* @public
* @static
* @example
* Ink.requireModules(['Ink.Util.Cookie_1'], function( InkCookie ){
* var myCookieValue = InkCookie.get('someVarThere');
* console.log( myCookieValue ); // This will output the value of the cookie 'someVarThere', from the cookie object.
* });
* @sample Ink_Util_Cookie_get.html
*/
get: function(name)
{
Expand Down Expand Up @@ -65,11 +64,7 @@ Ink.createModule('Ink.Util.Cookie', '1', [], function() {
* @param {Boolean} [secure] Flag for secure. Default 'false'.
* @public
* @static
* @example
* Ink.requireModules(['Ink.Util.Cookie_1'], function( InkCookie ){
* var expireDate = new Date( 2014,00,01, 0,0,0);
* InkCookie.set( 'someVarThere', 'anyValueHere', expireDate.getTime() );
* });
* @sample Ink_Util_Cookie_set.html
*/
set: function(name, value, expires, path, domain, secure)
{
Expand Down Expand Up @@ -135,10 +130,7 @@ Ink.createModule('Ink.Util.Cookie', '1', [], function() {
* @param {String} [domain] Domain of the cookie. Defaults to current hostname.
* @public
* @static
* @example
* Ink.requireModules(['Ink.Util.Cookie_1'], function( InkCookie ){
* InkCookie.remove( 'someVarThere' );
* });
* @sample Ink_Util_Cookie_remove.html
*/
remove: function(cookieName, path, domain)
{
Expand Down
11 changes: 5 additions & 6 deletions src/js/Ink/Util/Date/1/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Ink.createModule('Ink.Util.Date', '1', [], function() {

'use strict';

/**
* @namespace Ink.Util.Date_1
*/
var InkDate = {

/**
Expand Down Expand Up @@ -163,12 +166,7 @@ Ink.createModule('Ink.Util.Date', '1', [], function() {
* @return {String} Formatted date
* @public
* @static
* @example
* <script>
* Ink.requireModules( ['Ink.Util.Date_1'], function( InkDate ){
* console.log( InkDate.get('Y-m-d') ); // Result (at the time of writing): 2013-05-07
* });
* </script>
* @sample Ink_Util_Date_get.html
*/
get: function(format, _date){
/*jshint maxcomplexity:65 */
Expand Down Expand Up @@ -408,6 +406,7 @@ Ink.createModule('Ink.Util.Date', '1', [], function() {
* @return {Date} Date object based on the formatted date and format
* @public
* @static
* @sample Ink_Util_Date_set.html
*/
set : function( format , str_date ) {
if ( typeof str_date === 'undefined' ) { return ; }
Expand Down
6 changes: 5 additions & 1 deletion src/js/Ink/Util/Dumper/1/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ Ink.createModule('Ink.Util.Dumper', '1', [], function() {

'use strict';

/**
* @namespace Ink.Util.Dumper_1
*/

var Dumper = {

/**
Expand Down Expand Up @@ -196,4 +200,4 @@ Ink.createModule('Ink.Util.Dumper', '1', [], function() {

return Dumper;

});
});
21 changes: 6 additions & 15 deletions src/js/Ink/Util/Json/1/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Ink.createModule('Ink.Util.Json', '1', [], function() {

/**
* Use this class to convert JSON strings to JavaScript objects
* `(Json.parse)` and also to do the opposite operation `(Json.stringify)`.
* `.parse()` and also to do the opposite operation `.stringify()`.
* Internally, the standard JSON implementation is used if available
* Otherwise, the functions mimic the standard implementation.
*
Expand All @@ -56,7 +56,8 @@ Ink.createModule('Ink.Util.Json', '1', [], function() {
* var source = '{"key": "value", "array": [true, null, false]}';
* Json.parse(source); // The above JSON string as an object
* });
* @namespace Ink.Util.Json
*
* @namespace Ink.Util.Json_1
* @static
*
*/
Expand Down Expand Up @@ -198,8 +199,7 @@ Ink.createModule('Ink.Util.Json', '1', [], function() {
* @param {Boolean} convertToUnicode When `true`, converts string contents to unicode \uXXXX
* @return {String} Serialized string
*
* @example
* Json.stringify({a:1.23}); // -> string: '{"a": 1.23}'
* @sample Ink_Util_Json_stringify.html
*/
stringify: function(input, convertToUnicode) {
this._convertToUnicode = !!convertToUnicode;
Expand All @@ -217,17 +217,8 @@ Ink.createModule('Ink.Util.Json', '1', [], function() {
* @param reviver {Function} Function receiving `(key, value)`, and `this`=(containing object), used to walk objects.
*
* @return {Object} JSON object
* @example
* Simple example:
*
* Json.parse('{"a": "3","numbers":false}',
* function (key, value) {
* if (!this.numbers && key === 'a') {
* return "NO NUMBERS";
* } else {
* return value;
* }
* }); // -> object: {a: 'NO NUMBERS', numbers: false}
* @sample Ink_Util_Json_parse.html
*/
/* From https://github.com/douglascrockford/JSON-js/blob/master/json.js */
parse: function (text, reviver) {
Expand Down Expand Up @@ -313,4 +304,4 @@ Ink.createModule('Ink.Util.Json', '1', [], function() {
};

return InkJson;
});
});
3 changes: 3 additions & 0 deletions src/js/Ink/Util/String/1/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Ink.createModule('Ink.Util.String', '1', [], function() {

'use strict';

/**
* @namespace Ink.Util.String_1
*/
var InkUtilString = {

/**
Expand Down
62 changes: 10 additions & 52 deletions src/js/Ink/Util/Url/1/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Ink.createModule('Ink.Util.Url', '1', [], function() {

'use strict';

/**
* @namespace Ink.Util.Url_1
*/
var Url = {

/**
Expand All @@ -28,10 +31,7 @@ Ink.createModule('Ink.Util.Url', '1', [], function() {
* @return Current URL
* @public
* @static
* @example
* Ink.requireModules(['Ink.Util.Url_1'], function( InkUrl ){
* console.log( InkUrl.getUrl() ); // Will return it's window URL
* });
* @sample Ink_Util_Url_getUrl.html
*/
getUrl: function()
{
Expand All @@ -47,15 +47,7 @@ Ink.createModule('Ink.Util.Url', '1', [], function() {
* @return {String} URI with query string set
* @public
* @static
* @example
* Ink.requireModules(['Ink.Util.Url_1'], function( InkUrl ){
* var queryString = InkUrl.genQueryString( 'http://www.sapo.pt/', {
* 'param1': 'valueParam1',
* 'param2': 'valueParam2'
* });
*
* console.log( queryString ); // Result: http://www.sapo.pt/?param1=valueParam1&param2=valueParam2
* });
* @sample Ink_Util_Url_genQueryString.html
*/
genQueryString: function(uri, params) {
var hasQuestionMark = uri.indexOf('?') !== -1;
Expand Down Expand Up @@ -88,16 +80,7 @@ Ink.createModule('Ink.Util.Url', '1', [], function() {
* @return {Object} Key-Value pair object
* @public
* @static
* @example
* Ink.requireModules(['Ink.Util.Url_1'], function( InkUrl ){
* var queryStringParams = InkUrl.getQueryString( 'http://www.sapo.pt/?var1=valueVar1&var2=valueVar2' );
* console.log( queryStringParams );
* // Result:
* // {
* // var1: 'valueVar1',
* // var2: 'valueVar2'
* // }
* });
* @sample Ink_Util_Url_getQueryString.html
*/
getQueryString: function(str)
{
Expand Down Expand Up @@ -129,11 +112,7 @@ Ink.createModule('Ink.Util.Url', '1', [], function() {
* @return {String|Boolean} Hash in the URL. If there's no hash, returns false.
* @public
* @static
* @example
* Ink.requireModules(['Ink.Util.Url_1'], function( InkUrl ){
* var anchor = InkUrl.getAnchor( 'http://www.sapo.pt/page.php#TEST' );
* console.log( anchor ); // Result: TEST
* });
* @sample Ink_Util_Url_getAnchor.html
*/
getAnchor: function(str)
{
Expand All @@ -158,16 +137,7 @@ Ink.createModule('Ink.Util.Url', '1', [], function() {
* @return {Object} Key-value pair object of the URL's hashtag 'variables'
* @public
* @static
* @example
* Ink.requireModules(['Ink.Util.Url_1'], function( InkUrl ){
* var hashParams = InkUrl.getAnchorString( 'http://www.sapo.pt/#var1=valueVar1&var2=valueVar2' );
* console.log( hashParams );
* // Result:
* // {
* // var1: 'valueVar1',
* // var2: 'valueVar2'
* // }
* });
* @sample Ink_Util_Url_getAnchorString.html
*/
getAnchorString: function(string)
{
Expand Down Expand Up @@ -200,20 +170,7 @@ Ink.createModule('Ink.Util.Url', '1', [], function() {
* @return {Object} Parsed URL as a key-value object.
* @public
* @static
* @example
* Ink.requireModules(['Ink.Util.Url_1'], function( InkUrl ){
* var parsedURL = InkUrl.parseUrl( 'http://www.sapo.pt/index.html?var1=value1#anchor' )
* console.log( parsedURL );
* // Result:
* // {
* // 'scheme' => 'http',
* // 'host' => 'www.sapo.pt',
* // 'path' => '/index.html',
* // 'query' => 'var1=value1',
* // 'fragment' => 'anchor'
* // }
* });
*
* @sample Ink_Util_Url_parseUrl.html
*/
parseUrl: function(url) {
var aURL = {};
Expand Down Expand Up @@ -330,6 +287,7 @@ Ink.createModule('Ink.Util.Url', '1', [], function() {
* @return {DOMElement|Boolean} Returns the <script> DOM Element or false if unable to find it.
* @public
* @static
* @sample Ink_Util_Url_currentScriptElement.html
*/
currentScriptElement: function(match)
{
Expand Down
5 changes: 4 additions & 1 deletion src/js/Ink/Util/Validator/1/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Ink.createModule('Ink.Util.Validator', '1', [], function() {

'use strict';

/**
* @namespace Ink.Util.Validator_1
*/
var Validator = {

/**
Expand Down Expand Up @@ -1298,4 +1301,4 @@ Ink.createModule('Ink.Util.Validator', '1', [], function() {

return Validator;

});
});

0 comments on commit c61a2e3

Please sign in to comment.