Skip to content

Commit

Permalink
packed version added
Browse files Browse the repository at this point in the history
  • Loading branch information
kkamkou committed Dec 23, 2015
1 parent 5957ebb commit 6118428
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 36 deletions.
4 changes: 2 additions & 2 deletions Jakefile.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ var files = {
};

function getComment () {
var version = '1.2.9',
var version = '1.2.10',
date = new Date(),
buildDate = date.getFullYear() + '-' +
(date.getMonth() >= 9 ? '' : '0') + (date.getMonth() + 1) + '-' +
Expand Down Expand Up @@ -84,7 +84,7 @@ file(
function () {
console.log('optimizing jquery.fenster.css');

var css_optimized = csso.justDoIt(fs.readFileSync('production/jquery.fenster.full.css').toString())
var css_optimized = csso.minify(fs.readFileSync('production/jquery.fenster.full.css').toString())
fs.writeFileSync(this.name, getComment() + css_optimized);
}
);
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
"dependencies": {
"jquery": ">=1.6"
},
"devDependencies": {
"csso": "~1.4.4",
"jake": "~8.0.12",
"uglify-js": "~1.3.5"
},
"repository": {
"type" : "git",
"url" : "https://github.com/kkamkou/jqFenster.git"
Expand Down
4 changes: 2 additions & 2 deletions production/jquery.fenster.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion production/jquery.fenster.full.css
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* jqFenster - Lightweight Modal Framework
* Version: 1.2.9 (2015-05-05)
* Version: 1.2.10 (2015-12-23)
* https://github.com/kkamkou/jqFenster
*/

Expand Down
64 changes: 36 additions & 28 deletions production/jquery.fenster.full.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* jqFenster - Lightweight Modal Framework
* Version: 1.2.9 (2015-05-05)
* Version: 1.2.10 (2015-12-23)
* https://github.com/kkamkou/jqFenster
*/
(function($) {
Expand All @@ -26,13 +26,13 @@
*
* Link selectors (if we have information about link only)
* jQuery('.myElement').fenster().open().close();
* jQuery('.myElement').fenster({'href': 'newUri'}).reInit();
* jQuery('.myElement').fenster({href: 'newUri'}).reInit();
*
* Owners (working in the opened popup)
* jQuery.fensterFinder(this).setOptions({'href': 'newUri'}).reInit();
* jQuery.fensterFinder(this).setOptions({href: 'newUri'}).reInit();
*
* Anonymous (creates popup on the fly)
* jQuery.fenster({'href': 'uri'}).open();
* jQuery.fenster({href: 'uri'}).open();
* jQuery.fenster('#myPopup').open();
*/

Expand All @@ -41,12 +41,12 @@

// default options
var defaultOptions = {
'href': null,
'selector': null,
'options': null,
'delayOpen': 200,
'callbackOpen': $.noop,
'callbackClose': $.noop
href: null,
selector: null,
options: null,
delayOpen: 200,
callbackOpen: $.noop,
callbackClose: $.noop
};

// the main object
Expand All @@ -64,8 +64,7 @@
}

// dynamic object requires custom init
if (!this.element.hasClass('jqFenster')) {
this.element.addClass('jqFenster');
if (this.isDestroyable()) {
this._init();
}
};
Expand All @@ -83,14 +82,26 @@
return this;
},

isDestroyable: function () {
return !!(this.element && this.element.data('jqFensterDestroyable'));
},

// DOM cleanup (removes <a> at the end of body)
destroy: function () {
if (this.element.data('jqFensterDestroyable')) {
this.element.remove();
if (!this.isDestroyable()) {
return false;
}
this.close();
this.element.remove();
this.element = null;
return true;
},

open: function (cb) {
if (!this.element) {
return this;
}

var cbToExecute = function () {
this.options.callbackOpen.call(null, this.getHolder());
if ($.type(cb) === 'function') {
Expand All @@ -99,15 +110,18 @@
return this;
};

// we have the holder here
if (this.getHolder()) {
return cbToExecute.call(this);
}

// and now we have to click and wait for the holder
this.element.trigger('click');

setTimeout(function () {
this.setHolder(this.element.data('jqFensterHolder'));
this.setHolder(
this.element.data('jqFensterHolder')
.on('jqFensterCallbackClose', this.close.bind(this))
);
cbToExecute.call(this);
}.bind(this), this.options.delayOpen);

Expand Down Expand Up @@ -148,33 +162,30 @@
},

_init: function () {
// href
if (this.options.href !== null) {
this.element.data('href', this.options.href);
}

// selector
if (this.options.selector !== null) {
this.element.data('selector', this.options.selector);
}

// data-options
if (this.options.options) {
this.element.data('options', this.options.options);
}

return this;
}
};

// jQuery plugin
$.fn.fenster = function (options) {
if (!this.hasClass('jqFenster')) {
return $.fenster(this.selector);
}
return new JqFensterApi(this, options);
};

// helps to find/creatre the jqFenster object
$.extend({
// working inside opened window
// $.fensterFinder(selector|this)
fensterFinder: function (target) {
var $target = $(target), $elem;

Expand All @@ -192,21 +203,18 @@
return null;
},

// quick helper
// $.fenster(selector)
fenster: function (options) {
// notice api that we should remove this element after execution
var $elem = $('<a />', {css: {display: 'none'}})
.addClass('jqFenster')
.data('jqFensterDestroyable', true);

// DOM update
$('body').append($elem);

// quick helper for the jQuery selector
if ($.type(options) === 'string') {
options = {'selector': options};
}

// new instance
return $elem.fenster(options);
}
});
Expand Down
Loading

0 comments on commit 6118428

Please sign in to comment.