Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…and some IE8-9 bugs and styling issue
  • Loading branch information
Danial Farid authored and Danial Farid committed Apr 13, 2015
1 parent e7247e1 commit 28136db
Show file tree
Hide file tree
Showing 20 changed files with 4,769 additions and 372 deletions.
8 changes: 5 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ module.exports = function(grunt) {
}, {
expand : true,
cwd : 'demo/war/js/',
src : 'FileAPI.min.js',
src : 'FileAPI.js',
dest : 'dist/',
flatten : true,
filter : 'isFile'
Expand Down Expand Up @@ -75,7 +75,9 @@ module.exports = function(grunt) {
files : [ {
'dist/angular-file-upload.min.js' : 'dist/angular-file-upload.js',
'dist/angular-file-upload-shim.min.js' : 'dist/angular-file-upload-shim.js',
'dist/angular-file-upload-all.min.js' : 'dist/angular-file-upload-all.js'
'dist/angular-file-upload-all.min.js' : 'dist/angular-file-upload-all.js',
'dist/FileAPI.min.js' : 'dist/FileAPI.js',
'demo/war/js/FileAPI.min.js' : 'demo/war/js/FileAPI.js'
} ]
}
},
Expand All @@ -101,6 +103,6 @@ module.exports = function(grunt) {
grunt.loadNpmTasks('grunt-text-replace');
grunt.loadNpmTasks('grunt-contrib-concat');

grunt.registerTask('default', [ 'concat:dist', 'copy:build', 'uglify', 'copy:fileapi', 'copy:bower', 'replace:version' ]);
grunt.registerTask('default', [ 'concat:dist', 'copy:build', 'copy:fileapi', 'uglify', 'copy:bower', 'replace:version' ]);

};
9 changes: 9 additions & 0 deletions demo/.buildpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<buildpath>
<buildpathentry kind="src" path="src"/>
<buildpathentry kind="con" path="org.eclipse.dltk.mod.launching.INTERPRETER_CONTAINER"/>
<buildpathentry kind="con" path="org.eclipse.vjet.eclipse.core.JSNATIVE_CONTAINER/JS Native Types"/>
<buildpathentry kind="con" path="org.eclipse.vjet.eclipse.core.BROWSER_CONTAINER/Browser SDK"/>
<buildpathentry external="true" kind="lib" path="/Applications/eclipse-luna/plugins/com.google.appengine.eclipse.sdkbundle_1.9.10/appengine-java-sdk-1.9.10/lib/shared/appengine-local-runtime-shared.jar"/>
<buildpathentry external="true" kind="lib" path="/Applications/eclipse-luna/plugins/com.google.appengine.eclipse.sdkbundle_1.9.10/appengine-java-sdk-1.9.10/lib/opt/user/appengine-api-labs/v1/appengine-api-labs.jar"/>
</buildpath>
8 changes: 7 additions & 1 deletion demo/.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.vjet.eclipse.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
Expand Down Expand Up @@ -37,8 +42,9 @@
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.vjet.core.nature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>com.google.appengine.eclipse.core.gaeNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
</natures>
</projectDescription>
4 changes: 4 additions & 0 deletions demo/war/common.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ body {
font-family: Helvetica, arial, freesans, clean, sans-serif;
}

/* object {
border: 3px solid red;
} */

.upload-buttons input[type="file"] {
width: 6.3em \0/IE9;
}
Expand Down
203 changes: 114 additions & 89 deletions demo/war/js/FileAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -3468,73 +3468,75 @@
}
while( (node = node.parentNode) && (node !== document.body) );
},


disableMouseover: false,

