Permalink
Browse files

1.4.0

  • Loading branch information...
1 parent eacb684 commit 08c370ec903131df8743c89e4948afb410117fb6 @MohammadYounes committed Apr 21, 2015
Showing with 471 additions and 256 deletions.
  1. +23 −13 Gruntfile.js
  2. +8 −0 RELEASENOTES.md
  3. +91 −26 build/alertify.js
  4. +4 −3 build/alertify.min.js
  5. BIN build/alertifyjs.zip
  6. +24 −34 build/css/alertify.css
  7. +6 −3 build/css/alertify.min.css
  8. +24 −34 build/css/alertify.rtl.css
  9. +6 −3 build/css/alertify.rtl.min.css
  10. +5 −0 build/css/themes/bootstrap.css
  11. +5 −2 build/css/themes/bootstrap.min.css
  12. +5 −0 build/css/themes/bootstrap.rtl.css
  13. +5 −2 build/css/themes/bootstrap.rtl.min.css
  14. +5 −0 build/css/themes/default.css
  15. +5 −2 build/css/themes/default.min.css
  16. +5 −0 build/css/themes/default.rtl.css
  17. +5 −2 build/css/themes/default.rtl.min.css
  18. +6 −2 build/css/themes/semantic.css
  19. +6 −3 build/css/themes/semantic.min.css
  20. +6 −2 build/css/themes/semantic.rtl.css
  21. +6 −3 build/css/themes/semantic.rtl.min.css
  22. +91 −26 docpad/files/build/alertify.js
  23. +4 −3 docpad/files/build/alertify.min.js
  24. BIN docpad/files/build/alertifyjs.zip
  25. +24 −34 docpad/files/build/css/alertify.css
  26. +6 −3 docpad/files/build/css/alertify.min.css
  27. +24 −34 docpad/files/build/css/alertify.rtl.css
  28. +6 −3 docpad/files/build/css/alertify.rtl.min.css
  29. +5 −0 docpad/files/build/css/themes/bootstrap.css
  30. +5 −2 docpad/files/build/css/themes/bootstrap.min.css
  31. +5 −0 docpad/files/build/css/themes/bootstrap.rtl.css
  32. +5 −2 docpad/files/build/css/themes/bootstrap.rtl.min.css
  33. +5 −0 docpad/files/build/css/themes/default.css
  34. +5 −2 docpad/files/build/css/themes/default.min.css
  35. +5 −0 docpad/files/build/css/themes/default.rtl.css
  36. +5 −2 docpad/files/build/css/themes/default.rtl.min.css
  37. +6 −2 docpad/files/build/css/themes/semantic.css
  38. +6 −3 docpad/files/build/css/themes/semantic.min.css
  39. +6 −2 docpad/files/build/css/themes/semantic.rtl.css
  40. +6 −3 docpad/files/build/css/themes/semantic.rtl.min.css
  41. +2 −1 package.json
View
@@ -9,6 +9,23 @@ module.exports = function (grunt) {
build: ['staging', 'build']
},
+ usebanner: {
+ dist: {
+ options: {
+ position: 'top',
+ banner: '/**\n' +
+ ' * <%= pkg.name %> <%= pkg.version %> <%= pkg.homepage %>\n' +
+ ' * <%= pkg.description %>\n' +
+ ' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %> \n' +
+ ' * Licensed under <%= pkg.licenses[0].type %> <<%= pkg.licenses[0].url %>>*/\n',
+ linebreak: false
+ },
+ files: {
+ src: ['build/**/*.css']
+ }
+ }
+ },
+
less: {
options: {
paths: ['./src/less'],
@@ -67,8 +84,6 @@ module.exports = function (grunt) {
cssmin: {
options: {
- banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' +
- '<%= pkg.author %> */\n',
report: 'gzip'
},
min: {
@@ -114,16 +129,10 @@ module.exports = function (grunt) {
options: {
stripBanners: false,
banner: '/**\n' +
- ' * <%= pkg.name %>\n' +
+ ' * <%= pkg.name %> <%= pkg.version %> <%= pkg.homepage %>\n' +
' * <%= pkg.description %>\n' +
- ' *\n' +
- ' * @author <%= pkg.author %> \n' +
- ' * @copyright <%= grunt.template.today("yyyy") %>\n' +
- ' * @license <%= pkg.licenses[0].type %> <<%= pkg.licenses[0].url %>>\n' +
- ' * @link <%= pkg.homepage %>\n' +
- ' * @module <%= pkg.name %>\n' +
- ' * @version <%= pkg.version %>\n' +
- ' */\n'
+ ' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %> \n' +
+ ' * Licensed under <%= pkg.licenses[0].type %> <<%= pkg.licenses[0].url %>>*/\n',
},
dist: {
src: [
@@ -213,10 +222,11 @@ module.exports = function (grunt) {
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-watch');
- grunt.loadNpmTasks('grunt-contrib-compress');
+ grunt.loadNpmTasks('grunt-contrib-compress');
+ grunt.loadNpmTasks('grunt-banner');
// Default task
- grunt.registerTask('css', ['less', 'autoprefixer:build', 'rtlcss','copy:rtl', 'copy:ltr','cssmin']);
+ grunt.registerTask('css', ['less', 'autoprefixer:build', 'rtlcss', 'copy:rtl', 'copy:ltr', 'cssmin', 'usebanner']);
grunt.registerTask('build', ['clean:build', 'css', 'concat', 'uglify', 'compress', 'copy:build']);
grunt.registerTask('default', ['build', 'jshint']);
};
View
@@ -1,4 +1,12 @@
# Release Notes
+
+* **v1.4.0** [22 Apr. 2015]
+ * Prompt dialog: Added support for changing the HTML type of the input field.
+ * Support percent unit in `ResizeTo` method.
+ * Maintain document scroll position.
+ * Allow reusing dialog contents by not destroying the DOM, plus faster content clearing.
+ * Fixes the context for some callbacks.
+
* **v1.3.0** [14 Mar. 2015]
* New API feature: autoReset option to control whether to reset dialog size/position on window resize or not.
* Always use a copy of buttons definition. Fixes #32
View
@@ -1,14 +1,8 @@
/**
- * alertifyjs
+ * alertifyjs 1.4.0 http://alertifyjs.com
* AlertifyJS is a javascript framework for developing pretty browser dialogs and notifications.
- *
- * @author Mohammad Younes <Mohammad@alertifyjs.com> (http://alertifyjs.com)
- * @copyright 2015
- * @license MIT <http://opensource.org/licenses/mit-license.php>
- * @link http://alertifyjs.com
- * @module alertifyjs
- * @version 1.3.0
- */
+ * Copyright 2015 Mohammad Younes <Mohammad@alertifyjs.com> (http://alertifyjs.com)
+ * Licensed under MIT <http://opensource.org/licenses/mit-license.php>*/
( function ( window ) {
'use strict';
@@ -125,6 +119,17 @@
}
/**
+ * Helper: clear contents
+ *
+ */
+ function clearContents(element){
+ while (element.lastChild) {
+ element.removeChild(element.lastChild);
+ }
+ }
+
+
+ /**
* Use a closure to return proper event listener method. Try to use
* `addEventListener` by default but fallback to `attachEvent` for
* unsupported browser. The closure simply ensures that the test doesn't
@@ -537,6 +542,19 @@
}
/**
+ * Helper: maintains scroll position
+ *
+ */
+ var scrollX, scrollY;
+ function saveScrollPosition(){
+ scrollX = window.scrollX;
+ scrollY = window.scrollY;
+ }
+ function restoreScrollPosition(){
+ window.scrollTo(scrollX, scrollY);
+ }
+
+ /**
* Helper: adds/removes no-overflow class from body
*
*/
@@ -1312,12 +1330,15 @@
// once transition is complete, set focus
setFocus(instance);
+ //restore scroll to prevent document jump
+ restoreScrollPosition();
+
// allow handling key up after transition ended.
cancelKeyup = false;
// allow custom `onfocus` method
if (typeof instance.get('onfocus') === 'function') {
- instance.get('onfocus')();
+ instance.get('onfocus').call(instance);
}
// unbind the event
@@ -2009,21 +2030,35 @@
* A minimum height equal to the sum of header/footer heights.
*
*
- * @param {Number} width The new dialog width in pixels.
- * @param {Number} height The new dialog height in pixels.
+ * @param {Number or String} width The new dialog width in pixels or in percent.
+ * @param {Number or String} height The new dialog height in pixels or in percent.
*
* @return {Object} The dialog instance.
*/
resizeTo:function(width,height){
- if(!isNaN(width) && !isNaN(height) && this.get('resizable') === true){
+ var w = parseFloat(width),
+ h = parseFloat(height),
+ regex = /(\d*\.\d+|\d+)%/
+ ;
+
+ if(!isNaN(w) && !isNaN(h) && this.get('resizable') === true){
+
+ if(('' + width).match(regex)){
+ w = w / 100 * document.documentElement.clientWidth ;
+ }
+
+ if(('' + height).match(regex)){
+ h = h / 100 * document.documentElement.clientHeight;
+ }
+
var element = this.elements.dialog;
if (element.style.maxWidth !== 'none') {
element.style.minWidth = (minWidth = element.offsetWidth) + 'px';
}
element.style.maxWidth = 'none';
element.style.minHeight = this.elements.header.offsetHeight + this.elements.footer.offsetHeight + 'px';
- element.style.width = width + 'px';
- element.style.height = height + 'px';
+ element.style.width = w + 'px';
+ element.style.height = h + 'px';
}
return this;
},
@@ -2080,9 +2115,10 @@
*/
setHeader:function(content){
if(typeof content === 'string'){
+ clearContents(this.elements.header);
this.elements.header.innerHTML = content;
}else if (content instanceof window.HTMLElement && this.elements.header.firstChild !== content){
- this.elements.header.innerHTML = '';
+ clearContents(this.elements.header);
this.elements.header.appendChild(content);
}
return this;
@@ -2095,9 +2131,10 @@
*/
setContent:function(content){
if(typeof content === 'string'){
+ clearContents(this.elements.content);
this.elements.content.innerHTML = content;
}else if (content instanceof window.HTMLElement && this.elements.content.firstChild !== content){
- this.elements.content.innerHTML = '';
+ clearContents(this.elements.content);
this.elements.content.appendChild(content);
}
return this;
@@ -2142,6 +2179,9 @@
this.set('modal', modal);
}
+ //save scroll to prevent document jump
+ saveScrollPosition();
+
ensureNoOverflow();
// allow custom dialog class on show
@@ -2186,7 +2226,7 @@
// allow custom `onshow` method
if ( typeof this.get('onshow') === 'function' ) {
- this.get('onshow')();
+ this.get('onshow').call(this);
}
}else{
@@ -2236,7 +2276,7 @@
// allow custom `onclose` method
if ( typeof this.get('onclose') === 'function' ) {
- this.get('onclose')();
+ this.get('onclose').call(this);
}
//remove from open dialogs
@@ -2479,8 +2519,10 @@
*/
setContent: function (content) {
if (typeof content === 'string') {
+ clearContents(this.element);
this.element.innerHTML = content;
- } else {
+ } else if (content instanceof window.HTMLElement && this.element.firstChild !== content) {
+ clearContents(this.element);
this.element.appendChild(content);
}
return this;
@@ -2923,7 +2965,7 @@
},
callback: function (closeEvent) {
if (typeof this.get('onok') === 'function') {
- var returnValue = this.get('onok').call(undefined, closeEvent);
+ var returnValue = this.get('onok').call(this, closeEvent);
if (typeof returnValue !== 'undefined') {
closeEvent.cancel = !returnValue;
}
@@ -3091,15 +3133,15 @@
switch (closeEvent.index) {
case 0:
if (typeof this.get('onok') === 'function') {
- returnValue = this.get('onok').call(undefined, closeEvent);
+ returnValue = this.get('onok').call(this, closeEvent);
if (typeof returnValue !== 'undefined') {
closeEvent.cancel = !returnValue;
}
}
break;
case 1:
if (typeof this.get('oncancel') === 'function') {
- returnValue = this.get('oncancel').call(undefined, closeEvent);
+ returnValue = this.get('oncancel').call(this, closeEvent);
if (typeof returnValue !== 'undefined') {
closeEvent.cancel = !returnValue;
}
@@ -3204,9 +3246,10 @@
},
setMessage: function (message) {
if (typeof message === 'string') {
+ clearContents(p);
p.innerHTML = message;
} else if (message instanceof window.HTMLElement && p.firstChild !== message) {
- p.innerHTML = '';
+ clearContents(p);
p.appendChild(message);
}
},
@@ -3216,6 +3259,7 @@
onok: undefined,
oncancel: undefined,
value: '',
+ type:'text',
reverseButtons: undefined,
},
settingUpdated: function (key, oldValue, newValue) {
@@ -3226,6 +3270,27 @@
case 'value':
input.value = newValue;
break;
+ case 'type':
+ switch (newValue) {
+ case 'text':
+ case 'color':
+ case 'date':
+ case 'datetime-local':
+ case 'email':
+ case 'month':
+ case 'number':
+ case 'password':
+ case 'search':
+ case 'tel':
+ case 'time':
+ case 'week':
+ input.type = newValue;
+ break;
+ default:
+ input.type = 'text';
+ break;
+ }
+ break;
case 'labels':
if (newValue.ok && this.__internal.buttons[0].element) {
this.__internal.buttons[0].element.innerHTML = newValue.ok;
@@ -3249,15 +3314,15 @@
case 0:
this.value = input.value;
if (typeof this.get('onok') === 'function') {
- returnValue = this.get('onok').call(undefined, closeEvent, this.value);
+ returnValue = this.get('onok').call(this, closeEvent, this.value);
if (typeof returnValue !== 'undefined') {
closeEvent.cancel = !returnValue;
}
}
break;
case 1:
if (typeof this.get('oncancel') === 'function') {
- returnValue = this.get('oncancel').call(undefined, closeEvent);
+ returnValue = this.get('oncancel').call(this, closeEvent);
if (typeof returnValue !== 'undefined') {
closeEvent.cancel = !returnValue;
}
Oops, something went wrong.
View
Binary file not shown.
Oops, something went wrong.

0 comments on commit 08c370e

Please sign in to comment.