mouseover: function (evt){
var target = api.event.fix(evt).target;

if( /input/i.test(target.nodeName) && target.type == 'file' && !target.disabled ){
var
state = target.getAttribute(_attr)
, wrapper = flash.getWrapper(target)
;

if( api.multiFlash ){
// check state:
// i — published
// i — initialization
// r — ready
if( state == 'i' || state == 'r' ){
// publish fail
return false;
}
else if( state != 'p' ){
// set "init" state
target.setAttribute(_attr, 'i');

var dummy = document.createElement('div');

if( !wrapper ){
api.log('[err] FlashAPI.mouseover: js-fileapi-wrapper not found');
return;
if (!flash.disableMouseover) {
var target = api.event.fix(evt).target;

if( /input/i.test(target.nodeName) && target.type == 'file' && !target.disabled ){
var
state = target.getAttribute(_attr)
, wrapper = flash.getWrapper(target)
;

if( api.multiFlash ){
// check state:
// i — published
// i — initialization
// r — ready
if( state == 'i' || state == 'r' ){
// publish fail
return false;
}

_css(dummy, {
top: 0
, left: 0
, width: target.offsetWidth
, height: target.offsetHeight
, zIndex: 1e6+'' // set max zIndex
, position: 'absolute'
});

wrapper.appendChild(dummy);
flash.publish(dummy, api.uid());

// set "publish" state
target.setAttribute(_attr, 'p');
else if( state != 'p' ){
// set "init" state
target.setAttribute(_attr, 'i');

var dummy = document.createElement('div');

if( !wrapper ){
api.log('[err] FlashAPI.mouseover: js-fileapi-wrapper not found');
return;
}

_css(dummy, {
top: 0
, left: 0
, width: target.offsetWidth
, height: target.offsetHeight
, zIndex: 1e6+'' // set max zIndex
, position: 'absolute'
});

wrapper.appendChild(dummy);
flash.publish(dummy, api.uid());

// set "publish" state
target.setAttribute(_attr, 'p');
}

return true;
}
else if( wrapper ){
// Use one flash element
var box = _getDimensions(wrapper);
_css(flash.getEl(), box);

// Set current input
flash.curInp = target;
}

return true;
}
else if( wrapper ){
// Use one flash element
var box = _getDimensions(wrapper);

_css(flash.getEl(), box);

// Set current input
flash.curInp = target;
else if( !/object|embed/i.test(target.nodeName) ){
_css(flash.getEl(), { top: 1, left: 1, width: 5, height: 5 });
}
}
else if( !/object|embed/i.test(target.nodeName) ){
_css(flash.getEl(), { top: 1, left: 1, width: 5, height: 5 });
}
},

onEvent: function (evt){
var type = evt.type;

if( type == 'ready' ){
try {
// set "ready" state
Expand All @@ -3559,8 +3561,12 @@
}, 1);
}
},


mouseDown: function(evt) {
flash.disableMouseover = true;
},
cancel: function(evt) {
flash.disableMouseover = false;
},
mouseenter: function (evt){
var node = flash.getInput(evt.flashId);

Expand Down Expand Up @@ -3609,32 +3615,35 @@


select: function (evt){
var
inp = flash.getInput(evt.flashId)
, uid = api.uid(inp)
, files = evt.target.files
, event
;

_each(files, function (file){
api.checkFileObj(file);
});

_files[uid] = files;

if( document.createEvent ){
event = document.createEvent('Event');
event.files = files;
event.initEvent('change', true, true);
inp.dispatchEvent(event);
}
else if( jQuery ){
jQuery(inp).trigger({ type: 'change', files: files });
}
else {
event = document.createEventObject();
event.files = files;
inp.fireEvent('onchange', event);
try {
var
inp = flash.getInput(evt.flashId)
, uid = api.uid(inp)
, files = evt.target.files
, event
;
_each(files, function (file){
api.checkFileObj(file);
});

_files[uid] = files;

if( document.createEvent ){
event = document.createEvent('Event');
event.files = files;
event.initEvent('change', true, true);
inp.dispatchEvent(event);
}
else if( jQuery ){
jQuery(inp).trigger({ type: 'change', files: files });
}
else {
event = document.createEventObject();
event.files = files;
inp.fireEvent('onchange', event);
}
} finally {
flash.disableMouseover = false;
}
},

Expand Down Expand Up @@ -3966,6 +3975,7 @@
}
try { el.style[key] = val; } catch (e) {}
}

}
}

Expand Down Expand Up @@ -4087,12 +4097,27 @@
, body = document.body
, docEl = (el && el.ownerDocument).documentElement
;


function getOffset(obj) {
var left, top;
left = top = 0;
if (obj.offsetParent) {
do {
left += obj.offsetLeft;
top += obj.offsetTop;
} while (obj = obj.offsetParent);
}
return {
left : left,
top : top
};
};

return {
top: box.top + (window.pageYOffset || docEl.scrollTop) - (docEl.clientTop || body.clientTop || 0)
, left: box.left + (window.pageXOffset || docEl.scrollLeft) - (docEl.clientLeft || body.clientLeft || 0)
, width: box.right - box.left
, height: box.bottom - box.top
top: getOffset(el).top
, left: getOffset(el).left
, width: el.offsetWidth
, height: el.offsetHeight
};
}

Expand Down
6 changes: 3 additions & 3 deletions demo/war/js/FileAPI.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 28136db

Please sign in to comment.